Skip to content

Commit 58b796e

Browse files
committed
soft reset
1 parent ed49c2e commit 58b796e

File tree

2 files changed

+46
-51
lines changed

2 files changed

+46
-51
lines changed

Gemfile.lock

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -170,33 +170,32 @@ GEM
170170
rspec-expectations (~> 3.12)
171171
arel-helpers (2.16.0)
172172
activerecord (>= 3.1.0, < 8.1)
173-
ast (2.4.3)
173+
ast (2.4.2)
174174
aws-eventstream (1.3.2)
175-
aws-partitions (1.1084.0)
176-
aws-sdk-core (3.222.1)
175+
aws-partitions (1.1065.0)
176+
aws-sdk-core (3.220.1)
177177
aws-eventstream (~> 1, >= 1.3.0)
178178
aws-partitions (~> 1, >= 1.992.0)
179179
aws-sigv4 (~> 1.9)
180180
base64
181181
jmespath (~> 1, >= 1.6.1)
182-
logger
183-
aws-sdk-ec2 (1.515.0)
182+
aws-sdk-ec2 (1.511.0)
184183
aws-sdk-core (~> 3, >= 3.216.0)
185184
aws-sigv4 (~> 1.5)
186185
aws-sdk-ec2instanceconnect (1.55.0)
187186
aws-sdk-core (~> 3, >= 3.216.0)
188187
aws-sigv4 (~> 1.5)
189-
aws-sdk-iam (1.120.0)
188+
aws-sdk-iam (1.119.0)
190189
aws-sdk-core (~> 3, >= 3.216.0)
191190
aws-sigv4 (~> 1.5)
192191
aws-sdk-kms (1.99.0)
193192
aws-sdk-core (~> 3, >= 3.216.0)
194193
aws-sigv4 (~> 1.5)
195-
aws-sdk-s3 (1.183.0)
194+
aws-sdk-s3 (1.182.0)
196195
aws-sdk-core (~> 3, >= 3.216.0)
197196
aws-sdk-kms (~> 1)
198197
aws-sigv4 (~> 1.5)
199-
aws-sdk-ssm (1.192.0)
198+
aws-sdk-ssm (1.191.0)
200199
aws-sdk-core (~> 3, >= 3.216.0)
201200
aws-sigv4 (~> 1.5)
202201
aws-sigv4 (1.11.0)
@@ -211,20 +210,20 @@ GEM
211210
msgpack (~> 1.2)
212211
bson (5.0.2)
213212
builder (3.3.0)
214-
byebug (12.0.0)
213+
byebug (11.1.3)
215214
chunky_png (1.4.0)
216215
coderay (1.1.3)
217216
concurrent-ruby (1.3.4)
218217
connection_pool (2.5.0)
219218
cookiejar (0.3.4)
220219
crass (1.0.6)
221-
csv (3.3.3)
220+
csv (3.3.2)
222221
daemons (1.4.1)
223222
date (3.4.1)
224223
debug (1.8.0)
225224
irb (>= 1.5.0)
226225
reline (>= 0.3.1)
227-
diff-lcs (1.6.1)
226+
diff-lcs (1.6.0)
228227
dnsruby (1.72.4)
229228
base64 (~> 0.2.0)
230229
logger (~> 1.6.5)
@@ -258,7 +257,7 @@ GEM
258257
faraday-net_http (>= 2.0, < 3.1)
259258
ruby2_keywords (>= 0.0.4)
260259
faraday-net_http (3.0.2)
261-
faraday-retry (2.3.1)
260+
faraday-retry (2.2.1)
262261
faraday (~> 2.0)
263262
faye-websocket (0.11.3)
264263
eventmachine (>= 0.12.0)
@@ -305,11 +304,9 @@ GEM
305304
nokogiri (>= 1.12.0)
306305
memory_profiler (1.1.0)
307306
metasm (1.0.5)
308-
metasploit-concern (5.0.5)
307+
metasploit-concern (5.0.4)
309308
activemodel (~> 7.0)
310309
activesupport (~> 7.0)
311-
drb
312-
mutex_m
313310
railties (~> 7.0)
314311
zeitwerk
315312
metasploit-credential (6.0.14)
@@ -339,10 +336,10 @@ GEM
339336
webrick
340337
metasploit_payloads-mettle (1.0.35)
341338
method_source (1.1.0)
342-
mime-types (3.6.2)
339+
mime-types (3.6.0)
343340
logger
344341
mime-types-data (~> 3.2015)
345-
mime-types-data (3.2025.0408)
342+
mime-types-data (3.2025.0304)
346343
mini_portile2 (2.8.8)
347344
minitest (5.25.5)
348345
mqtt (0.6.0)
@@ -366,7 +363,7 @@ GEM
366363
network_interface (0.0.4)
367364
nexpose (7.3.0)
368365
nio4r (2.7.4)
369-
nokogiri (1.18.7)
366+
nokogiri (1.18.3)
370367
mini_portile2 (~> 2.8.2)
371368
racc (~> 1.4)
372369
nori (2.7.1)
@@ -381,7 +378,7 @@ GEM
381378
packetfu (2.0.0)
382379
pcaprub (~> 0.13.1)
383380
parallel (1.26.3)
384-
parser (3.3.7.4)
381+
parser (3.3.7.1)
385382
ast (~> 2.4.1)
386383
racc
387384
patch_finder (1.0.2)
@@ -393,13 +390,12 @@ GEM
393390
ruby-rc4
394391
ttfunk
395392
pg (1.5.9)
396-
prism (1.4.0)
397-
pry (0.15.2)
393+
pry (0.14.2)
398394
coderay (~> 1.1)
399395
method_source (~> 1.0)
400-
pry-byebug (3.11.0)
401-
byebug (~> 12.0)
402-
pry (>= 0.13, < 0.16)
396+
pry-byebug (3.10.1)
397+
byebug (~> 11.0)
398+
pry (>= 0.13, < 0.15)
403399
public_suffix (6.0.1)
404400
puma (6.6.0)
405401
nio4r (~> 2.0)
@@ -435,11 +431,11 @@ GEM
435431
rasn1 (0.14.0)
436432
strptime (~> 0.2.5)
437433
rb-readline (0.5.5)
438-
recog (3.1.16)
434+
recog (3.1.14)
439435
nokogiri
440436
redcarpet (3.6.1)
441437
regexp_parser (2.10.0)
442-
reline (0.6.1)
438+
reline (0.6.0)
443439
io-console (~> 0.5)
444440
require_all (3.0.0)
445441
rex-arch (0.1.18)
@@ -488,8 +484,7 @@ GEM
488484
rex-socket
489485
rex-text
490486
rex-struct2 (0.1.5)
491-
rex-text (0.2.61)
492-
bigdecimal
487+
rex-text (0.2.60)
493488
rex-zip (0.1.6)
494489
rex-text
495490
rexml (3.4.1)
@@ -531,9 +526,8 @@ GEM
531526
rubocop-ast (>= 1.32.2, < 2.0)
532527
ruby-progressbar (~> 1.7)
533528
unicode-display_width (>= 2.4.0, < 3.0)
534-
rubocop-ast (1.44.0)
535-
parser (>= 3.3.7.2)
536-
prism (~> 1.4)
529+
rubocop-ast (1.38.1)
530+
parser (>= 3.3.1.0)
537531
ruby-macho (4.1.0)
538532
ruby-mysql (4.2.0)
539533
ruby-prof (1.4.2)
@@ -581,7 +575,7 @@ GEM
581575
bigdecimal (~> 3.1)
582576
tzinfo (2.0.6)
583577
concurrent-ruby (~> 1.0)
584-
tzinfo-data (1.2025.2)
578+
tzinfo-data (1.2025.1)
585579
tzinfo (>= 1.0.0)
586580
unicode-display_width (2.6.0)
587581
unix-crypt (1.3.1)

