Skip to content

Instantly share code, notes, and snippets.

@73spica
Last active October 4, 2016 15:28
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 73spica/316d15cb39071065d431ef09289a2efb to your computer and use it in GitHub Desktop.
Save 73spica/316d15cb39071065d431ef09289a2efb to your computer and use it in GitHub Desktop.
from m1z0r3.crypro import *
from math import sqrt
import time
# H4CK1T CTF 2016 Online
# Mongolia – HellMath (PPC 100 pts)
def do_calc(num):
span = 2
b = 1
if num%2==0:
a = 2
elif str(num)[-1]=="5":
a = 5
span = 5
else:
a = 3
detect_f = False
while True:
if detect_f:
break
b=1
while True:
ans = a**b
if ans > num:
# print "none.",a
break
if ans == num:
print "[+] complete!!"
print "[+] a = %s , b = %s"%(a,b)
return a,b
b+=1
# print ans
a+=span
def main():
remoteip = "ctf.com.ua"
remoteport = 9988
s,f = sock(remoteip,remoteport)
for i in xrange(100):
print "[+] stage%s"%i
data = read_until(f,"C = ")
num = read_until(f)
print "[+]",num
a,b = do_calc(int(num))
ans = "%s %s\n"%(a,b)
print "send:",ans
s.send(ans)
shell(s) # h4ck1t{R4ND0M_1S_MY_F4V0UR1T3_W34P0N}
f.close()
s.close()
if __name__ == '__main__':
main()
@73spica
Copy link
Author

73spica commented Oct 3, 2016

H4CK1T CTF 2016 Online
Mongolia – HellMath (PPC 100 pts)

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