LoginSignup
0
0

More than 3 years have passed since last update.

picoCTF 2021 What's your input?

Posted at

できなかった問題をwriteup等を参考に勉強した記録を残す。

What's your input?

nc mercury.picoctf.net 39137
ヒント python2

in.py
#!/usr/bin/python2 -u
import random

cities = open("./city_names.txt").readlines()
city = random.choice(cities).rstrip()
year = 2018

print("What's your favorite number?")
res = None
while not res:
    try:
        res = input("Number? ")
        print("You said: {}".format(res))
    except:
        res = None

if res != year:
    print("Okay...")
else:
    print("I agree!")

print("What's the best city to visit?")
res = None
while not res:
    try:
        res = input("City? ")
        print("You said: {}".format(res))
    except:
        res = None

if res == city:
    print("I agree!")
    flag = open("./flag").read()
    print(flag)
else:
    print("Thanks for your input!")


$ nc mercury.picoctf.net 39137
What's your favorite number?
Number? 1
You said: 1
Okay...
What's the best city to visit?
City? Detroit
City? Roma
City? Barcelona
City?

無限ループみたい。
そもそも推測やブルートフォースに python2 は関係ないな。
何か別な方法があるはず。
↑ここまでは自力

他力によると変数名を入力するとその変数の値になるような脆弱性があったとのこと。

$ nc mercury.picoctf.net 39137
What's your favorite number?
Number? 1
You said: 1
Okay...
What's the best city to visit?
City? city
You said: Jefferson
I agree!
picoCTF{v4lua4bl3_1npu7_8433797}

本当だ。

でも,ググっても脆弱性が見つからない。

あった。

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