我所知道的管理員在上傳方面的部分設計漏洞

其實都很簡單,都和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不是早就完蛋翹了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章