Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to log and email IE History 1

Status
Not open for further replies.

ppuddick

ISP
Nov 15, 2002
56
GB
Hi all,

Here's the scenario. I have a customer on a small LAN with all web traffic going out through the NATted router/firewall. Thats fine. They've come to me asking if we can record and log everyone's (only 10 machines) Internet history/activity and then automatically email that to one of the Directors on a weekly basis. I know you can do something like with this ISA Server but as they have no proxy server I was thinking of the possibilites of a script to do this.

Any help or pointers in the right direction wolud be much appreciated and thank you for reading
 
Here is something to get you started. This is designed to be saed and run as an HTML file. Give it a shot and you could easily modify it to parse the log file and email it as you need.

Code:
<HTML><HEAD><TITLE>IE Spy - by Vengy</TITLE></HEAD><pre>

<script language="VBScript" TYPE="text/vbscript">

' ======================== Let The Games Begin! ========================
' Contact Info
' ------------
' Author: Vengy
' Email : cyber_flash@hotmail.com

' How it works
' ------------
' INDEX.DAT files keep a list of websites you have visited, cookies received and files opened/downloaded.
' As a result anyone can find out what you have been doing on the Internet!
'
' This program scans all history index files looking for any HTTP:// or FILE:// entries.
' If found, they're stored in a file called C:\SPY.HTM along with the user.

' Aside: This program invokes a local windows program called FIND.EXE to
' parse the index.dat files. (I was too lazy to code it myself. ;)

' Have Fun! (-_-)


' ======================== The Banner ========================
document.writeln "INDEX.DAT files keep a list of websites you have visited, cookies received and files opened/downloaded."
document.writeln "As a result anyone can find out what you have been doing on the Internet!"+VBNewLine
document.writeln "This program scans all history index files looking for any HTTP:// or FILE:// entries."
document.writeln "If found, the User/URL's are stored in a file called C:\SPY.HTM."+VBNewLine


' ======================== ActiveX Warning ========================
MsgBox "NOTE: Please click 'Yes' if prompted with the following message:"+VBNewLine+VBNewLine+"An ActiveX control on this page might be unsafe to"+VBNewLine+"interact with other parts of the page. Do you want to"+VBNewLine+"allow this interaction?"+VBNewLine+VBNewLine+"Click OK to start Spy scan ...",vbOKOnly,"Welcome"


' ======================== Setup Objects ========================
Dim oFSO     : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim arrFiles : arrFiles=Array()
Dim oWShell  : Set oWShell = CreateObject("WScript.Shell")


