
1 2 3 4 5
| 提示:继某两所大学校内餐厅被黑后,终于考上大学的小明也想“逝世”,但是他遇到了一些困难于是请求你的帮助。他给你留了一个webshell,并给你的一条线索,去帮他完成吧。
请联系CTF生活,写一篇文章,谈谈你的认识与思考。
要求:(1)自拟题目;(2)不少于 800字。
|
根据提示小明留了一个webshell和一个线索
webshell可以用dirsearch扫出来,但是直接访问不行,找一下线索


在源码可以看到一个像base64的编码,直接base64解码不行,猜测还有rot13编码,python解码
1 2 3 4 5 6 7 8 9 10
| import base64 import codecs
cipher = "5bvE5YvX5Ylt5YdT5Yvdp2uyoTjhpTujYPQyhXoxhVcmnT935L+P5cJjM2I05oPC5cvB55dR5Mlw6LTK54zc5MPa" rot13_str = codecs.decode(cipher, 'rot_13') print(f"ROT13: {rot13_str}") decoded_bytes = base64.b64decode(rot13_str) result = decoded_bytes.decode('utf-8') print(f"Result: {result}")
|

带上show参数直接显示源码

md5找个网站解就行

flag在系统找不到,存在数据库里面,命令查看index.php源码

排除没用的代码,可以看到我们的钱是被永远固定的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <?php include 'connect.php';
$my_money = 3.00; $msg = ""; $target_id = 0;
if (isset($_POST['buy']) && isset($_POST['item_id'])) { $target_id = (int)$_POST['item_id'];
if ($target_id > 0) { try { $stmt = $pdo->prepare("CALL buy_item(?, ?)"); $stmt->execute([$target_id, $my_money]); $res = $stmt->fetch(); $msg = $res['final_message']; $my_money -= $res['current_price']; } catch (Exception $e) { $msg = "Transaction Error: " . $e->getMessage(); } } else { $msg = "Invalid item selected."; } } else { try { $stmt = $pdo->query("SELECT id, name, price FROM goods ORDER BY id ASC"); if ($stmt === false) { exit; } $goods_list = $stmt->fetchAll(); } catch (Exception $e) { die("Error fetching goods list."); } } ?>
|
使用命令把index.php固定的3块钱,替换成大于50的数字
1
| sed -i "s/3.00/100.00/g" ../index.php
|

回到index.php,可以看到已经变成了100

购买flag
