-
-
Save hexens-kasper/fcdfdf0488368684a2f686af5343bcf0 to your computer and use it in GitHub Desktop.
hash_hunt.py
This file contains hidden or 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 check_hash(h): | |
| data = bytes.fromhex(h) + 32 * b'\x00' | |
| offset = 0 | |
| # 1. | |
| if data[offset] < 0xc0: | |
| offset += 1 | |
| # 2. | |
| if data[offset] < 0xc0: | |
| return False | |
| offset += get_offset(data[offset]) | |
| # 3. | |
| for _ in range(3): | |
| offset += get_length(data[offset:]) | |
| if offset > 27: | |
| return False | |
| # 4. | |
| log_len = get_length(data[offset:]) | |
| if data[offset] < 0xf9 or log_len < 0x800: | |
| return False | |
| offset += get_offset(data[offset]) | |
| if offset > 30: | |
| return False | |
| # 5. | |
| if data[offset] < 0xb9 or (data[offset] >= 0xc0 and data[offset] < 0xf9): | |
| return False | |
| buffer_len = get_length(data[offset:]) | |
| if buffer_len > (log_len - 3) or buffer_len < 0x800 or buffer_len > 0xfffff: | |
| return False | |
| return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment