2013-12-15 14:34:50 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-12-15 14:34:50 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2013-12-26 16:30:30 +00:00
|
|
|
'Name' => 'Poison Ivy Command and Control Scanner',
|
2013-12-23 23:35:42 +00:00
|
|
|
'Description' => %q{
|
2013-12-26 16:30:30 +00:00
|
|
|
Enumerate Poison Ivy Command and Control (C&C) on ports 3460, 80, 8080 and 443. Adaptation of iTrust Python script.
|
2013-12-23 23:35:42 +00:00
|
|
|
},
|
2013-12-16 16:38:49 +00:00
|
|
|
'Author' => ['SeawolfRN'],
|
2013-12-15 14:34:50 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2013-12-16 11:33:08 +00:00
|
|
|
OptString.new('PORTS', [true, "Ports to Check","80,8080,443,3460"]),
|
2013-12-20 18:44:42 +00:00
|
|
|
OptInt.new('TIMEOUT', [true, "The socket connect timeout in milliseconds", 1000]),
|
2013-12-23 23:35:42 +00:00
|
|
|
OptInt.new('CONCURRENCY', [true, "The number of concurrent ports to check per host", 10])
|
2013-12-15 14:34:50 +00:00
|
|
|
], self.class)
|
|
|
|
|
|
|
|
deregister_options('RPORT')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
timeout = datastore['TIMEOUT'].to_i
|
|
|
|
|
2013-12-15 22:02:14 +00:00
|
|
|
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
|
2013-12-15 14:34:50 +00:00
|
|
|
|
2013-12-18 20:55:51 +00:00
|
|
|
if ports.empty?
|
|
|
|
raise Msf::OptionValidateError.new(['PORTS'])
|
|
|
|
end
|
|
|
|
|
2013-12-15 14:34:50 +00:00
|
|
|
while(ports.length > 0)
|
|
|
|
t = []
|
|
|
|
r = []
|
|
|
|
begin
|
|
|
|
1.upto(datastore['CONCURRENCY']) do
|
|
|
|
this_port = ports.shift
|
|
|
|
break if not this_port
|
|
|
|
t << framework.threads.spawn("Module(#{self.refname})-#{ip}:#{this_port}", false, this_port) do |port|
|
|
|
|
begin
|
|
|
|
s = connect(false,
|
|
|
|
{
|
|
|
|
'RPORT' => port,
|
|
|
|
'RHOST' => ip,
|
|
|
|
'ConnectTimeout' => (timeout / 1000.0)
|
|
|
|
}
|
|
|
|
)
|
2013-12-15 22:02:14 +00:00
|
|
|
r << [ip,port,"open",'Unknown']
|
2013-12-20 18:44:42 +00:00
|
|
|
s.puts("\x00"*0x100,0) #Send 0x100 zeros, wait for answer
|
2014-12-17 18:46:12 +00:00
|
|
|
data = s.get_once(0x100) || ''
|
2013-12-16 22:12:35 +00:00
|
|
|
if data.length == 0x100
|
2014-12-17 18:46:12 +00:00
|
|
|
data = s.get_once(0x4) || ''
|
2013-12-16 22:12:35 +00:00
|
|
|
if data == "\xD0\x15\x00\x00" #Signature for PIVY C&C
|
2013-12-15 14:34:50 +00:00
|
|
|
print_status("#{ip}:#{port} - C&C Server Found")
|
2013-12-15 22:02:14 +00:00
|
|
|
r << [ip,port,"open",'Poison Ivy C&C']
|
2013-12-15 14:34:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionRefused
|
|
|
|
vprint_status("#{ip}:#{port} - TCP closed")
|
2013-12-15 22:02:14 +00:00
|
|
|
r << [ip,port,"closed",'']
|
2013-12-15 14:34:50 +00:00
|
|
|
rescue ::Rex::ConnectionError, ::IOError, ::Timeout::Error
|
|
|
|
rescue ::Rex::Post::Meterpreter::RequestError
|
|
|
|
raise $!
|
|
|
|
ensure
|
|
|
|
disconnect(s) rescue nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
t.each {|x| x.join }
|
|
|
|
|
|
|
|
rescue ::Timeout::Error
|
|
|
|
ensure
|
|
|
|
t.each {|x| x.kill rescue nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
r.each do |res|
|
2013-12-15 22:02:14 +00:00
|
|
|
report_service(:host => res[0], :port => res[1], :state => res[2], :name=> res[3])
|
2013-12-15 14:34:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|