azure_enum 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8524bf549464d7ae0cd68b6275d3e2aeba8860a0e25906e12fc49eaa5bf15cca
4
- data.tar.gz: abb7629d5ffd9eb34804c1a6b4d7b77463af57ba1f9fb44acfd1fae19a42e8e0
3
+ metadata.gz: 6fdc83880b2b733e7d62d3547acddfaf63545d96fe971e40476141aff0478a41
4
+ data.tar.gz: f41d54b8da002a67330179fe77f64dd419fd7588494fa1f0b2bdd0384f92d98c
5
5
  SHA512:
6
- metadata.gz: cc796bf48aec39d47d518c45044abd3fcf245f32cc6d4c5cea57349126bc73b48b75f7d0213d0d3e29fb22097df5c34672c99bdccd3a40ea317696c39f35ac41
7
- data.tar.gz: 4437c39d381676c7b0bb3b3ac3610dab7d015c9590cdb2579c1f316be09c882735a51b0c032d0ef8332f1233a506623e33cb23f3b49dd60b1e7a60e8ebfcb148
6
+ metadata.gz: a3a494b52395dac75e451203506bd73b3f17613fbe28c4716837d6299363379df4220bdad19da13ce144d16f3ed3be499c0188fed1161301d975f89c23394d93
7
+ data.tar.gz: 601600c96b145a70524b6b390f30caee359451e49e9398fa7e04e242e5c9264936db14783d4b1c510a7c684361efab7d05728032289d82f733a17957bdcfd876
@@ -1,2 +1,11 @@
1
1
  Style/StringLiterals:
2
2
  EnforcedStyle: double_quotes
3
+ Metrics/LineLength:
4
+ Max: 100
5
+ Metrics/MethodLength:
6
+ Max: 25
7
+
8
+ Naming/AccessorMethodName:
9
+ Exclude:
10
+ - 'lib/azure_enum.rb'
11
+
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AzureEnum
2
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.
3
+ This Ruby Gem assists in enumeration of Office 365 or Exchange on-premise federated domains. This can allow you to identify domains associated with a business, not easily identified through traditional means. The examples below demonstrate how output can be interesting.
4
4
 
5
5
  The time this process takes can vary from a few seconds to a few minutes depending on the hosting server.
6
6
  ## Installation
@@ -37,6 +37,44 @@ lolzware.onmicrosoft.com
37
37
  lolware.net