' ======================== Locate Index.Dat Folder ========================
' ---> WINXP/2K
If oFSO.FolderExists("C:\Documents and Settings\") Then
  index_folder = "C:\Documents and Settings"
' ---> WIN9X
Elseif oFSO.FolderExists("C:\windows\") Then
  index_folder = "C:\windows"
' ---> Browse For Folder
Else
  index_folder = fnGetMyPathVB
End If


' ======================== Start Spy Scan ========================
If index_folder="None" Then
  MsgBox "No Specified Folder. Scan Aborted."
Else
  Set oStartDir = oFSO.GetFolder(index_folder)
  sFileRegExPattern = "\index.dat$"
  RecurseFilesAndFolders oStartDir, sFileRegExPattern
  DisplayResults
End If


' ======================== Find ALL Index.Dat Files ========================
Sub RecurseFilesAndFolders(oRoot, sFileEval)
    Dim oSubFolder, oFile, oRegExp
    Set oRegExp = New RegExp
    oRegExp.IgnoreCase = True

    window.status="Scanning: "+oRoot

    If Not (sFileEval = "") Then
      oRegExp.Pattern = sFileEval
      For Each oFile in oRoot.Files
        If (oRegExp.Test(oFile.Name)) Then
          If (InStr(oFile.Path,"History.IE")<>0) Then
            ReDim Preserve arrFiles(UBound(arrFiles) + 1)
            arrFiles(UBound(arrFiles)) = oFile.Path
          End If
        End If
      Next
    End If

    For Each oSubFolder In oRoot.SubFolders
      RecurseFilesAndFolders oSubFolder, sFileEval
    Next
End Sub


' ======================== Display Results ========================
Sub DisplayResults()

    Dim sReadLine, sArray, start, count,ub
    Const ForReading = 1

    Window.status="Scanning ..."

    Set oTextStream = oFSO.CreateTextFile("C:\spy.bat")
    oTextStream.Write "echo off"+VBNewLine

    count=0
    ub=UBound(arrFiles)
    For Each elem In arrFiles
      count=count+1
      document.writeln elem
      oTextStream.Write "echo Remaining Scans: "+CStr(ub+1-count)+VBNewLine
      oTextStream.Write "find "+chr(34)+"[URL unfurl="true"]http://"+chr(34)+"[/URL] "+chr(34)+elem+chr(34)+" >>c:\spy.txt"+VBNewLine
      oTextStream.Write "find "+chr(34)+"file://"+chr(34)+" "+chr(34)+elem+chr(34)+" >>c:\spy.txt"+VBNewLine
    Next

    oTextStream.Close

    If count=0 Then
      Window.status="Aborted."
      MsgBox "No Index.dat files found. Scan Aborted."
      Exit Sub
    End If

    oWShell.Run "c:\spy.bat", , True

    oFSO.DeleteFile "C:\spy.bat"

    If oFSO.FileExists("C:\spy.htm") Then
      oFSO.DeleteFile "C:\spy.htm"
    End If

    Set oTextStream = oFSO.CreateTextFile("C:\spy.htm")
    Set oFilein = oFSO.OpenTextFile("c:\spy.txt",ForReading)

    oTextStream.Writeline "<html><title>IE is spying on you!</title><body><b>Welcome</b><br><font size=2>"

    Do While Not oFilein.AtEndOfStream
      sReadLine = oFilein.ReadLine
      start = Instr(sReadLine,": ")
      If start <> 0 Then
        sReadLine = Mid(sReadLine,start+2)
        sArray = Split(sReadLine,"@")
        oTextStream.Write sArray(0)                                          ' User
        oTextStream.Writeline " <a href="+sArray(1)+">"+sArray(1)+"</a><br>" ' Visited URL
      End If
    loop

    oTextStream.Writeline "</font><b>End of Report</b></body></html>"

    oFilein.Close
    oTextStream.Close

    oFSO.DeleteFile "C:\spy.txt"

    Window.status="Done"
    document.writeln "<b>Scan Completed.</b>"
    MsgBox "Please check C:\SPY.HTM for details. Thanks!",0,"Spy Scan Completed."
    oWShell.Run "C:\PROGRA~1\INTERN~1\IEXPLORE.EXE C:\SPY.HTM"

End Sub


' ======================== Specify Custom Index.dat Folder ========================
function fnGetMyPathVB()
    dim oShell
    dim oFolder
    dim oFolderItem

    set oShell = CreateObject("Shell.Application")
    set oFolder = oShell.BrowseForFolder(0, "Choose a Folder", 0)

    If oFolder is nothing Then
      fnGetMyPathVB = "None"
    Else
      set oFolderItem = oFolder.Items.Item
      fnGetMyPathVB = oFolderItem.Path
    End If
end function


' ======================== End Of VBscript ========================
</script>

</pre></HTML>

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Im not the OP but help me understand this .. this needs to be created as a .html file and ran as an html file?

::.I may not know it all, but I still approach it with confidence to figure it out::.
 
And to avoid the ActiveX warning you may convert it to an hta file.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
So this mean yes, create a html of it.. correct? Im not in a position to do so at the moment, when i get to my home office i will try it ..

::.I may not know it all, but I still approach it with confidence to figure it out::.
 
yes, save it with an htm extension.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Will do ..

::.I may not know it all, but I still approach it with confidence to figure it out::.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top