@@ -479,7 +479,7 @@ def cmd_hosts(*args)
479
479
'SortIndex' => order_by
480
480
} )
481
481
482
- # Sentinal value meaning all
482
+ # Sentinel value meaning all
483
483
host_ranges . push ( nil ) if host_ranges . empty?
484
484
485
485
case
@@ -717,7 +717,7 @@ def cmd_services(*args)
717
717
'SortIndex' => order_by
718
718
} )
719
719
720
- # Sentinal value meaning all
720
+ # Sentinel value meaning all
721
721
host_ranges . push ( nil ) if host_ranges . empty?
722
722
ports = nil if ports . empty?
723
723
@@ -1115,7 +1115,7 @@ def make_sortable(input)
1115
1115
def cmd_loot_help
1116
1116
print_line "Usage: loot <options>"
1117
1117
print_line " Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]"
1118
- print_line " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [ -t [type]"
1118
+ print_line " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] -t [type]"
1119
1119
print_line " Del: loot -d [addr1 addr2 ...]"
1120
1120
print_line
1121
1121
print_line " -a,--add Add loot to the list of addresses, instead of listing"
@@ -1187,34 +1187,38 @@ def cmd_loot(*args)
1187
1187
'Columns' => [ 'host' , 'service' , 'type' , 'name' , 'content' , 'info' , 'path' ] ,
1188
1188
} )
1189
1189
1190
- # Sentinal value meaning all
1190
+ # Sentinel value meaning all
1191
1191
host_ranges . push ( nil ) if host_ranges . empty?
1192
1192
1193
- if mode == :add
1194
- if info . nil?
1195
- print_error ( "Info required" )
1196
- return
1197
- end
1198
- if filename . nil?
1199
- print_error ( "Loot file required" )
1200
- return
1201
- end
1202
- if types . nil? or types . size != 1
1203
- print_error ( "Exactly one loot type is required" )
1204
- return
1205
- end
1206
- type = types . first
1207
- name = File . basename ( filename )
1208
- host_ranges . each do |range |
1209
- range . each do |host |
1210
- file = File . open ( filename , "rb" )
1211
- contents = file . read
1212
- lootfile = framework . db . find_or_create_loot ( :type => type , :host => host , :info => info , :data => contents , :path => filename , :name => name )
1213
- print_status ( "Added loot for #{ host } (#{ lootfile } )" )
1193
+ if mode == :add
1194
+ if host_ranges . compact . empty?
1195
+ print_error ( 'Address list required' )
1196
+ return
1197
+ end
1198
+ if info . nil?
1199
+ print_error ( "Info required" )
1200
+ return
1214
1201
end
1202
+ if filename . nil?
1203
+ print_error ( "Loot file required" )
1204
+ return
1205
+ end
1206
+ if types . nil? or types . size != 1
1207
+ print_error ( "Exactly one loot type is required" )
1208
+ return
1209
+ end
1210
+ type = types . first
1211
+ name = File . basename ( filename )
1212
+ file = File . open ( filename , "rb" )
1213
+ contents = file . read
1214
+ host_ranges . each do |range |
1215
+ range . each do |host |
1216
+ lootfile = framework . db . find_or_create_loot ( :type => type , :host => host , :info => info , :data => contents , :path => filename , :name => name )
1217
+ print_status ( "Added loot for #{ host } (#{ lootfile } )" )
1218
+ end
1219
+ end
1220
+ return
1215
1221
end
1216
- return
1217
- end
1218
1222
1219
1223
each_host_range_chunk ( host_ranges ) do |host_search |
1220
1224
framework . db . hosts ( framework . db . workspace , false , host_search ) . each do |host |
0 commit comments