azure_enum 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8524bf549464d7ae0cd68b6275d3e2aeba8860a0e25906e12fc49eaa5bf15cca
4
+ data.tar.gz: abb7629d5ffd9eb34804c1a6b4d7b77463af57ba1f9fb44acfd1fae19a42e8e0
5
+ SHA512:
6
+ metadata.gz: cc796bf48aec39d47d518c45044abd3fcf245f32cc6d4c5cea57349126bc73b48b75f7d0213d0d3e29fb22097df5c34672c99bdccd3a40ea317696c39f35ac41
7
+ data.tar.gz: 4437c39d381676c7b0bb3b3ac3610dab7d015c9590cdb2579c1f316be09c882735a51b0c032d0ef8332f1233a506623e33cb23f3b49dd60b1e7a60e8ebfcb148
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in azure_enum.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Technion
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # AzureEnum
2
+
3
+ This Ruby Gem assists in enumeration of Office 365 federated domains. This can allow you to identify domains associated with a business, not easily identified through traditional means.
4
+
5
+ The time this process takes can vary from a few seconds to a few minutes depending on the hosting server.
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'azure_enum'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install azure_enum
21
+
22
+ ## Usage
23
+
24
+ You can use this gem from within an application:
25
+
26
+ ```
27
+ require "azure_enum"
28
+ x = AzureEnum.federated("lolware.net")
29
+ => ["lolzware.onmicrosoft.com", "lolware.net"]
30
+ ```
31
+
32
+ Or by installing and running the binary:
33
+ ```
34
+ bundle exec ./bin/azure_enum lolware.net
35
+ Please wait while the given domain is enumerated.
36
+ lolzware.onmicrosoft.com
37
+ lolware.net
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/technion/azure_enum.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "azure_enum/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "azure_enum"
8
+ spec.version = AzureEnum::VERSION
9
+ spec.authors = ["Technion"]
10
+ spec.email = ["technion@lolware.net"]
11
+
12
+ spec.summary = %q{Enumerate Office 365 tenancies for federated domains.}
13
+ spec.description = %q{External enumeration toolkit to identify organisation relationships in Office 365.}
14
+ spec.homepage = "https://github.com/technion"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_dependency "httpclient", "~> 2.8.0"
28
+ spec.add_dependency "nokogiri", "~> 1.8.0"
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "azure_enum"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/discovery.xml.erb ADDED
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:exm="http://schemas.microsoft.com/exchange/services/2006/messages"
3
+ xmlns:ext="http://schemas.microsoft.com/exchange/services/2006/types"
4
+ xmlns:a="http://www.w3.org/2005/08/addressing"
5
+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
6
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
8
+ <soap:Header>
9
+ <a:MessageID>urn:uuid:6389558d-9e05-465e-ade9-aae14c4bcd10</a:MessageID>
10
+ <a:Action soap:mustUnderstand="1">http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetFederationInformation
11
+ </a:Action>
12
+ <a:To soap:mustUnderstand="1"><%= @url %></a:To>
13
+ <a:ReplyTo>
14
+ <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
15
+ </a:ReplyTo>
16
+ </soap:Header>
17
+ <soap:Body>
18
+ <GetFederationInformationRequestMessage
19
+ xmlns="http://schemas.microsoft.com/exchange/2010/Autodiscover">
20
+ <Request>
21
+ <Domain><%= @domain %></Domain>
22
+ </Request>
23
+ </GetFederationInformationRequestMessage>
24
+ </soap:Body>
25
+ </soap:Envelope>
data/exe/azure_enum ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "azure_enum"
4
+
5
+ if (ARGV.length == 0)
6
+ warn "Please provide domain to enumerate on command line. eg azure_enum lolware.net"
7
+ exit
8
+ end
9
+
10
+ puts "Please wait while the given domain is enumerated."
11
+ puts AzureEnum.federated(ARGV[0])
12
+
data/lib/azure_enum.rb ADDED
@@ -0,0 +1,82 @@
1
+ require "azure_enum/version"
2
+ require "erb"
3
+ require "httpclient"
4
+ require "nokogiri"
5
+
6
+ module AzureEnum
7
+ class Federation
8
+ def initialize(domain)
9
+ @domain = domain
10
+ @xml_text = nil
11
+ @redirect = nil
12
+ end
13
+
14
+ def check_redirect
15
+ url = "http://autodiscover.#{@domain}/autodiscover/autodiscover.svc"
16
+ begin
17
+ res = HTTPClient.head(url)
18
+ rescue
19
+ return nil
20
+ end
21
+ return nil unless res.status_code == 302
22
+ @redirect = res.header["Location"][0]
23
+ end
24
+
25
+ def enumerate_autodisc
26
+ httpsdomains = [
27
+ "https://#{@domain}/autodiscover/autodiscover.svc",
28
+ "https://autodiscover.#{@domain}/autodiscover/autodiscover.svc"
29
+ ]
30
+
31
+ httpsdomains.unshift @redirect if @redirect
32
+ httpsdomains.each do |url|
33
+ xml = get_xml(@domain, url)
34
+ begin
35
+ http = HTTPClient.new
36
+ content = { "Content-Type" => "text/xml; charset=utf-8" }
37
+ res = http.post(url, xml, content)
38
+ @xml_text = res.content
39
+ return @xml_text
40
+ last
41
+ rescue
42
+ next
43
+ end
44
+ end
45
+ end
46
+ def getdomains
47
+ fail "enumumerate_autodisc not called yet" unless @xml_text
48
+ tree = Nokogiri.parse(@xml_text)
49
+ tree.xpath(
50
+ "//ad:GetFederationInformationResponseMessage/ad:Response/ad:Domains/ad:Domain",
51
+ "ad": "http://schemas.microsoft.com/exchange/2010/Autodiscover")
52
+ .map do |node|
53
+ node.text
54
+ end
55
+ end
56
+
57
+ private
58
+ class Discovery
59
+ def initialize(domain, url)
60
+ @domain = domain
61
+ @url = url
62
+ end
63
+ def get_binding
64
+ binding
65
+ end
66
+ end
67
+ def get_xml(domain, url)
68
+ template = File.read("discovery.xml.erb")
69
+ renderer = ERB.new(template)
70
+ discovery = Discovery.new(domain, url)
71
+ renderer.result(discovery.get_binding)
72
+ end
73
+ end
74
+ class << self
75
+ def federated(domain)
76
+ e = Federation.new(domain)
77
+ e.check_redirect
78
+ e.enumerate_autodisc
79
+ e.getdomains
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,3 @@
1
+ module AzureEnum
2
+ VERSION = "0.1.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: azure_enum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Technion
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httpclient
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.0
83
+ description: External enumeration toolkit to identify organisation relationships in
84
+ Office 365.
85
+ email:
86
+ - technion@lolware.net
87
+ executables:
88
+ - azure_enum
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - azure_enum.gemspec
100
+ - bin/console
101
+ - bin/setup
102
+ - discovery.xml.erb
103
+ - exe/azure_enum
104
+ - lib/azure_enum.rb
105
+ - lib/azure_enum/version.rb
106
+ homepage: https://github.com/technion
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.7.7
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Enumerate Office 365 tenancies for federated domains.
130
+ test_files: []