본문 바로가기

Wargame

(46)
[Dreamhack] uaf_overwrite 보호 기법을 확인해보자. #include #include #include #include struct Human { char name[16]; int weight; long age; }; struct Robot { char name[16]; int weight; void (*fptr)(); }; struct Human *human; struct Robot *robot; char *custom[10]; int c_idx; void print_name() { printf("Name: %s\n", robot->name); } void menu() { printf("1. Human\n"); printf("2. Robot\n"); printf("3. Custom\n"); printf("> "); } void hu..
[Dreamhack] basic_exploitation_002 환경 정보를 보면 NX 보호기법이 활성화되었다. #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { system("/bin/sh"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); read(0, buf, 0x80); printf(buf); exit(0); } m..
[Dreamhack] Return to library 보호 기법에 카나리와 NX가 포함되었다. #include #include const char* binsh = "/bin/sh"; int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); // Add system function to plt's entry system("echo 'system@plt"); // Leak canary printf("[1] Leak Canary\n"); printf("Buf: "); read(0, buf, 0x100); //buf ~ canary 거리+1 만큼 입력해 canary 앞 \x00을 제거하면 printf("Buf: %s\n", buf); //카나리 출력 가능 // ..
[Dreamhack] ssp-001 #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { //쉘을 띄워주는 함수 system("/bin/sh"); } void print_box(unsigned char *box, int idx) { //원하는 인덱스의 box 값을 출력 printf("Element of index %d is : %02x\n", idx, box[idx]);..
[Dreamhack] Return to shallcode Canary found. 카나리 방어 기법이 걸려있다. #include #include void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } int main() { char buf[0x50]; //80 bytes만큼 할당 init(); printf("Address of the buf: %p\n", buf); printf("Distance between buf and $rbp: %ld\n", (char*)__builtin_frame_address(0) - buf); //buf의 주소와 buf ~ $rbp 의 offset을 출력 printf("[1] Leak the canary\n"); printf("Input: "); fflush(stdou..
[pwnable.kr] bof 아래는 다운받은 bof.c 코드이다. #include #include #include void func(int key){ char overflowme[32]; printf("overflow me : "); gets(overflowme);// smash me! if(key == 0xcafebabe){ system("/bin/sh"); } else{ printf("Nah..\n"); } } int main(int argc, char* argv[]){ func(0xdeadbeef); return 0; } main 함수의 func()에서 key = 0xdeadbeef를 위쪽 func()처럼 key = 0xcafebabe 로 바꿔주면 쉘을 띄워준다. gets 함수를 통해 입력을 받는데, 입력값의 길이를 제한하지 ..
[Dreamhack] basic_exploitation_000 환경정보를 살펴보면, 보호기법이 아무것도 적용되지 않고 있다. #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); printf("buf = (%p)\n", buf); scanf("%141s", buf); return 0; } main 함수를 보면 buf..
[Dreamhack] XSS-1 #!/usr/bin/python3 from flask import Flask, request, render_template from selenium import webdriver from selenium.webdriver.chrome.service import Service import urllib import os app = Flask(__name__) app.secret_key = os.urandom(32) try: FLAG = open("./flag.txt", "r").read() except: FLAG = "[**FLAG**]" def read_url(url, cookie={"name": "name", "value": "value"}): cookie.update({"domain": "127.0.0..