modifed to work with single pwd
This commit is contained in:
@ -3,7 +3,7 @@ import json
|
|||||||
import base64
|
import base64
|
||||||
|
|
||||||
# Fill in the right target here
|
# Fill in the right target here
|
||||||
HOST = "netsec.net.in.tum.de" # TODO
|
HOST = "localhost" # TODO
|
||||||
# HOST = "localhost"
|
# HOST = "localhost"
|
||||||
PORT = 20204 # TODO
|
PORT = 20204 # TODO
|
||||||
|
|
||||||
@ -27,15 +27,12 @@ def search_password(target_pass, rainbow_dict):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def crack_hash(targets):
|
def crack_hash(target):
|
||||||
rainbow_dict = None
|
rainbow_dict = None
|
||||||
with open("rainbow_table.json", "r") as f:
|
with open("rainbow_table.json", "r") as f:
|
||||||
rainbow_dict = json.load(f)
|
rainbow_dict = json.load(f)
|
||||||
hash_dict = decode_hash(rainbow_dict)
|
hash_dict = decode_hash(rainbow_dict)
|
||||||
found_dict = {}
|
return search_password(target, hash_dict)
|
||||||
for target in targets:
|
|
||||||
found_dict[search_password(target, hash_dict)] = target
|
|
||||||
return found_dict
|
|
||||||
|
|
||||||
|
|
||||||
def get_flag():
|
def get_flag():
|
||||||
@ -44,26 +41,29 @@ def get_flag():
|
|||||||
s.connect((HOST, PORT))
|
s.connect((HOST, PORT))
|
||||||
sf = s.makefile("rw") # we use a file abstraction for the sockets
|
sf = s.makefile("rw") # we use a file abstraction for the sockets
|
||||||
print(sf.readline().rstrip("\n"))
|
print(sf.readline().rstrip("\n"))
|
||||||
|
print("GET_SECRET Initiated")
|
||||||
sf.write("GET_SECRET\n")
|
sf.write("GET_SECRET\n")
|
||||||
sf.flush()
|
sf.flush()
|
||||||
print(sf.readline().rstrip("\n"))
|
print(sf.readline().rstrip("\n"))
|
||||||
|
print("inserted Username admin")
|
||||||
sf.write("admin\n")
|
sf.write("admin\n")
|
||||||
sf.flush()
|
sf.flush()
|
||||||
print(sf.readline().rstrip("\n"))
|
print(sf.readline().rstrip("\n"))
|
||||||
|
print("inserted password 'rand123'")
|
||||||
sf.write("ran123\n")
|
sf.write("ran123\n")
|
||||||
sf.flush()
|
sf.flush()
|
||||||
output = sf.readline().rstrip("\n").split("Passwords do not match hashes ")[1]
|
output = sf.readline().rstrip("\n").split("Passwords do not match hashes ")[1]
|
||||||
pos_pas = parse_list_string(output)
|
pos_pas = parse_list_string(output)
|
||||||
passwords = crack_hash(pos_pas)
|
password = crack_hash(pos_pas[0])
|
||||||
print(passwords)
|
print(f"Password found {password}")
|
||||||
for password in passwords:
|
print(sf.readline().rstrip("\n"))
|
||||||
print(sf.readline().rstrip("\n"))
|
sf.write("admin\n")
|
||||||
sf.write("admin\n")
|
sf.flush()
|
||||||
sf.flush()
|
print(sf.readline().rstrip("\n"))
|
||||||
print(sf.readline().rstrip("\n"))
|
print(f"inserted password '{password}'")
|
||||||
sf.write(f"{password}\n")
|
sf.write(f"{password}\n")
|
||||||
sf.flush()
|
sf.flush()
|
||||||
print(sf.readline().rstrip("\n"))
|
print(sf.readline().rstrip("\n"))
|
||||||
print(sf.readline().rstrip("\n"))
|
print(sf.readline().rstrip("\n"))
|
||||||
sf.close()
|
sf.close()
|
||||||
s.close()
|
s.close()
|
||||||
|
Reference in New Issue
Block a user