Welcome to HBH V2 ! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

# sever hacking - Python Code Bank

sever hacking
hack a sever
```                ```# Created by UnknownSinister

#Hack the Server Challenged

#Given Data: Base 1511^x, modulus and output.
base=1511
modulus=35948145881546650497425055363061529726
output=10899914993644372325321260353822561193

#Baby/Giant steps discrete logarithms to evaluate exponential \$x.
#You need a lot of memory to be able to run that code.
#CAUTION: DO NOT RUN ON PHONE
def baby_steps_giant_steps(a,b,p,N = None):
if not N: N = 1 + int((p)**0.5)

#initialize baby_steps table
baby_steps = {}
baby_step = 1
for r in range(N+1):
baby_steps[baby_step] = r
baby_step = baby_step * a % p

#now take the giant steps
giant_stride = pow(a,(p-2)*N,p)
giant_step = b
for q in range(N+1):
if giant_step in baby_steps:
return q*N + baby_steps[giant_step]
else:
giant_step = giant_step * giant_stride % p
return "No Match"

#I run this on my desktop PC and waited to obtain the results

# Code: baby_steps_giant_steps(base,output,modulus)

#I have also used the Pohlig-Hellman Algorith to obtain the folowing output:

x=5846138770670624478648053421625897
y=13876455641232175195163569384472100

#Note that y is just an arbitary output because it is not the exponential and give the output
def check(x):
true="The value "+str(x) +" is the corresponding value of exponential \$x"
false="The value "+str(x)+" is NOT the corresponding value of exponential \$x"
if pow(1511,x,modulus)==output:
return str(true)
else:
return str(false)

#The true exponential value will be in the form:
#  \$x = x+y*k where k is a constant

#Hence I find a value k such that I get a 39 digit long exponential
#Note: I have ensured that the lenght of x is 39 digit long because 38 digit will produce a 31 characters flag.
#The demanded length of the flag is 32 characters.
#Thus length of x must be 39 digit long
def find(x,y):
i=0
while True:
z=x+y*i
if len(str(z))!=39:
i+=1
else:
break
return i

def dec2hex(dec):
hexstring=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
c=0
remainder=[]
res=""
if dec>0:
while dec>0:
remainder.append(dec%16)
dec=dec//16
c+=1
for reverse in remainder[::-1]:
res+=hexstring[reverse]
else:
res="0"
return res

def hacktheserver(x,y):
yes="~#### SERVER HAS BEEN HACKED ####~"
print("~#### HACK THE SERVER CHALLENGE ####~")
print("The value of x is:",x)
print("The value of y is:",y)
print("The Exponential is in the form x+y*k")
print("The value of k is:",find(x,y))
print(check(x+y*find(x,y)))
print("Flag decimal value:",x+y*find(x,y))