Advertisement
cookthebook

Guessing Game writeup

Mar 4th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Simple/Not-so-simple/Cruel Guessing Game writeup:
  2. Solved by AuPhish member cookthebook for sCTF 2015
  3.  
  4. These challenges can all be solved with the same script. The server you are prompted to connect to takes the value you send it and compares it to a random value it chooses (which changes every time you connect). So, to solve each of these challenges I wrote one single script that simply connects and reconnects constantly, sending the value 1 until it returns a match. The running time is fairly quick for each challenge, each one taking slightly longer than the other. Here is the python script:
  5.  
  6. -------------------------------------------------------------
  7. import socket, time
  8.  
  9. while True:
  10. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  11. s.connect(("python.sctf.io", 11234))
  12. s.recv(1024)
  13. s.send('1')
  14. data = s.recv(1024)
  15. s.close()
  16. print 'Received', repr(data)
  17. time.sleep(1)
  18. -------------------------------------------------------------
  19.  
  20. Simply change the port to the appropriate challenge and it will run.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement