我所知道的管理员在上传方面的部分设计漏洞

其实都很简单,都和JS有关。

例子1:
一个文档上传处:
--------code begin---------
function Checkvalue(the){
var yes=true;
if( the.username.value==/"/" || the.password.value==/"/" || the.primarykey.value==/"/"){
alert(/"表单中标示 * 的项目必须填写完整 !/");
yes=false;}
var fileext=the.primarykey.value.substring(the.primarykey.value.length-4,the.primarykey.value.length)
fileext=fileext.toLowerCase()
if (!(fileext=='.doc' || fileext=='.txt' || fileext=='.dat'))
{alert(/"对不起,不正确的文件位置,必须为.doc、.txt或.dat !/");
the.primarykey.focus();
yes=false;
}
return yes;
}
--------code end---------
他只用javascript做限制,而没有从PHP环境下改正。
直接把那个网页当到本地后,改了改原代码。
他当中的if (!(fileext=='.doc' || fileext=='.txt' || fileext=='.dat'))
修改成
if ((fileext=='.doc' || fileext=='.txt' || fileext=='.dat'))
并且修改FORM里头的地址从upload.php改为http://IP/upload.php

例子2:
一个网站的上传处:
--------code begin---------
function getFileExtension(filePath) { //v1.0
fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('')+1,filePath.length));
return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
}

function checkFileUpload(form,extensions) { //v1.0
document.MM_returnValue = true;
if (extensions && extensions != '') {
for (var i = 0; i field = form.elements[i];
if (field.type.toUpperCase() != 'FILE') continue;
if (field.value == '') {
alert('文件框中必须保证已经有文件被选中!');
document.MM_returnValue = false;field.focus();break;
}
if (extensions.toUpperCase().indexOf(getFileExtension(field.value).toUpperCase()) == -1) {
alert('这种文件类型不允许上传!.//n只有以下类型的文件才被允许上传: ' + extensions + './/n请选择别的文件并重新上传.');
document.MM_returnValue = false;field.focus();break;
} } }
}
--------code end---------
初看觉得,没有上面提到的那样白痴的问题,当时我们接着来
--------code begin---------


--------code end---------

上面这句话让他死的很难看,把checkFileUpload(this,'zip,gtp,gp3');checkFileUpload(this,'zip')改成checkFileUpload(this,'asp,gtp,gp3');checkFileUpload(this,'asp')或者直接?*晃猚heckFileUpload(this,'asp'),呵呵,一样可以随便传东西上去喽!
不过记的前面的action中的地址要改成绝对地址http://ip/upload/webpage/upload/upl...?GP_upload=true

例子3:
这个是17173的一个图片上传的地方:
--------code begin---------
function form1_onsubmit(theForm) {
if(theForm.file1.value == /"/")
{
alert(/"选择照片/");
return(false);
}

if (theForm.title.value == /"/")
{
alert(/"请输入照片名称/");
theForm.title.focus();
return (false);
}
if (theForm.gameid.value == /"/")
{
alert(/"请输入您在游戏中的ID/");
theForm.gameid.focus();
return (false);
}

if (theForm.onlinetime.value == /"/")
{
alert(/"请输入您的上线时间/");
theForm.onlinetime.focus();
return (false);
}
if (theForm.author.value == /"/")
{
alert(/"请输入您的名字/");
theForm.author.focus();
return (false);
}
if (theForm.webgame.value == /"/")
{
alert(/"您是哪个网络游戏服务器的玩家??/");
theForm.webgame.focus();
return (false);
}
if(theForm.email.value == /"/")
{
alert(/"请输入您的email/");
theForm.email.focus();
return(false);
}
if(theForm.other.value == /"/")
{
alert(/"请输入简介/");
theForm.other.focus();
return(false);
}

if (theForm.title.value.length > 20)
{
alert(/"非法名称/");
theForm.title.focus();
return (false);
}

if(theForm.catalogid.value == /"0/")
{
alert(/"选择类别/");
return(false);
}

if (theForm.author.value.length > 20)
{
alert(/"非法作者名字/");
theForm.author.focus();
return (false);
}


var checkOK = /"@./";
var checkStr = theForm.email.value;
var allValid = true;
for (i = 0; i < checkOK.length; i++)
{
j=checkStr.indexOf(checkOK.charAt(i));

if ( (j==-1) && (checkStr!=/"/") )

{

alert(/"非法电子邮件/");
theForm.email.focus();
return (false);
}
}
var fname = document.form1.file1.value;
var ftype = fname.substring(fname.length-3,fname.length);
if(ftype!='jpg' && ftype!='gif' && ftype!='tif' && ftype!='zip' && ftype!='asp')
{
alert(/"图片格式必须是:*.jpg,*.gif,*.tif/");
return(false);
}
theForm.filetype.value = theForm.file1.value.substr(theForm.file1.value.length-3,3) ;

return (true);
}
--------code end---------
不难看出
if(ftype!='jpg' && ftype!='gif' && ftype!='tif' && ftype!='zip' && ftype!='asp')这句话证明了他只对文件后缀做限制
把他改成if(ftype!='jpg' && ftype!='gif' && ftype!='tif' && ftype!='zip' && ftype!='asp')
再把ACTION里头的地址改改,可以上传了,不过结果没预料的那么好,我们读取不到文件,呵呵,如果都被读取了,那么17173不是早就完蛋翘了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值