---
# System prepended metadata

title: Is they same?

---

# Is they same?

Identical Prefix 或 ASCII Collision。

使用 hashclash 的 `generic_ipc.sh`：

```shell
echo "is1abcis1abcis1a" > prefix.txt && <hashclash>/scripts/generic_ipc.sh prefix.txt
```

> 記得把 `<hashclash>` 換成你的位置。

等待幾分鐘後可以製作出自訂前綴的 `.bin`，再把 `collision1.bin`、`collision2.bin` 再用腳本把所有的位元拿去轉成 ASCII：

```python
import hashlib

def read_and_process_file(file_path):
    # Read the binary content of the file
    with open(file_path, 'rb') as f:
        binary_data = f.read()

    # Print the MD5 hash of the binary content
    md5_hash = hashlib.md5(binary_data).hexdigest()
    print(f"MD5 hash of {file_path}: {md5_hash}")

    # Convert the binary data to its ASCII representation
    ascii_representation = ",".join([str(byte) for byte in binary_data])

    return ascii_representation

# File paths
file1 = 'collision1.bin'
file2 = 'collision2.bin'

# Process each file and print the ASCII representation
ascii1 = read_and_process_file(file1)
ascii2 = read_and_process_file(file2)

print(f"ASCII representation of {file1}: {ascii1}")
print(f"ASCII representation of {file2}: {ascii2}")
```

```shell!
$ python3 to_ascii.py
MD5 hash of collision1.bin: 56dcab0a720d8a9d39e71d72f7d00932
MD5 hash of collision2.bin: 56dcab0a720d8a9d39e71d72f7d00932
ASCII representation of collision1.bin: 105,115,49,97,98,99,105,115,49,97,98,99,105,115,49,97,135,51,57,167,177,189,208,113,66,42,8,59,95,24,180,66,212,115,101,238,41,106,186,7,162,253,139,161,213,181,180,60,247,129,249,101,33,139,97,202,161,251,25,118,66,245,48,239,118,12,240,219,2,247,173,47,59,188,215,245,78,92,90,162,20,55,58,104,49,169,78,35,133,252,228,52,118,66,220,237,161,109,207,23,36,3,120,152,207,66,88,11,145,216,83,219,56,34,112,238,9,191,217,133,161,121,32,16,214,172,74,91
ASCII representation of collision2.bin: 105,115,49,97,98,99,105,115,49,98,98,99,105,115,49,97,135,51,57,167,177,189,208,113,66,42,8,59,95,24,180,66,212,115,101,238,41,106,186,7,162,253,139,161,213,181,180,60,247,129,249,101,33,139,97,202,161,251,25,118,66,245,48,239,118,12,240,219,2,247,173,47,59,187,215,245,78,92,90,162,20,55,58,104,49,169,78,35,133,252,228,52,118,66,220,237,161,109,207,23,36,3,120,152,207,66,88,11,145,216,83,219,56,34,112,238,9,191,217,133,161,121,32,16,214,172,74,91
```

把結果複製貼上到題目裡：

```shell!
$ ncat 127.0.0.1 37358

    Welcome to the is they same? challenge!

    In this challenge, you are required to input two strings.
    These two strings must have different contents, but their MD5 hashes must be identical.
    Additionally, both strings must start with "is1ab".

    Input please transform by (",".join([str(i) for i in string]).encode()).
    For example, if you're string is "is1ab", you're output will be "105,115,49,97,98".

Please input your string 1:105,115,49,97,98,99,105,115,49,97,98,99,105,115,49,97,135,51,57,167,177,189,208,113,66,42,8,59,95,24,180,66,212,115,101,238,41,106,186,7,162,253,139,161,213,181,180,60,247,129,249,101,33,139,97,202,161,251,25,118,66,245,48,239,118,12,240,219,2,247,173,47,59,188,215,245,78,92,90,162,20,55,58,104,49,169,78,35,133,252,228,52,118,66,220,237,161,109,207,23,36,3,120,152,207,66,88,11,145,216,83,219,56,34,112,238,9,191,217,133,161,121,32,16,214,172,74,91
Please input your string 2:105,115,49,97,98,99,105,115,49,98,98,99,105,115,49,97,135,51,57,167,177,189,208,113,66,42,8,59,95,24,180,66,212,115,101,238,41,106,186,7,162,253,139,161,213,181,180,60,247,129,249,101,33,139,97,202,161,251,25,118,66,245,48,239,118,12,240,219,2,247,173,47,59,187,215,245,78,92,90,162,20,55,58,104,49,169,78,35,133,252,228,52,118,66,220,237,161,109,207,23,36,3,120,152,207,66,88,11,145,216,83,219,56,34,112,238,9,191,217,133,161,121,32,16,214,172,74,91
You're right
is1abCTF{Md5_l5_NOT_sAFe_443fe166cf3a}
```

### Reference

- <https://book.jorianwoltjer.com/cryptography/hashing#md5-ascii-collision>
