网站帮助
设为首页加入收藏加入QQ书签会员中心 RSS
首页文章中心下载中心图片 论坛 英语资料

您所在的位置: 首页 > 文章中心 > 安全技术 > 安全漏洞 > 文章正文

 

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



实都很简单,都和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不是早就完蛋翘了。




文章来源:http://www.niubm.com/Article/2006/2201.html
相关链接
  • 无相关信息
本栏目最新文章
本栏目推荐文章
评论
平均得分为: 分,共有 参与评分. 已有 位对此文章感兴趣的网友发表了看法
用户名: 密码: 验证码: 匿名发表
* 您必须遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他有关法律法规。
* 承担一切因您的行为而直接或间接导致的民事或刑事法律责任。
* 如果因您不良评论或重复评论导致评论被删,您将会被扣掉一定数额的点数。
* 您发表的文章仅代表个人观点,与本站无关。
* 本站管理人员有权保留或删除其评论中的任意内容。
* 您在本站评论系统发表的作品,本站有权在网站内转载或引用。
* 参与本评论即表明您已经阅读并接受上述条款。
我所知道的管理员在上传方面的部分设计漏洞
小强下载
资源共享
Google
热门:软件 英语口语 英语翻译 英语学习
精彩推荐

文章排行榜

热点

最新

推荐

评论


论坛推荐
经典资料 更多>>
免责声明:本站只提供资源共享平台,如果站内部分资源侵犯您的权益,请您告知,站长会立即处理。
Copyright©2006-2008NiuBM.Com小强下载.All Rights Reserved .
QQ:4489167 Email:chaqiang@gmail.com苏苏ICP备06014543号站长:小强