picoctf/misc/endianness/solve.py

29 lines
665 B
Python
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -p python3 -i python3 python3Packages.pwntools
from pwn import *
ADDR, PORT, *_ = "titan.picoctf.net 62735".split()
def main():
r = remote(ADDR, PORT)
r.recvuntil(b'Word: ')
word = r.recvline().strip()
r.recvuntil(b'Enter the Little Endian representation: ')
little_endian = ''.join(hex(b)[2:] for b in reversed(word))
r.sendline(little_endian.encode())
r.recvuntil(b'Enter the Big Endian representation: ')
big_endian = ''.join(hex(b)[2:] for b in word)
r.sendline(big_endian.encode())
r.recvuntil(b'Your Flag is: ')
print(r.recvline().decode())
r.close()
if __name__ == "__main__":
main()