목록전체 글 (33)
D1N0's hacking blog
포너블에서 너무 중요하고 기초적인 내용이지만 아직도 헷갈려서 정리한다 이 글은 독자가 기초적인 C언어와 어셈블리어를 알고 있는 상태라고 가정한다 모든 코드는 WSL Ubuntu 20.04 LTS에서 -m32 -no-pie 옵션을 사용해서 gcc로 컴파일 되었고, 실행 파일들은 글 하단에 올려놓았다 cdecl은 수많은 32bit 프로그램에서 사용되는 방식이다 함수를 호출하고, 호출자가 스택을 정리하는 호출자 정리 방식의 일종이다 #include int foo(int a, int b, int c) { return a+b+c; } int main() { int a = foo(1, 2, 3); return 0; } 위와 같은 C 코드를 짜고 32bit 컴파일을 했다 gef gdb로 까 보면 main 함수는 이렇..
z3 solver를 써볼 문제를 찾다가 이걸 선택하게 되었다 굳이 z3 solver를 안 써도 풀 수 있을 것 같기는 한데 그래도 이왕 배운 거 써먹어보고 싶었다 문제 풀이 분석 일단 주어진 파일의 hex값을 보면 elf파일임을 알 수 있다 실행을 해보면 입력을 받는다 그리고 바로 끝나는데 키가 맞으면 뭔가 일어날 것 같다 IDA로 까보면 입력을 받고 check_key를 실행하여 1이면 flag 파일을 열어 출력해주는 것을 알 수 있다 check_key 함수는 입력받은 문자열을 encoding 함수에 넣고 OO]oUU2U
Z3 solver z3 solver는 특정 값들을 찾아주는 SMT solver 모듈이라고 한다 쉽게 말하면 여러 수식을 풀어주는 모듈이라고 생각하면 된다 리버싱 할 때도 많이 필요하고 그게 아니더라도 유용히 쓸 수 있을 거 같아서 정리하기로 했다 설치 일단 Z3 solver 모듈의 링크는 이곳이다 github.com/Z3Prover/z3 들어가면 다양한 언어에서의 설치 과정이 자세히 나와있지만 나는 파이썬을 쓸 거라서 pip로 간단히 설치가 가능하다 pip install z3-solver or pip3 install z3-solver 기본 문법 사용 전 모듈 불러오기 from z3 import * 정수형 미지수 선언 x = Int('x') y = Int('y') 실수형 미지수 선언 x = Real('x'..