modules/auxiliary/gather/shodan_search.rb

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def initialize(info = {})
3636
[
3737
OptString.new('SHODAN_APIKEY', [true, 'The SHODAN API key']),
3838
OptString.new('QUERY', [true, 'Keywords you want to search for']),
39-
OptString.new('FACETS', [true, 'List of facets']),
39+
OptString.new('FACETS', [false, 'List of facets']),
4040
OptString.new('OUTFILE', [false, 'A filename to store the list of IPs']),
4141
OptBool.new('DATABASE', [false, 'Add search results to the database', false]),
4242
OptInt.new('MAXPAGE', [true, 'Max amount of pages to collect', 1]),
@@ -125,22 +125,23 @@ def run
125125

126126
# results gets our results from shodan_query
127127
results = []
128-
results[0] = shodan_query(apikey, query, facets, 1)
128+
first_page = 0
129+
results[first_page] = shodan_query(apikey, query, facets, 1)
129130

130-
if results[0]['total'].nil? || results[0]['total'] == 0
131+
if results[first_page]['total'].nil? || results[first_page]['total'] == 0
131132
msg = "No results."
132-
if results[0]['error'].to_s.length > 0
133-
msg << " Error: #{results[0]['error']}"
133+
if results[first_page]['error'].to_s.length > 0
134+
msg << " Error: #{results[first_page]['error']}"
134135
end
135136
print_error(msg)
136137
return
137138
end
138139

139140
# Determine page count based on total results
140-
if results[0]['total'] % 100 == 0
141-
tpages = results[0]['total'] / 100
141+
if results[first_page]['total'] % 100 == 0
142+
tpages = results[first_page]['total'] / 100
142143
else
143-
tpages = results[0]['total'] / 100 + 1
144+
tpages = results[first_page]['total'] / 100 + 1
144145
end
145146
maxpage = tpages if datastore['MAXPAGE'] > tpages
146147

@@ -150,23 +151,23 @@ def run
150151
'Indent' => 1,
151152
'Columns' => ['Facet', 'Name', 'Count']
152153
)
153-
print_status("Total: #{results[0]['total']} on #{tpages} " \
154+
print_status("Total: #{results[first_page]['total']} on #{tpages} " \
154155
'pages. Showing facets')
155-
facet = results[0]['facets']
156+
facet = results.dig(first_page,'facets')
156157
facet.each do |name, list|
157158
list.each do |f|
158159
facets_tbl << [name.to_s, (f['value']).to_s, (f['count']).to_s]
159160
end
160161
end
161162
else
162163
# start printing out our query statistics
163-
print_status("Total: #{results[0]['total']} on #{tpages} " +
164+
print_status("Total: #{results[first_page]['total']} on #{tpages} " +
164165
"pages. Showing: #{maxpage} page(s)")
165166

166167
# If search results greater than 100, loop & get all results
167168
print_status('Collecting data, please wait...')
168169

169-
if results[0]['total'] > 100
170+
if results[first_page]['total'] > 100
170171
page = 1
171172
while page < maxpage
172173
page_result = shodan_query(apikey, query, facets, page+1)
@@ -188,17 +189,17 @@ def run
188189
regex = datastore['REGEX'] if datastore['REGEX']
189190
results.each do |page|
190191
page['matches'].each do |host|
191-
city = host['location']['city'] || 'N/A'
192-
ip = host['ip_str'] || 'N/A'
193-
port = host['port'] || ''
194-
country = host['location']['country_name'] || 'N/A'
195-
hostname = host['hostnames'][0]
196-
data = host['data']
192+
city = host.dig('location','city') || 'N/A'
193+
ip = host.fetch('ip_str', 'N/A')
194+
port = host.fetch('port', '')
195+
country = host.dig('location','country_name') || 'N/A'
196+
hostname = host.dig('hostnames',0)
197+
data = host.dig('data')
197198

198199
report_host(:host => ip,
199200
:name => hostname,
200201
:comments => 'Added from Shodan',
201-
:info => host['info']
202+
:info => host.dig('info')
202203
) if datastore['DATABASE']
203204

204205
report_service(:host => ip,

0 commit comments

Comments
 (0)