File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -84,19 +84,22 @@ def save_output(data)
84
84
end
85
85
86
86
# Check to see if api.shodan.io resolves properly
87
- def shodan_rhost
88
- @res = Net ::DNS ::Resolver . new
89
- dns_query = @res . query ( 'api.shodan.io' , 'A' )
90
- if dns_query . answer . length == 0
91
- print_error ( 'Could not resolve api.shodan.io' )
92
- raise ::Rex ::ConnectError ( 'api.shodan.io' , '443' )
87
+ def shodan_resolvable?
88
+ begin
89
+ Rex ::Socket . resolv_to_dotted ( "api.shodan.io" )
90
+ rescue RuntimeError , SocketError
91
+ return false
93
92
end
94
- dns_query . answer [ 0 ] . to_s . split ( /[\s ,]+/ ) [ 4 ]
93
+
94
+ true
95
95
end
96
96
97
97
def run
98
98
# check to ensure api.shodan.io is resolvable
99
- shodan_rhost
99
+ unless shodan_resolvable?
100
+ print_error ( "Unable to resolve api.shodan.io" )
101
+ return
102
+ end
100
103
101
104
# create our Shodan request parameters
102
105
query = datastore [ 'QUERY' ]
You can’t perform that action at this time.
0 commit comments