File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change 9
9
10
10
class MetasploitModule < Msf ::Auxiliary
11
11
12
+ include Msf ::Auxiliary ::Report
13
+
12
14
def initialize ( info = { } )
13
15
super ( update_info ( info ,
14
16
'Name' => 'Censys Search' ,
@@ -80,14 +82,39 @@ def search(keyword, search_type)
80
82
end
81
83
end
82
84
85
+ def valid_domain? ( domain )
86
+ domain =~ /^([a-z0-9]+(-[a-z0-9]+)*\. )+[a-z]{2,}$/
87
+ end
88
+
89
+ def domain2ip ( domain )
90
+ ips = [ ]
91
+ begin
92
+ ips = Rex ::Socket . getaddresses ( domain )
93
+ rescue SocketError
94
+ end
95
+ ips
96
+ end
97
+
83
98
def parse_certificates ( records )
99
+ ips = [ ]
84
100
records . each do |certificate |
85
101
# parsed.fingerprint_sha256
86
102
# parsed.subject_dn
87
103
# parsed.issuer_dn
88
- print_status ( certificate [ 'parsed.fingerprint_sha256' ] . join ( ',' ) )
89
- print_status ( certificate [ 'parsed.subject_dn' ] . join ( ',' ) )
90
- print_status ( certificate [ 'parsed.issuer_dn' ] . join ( ',' ) )
104
+ subject_dn = certificate [ 'parsed.subject_dn' ] . join ( ',' )
105
+ next unless subject_dn . include? ( 'CN=' )
106
+
107
+ host = subject_dn . split ( 'CN=' ) [ 1 ]
108
+ if Rex ::Socket . is_ipv4? ( host )
109
+ ips << host
110
+ elsif valid_domain? ( host ) # Fake DNS server
111
+ ips |= domain2ip ( host )
112
+ end
113
+
114
+ ips . each do |ip |
115
+ print_good ( "#{ ip } - #{ subject_dn } " )
116
+ report_host ( :host => ip , :info => subject_dn )
117
+ end
91
118
end
92
119
end
93
120
You can’t perform that action at this time.
0 commit comments