본문 바로가기
반응형

CTF.17

08_angr_constraints #Angr Tutorial For CTF 이번 문제는 main함수에서 문자열을 입력받고, 해당 문자열을 특정 연산 후에 check_equals 함수에서 몇개의 문자가 맞는지 확인을 한다. 시작 주소는 scanf 이후로 잡고, buffer 변수를 만든다. start_address = 0x08048622 initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS} ) buffer = claripy.BVS('buffer', 16 * 8) buffer_address = 0x0804A050 initi.. 2022. 8. 27.
07_angr_symbolic_file #Angr Tutorial For CTF 문자열을 입력받은 후, ignore_me 함수에서 OJKSQYDP.txt에 값을 저장한다. 다시 main 함수로 돌아와 OJKSQYDP.txt 함수를 읽고, 일정한 문자열과 비교를 한다. 시작 주소는 memset이 끝나고 fopen 시작 부분으로 해준다. start_address = 0x080488E7 initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS} ) file 이름과 symbolic file 크기를 지정해준다. fread(buffer, .. 2022. 8. 26.
06_angr_symbolic_daynamic_memory #Angr Tutorial For CTF 이번엔 동적 할당을 한 변수가 나왔다. start_address는 scanf 이후로 한다. start_address = 0x08048699 initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS} ) # The binary is calling scanf("%8s %8s"). # (!) password0 = claripy.BVS('password0', 64) password1 = claripy.BVS('password1', 64) 동적 할당한다면 어.. 2022. 8. 25.
05_angr_symbolic_memory #Angr Tutorial For CTF sacnf로 전역변수에 값을 쓰고, 비교를 하는 함수다. 우선 %8s %8s %8s %8s 이므로 start_address를 scanf 이후로 맞춰주고, 변수들을 만들어 준다. 또한 8바이트를 받으므로 64(8*8)비트를 넣어준다. start_address = 0x08048601 initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS} ) # The binary is calling scanf("%8s %8s %8s %8s"). # (!) passw.. 2022. 8. 24.
04_angr_symbolic_stack #Angr Tutorial For CTF 음.. 이전 문제와 비슷한거 같은데.. scanf가 %u %u로 되어 있으니 시작 주소는 scanf 주소 이후로 맞춰준다. start_address = 0x8048697 initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS} ) * 시작주소는 scanf 이 후 어떤 주소든 상관없다. complex_function0 위로 잡으면 된다. 이 문제는 전과 같이 scanf로 받은 값을 레지스터에 저장을 안하고 스택에서 사용을 한다. 이래서 symboli.. 2022. 8. 23.
03_angr_symbolic_registers #Angr Tutorial For CTF 입력 받는 scanf 함수들이 get_user_input 함수에 들어있다. angr는 scanf에 %x %x와 같이 여러가지 입력을 지원하지 않는다. 따라서 시작 주소 기존의 entry_state가 아닌 scanf 이후로 맞춰둬야 한다. scanf는 get_user_input 함수에 있으니, 끝났을 때의 기준으로 맞췄다. start_address = 0x08048980 # :integer (probably hexadecimal) initial_state = project.factory.blank_state( addr=start_address, add_options = { angr.options.SYMBOL_FILL_UNCONSTRAINED_MEMORY, angr.options.SYMBOL_FILL_UNC.. 2022. 8. 22.
02_angr_find_condition #Angr Tutorial For CTF 음.. 1번 문제와 매우 같다. 하지만 이번 문제는 Good Job을 호출하는 부분이 많아 특정 주소를 못 적는다. 따라서 상태에 따라서 플레그를 출력 하게 해야 한다. # It is very useful to be able to search for a state that reaches a certain # instruction. However, in some cases, you may not know the address of the # specific instruction you want to reach (or perhaps there is no single # instruction goal.) In this challenge, you don't know which instruction # grant.. 2022. 8. 21.
01_angr_avoid #Angr Tutorial For CTF 흠.. 크기가 너무 커서 Hex-Ray가 작동하지 않는다. 이번 문제도 패스워드를 입력하면 complex_function에서 연산하고, avoid_me를 피한채로 maybe_good으로 들어가면 된다. avoid_me 에 들어가면 should_succeed가 0이 되므로 피해야 한다. import angr def main(): proj = angr.Project('./01_angr_avoid') init_state = proj.factory.entry_state() simulation = proj.factory.simgr(init_state) print_good = 0x80485E5 avoid_addr = 0x80485A8 simulation.explore(find=print_good, avoid=avo.. 2022. 8. 20.
00_angr_find #Angr Tutorial For CTF 문자열을 입력받고 해당 문자열을 complex_function으로 보낸다. complex_function에서는 어떠한 연산을 진행하고 return 한다. import angr def main(): # create project proj = angr.Project('./00_angr_find') # entry point init_state = proj.factory.entry_state() # create simulation simulation = proj.factory.simgr(init_state) # expected address print_good = 0x804867d # start explore simulation.explore(find=print_good) if simulation.found: .. 2022. 8. 19.
Warm up Write-Up #ASIS CTF Quals 2018 Points : 27 Solves : 283 Description : Must-Have Pre-Workout Warm up Challenge. 파일을 다운로드 받으면 warmup 파일이 있다. ExeinfoPE 로 확인해보니 Text 파일이며 #define M 37로 시작한다는 것을 알 수 있다. VScode로 확인해보면 define 이 있고, 무언가 쭉 있다. https://codebeautify.org/c-formatter-beautifier Best C Formatter and Beautifier C Formatter will help to format, beautify, minify, compact C code, string, text. Format, Save, Share codebeautify... 2022. 8. 8.
Matriochka Step 1~3 Write-Up #Nuit du Hack CTF Quals 2016 #Matriochka Step1 Points : 50 Solves : 432 Description : Can you help me? Recently, I found an executable binary. As I'm a true newbie, Certainly, to solve it, I will have difficulties. Keep in mind, the first step is quite easy. Maybe the last one will be quite tricky. Emulating it could be a good idea. The challenge is available at : http://static.quals.nuitduhack.com/stage1.bin stage1.bin 을 실.. 2022. 8. 5.
ServerfARM Write-Up #Internetwache CTF 2016 Points : 70 Solves : 156 Description: Someone handed me this and told me that to pass the exam, I have to extract a secret string. I know cheating is bad, but once does not count. So are you willing to help me? Attachment: rev70.zip 비밀 문자열을 추출해 달라고 한다.. main 함수 부분이다. 특별한 건 없으니 handle_task부분으로 넘어가자. handle_task 부분이다. case0의 if문을 보면 참일 경우 문자열 "IW{"를 출력하는 것을 볼 수있고, 밑에 putchar(83), printf("%c%c\n", .. 2022. 8. 5.
File Checker Write-Up #Internetwache CTF 2016 Points : 60 Solves : 190 Description: My friend sent me this file. He told that if I manage to reverse it, I'll have access to all his devices. My misfortune that I don't know anything about reversing :/ Attachment: rev60.zip 실행을 해봤는데 Fatal error: File does not exist가 나온다. 특정한 파일을 생성해야 하는 문제 인 것 같다. main 함수다. .password 파일을 열어서 안에 있는 문자열을 꺼내와 sub_40079C에서 연산을 하고 v8과 or 연산을 하여 마지막에 v8이 0이면 Congrat.. 2022. 8. 4.
SPIM Write-Up #Internetwache CTF 2016 Points : 50 Solves : 208 Description : My friend keeps telling me, that real hackers speak assembly fluently. Are you a real hacker? Decode this string: "IVyN5U3X)ZUMYCs" User Text Segment [00400000]..[00440000] [00400000] 8fa40000 lw $4, 0($29) ; 183: lw $a0 0($sp) # argc [00400004] 27a50004 addiu $5, $29, 4 ; 184: addiu $a1 $sp 4 # argv [00400008] 24a60004 addiu $6, $5, 4 ; 185: addiu $a2 $a1 .. 2022. 8. 4.
Serial Write-Up #Sharif University CTF 2016 Points : 150 Solves : 108 Description : Run and capture the flag! 실행을 하면 문자열을 입력 받는다. 올바른 시리얼 넘버를 찾는 문제인 것 같다. 동적분석 하면서 찾은 첫번째 비교문이다. strlen 으로 0x10과 비교하고 있다. 입력 문자열의 길이는 10인 것을 알 수 있다. 첫번째 문자와 비교하는 부분이다. rbp-200h에 입력한 문자열이 들어간다. 첫번째 문자 : E rbp-200h가 문자열의 시작이라면, rbp-1F1은 문자열의 맨 마지막이다. 첫번째 문자(E) + x = 0x9B가 되어야 한다. 마지막 문자 : V (0x56) 두번째 문자와 비교하는 부분이다. 두번째 문자 : Z 두번째 문자와 문자열의 맨 마지막에서 두번째의 문자를 더한 값.. 2022. 7. 26.
반응형