Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import binascii
  2. from pwn import * # pwntools
  3.  
  4. # connect
  5. r = remote('2018shell.picoctf.com', 1225)
  6.  
  7. # binary
  8. print r.readline() # get the first line over with
  9. word1 = r.readline() # for some reason the word for part 1 is echoed, so read it in
  10. print r.recvuntil("Input:") # skip to where we input word 1
  11. r.send(word1) # send it!
  12.  
  13. # hex
  14. print r.recvuntil("the ") # skip to right position to read in the hex string
  15. word2 = r.recvuntil(" ") # read string up to the space
  16. word2_hex = word2[:-1] # strip the space
  17. word2_ascii = binascii.unhexlify(word2_hex) # convert to ascii
  18. print r.recvuntil("Input:") # skip to entry
  19. r.send(word2_ascii + "\n") # send it!
  20.  
  21. # octal
  22. print r.recvuntil("the ") # skip to integer list
  23. word3 = ""
  24. while True:
  25. number = r.recvn(3) # read integer
  26. if number != "as ": # end of the list?
  27. word3 += chr(int(number,8)) # convert to decimal!
  28. r.recvn(1) # and discard the space
  29. else:
  30. break # we're done - dump out
  31. print r.recvuntil("Input:") # skip to entry
  32. r.send(word3 + "\n") # send it!
  33. r.interactive() # read the rest of the input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement