Security/Write Up 18

[Dreamhack] littlevsbig

Dreamhack CTF Season S4 Round #4 해당 문제는 리눅스 환경에서 nc host3.dreamhack.games [포트 번호] 로 접속한다. 접속하면 Input: 으로 사용자 입력을 받고, 입력 받은 문자를 16진수로 출력해준다. unsigned char arr[9]; scanf("%8s", arr); printf("arr | 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x |\n", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7]); unsigned int * int_arr = (unsigned int *)arr; printf("arr | 0x%x 0x%x |\n", int_arr[0], int_..

Security/Write Up 2023.08.28

[Dreamhack] blind-command

문제 페이지에 접속하면 아무것도 없다.. URL에 os command injection 명령어를 입력해봤지만 문자열을 그대로 보여준다. 문제 파일 #!/usr/bin/env python3 from flask import Flask, request import os app = Flask(__name__) @app.route('/' , methods=['GET']) def index(): cmd = request.args.get('cmd', '') if not cmd: return "?cmd=[cmd]" if request.method == 'GET': '' else: os.system(cmd) return cmd app.run(host='0.0.0.0', port=8000) GET 메소드가 아닌 다른 메소..

Security/Write Up 2023.08.28

[Dreamhack] web-ssrf

서버 측 요청 위조(Server-Side Request Forgery, SSRF) SSRF는 서버에서 위조된 요청을 보내도록 유도하는 취약점이다. 공격자는 SSRF 취약점을 이용하여 서버 측에서 임의의 주소로 HTTP 요청을 보내게 하여 사용자가 접근할 수 없었던 서버 내부 자원에 접근할 수 있게 된다. 문제 페이지에는 이미지를 출력하는 Image Viewer가 있다. Burp Suite를 이용해 패킷을 잡아보면 url 파라미터에 입력값이 들어가는 것이 확인된다. 코드를 보면 url = "http://localhost:8000" + url url 파라미터에 위와 같이 값을 넣어주면 될 것 같다. elif ("localhost" in urlp.netloc) or ("127.0.0.1" in urlp.net..

Security/Write Up 2023.08.28

[Dreamhack] Flying Chars

문제 페이지로 접속하면 눈이 아프다.. 개발자 도구로 script 코드를 보면 function anim(elem, pos, dis){ function move() { pos += dis; if (pos > max_pos) { pos = 0; } elem.style.transform = `translateX(${pos}px)`; requestAnimationFrame(move); } move(); } for(var i = 0; i < 20; i++){ anim(imgs[i], 0, Math.random()*60+20); } 위와 같이 move() 함수가 있고 pos 변수에 일정 값을 더해주고 있는 것을 알 수 있다. pos += dis; 또한 random() 함수를 이용해서 이미지들을 움직이는 것으로 보이..

Security/Write Up 2023.08.25

[Dreamhack] proxy-1

HTTP 요청 헤더를 직접 작성해야 한다. 요청 헤더에 들어가야할 내용은 코드를 통해 힌트를 얻을 수 있다. POST 메소드 /admin User-Agent DreamhackUser Cookie body에는 userid가 포함된다. 이 외에도 기본으로 추가되어야 할 값은 Host Content-Type Content-Length 가 있다. POST /admin HTTP/1.1 Host: {해당 URL} User-Agent: Admin Browser DreamhackUser: admin Cookie: admin=true Content-Type: application/x-www-form-urlencoded Content-Length: 12 userid=admin

Security/Write Up 2023.08.21

[Dreamhack] simple_sqli_chatgpt

GPT 사용 X 코드에서 userlevel 0은 guest임을 확인할 수 있다. SQL Injection은 쿼리문을 알면 쉽게 풀린다. select * from users where userlevel='{userlevel}'; 에서 {userlevel}을 페이지에서 사용자에게 입력받고 있다. FLAG는 userid가 admin이고, userlevel이 0일 때 얻을 수 있다. userlevel에 0, userid에 admin을 넣어 쿼리를 완성할 수도 있고, 항상 참이 되는 쿼리를 이용할 수도 있다. (단 admin과 guest userlevel이 0으로 동일하기 때문에 참이 되는 쿼리는 userlevel에만 사용해야 한다.) 0' and userid='admin ' or 1=1 and userid='a..

Security/Write Up 2023.08.21
728x90