Skip to content

Instantly share code, notes, and snippets.

@senges
Created December 22, 2018 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senges/1b58ed5ef8f42e3982091fc5680e6914 to your computer and use it in GitHub Desktop.
Save senges/1b58ed5ef8f42e3982091fc5680e6914 to your computer and use it in GitHub Desktop.

Menthal arithmetic

Le sujet nous fournit une adresse IP et un Port. On essaye donc de s'y connecter :

nc 51.75.202.113 10001

You must calculate the square root of the 1st number, multiply the result by the cube of the 2nd number and send the integer part of the final result... I almost forget, you only have 2 seconds to send me the result 1st number : 4357
2nd number : 5806

Un peu de programmation donc (qualité du code discutable, mais bon réfléchir demande trop d'effort) :

# coding: utf-8

import socket
import math

hote = "51.75.202.113"
port = 10001
big_number = 99999

print "[+] Connection on {}".format(port)
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((hote, port))

print "[+] get introduction message"
print socket.recv(big_number)

print "[+] get numbers"
raw = socket.recv(big_number)

print "[+] replacing"
raw = raw.replace("1st number : ", "")
raw = raw.replace("2nd number : ", "")

nbrs = []

for line in raw.splitlines():
	nbrs.append(int(line))

print nbrs[0]
print nbrs[1]

print "[+] some maths"
result = math.sqrt(nbrs[0]) * (nbrs[1] ** 3)
print result

[+] sending result
socket.send(str(int(result)));
print socket.recv(big_number)

print "[+] Close"
socket.close()

Et voilà

Congratz!! Flag : IMTLD{TheFastestManAlive}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment