Skip to content

Commit 226cd24

Browse files
committed
Added Poison Ivy Command and Control Scanner\n Auxiliary module to scan for Poison Ivy C&C on ports 80,8080,443 and 3460
1 parent 3dec7f6 commit 226cd24

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
7+
require 'msf/core'
8+
9+
class Metasploit3 < Msf::Auxiliary
10+
11+
include Msf::Exploit::Remote::Tcp
12+
13+
include Msf::Auxiliary::Report
14+
include Msf::Auxiliary::Scanner
15+
16+
17+
def initialize
18+
super(
19+
'Name' => 'Poison Ivy C&C Scanner',
20+
'Description' => 'Enumerate Poison Ivy C&C on ports 3460,80,8080 and 443. Adaptation of iTrust Python script.
21+
www.malware.lu/Pro/RAP002_APT1_Technical_backstage.1.0.pdf',
22+
'Author' => [ 'SeawolfRN'],
23+
'License' => MSF_LICENSE
24+
)
25+
26+
register_options(
27+
[
28+
OptInt.new('TIMEOUT', [true, "The socket connect timeout in milliseconds", 1000]),
29+
OptInt.new('CONCURRENCY', [true, "The number of concurrent ports to check per host", 10]),
30+
], self.class)
31+
32+
deregister_options('RPORT')
33+
34+
end
35+
36+
37+
def run_host(ip)
38+
39+
timeout = datastore['TIMEOUT'].to_i
40+
41+
ports = Rex::Socket.portspec_crack("3460,80,443,8080")
42+
43+
while(ports.length > 0)
44+
t = []
45+
r = []
46+
begin
47+
1.upto(datastore['CONCURRENCY']) do
48+
this_port = ports.shift
49+
break if not this_port
50+
t << framework.threads.spawn("Module(#{self.refname})-#{ip}:#{this_port}", false, this_port) do |port|
51+
begin
52+
s = connect(false,
53+
{
54+
'RPORT' => port,
55+
'RHOST' => ip,
56+
'ConnectTimeout' => (timeout / 1000.0)
57+
}
58+
)
59+
r << [ip,port,"open"]
60+
s.send("\x00"*0x100,0) #Send 0x100 zeros, wait for answer
61+
data=s.recv(0x100)
62+
if data.length==0x100
63+
data=s.recv(0x4)
64+
if data=="\xD0\x15\x00\x00" #Signature for PIVY C&C
65+
print_status("#{ip}:#{port} - C&C Server Found")
66+
end
67+
end
68+
rescue ::Rex::ConnectionRefused
69+
vprint_status("#{ip}:#{port} - TCP closed")
70+
r << [ip,port,"closed"]
71+
rescue ::Rex::ConnectionError, ::IOError, ::Timeout::Error
72+
rescue ::Rex::Post::Meterpreter::RequestError
73+
rescue ::Interrupt
74+
raise $!
75+
rescue ::Exception => e
76+
print_error("#{ip}:#{port} exception #{e.class} #{e} #{e.backtrace}")
77+
ensure
78+
disconnect(s) rescue nil
79+
end
80+
end
81+
end
82+
t.each {|x| x.join }
83+
84+
rescue ::Timeout::Error
85+
ensure
86+
t.each {|x| x.kill rescue nil }
87+
end
88+
89+
r.each do |res|
90+
report_service(:host => res[0], :port => res[1], :state => res[2])
91+
end
92+
end
93+
end
94+
95+
end

0 commit comments

Comments
 (0)