- Notifications
You must be signed in to change notification settings - Fork0
giuliano-macedo/picottf18-be-quick-or-be-dead-2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PicoCTF 2018 solution for the problem 'Be quick or be dead 2' using the iterative Fibonacci function
i got the binary fromhere
this solution is very overkill
- python >=3.6
- pip
- gcc
just pip it aftervenv
pip install -r requirements.txt
the binary contains a recursive implementation of nth Fibonacci number function,called 'fib', that is calculation for the 1083th Fibonacci number that is used to print the flag,since the recursive function is very slow, and that this number causes 64bit integer overflow the functionmay run forever.
the correct answer for the problem would be:
9641162182178966878126331027202834784434723577592322830700454745652427494401346945631082965963962317692358822696127040961581675695438118874508418491101822679355067810556808551572644321954159676320600161466564032755133080685122
however, since overflow, the program would accept the following integer from the fib function:-1066907070
the program then waits for the computation for 3 seconds, if the fib function is still running until thereit will fail and not print the flag, otherwise it will print the flag.
this solution therefore compiles an iterative version of the nth Fibonacci number computation in another binaryextracts it and patch onto the original binary,since this solution isO(1) it will run basically instantly in any machine and print the flag.
run thecompile_fib.py
to generatefib_iterative.txt
that have the assembly code forthe iterative version of the Fibonacci, edit the labels from the jump-based instructionsand insert intopatch_it
and the binarybe-quick-or-be-dead-2_patched
will be createdand will print the flag.
About
PicoCTF 2018 solution for the problem 'Be quick or be dead 2' using the iterative Fibonacci function
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.