$ cat writeup.md…
$ cat writeup.md…
HackTheBox
Luigi is not posixtive we can challenge his scripting abilities. He's convinced we cannot understand the secret hidden inside his l33t coding abilities. We can't let that slide!
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Luigi is not posixtive we can challenge his scripting abilities. He's convinced we cannot understand the secret hidden inside his l33t coding abilities. We can't let that slide!
The challenge provides a Python server with several key components:
Input validation functions:
check_stricter_values() - allows max 4 chars, only alphabetic and dotscheck_values() - allows max 13 chars, only alphabetic and dotscheck_operands() - blocks operators +, -, *, /, %, =, x, o, b but allows ~Execute function:
subprocess.run([bin, switch, compl])returncode * modeWin condition:
if debug[0] != debug[1] and str(debug[0]) != str(debug[1]) and hash(debug[0]) == hash(debug[1]) and isinstance(debug[0], type(debug[1])): print("What an awesome player! You have beaten the competitor, you deserve this:", open('flag.txt').read())
The win condition requires finding two values that:
!=)In Python, hash(-1) == hash(-2) == -2. This is a known implementation detail of Python's hash function where -1 is reserved as an error indicator, so hash(-1) returns -2 instead.
>>> hash(-1) -2 >>> hash(-2) -2 >>> hash(-1) == hash(-2) True
Mode = ~0
- operator is blocked, but ~ (bitwise NOT) is not~0 = -1 in Pythoneval() in check_operands()Binary = grep
grep pattern file returns:
Arguments = server.py,nonexistent
server.py exists on the servernonexistent does not exist...
$ grep --similar