問題サーバに接続すると、金額が提示されるので、それを1万ドル紙幣~1ドル紙幣、および50セント貨幣~1セント貨幣の枚数で答える問題です。Coinslot25#Hope #Change #Obama2008nc misc.chal.csaw.io 8000
金額の大きい紙幣、貨幣の順に枚数を聞いてくるので、聞かれた紙幣、貨幣の金額で割った商、余りを計算していけば良いです。商が聞かれた紙幣、貨幣の枚数になり、余りを残りの紙幣、貨幣の計算に引き継ぎいでいきます。Pythonプログラムを下記に載せます。$15180.83$10,000 bills: 1
$5,000 bills: 1
(略)
import itertoolsimport sys,sockethost = 'misc.chal.csaw.io'if len(sys.argv) > 1:host = sys.argv[1]port = 8000if len(sys.argv) > 2:host = int(sys.argv[2])client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)client.connect((host, port))client_file = client.makefile('b')while True:buf = client.recv(100)ary = buf.split('\n')for tmp in ary:print tmpif tmp.startswith('$10,000 bills:'):c = money // (10000 * 100)money = money - c * (10000 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$5,000 bills:'):c = money // (5000 * 100)money = money - c * (5000 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$1,000 bills:'):c = money // (1000 * 100)money = money - c * (1000 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$500 bills:'):c = money // (500 * 100)money = money - c * (500 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$100 bills:'):c = money // (100 * 100)money = money - c * (100 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$50 bills:'):c = money // (50 * 100)money = money - c * (50 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$20 bills:'):c = money // (20 * 100)money = money - c * (20 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$10 bills:'):c = money // (10 * 100)money = money - c * (10 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$5 bills:'):c = money // (5 * 100)money = money - c * (5 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('$1 bills:'):c = money // (1 * 100)money = money - c * (1 * 100)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('half-dollars (50c):'):c = money // (50)money = money - c * (50)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('quarters (25c):'):c = money // (25)money = money - c * (25)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('dimes (10c):'):c = money // (10)money = money - c * (10)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('nickels (5c):'):c = money // (5)money = money - c * (5)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('pennies (1c):'):c = money // (1)money = money - c * (1)client_file.write(str(c) + "\n")client_file.flush()print str(c)elif tmp.startswith('correct!'):passelif tmp.find('flag') > -1:sys.exit(1)elif tmp.startswith('$'):money = int(tmp.strip().translate(None, '$.'))else:sys.exit(1)
実行すると、次のようになります。
(略)$1681.90$10,000 bills:0$5,000 bills:0$1,000 bills:1$500 bills:1$100 bills:1$50 bills:1$20 bills:1$10 bills:1$5 bills:0$1 bills:1half-dollars (50c):1quarters (25c):1dimes (10c):1nickels (5c):1pennies (1c):0correct!flag{started-from-the-bottom-now-my-whole-team-fucking-here}
フラグは、
flag{started-from-the-bottom-now-my-whole-team-fucking-here}