38
38
  ```
39
39
 
40
+ ## Examples
41
+
42
+ The following examples against some random domains demonstrate the tools capabilities.
43
+
44
+ ```
45
+ $ azure_enum afl.com.au
46
+ Please wait while the given domain is enumerated.
47
+ afl.com.au
48
+ aflnt.com.au
49
+ ntthunder.com.au
50
+ aflgoulburnmurray.com.au
51
+ aflwesterndistrict.com.au
52
+ aflgippsland.com.au
53
+ aflyarraranges.com.au
54
+
55
+ $ azure_enum kmart.com.au
56
+ Please wait while the given domain is enumerated.
57
+ kmart.com.au
58
+ KASAsia.com
59
+
60
+ $ azure_enum microsoft.com
61
+ Please wait while the given domain is enumerated.
62
+ corp.webtv.net
63
+ microsoft.onmicrosoft.com
64
+ surface.com
65
+ bungie.com
66
+ navic.tv
67
+ middleeast.corp.microsoft.com
68
+ wingroup.windeploy.ntdev.microsoft.com
69
+ exchangecalendarsharing.com
70
+ redmond.corp.microsoft.com
71
+ northamerica.corp.microsoft.com
72
+ bing.com
73
+ corp.microsoft.com
74
+ placeware.com
75
+ (snip large list)
76
+ ```
77
+
40
78
  ## Development
41
79
 
42
80
  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.
@@ -46,6 +84,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
46
84
  ## Contributing
47
85
 
48
86
  Bug reports and pull requests are welcome on GitHub at https://github.com/technion/azure_enum.
87
+ Sometimes you get this output:
88
+
89
+ Unknown key: Max-Age = 31536000
90
+
91
+ It seems to be a known bug in HTTPClient.
49
92
 
50
93
  ## License
51
94
 
@@ -8,5 +8,10 @@ if (ARGV.length == 0)
8
8
  end
9
9
 
10
10
  puts "Please wait while the given domain is enumerated."
11
- puts AzureEnum.federated(ARGV[0])
11
+ domains = AzureEnum.federated(ARGV[0])
12
+ if (!domains || domains == [])
13
+ puts "Unfortunately this domain cannot be enumerated"
14
+ exit
15
+ end
12
16
 
17
+ puts domains
@@ -3,7 +3,9 @@ require "erb"
3
3
  require "httpclient"
4
4
  require "nokogiri"
5
5
 
6
+ # Azure and Exchange federated domain enumerator
6
7
  module AzureEnum
8
+ # Class initializes with a domain name, and provides methods to interact with MS Autodiscover
7
9
  class Federation
8
10
  def initialize(domain)
9
11
  @domain = domain
@@ -11,6 +13,7 @@ module AzureEnum
11
13
  @redirect = nil
12
14
  end
13
15
 
16
+ # This will identify if the http:// redirect exists for the domain, usually per Office 365
14
17
  def check_redirect
15
18
  url = "http://autodiscover.#{@domain}/autodiscover/autodiscover.svc"
16
19
  begin
@@ -24,8 +27,8 @@ module AzureEnum
24
27
 
25
28
  def enumerate_autodisc
26
29
  httpsdomains = [
27
- "https://#{@domain}/autodiscover/autodiscover.svc",
28
- "https://autodiscover.#{@domain}/autodiscover/autodiscover.svc"
30
+ "https://autodiscover.#{@domain}/autodiscover/autodiscover.svc",
31
+ "https://#{@domain}/autodiscover/autodiscover.svc"
29
32
  ]
30
33
 
31
34
  httpsdomains.unshift @redirect if @redirect
@@ -36,47 +39,58 @@ module AzureEnum
36
39
  content = { "Content-Type" => "text/xml; charset=utf-8" }
37
40
  res = http.post(url, xml, content)
38
41
  @xml_text = res.content
39
- return @xml_text
40
- last
42
+ return true
43
+ # It is bad style to rescue "all" errors. However, it turns out there is a practically
44
+ # never ending list of ways this can fail. And "any" failure is reason to rule out the address
41
45
  rescue
42
46
  next
43
47
  end
44
48
  end
49
+ return false
45
50
  end
51
+
46
52
  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
53
+ raise "enumumerate_autodisc not called yet" unless @xml_text
54
+ tree = Nokogiri.parse(@xml_text)
55
+ tree.xpath(
56
+ "//ad:GetFederationInformationResponseMessage/ad:Response/ad:Domains/ad:Domain",
57
+ ad: "http://schemas.microsoft.com/exchange/2010/Autodiscover"
58
+ ).map(&:text)
55
59
  end
56
60
 
57
61
  private
62
+
63
+ # This is an internal class just to pass the correct structure to ERB in get_xml
58
64
  class Discovery
59
65
  def initialize(domain, url)
60
66
  @domain = domain
61
67
  @url = url
62
68
  end
69
+
63
70
  def get_binding
64
71
  binding
65
72
  end
66
73
  end
74
+
67
75
  def get_xml(domain, url)
68
- template = File.read("discovery.xml.erb")
76
+ path = File.dirname __dir__
77
+ template = File.read(File.join(path, "discovery.xml.erb"))
69
78
  renderer = ERB.new(template)
70
79
  discovery = Discovery.new(domain, url)
71
80
  renderer.result(discovery.get_binding)
72
81
  end
73
82
  end
83
+
84
+ # This is the intended API: runs each step of the enumeration process and returns a result
74
85
  class << self
75
86
  def federated(domain)
76
87
  e = Federation.new(domain)
77
88
  e.check_redirect
78
- e.enumerate_autodisc
79
- e.getdomains
89
+ if e.enumerate_autodisc
90
+ e.getdomains
91
+ else
92
+ nil
93
+ end
80
94
  end
81
95
  end
82
96
  end
@@ -1,3 +1,3 @@
1
1
  module AzureEnum
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Technion