---
# System prepended metadata

title: haxXor
tags: [DarkCTF, crypto]

---

###### tags: `DarkCTF` `crypto`

# haxXor

### Description
- you either know it or not take this and get your flag

- 5552415c2b3525105a4657071b3e0b5f494b034515

### exploit
- 基於xor原則
    - 明文 xor key = 密文
    - 密文 xor key = 明文
    - 密文 xor 明文 = key
- 密文 - 5552415c2b3525105a4657071b3e0b5f494b034515
    - 16進位的密文，要轉換為bytes形式
- 預測明文flag的值前端為`darkCTF{`
    - 基於前項原則 - "darkCTF{" xor "密文前八bytes" = key[:8]
    - 

- `flag[:len(flag_prefix)`印出flag前八個byte

```python=
from pwnlib.util.fiddling import xor

flag = bytes.fromhex('5552415c2b3525105a4657071b3e0b5f494b034515')
flag_prefix = b'darkCTF{'
xorstr = xor(flag_prefix, flag[:len(flag_prefix)])
print(xor(flag, xorstr))

```

### 小記
- 5552415c2b352510 密文[:8]
- 6461726b4354467b flag[:8] "dackCTF{"
- 313333376861636b key[:8]
- 5552415c2b3525105a4657071b3e0b5f494b034515 密文
- 313333376861636b313333376861636b3133333768 key
- 6461726b4354467b6b756430735f6834787830727d 明文