반응형
c lang : shellcode 작성 ][test111 폴더 생성하기
■ 사용법
sudo apt install nasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .text | |
global _start | |
_start: | |
jmp folder | |
main: | |
xor rax,rax | |
pop rdi | |
mov si,0x1ef | |
add al,83 | |
syscall | |
xor rax,rax | |
add al,60 | |
syscall | |
folder: | |
call main | |
fname db "test111" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nasm -f elf64 shell.asm -o shell.o | |
ld shell.o -o shell | |
./shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objdump -d shell | |
for i in $(objdump -d shell | grep "^ " | cut -f 2); do echo -n \\x$i; done | |
\xeb\x13\x48\x31\xc0\x5f\x66\xbe\xef\x01\x04\x53\x0f\x05\x48\x31\xc0\x04\x3c\x0f\x05\xe8\xe8\xff\xff\xff\x74\x65\x73\x74\x31\x31\x31 | |
for i in $(objdump -d shell | grep "^ " | cut -f 2); do echo -n $i; done | |
eb134831c05f66beef0104530f054831c0043c0f05e8e8ffffff74657374313131 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// gcc -o test test.c -m64 | |
// | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/mman.h> | |
#include <err.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
unsigned char shellcode[] = "\xeb\x13\x48\x31\xc0\x5f\x66\xbe\xef\x01\x04\x53\x0f\x05\x48\x31\xc0\x04\x3c\x0f\x05\xe8\xe8\xff\xff\xff\x74\x65\x73\x74\x31\x31\x31"; | |
int | |
main(void) | |
{ | |
void (*p)(); | |
int fd; | |
printf("Lenght: %d\n", strlen(shellcode)); | |
fd = open("/tmp/. ", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); | |
if (fd < 0) | |
err(1, "open"); | |
write(fd, shellcode, strlen(shellcode)); | |
if ((lseek(fd, 0L, SEEK_SET)) < 0) | |
err(1, "lseek"); | |
p = (void (*)())mmap(NULL, strlen(shellcode), PROT_READ|PROT_EXEC, MAP_SHARED, fd, 0); | |
if (p == (void (*)())MAP_FAILED) | |
err(1, "mmap"); | |
p(); | |
printf("succ"); | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -o test test.c -m64 |
https://speedr00t.tistory.com/596
c lang : shellcode 작성 ][test111 폴더 생성하기
c lang : shellcode 작성 ][test111 폴더 생성하기 ■ 사용법 sudo apt install nasm https://speedr00t.tistory.com/596
speedr00t.tistory.com
반응형
'C 언어 > 0x08-shellcode' 카테고리의 다른 글
[c lang ] : read and execute shellcode from a File (0) | 2023.01.18 |
---|---|
shell 코드 64bit코딩시 컴파일 방법 (0) | 2014.10.12 |