iT邦幫忙

2024 iThome 鐵人賽

DAY 7
0
佛心分享-刷題不只是刷題

CTF 刷題系列 第 7

CTF Day 7 Reverse (unpackme.py)

  • 分享至 

  • xImage
  •  

今天也來解Reverse的題目

題目 unpackme.py

https://ithelp.ithome.com.tw/upload/images/20240921/20155574n4EoZOy2b1.png

import base64
from cryptography.fernet import Fernet
payload = b'gAAAAABkzWGO_8MlYpNM0n0o718LL-w9m3rzXvCMRFghMRl6CSZwRD5DJOvN_jc8TFHmHmfiI8HWSu49MyoYKvb5mOGm_Jn4kkhC5fuRiGgmwEpxjh0z72dpi6TaPO2TorksAd2bNLemfTaYPf9qiTn_z9mvCQYV9cFKK9m1SqCSr4qDwHXgkQpm7IJAmtEJqyVUfteFLszyxv5-KXJin5BWf9aDPIskp4AztjsBH1_q9e5FIwIq48H7AaHmR8bdvjcW_ZrvhAIOInm1oM-8DjamKvhh7u3-lA=='

key_str = 'correctstaplecorrectstaplecorrec'
key_base64 = base64.b64encode(key_str.encode())
f = Fernet(key_base64)
plain = f.decrypt(payload)
exec(plain.decode())

exec:
Python內建函數,用來動態執行"字串"形式的Python程式碼

import base64
from cryptography.fernet import Fernet
payload = b'gAAAAABkzWGO_8MlYpNM0n0o718LL-w9m3rzXvCMRFghMRl6CSZwRD5DJOvN_jc8TFHmHmfiI8HWSu49MyoYKvb5mOGm_Jn4kkhC5fuRiGgmwEpxjh0z72dpi6TaPO2TorksAd2bNLemfTaYPf9qiTn_z9mvCQYV9cFKK9m1SqCSr4qDwHXgkQpm7IJAmtEJqyVUfteFLszyxv5-KXJin5BWf9aDPIskp4AztjsBH1_q9e5FIwIq48H7AaHmR8bdvjcW_ZrvhAIOInm1oM-8DjamKvhh7u3-lA=='

key_str = 'correctstaplecorrectstaplecorrec'
key_base64 = base64.b64encode(key_str.encode())
f = Fernet(key_base64)
plain = f.decrypt(payload)
print(plain.decode())
#exec(plain.decode())

把plain打印出來
https://ithelp.ithome.com.tw/upload/images/20240921/20155574KVfjVpz1Hh.png


上一篇
CTF Day 6 Reverse (Ready Gladiator 0)
下一篇
CTF Day 8 Reverse (asm1)
系列文
CTF 刷題30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言