Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.8 KiB

  1. <html>
  2. <head>
  3. <title>Example WinSafer Html script</title>
  4. </head>
  5. <body>
  6. <h1>Example WinSafer Html script</h1>
  7. <script language="vbscript">
  8. msgbox("Hello friend, please press 'Yes' when Internet Explorer asks you a question!")
  9. </script>
  10. <table bgcolor="#cccc99" border=3>
  11. <tr><th>Script output is below:</th></tr>
  12. <tr><td bgcolor="#eeeeaa">
  13. <script language="vbscript">
  14. Option Explicit
  15. const filename1 = "c:\boot.ini"
  16. const filename2 = "e:\secret.txt"
  17. const foldername1 = "e:\spam"
  18. document.write("Howdy. I am a malicious script.<br>")
  19. document.write("<hr>")
  20. call ReadTheFile(filename1)
  21. document.write("<hr>")
  22. call ReadTheFile(filename2)
  23. document.write("<hr>")
  24. rem call DisplaySpecialFolders
  25. rem document.write("<hr>")
  26. rem call ReadTheRegistry
  27. rem document.write("<hr>")
  28. call DeleteFiles(foldername1)
  29. sub ReadTheRegistry
  30. On error resume next
  31. dim wscr, rr
  32. set wscr = CreateObject("WScript.Shell")
  33. set rr=wscr.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\EmailName")
  34. document.write("Read the registry: " & rr)
  35. end sub
  36. Sub ReadTheFile(filename)
  37. On error resume next
  38. dim fso, fileinput, linetext
  39. Set fso = CreateObject("Scripting.FileSystemObject")
  40. Err.Clear
  41. set fileinput = fso.OpenTextFile(filename,1)
  42. if (Err.Number <> 0) then
  43. document.write("I failed to open the file <B>" & filename & "</B> for reading: " & Err.Description & "<br>")
  44. else
  45. linetext = fileinput.ReadAll
  46. fileinput.Close
  47. document.write("I just read the file <B>" & filename & "</B> and it contained:<br><pre>" & linetext & "</pre><br>")
  48. End if
  49. End Sub
  50. Sub DeleteFiles(foldername)
  51. On error resume next
  52. dim fso, Folder, Files, File, filecount
  53. Set fso = CreateObject("Scripting.FileSystemObject")
  54. document.write("<ul>")
  55. document.write("<li>Going to delete all files from " & foldername)
  56. Err.Clear
  57. set Folder = fso.GetFolder(foldername)
  58. if (Err.Number <> 0) then
  59. document.write("<li>Failed to access <B>" & foldername & "</b>: " & Err.Description)
  60. else
  61. set files = Folder.Files
  62. if (Err.Number <> 0) then
  63. document.write("<li>Failed to access <B>" & foldername & "</b>: " & Err.Description)
  64. else
  65. filecount = Files.Count
  66. if Err.Number <> 0 then
  67. document.write("<li>Failed to access folder: " & Err.Description)
  68. else
  69. document.write("<li>There are " & CStr(filecount) & " files within <b>" & foldername & "</b>")
  70. for each File in Files
  71. Err.Clear
  72. document.write("<li>" & File.Path)
  73. if (Err.Number <> 0) then
  74. document.write("<li>Failed to delete files: " & Err.Description)
  75. else
  76. Err.Clear
  77. FSO.DeleteFile(File.Path)
  78. if (Err.Number <> 0) then
  79. document.write(": failed to delete, " & Err.Description)
  80. else
  81. document.write(": <B>successfully deleted!!</B>")
  82. end if
  83. end if
  84. Next
  85. end if
  86. end if
  87. end if
  88. document.write("</ul>")
  89. end sub
  90. sub DisplaySpecialFolders
  91. On error resume next
  92. dim fso, dirwin, dirsystem, dirtemp
  93. Set fso = CreateObject("Scripting.FileSystemObject")
  94. Set dirwin = fso.GetSpecialFolder(0)
  95. Set dirsystem = fso.GetSpecialFolder(1)
  96. Set dirtemp = fso.GetSpecialFolder(2)
  97. document.write("Your Windows directory is: " & dirwin & "<br>")
  98. document.write("Your System directory is: " & dirsystem & "<br>")
  99. document.write("Your Temporary directory is: " & dirtemp & "<br>")
  100. rem Interestingly enough, when running in an untrusted level,
  101. rem the vbscript fails to be able to determine the user's
  102. rem personal temporary directory.
  103. end sub
  104. </script>
  105. </td></tr></table>
  106. </body>
  107. </html>