TCP - Retour au collège
Rédaction d'un script python
import socket
import re
import base64
def netcat(HOST,PORT):
# Create a socket object
s = socket.socket()
# connect to the server on local computer
s.connect((HOST, PORT))
# receive data from the server and decoding to get the string.
res = s.recv(1024).decode()
print(res)
# read number
regex = "\'(.*)\'"
# Search regex
search = re.search(regex, res)
# # caclul square
res = base64.b64decode(search.group(1)).decode('utf-8')
print(f'The res : {res}')
# send result
s.sendall((str(res)+"\n").encode())
return s.recv(1024).decode()
def main():
print(netcat("challenge01.root-me.org",52023))
if __name__ == "__main__":
main()
Flag :
RM{TCP_Enc0d3_4nd_D3c0d3}