-
-
Save vifly/1f23c692a07967c3a3175579656177cd to your computer and use it in GitHub Desktop.
Hackergame 2022 writeup code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert(line: str) -> list[str]: | |
result = [] | |
right_val = line.split("=")[1].replace(" ", "") | |
list_indexs = line[line.find("[") + 1: line.find("]")] | |
list_indexs = [i.replace(" ", "") for i in list_indexs.split("|")] | |
for index in list_indexs: | |
result.append(f"a[{index}] = {right_val}") | |
return result | |
with open("./getflag.hei.py", "r") as f: | |
result = [] | |
for line in f: | |
if line.startswith("a["): | |
result = result + convert(line) | |
else: | |
result.append(line) | |
with open("./getflag.py", "w") as new_f: | |
new_f.writelines(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from lxml import etree | |
cookies = { | |
"session": "" | |
} | |
SESS = requests.session() | |
def calc(content: str) -> str: | |
content = content.split(" ")[0] | |
return str(eval(content)) | |
def crack(): | |
r = SESS.get("http://202.38.93.111:10047/xcaptcha", cookies=cookies) | |
tree = etree.HTML(r.text) | |
calc_list = tree.xpath("//div/label/text()") | |
data = {} | |
for index, content in enumerate(calc_list): | |
data[f"captcha{index+1}"] = calc(content) | |
r = SESS.post("http://202.38.93.111:10047/xcaptcha", data=data) | |
print(r.text) | |
crack() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment