415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
|
# File 'lib/wasp/wasp.rb', line 415
def _attack (wasps, num, conn, urls, time=nil)
coop = conn / wasps.count
num = num / wasps.count if not num.nil?
print "Get communication channel for wasps..\n"
threads = []
wasps.each do |b|
threads << Thread.new(b) { |wasp|
begin
wasp[:ssh] = Net::SSH.start(wasp[:instance_name], wasp[:login],
:keys => ENV['HOME'] + '/.ssh/' + wasp[:key_name] + '.pem')
print "Wasp " + "#{wasp[:instance_id]}".yellow + " is joining the wasp.\n"
rescue => ex
puts "[Error] ".red + "#{ex.message}"
puts "Cannot reach to " + "#{wasp[:instance_id]}".yellow
end
}
end
threads.each { |aThread| aThread.join }
threads = []
i = 0
wasps.each do |b|
url = urls[i%urls.count]
i += 1
threads << Thread.new(b) { |wasp|
begin
weapon = get_weapon
if weapon.check(wasp[:ssh]) then
print "Wasp " + "#{wasp[:instance_id]}".yellow + " is firing its stings. Ping ping!\n"
wasp[:rawreport] = weapon.fire(num, coop, url, wasp[:instance_id], @report, @keepalive, @without_cookie, time, )
print "Wasp " + "#{wasp[:instance_id]}".yellow + " is out of ammo.\n"
else
print "Wasp " + "#{wasp[:instance_id]}".yellow + " has no weapon.\n"
end
rescue => ex
print "[WARN]".yellow + " #{ex.message}.\n"
end
}
end
threads.each { |aThread| aThread.join }
wasps.each do |wasp|
begin
wasp[:ssh].close
rescue => ex
puts "[WARN]".yellow + "#{ex.message}"
end
end
wasps
end
|