2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2010-11-23 01:23:24 +00:00
|
|
|
|
|
|
|
require 'msf/base/sessions/command_shell_options'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This module provides methods for scanning modules that yield
|
|
|
|
# Command Shell sessions.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
|
|
|
module Auxiliary::CommandShell
|
|
|
|
|
|
|
|
include Msf::Sessions::CommandShellOptions
|
|
|
|
|
|
|
|
#
|
|
|
|
# Ghetto
|
|
|
|
#
|
|
|
|
module CRLFLineEndings
|
2011-05-02 21:39:09 +00:00
|
|
|
def put(str, opts={})
|
2010-11-23 01:23:24 +00:00
|
|
|
return super if not str
|
2011-05-02 21:39:09 +00:00
|
|
|
super(str.strip + "\r\n", opts)
|
2010-11-23 01:23:24 +00:00
|
|
|
end
|
2011-05-02 21:39:09 +00:00
|
|
|
def write(str, opts={})
|
2011-05-01 23:56:57 +00:00
|
|
|
return super if not str
|
2011-05-02 21:39:09 +00:00
|
|
|
super(str.strip + "\r\n", opts)
|
2011-05-01 23:56:57 +00:00
|
|
|
end
|
2010-11-23 01:23:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def start_session(obj, info, ds_merge, crlf = false, sock = nil)
|
|
|
|
if crlf
|
|
|
|
# Windows telnet server requires \r\n line endings and it doesn't
|
|
|
|
# seem to affect anything else.
|
|
|
|
obj.sock.extend(CRLFLineEndings)
|
|
|
|
end
|
|
|
|
|
|
|
|
sock ||= obj.sock
|
|
|
|
sess = Msf::Sessions::CommandShell.new(sock)
|
|
|
|
sess.set_from_exploit(obj)
|
|
|
|
sess.info = info
|
|
|
|
|
|
|
|
# Clean up the stored data
|
|
|
|
sess.exploit_datastore.merge!(ds_merge)
|
|
|
|
|
|
|
|
# Prevent the socket from being closed
|
|
|
|
obj.sockets.delete(sock)
|
|
|
|
obj.sock = nil if obj.respond_to? :sock
|
|
|
|
|
|
|
|
framework.sessions.register(sess)
|
|
|
|
sess.process_autoruns(datastore)
|
2011-07-14 19:42:03 +00:00
|
|
|
|
|
|
|
sess
|
2010-11-23 01:23:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|