Skip to content

Instantly share code, notes, and snippets.

@vifly
Created October 29, 2022 13:01
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 vifly/1f23c692a07967c3a3175579656177cd to your computer and use it in GitHub Desktop.
Save vifly/1f23c692a07967c3a3175579656177cd to your computer and use it in GitHub Desktop.
Hackergame 2022 writeup code
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)
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