Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/misc/poisonivy_control_scanner.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize11super(12'Name' => 'Poison Ivy Command and Control Scanner',13'Description' => %q{14Enumerate Poison Ivy Command and Control (C&C) on ports 3460, 80, 8080 and 443. Adaptation of iTrust Python script.15},16'Author' => ['SeawolfRN'],17'License' => MSF_LICENSE18)1920register_options(21[22OptString.new('PORTS', [true, "Ports to Check","80,8080,443,3460"]),23OptInt.new('TIMEOUT', [true, "The socket connect timeout in milliseconds", 1000]),24OptInt.new('CONCURRENCY', [true, "The number of concurrent ports to check per host", 10])25])2627deregister_options('RPORT')2829end303132def run_host(ip)3334timeout = datastore['TIMEOUT'].to_i3536ports = Rex::Socket.portspec_crack(datastore['PORTS'])3738if ports.empty?39raise Msf::OptionValidateError.new(['PORTS'])40end4142while(ports.length > 0)43t = []44r = []45begin461.upto(datastore['CONCURRENCY']) do47this_port = ports.shift48break if not this_port49t << framework.threads.spawn("Module(#{self.refname})-#{ip}:#{this_port}", false, this_port) do |port|50begin51s = connect(false,52{53'RPORT' => port,54'RHOST' => ip,55'ConnectTimeout' => (timeout / 1000.0)56}57)58r << [ip,port,"open",'Unknown']59s.puts("\x00"*0x100,0) #Send 0x100 zeros, wait for answer60data = s.get_once(0x100) || ''61if data.length == 0x10062data = s.get_once(0x4) || ''63if data == "\xD0\x15\x00\x00" #Signature for PIVY C&C64print_status("#{ip}:#{port} - C&C Server Found")65r << [ip,port,"open",'Poison Ivy C&C']66end67end68rescue ::Rex::ConnectionRefused69vprint_status("#{ip}:#{port} - TCP closed")70r << [ip,port,"closed",'']71rescue ::Rex::ConnectionError, ::IOError, ::Timeout::Error72rescue ::Rex::Post::Meterpreter::RequestError73raise $!74ensure75disconnect(s) rescue nil76end77end78end79t.each {|x| x.join }8081rescue ::Timeout::Error82ensure83t.each {|x| x.kill rescue nil }84end8586r.each do |res|87report_service(:host => res[0], :port => res[1], :state => res[2], :name=> res[3])88end89end90end91end929394