0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

picoCTF Writeup: two-sum

intオーバーフローを知ろう問題

  • ジャンル: Binary Exploitation
  • 難易度: Medium

Writeup

問題文

Can you solve this?
What two positive numbers can make this possible: n1 > n1 + n2 OR n2 > n1 + n2
Enter them here nc saturn.picoctf.net 60831. Source

intと宣言すると、32bit(4Bytes)で2の補数表現で扱われます。

intは最上位bitが符号bitなので、最大値と最小値は以下になります。

最大値 最小値
2,147,483,647 ( = 2^31 - 1) -2,147,483,648 ( = -2^31)

最大値21474836471を足すと、最上位bitが1となり最小値に変化します。

この考え方で、サーバーに接続してみます。

$ nc saturn.picoctf.net 57832
n1 > n1 + n2 OR n2 > n1 + n2 
What two positive numbers can make this possible:
2147483647
1
You entered 2147483647 and 1
You have an integer overflow
YOUR FLAG IS: picoCTF{Tw0_Sum_Integer_Bu773R_0v3rfl0w_482d8fc4}

flagとれました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?