题目下载地址:https://github.com/0xviol1t/CTF-challenges/tree/main/2024/WKCTF
PWN
baby_stack
wait
中存在格式化字符串漏洞,随便测一下发现输入6
的时候会输出一个libc
上的地址从而得到基址,通过libc
基址获取one gadget
地址
1 | void __fastcall wait() |
echo_inner
中存在栈上的off-by-null
,在栈上布置rop
并且通过输入长度控制将\x00
写到rbp
,返回到上层函数之后就会抬栈运行到布置的rop
,为了确保执行到ogg
需要将最后8
位覆盖成ogg
,前面全部覆盖成ret
1 | void __fastcall echo_inner(_BYTE *a1, int size) |
exp
1 | from pwn import * |
easy_heap
漏洞点出在edit
可以堆溢出
1 | unsigned __int64 edit() |
没有delete
且限制了show
的长度为一个地址,首先想到的就是house of orange
伪造top chunk
的条件:
- 保证原本
old top chunk
的size
大于MINSIZE
- 保证原本
old top chunk
的prev_inuse
位是1
- 原本
old top chunk
的地址加上其size
之后的地址要与页对齐 也就是address & 0xfff = 0x000
old chunk
的size
要小于申请的堆块大小加上MINSIZE
当申请的堆大小大于伪造的top chunk
大小时会将top chunk
释放,释放的大小为top chunk size - 0x20
,并且根据释放的大小判断进入fastbin
或者unsorted bin
所以本题可以先释放一次top chunk
到unsorted bin
泄露libc
,再释放一次top chunk
到fastbin
进行fastbin attack
exp
1 | from pwn import * |
something_changed
漏洞点是格式化字符串,并且存在后门,限制了输入内容不能包含$
,但还是可以直接用fmtstr_payload
工具
1 | int __fastcall main(int argc, const char **argv, const char **envp) |
测试出偏移是14
,开了canary
保护,所以可以将__stack_chk_fail_got
改成backdoor
1 | sudo qemu-aarch64 -L ./libc/libc/lib ./pwn |
exp
1 | from pwn import * |
WEB
ez_tp
GET参数s
内网ip地址: 10.40.35.73
1 |
|
ez_php
http://110.40.35.73:81/favicon.webp存在AKSK泄露: "ba260cf0-2e6b-4a0e-91c1-d52b8c3214a1"
文件上传拿到webshell
密码:shell
蚁剑直连
qiandao
1 | url?file=/flag |
MISC
signin
https://github.com/htr-tech/0xTwin/blob/master/twin_cipher.py
解码得到base64
编码的图片,图片是一个二维码但是扫不出来,找在线工具https://cli.im/deqr/other得到:**请发送 WKCTF2024 到微信公众号隐雾安全获取flag!**
照做得到flagWKCTF{hello_2024}
不套是你的谎言
DES
解密+字典爆破 GPT
脚本
1 | from Crypto.Cipher import DES # 导入DES加密模块 |
REVERSE
so_easy
主要函数
1 | __int64 __fastcall Java_com_so_easy_MainActivity_soEasy(__int64 a1, __int64 a2, __int64 a3) |
多次位分析最后和unk_560
比较
1 | unk_560[] = |
exp
1 | # 倒序板子 |
quite_easy
目测是一个TLS
花指令去掉了
如下
1 | .text: nop |
考点基本就是antidebug
动静结合得到加密流程
rand
得到ke
后前16
个与其异或后16
个和前16
个异或进行
exp
1 | #include <stdlib.h> // For srand() and rand() |
然后手动整理一下WKCTF{08898c40064d1fc4836db94fe}
AI
how_to_encrypt
问了下gpt
得知encrypt
的运行结果是ciphertext.txt
,其中会用到flag
和model.pth
,直接扔给gpt
,通过flag
和model.pth
求flag
1 | import torch |
CRYPTO
easy_random
先看给的2496
个8
位,python
的随机数用的是mt19937
,624
个32
位就能预测,回溯,8*4=32;2496/4=624
。显而易见,可以操作。参考2020 pwnhub CoinFlip2得到state
1 | state = [2922114156, 2886276701, 1168768544, 2339187170, 3551087255, 117510054, 4232565172, 1076139110, 3366831833, 1734453078, 4105913658, 1066792668, 2395352043, 785096749, 3707690263, 2430171307, 2064716469, 1119720065, 1112222395, 2136656989, 2232844740, 388978998, 1363102788, 67899517, 457789137, 3527002829, 1187847099, 1188611575, 3830294635, 3760337941, 297081839, 3230408812, 2906355860, 279725084, 3056220997, 1053068885, 3252084646, 2818726015, 3615795115, 2751222655, 74688614, 1452880497, 426221319, 1680367484, 4211465923, 908441837, 2290937869, 526329269, 3225608663, 350552485, 885538125, 3496826412, 3347875222, 2730243675, 1823616219, 1474037291, 2474670592, 1175091387, 1527449390, 2024565653, 2185945759, 902338428, 3571876882, 632524934, 1235569406, 3612682285, 2727233684, 2085380963, 1570339017, 3839696585, 1482742582, 646051896, 3804319832, 2113555238, 4150326517, 2606046640, 1454130831, 1919843931, 1018624146, 1956310311, 1162868231, 1118548906, 974692065, 3020424226, 2996838388, 1724936385, 1668410782, 3044755338, 3710133971, 1043581839, 362583150, 3880481779, 114234888, 1724135673, 1280834309, 2958310395, 3502226151, 620064160, 3244210820, 3839287479, 2283659292, 405764632, 29535149, 2759062778, 1662916252, 2374319319, 3359789079, 1896011543, 1991740933, 2041947596, 3393060496, 996086198, 193135800, 1184463268, 819767446, 410330102, 569788256, 3880255000, 340523190, 885031563, 2752345656, 4116368372, 1738848623, 1895472503, 85502529, 334873925, 3543996685, 3082948803, 3195880838, 1458851187, 2843458392, 20236078, 3136689072, 2121777470, 3543587943, 3590933177, 4057799526, 1241162800, 1014541188, 1031410742, 267989518, 92604561, 2190353015, 87786611, 435741463, 3800398555, 1860727248, 2608606593, 287619193, 768990059, 1686137462, 3255556540, 3234299857, 2087562050, 1575350832, 1982640551, 1476745138, 2757668599, 108958643, 337813164, 273001595, 3515727084, 2976758889, 2674818924, 2133197017, 3709052669, 1992118633, 2421927781, 174599786, 3608298365, 1708985493, 3925831183, 3063611093, 3852984733, 540242111, 1623482619, 1874921843, 1317809124, 2774735715, 3828180102, 1997343223, 1516869708, 941992323, 307089973, 368181535, 163007409, 596938343, 1686397275, 52708329, 230996593, 3597201983, 378926364, 3618422671, 2062721049, 3659976071, 546629459, 3976307656, 1509609055, 3677736141, 1613243397, 1378877471, 531534610, 2602178644, 4099876535, 1394187732, 1706260244, 1842911215, 3381571710, 456693813, 1667668257, 792813840, 4044011316, 1391972141, 1677638507, 1467741933, 2542725716, 3261642613, 1122181516, 1726857655, 2765884383, 2563231823, 1890137479, 3462591813, 290505918, 3480784421, 4146013364, 906268950, 1460571462, 625398701, 1868955581, 2562420879, 3524561573, 2480663847, 424010572, 3760440358, 506451740, 2616205788, 3835513223, 2698078113, 933669512, 2259175222, 1766445936, 3062774434, 3383207496, 165724374, 717679250, 872303977, 1054921507, 1640987195, 2398705310, 744526846, 2142916476, 3769314780, 3643489144, 906983325, 1001096018, 1522376663, 3516789445, 425379249, 1807654888, 1584889396, 996500676, 2138028000, 1877118731, 2780715755, 56317932, 994780643, 231703463, 1590924826, 449553992, 1970334362, 3631415563, 2378887069, 2645995105, 604040985, 766274135, 2897107084, 3122401328, 604584226, 3514594183, 3159592392, 539086862, 1966827756, 1548312674, 2223920152, 4193868755, 2604831097, 2301554299, 2919432501, 3445772747, 221908018, 1919849944, 1707243688, 1311680342, 1132835813, 824121832, 2623654824, 4245764621, 1669541543, 793028119, 1400611299, 2330555992, 1295319061, 2376883177, 3054784982, 1534527889, 3381065612, 431181624, 2520679460, 1612115175, 3417053178, 3202101207, 4112825474, 209873225, 3982289256, 3175605361, 1007754107, 1533969733, 3657972615, 1233249703, 1775877579, 2812100730, 3215107528, 1781386145, 3025989255, 3066346118, 3283795978, 1197222174, 2936543382, 3503535134, 2892598771, 2621962168, 931511531, 2231087188, 4146539078, 4002087507, 2491835423, 4060649251, 4048333160, 2444738719, 2691519303, 1556526141, 3615497232, 4050826531, 500299044, 717467546, 2206683369, 861398548, 3151369905, 4029791836, 3416545629, 4120104600, 1465267912, 483234533, 3035820989, 3832933168, 3568690105, 96174302, 2545526712, 1102861924, 1074783639, 4182941480, 1533353222, 1488829617, 1503690984, 185887778, 4211993208, 2290188486, 1146083769, 2041769341, 2684027677, 3176900642, 1387338494, 946259368, 1066487432, 795876682, 3861793354, 1668825820, 216618949, 2896083408, 3851619025, 442276681, 206355214, 270139248, 347366931, 1910792165, 3953458832, 2734158556, 2811136264, 1920172269, 1837836373, 3778467275, 3779230355, 3897121172, 2344011383, 1146522764, 2190434845, 609244986, 2013714652, 560173192, 2402932255, 1072869170, 1770725561, 952360909, 1412825165, 3696544236, 2306376326, 2830983153, 207976619, 4155556879, 3728896627, 2654370117, 3334033001, 1365410137, 1493856098, 1253593280, 1631830970, 5803336, 3918597809, 86127041, 333464839, 3604499396, 149662371, 2129288705, 1461710188, 3760680120, 3729872359, 2100765881, 3535556758, 444301423, 2716178967, 1126522126, 4087265377, 129975151, 3676574817, 946781552, 1144144314, 4160587561, 3992786314, 45372372, 2839307265, 3121990915, 2417091275, 2394722122, 2336989436, 3126674182, 3231554964, 3785353831, 3066121066, 4059908701, 3257600631, 3304564137, 976977941, 2994176851, 3509885563, 436168092, 2194926470, 572263581, 2964578564, 2577729800, 4257414592, 1074783671, 2629434251, 42822614, 1475322010, 3068645543, 3694724738, 3480058324, 4204711804, 3168448984, 2767935672, 3016152818, 4134435775, 2141315517, 2182008981, 2871864678, 2294299758, 1409773258, 3418660825, 3090287076, 3241139267, 2315623533, 2157788904, 334169841, 2062298350, 4075844652, 1672438569, 2994084656, 2204498767, 2430183901, 4179388667, 317027997, 2894184457, 3635887387, 1307832846, 3358657065, 734371454, 610520453, 3421706671, 3240587498, 3690351924, 935152653, 2737123774, 203357945, 1027962332, 3777141639, 743025036, 4046422672, 1085389282, 110265143, 320421926, 1931570193, 936595461, 2927488848, 2265674314, 3444945553, 786566925, 4133145648, 2879270131, 4165751769, 3985446237, 1971125873, 3724681025, 2661325531, 2441664181, 3290805620, 2459158763, 2102811157, 2881160687, 1153639082, 827213914, 3028527431, 2205345684, 3556675715, 1279123065, 4253124398, 3483559979, 4068430995, 4141206587, 2571521727, 2944439402, 443124686, 2268164570, 2235451426, 3679071975, 3129207272, 2516367556, 1468462786, 1881517367, 3491042253, 2913831047, 3164481275, 202602034, 3150723817, 1533130707, 1912730441, 2090267514, 3558123575, 1133228007, 3421482977, 2553693497, 3421969717, 2520271965, 2067324870, 1223636150, 2714495378, 3773685424, 2961634881, 88882886, 408668635, 904339271, 3187997208, 2883270961, 1911371885, 1111177434, 3677904221, 1424566197, 456428662, 3160502725, 2571618126, 1931038165, 1229862345, 885692642, 928907436, 281108918, 2025639202, 4098934983, 245166619, 3978368942, 2335134348, 2663736265, 3483476476, 1019177183, 1076843627, 2150626843, 3549898506, 497411044, 2948681730, 1293862520, 3364439483, 200913955, 876046583, 2810673955, 2828391839, 1905062360, 3783182365, 2472665728, 1439731349, 2736703148, 3316496080, 2996051367, 448455111, 3808598160, 2313472828, 1619655346, 1198200314, 3744504057, 1680713197, 2474661491, 3214410863, 1662774943, 3537885099, 3365412658, 3583677483] |
再到GitHub
里看这篇https://github.com/NonupleBroken/ExtendMT19937Predictor可以预测和回溯得到`data`,学习下面`randbytes`函数,写代码得到`key`,解`aes`即可
![Untitled (C:/Users/Lenovo/Desktop/viol1t战队WP/Untitled (3).png)](viol1t战队WP/Untitled (3).png)
1 | from Crypto.Cipher import AES |
fl@g
学习下概率论里的包含排斥原理
table
的长度是66,算出flag" "FLAG" "f14G" "7!@9
排列的情况 x=factorial(63)*4-factorial(60)*4+factorial(57)
之后很简单rsa
1 | from Crypto.Util.number import * |