Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import subprocess
  2. import string
  3. # We'll get the flag one char by one
  4.  
  5. # Added more 'a's just out of caution
  6. initial = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafying code is: &"
  7.  
  8. # The position at which the character is to be replaced
  9. replace = 122
  10.  
  11. while True:
  12. # instead of checking for all 256 bytes, since we know the flag
  13. # structure, check only for printable characters
  14. for c in string.printable:
  15. current = initial[:replace] + c + initial[(replace + 1):]
  16. output = subprocess.run(["nc", "2018shell3.picoctf.com", "33893"],
  17. input=bytes(current + '\n', 'utf-8'),
  18. stdout = subprocess.PIPE).stdout
  19. output = output[56:]
  20. if output[10 * 32: 10 * 32 + 32] == output[18 * 32: 18 * 32 + 32]:
  21. print(f'Found c: {c}')
  22. initial = current[1:]
  23. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement