上传漏洞:我所知道的管理员在上传方面的部分设计漏洞来源: 发布时间:星期六, 2009年9月12日 浏览:2次 评论:0
实都很简单都和JS有关
例子1: 个文档上传处: --------code begin--------- function Checkvalue(the){ var yes=true; ( the.username.value\"\" || the.password.value\"\" || the.primarykey.value\"\"){ alert(\"表单中标示 * 项目必须填写完整 !\"); yes=false;} var fileext=the.primarykey.value.sub(the.primarykey.value.length-4,the.primarykey.value.length) fileext=fileext.toLowerCase (!(fileext'.doc' || fileext'.txt' || fileext'.dat')) {alert(\"对不起不正确文件位置,必须为.doc、.txt或.dat !\"); the.primarykey.focus; yes=false; } yes; } --------code end--------- 他只用javascript做限制而没有从PHP环境下改正 直接把那个网页当到本地后改了改原代码 他当中 (!(fileext'.doc' || fileext'.txt' || fileext'.dat')) 修改成 ((fileext'.doc' || fileext'.txt' || fileext'.dat')) 并且修改FORM里头地址从upload.php改为http://IP/upload.php 例子2: 个网站WebSite上传处: --------code begin--------- function getFileExtension(filePath) { //v1.0 fileName = ((filePath.indexOf('/') > -1) ? filePath.sub(filePath.lastIndexOf('/')+1,filePath.length) : filePath.sub(filePath.lastIndexOf('\\\\')+1,filePath.length)); fileName.sub(fileName.lastIndexOf('.')+1,fileName.length); } function checkFileUpload(form,extensions) { //v1.0 document.MM_Value = true; (extensions && extensions != '') { for (var i = 0; i field = form.elements[i]; (field.type.toUpperCase != 'FILE') continue; (field.value '') { alert('文件框中必须保证已经有文件被选中!'); document.MM_Value = false;field.focus;; } (extensions.toUpperCase.indexOf(getFileExtension(field.value).toUpperCase) -1) { alert('这种文件类型不允许上传!.\\n只有以下类型文件才被允许上传: ' + extensions + '.\\n请选择别文件并重新上传.'); document.MM_Value = false;field.focus;; } } } } --------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) { (theForm.file1.value \"\") { alert(\"选择照片\"); (false); } (theForm.title.value \"\") { alert(\"请输入照片名称\"); theForm.title.focus; (false); } (theForm.gameid.value \"\") { alert(\"请输入您在游戏中ID\"); theForm.gameid.focus; (false); } (theForm.onlinetime.value \"\") { alert(\"请输入您上线时间\"); theForm.onlinetime.focus; (false); } (theForm.author.value \"\") { alert(\"请输入您名字\"); theForm.author.focus; (false); } (theForm.webgame.value \"\") { alert(\"您是哪个网络游戏服务器玩家??\"); theForm.webgame.focus; (false); } (theForm.email.value \"\") { alert(\"请输入您email\"); theForm.email.focus; (false); } (theForm.other.value \"\") { alert(\"请输入介绍\"); theForm.other.focus; (false); } (theForm.title.value.length > 20) { alert(\"非法名称\"); theForm.title.focus; (false); } (theForm.catalogid.value \"0\") { alert(\"选择类别\"); (false); } (theForm.author.value.length > 20) { alert(\"非法作者名字\"); theForm.author.focus; (false); } var checkOK = \"@.\"; var checkStr = theForm.email.value; var allValid = true; for (i = 0; i < checkOK.length; i) { j=checkStr.indexOf(checkOK.charAt(i)); ( (j-1) && (checkStr!=\"\") ) { alert(\"非法电子邮件\"); theForm.email.focus; (false); } } var fname = document.form1.file1.value; var ftype = fname.sub(fname.length-3,fname.length); (ftype!='jpg' && ftype!='g' && ftype!='t' && ftype!='zip' && ftype!='asp') { alert(\"图片格式必须是:*.jpg,*.g,*.t\"); (false); } theForm.filetype.value = theForm.file1.value.substr(theForm.file1.value.length-3,3) ; (true); } --------code end--------- 不难看出 (ftype!='jpg' && ftype!='g' && ftype!='t' && ftype!='zip' && ftype!='asp')这句话证明了他只对文件后缀做限制 把他改成(ftype!='jpg' && ftype!='g' && ftype!='t' && ftype!='zip' && ftype!='asp') 再把ACTION里头地址改改可以上传了不过结果没预料那么好我们读取不到文件呵呵如果都被读取了那么17173不是早就完蛋翘了 0
相关文章
读者评论发表评论 |