Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PicoCTF 2018 solution for the problem 'Be quick or be dead 2' using the iterative Fibonacci function

NotificationsYou must be signed in to change notification settings

giuliano-macedo/picottf18-be-quick-or-be-dead-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

disclaimer

i got the binary fromhere

this solution is very overkill

pre-requisites

  • python >=3.6
  • pip
  • gcc

installation

just pip it aftervenv

pip install -r requirements.txt

write up

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.

Usage

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp