Sign in to follow this  
Followers 0
mikeytown2

Internet Explorer & Firefox History

5 posts in this topic

#1 ·  Posted (edited)

I Got this idea from here UrlSearch

What this does is it grabs the history from the .dat files and saves just the URL's to a file. It also gets all open windows URL's except for firefox.

#include <Array.au3>
#include <file.au3>
#include <string.au3>
Opt("WinTitleMatchMode", 4)
$x = StringSplit(@AutoItExe, "\")
ProcessSetPriority($x[$x[0]], 0)
$debug = True

Dim $netwindows[1]
Dim $netwindowsURL[1]
Dim $HistURL[1]
$HistURL[0] = 0
Dim $HistURLFF[1]
$HistURLFF[0] = 0

If $debug Then ToolTip("Grabing Recently Played/Viewed Media")
$a = RegRead("HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\RecentFileList", "")
$b = RegRead("HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\RecentURLList", "")
Dim $c[1]
$c[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List", $c[0]) <> ""
    _ArrayAdd($c, RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List", $c[0])))
    $c[0] = $c[0] + 1
WEnd
$c[0] = $c[0] - 1

Dim $d[1]
$d[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.avi", $d[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.avi", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.avi", $d[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".avi") Then
        $t = StringSplit($t, ".avi", 1)
        _ArrayAdd($d, $t[1] & ".avi")
    EndIf
    $d[0] = $d[0] + 1
WEnd
$d[0] = UBound($d) - 2

Dim $e[1]
$e[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.bmp", $e[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.bmp", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.bmp", $e[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".bmp") Then
        $t = StringSplit($t, ".bmp", 1)
        _ArrayAdd($e, $t[1] & ".bmp")
    EndIf
    $e[0] = $e[0] + 1
WEnd
$e[0] = UBound($e) - 2

Dim $f[1]
$f[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.gif", $f[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.gif", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.gif", $f[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".gif") Then
        $t = StringSplit($t, ".gif", 1)
        _ArrayAdd($f, $t[1] & ".gif")
    EndIf
    $f[0] = $f[0] + 1
WEnd
$f[0] = UBound($f) - 2

Dim $g[1]
$g[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.htm", $g[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.htm", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.htm", $g[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".htm") Then
        $t = StringSplit($t, ".htm", 1)
        _ArrayAdd($g, $t[1] & ".htm")
    EndIf
    $g[0] = $g[0] + 1
WEnd
$g[0] = UBound($g) - 2

Dim $h[1]
$h[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.html", $h[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.html", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.html", $h[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".html") Then
        $t = StringSplit($t, ".html", 1)
        _ArrayAdd($h, $t[1] & ".html")
    EndIf
    $h[0] = $h[0] + 1
WEnd
$h[0] = UBound($h) - 2

Dim $l[1]
$l[0] = 1
While RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.jpg", $l[0]) <> ""
    $temp = StringSplit(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.jpg", RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.jpg", $l[0])), "")
    $t = ""
    For $i = 1 To $temp[0] Step + 4
        $t = $t & $temp[$i] & $temp[$i + 1]
    Next
    $t = _HexToString ($t)
    If StringInStr($t, ".jpg") Then
        $t = StringSplit($t, ".jpg", 1)
        _ArrayAdd($l, $t[1] & ".jpg")
    EndIf
    $l[0] = $l[0] + 1
WEnd
$l[0] = UBound($l) - 2


If $debug Then ToolTip("Grabing titles from Open Windows")
;Grab titles from open IE windows
$varB = WinList("classname=IEFrame")
For $i = 1 To $varB[0][0] Step + 1
    $netwindows[0] = $netwindows[0] + 1
    _ArrayAdd($netwindows, $varB[$i][0])
Next

For $i = 1 To $netwindows[0] Step + 1
    $t = StringSplit(WinGetText($netwindows[$i]), "http://", 1)
    _ArrayAdd($netwindowsURL, StringLeft($t[2], 80))
    $netwindowsURL[0] = $netwindowsURL[0] + 1
Next

;Grab titles from open FireFox windows
$varA = WinList("classname=MozillaUIWindowClass")
For $i = 1 To $varA[0][0] Step + 1
    $netwindows[0] = $netwindows[0] + 1
    _ArrayAdd($netwindows, $varA[$i][0])
Next

While $netwindows[0] <> $netwindowsURL[0]
    $netwindowsURL[0] = $netwindowsURL[0] + 1
    _ArrayAdd($netwindowsURL, "FireFox")
    
WEnd

;load up IE history file
If $debug Then ToolTip("Reading IE History File")
$file = FileOpen(@UserProfileDir & "\Cookies\index.dat", 0)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
Else
    While 1
        $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
        If StringInStr($line, "Cookie:" & @UserName & "@") Then
            
            $x = StringSplit($line, "Cookie:" & @UserName & "@", 1)
            $x = StringSplit($x[2], "/")
            If StringInStr($x[1], ".", "", -2) Then
                $x[1] = StringTrimLeft($x[1], StringInStr($x[1], ".", "", -2))
            EndIf
            
            $newUrl = $x[1]
            _ArrayAdd($HistURL, $newUrl)
            $HistURL[0] = $HistURL[0] + 1
            
        EndIf
        
    WEnd
EndIf
FileClose($file)

If $debug Then ToolTip("Sorting IE Data Part One")
_ArraySort($HistURL, 0, 1)

$s_TempFile = _TempFile ()
If $debug Then ToolTip("Sorting IE Data Part Two")
For $i = 1 To $HistURL[0]
    
    $ini = IniRead($s_TempFile, "History", $HistURL[$i], "default")
    If $ini = "default" Then
        IniWrite($s_TempFile, "History", $HistURL[$i], 1)
    Else
        IniWrite($s_TempFile, "History", $HistURL[$i], $ini + 1)
    EndIf
Next
$temp = IniReadSection($s_TempFile, "History")
If @error Then
Else
    FileDelete($s_TempFile)
    
    ReDim $HistURL[1]
    $HistURL[0] = 0
    For $i = 1 To $temp[0][0] Step + 1
        _ArrayAdd($HistURL, $temp[$i][0])
        $HistURL[0] = $HistURL[0] + 1
    Next
EndIf


;Load Up FireFox history file
If $debug Then ToolTip("Reading Firefox History File")
$FileList = _FileListToArray (@AppDataDir & "\Mozilla\Firefox\Profiles")
If (Not IsArray($FileList)) and (@error = 1) Then
    MsgBox(0, "", "No Files\Folders Found.")
Else
    
    For $i = 1 To $FileList[0] Step + 1
        $file = FileOpen(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $FileList[$i] & "\history.dat", 0)
        If $file = -1 Then
            MsgBox(0, "Error", "")
        Else
            While 1
                $line = FileReadLine($file)
                If @error = -1 Then ExitLoop
                If StringInStr($line, "=http://") Then
                    
                    $x = StringSplit($line, "=http://", 1)
                    $x = StringSplit($x[2], ")")
                    $x = StringSplit($x[1], "(")
                    $x = StringSplit($x[1], "\")
                    $x = StringSplit($x[1], "/")
                    If StringInStr($x[1], ".", "", -2) Then
                        $x[1] = StringTrimLeft($x[1], StringInStr($x[1], ".", "", -2))
                    EndIf
                    $newUrl = $x[1]
                    
                    _ArrayAdd($HistURLFF, $newUrl)
                    $HistURLFF[0] = $HistURLFF[0] + 1
                    
                EndIf
            WEnd
        EndIf
        FileClose($file)
    Next
    If $debug Then ToolTip("Sorting Firefox Data Part One")
    _ArraySort($HistURLFF, 0, 1)
;fix firefox
    $s_TempFile = _TempFile ()
    If $debug Then ToolTip("Sorting Firefox Data Part Two")
    For $i = 1 To $HistURLFF[0]
        
        $ini = IniRead($s_TempFile, "History", $HistURLFF[$i], "default")
        If $ini = "default" Then
            IniWrite($s_TempFile, "History", $HistURLFF[$i], 1)
        Else
            IniWrite($s_TempFile, "History", $HistURLFF[$i], $ini + 1)
        EndIf
    Next
    $temp = IniReadSection($s_TempFile, "History")
    If @error Then
    Else
        FileDelete($s_TempFile)
        
        ReDim $HistURLFF[1]
        $HistURLFF[0] = 0
        For $i = 1 To $temp[0][0] Step + 1
            _ArrayAdd($HistURLFF, $temp[$i][0])
            $HistURLFF[0] = $HistURLFF[0] + 1
        Next
    EndIf
;firefox fixed
EndIf

ToolTip("")
$Save = FileSaveDialog("Save Log File", @DesktopDir, "Text files (*.ini;*.txt)", "", "INetHistory.ini")
If FileExists($Save) Then
    If MsgBox(4, "Erase Old Data?", "Do you wish to clear out the old data?" & @CRLF & "No will Exit without Writing") = 7 Then
        Exit
    Else
        FileDelete($Save)
    EndIf
EndIf
If $debug Then ToolTip("Saving File")
For $i = 1 To $netwindows[0] Step + 1
    IniWrite($Save, "Windows Open Right Now", $netwindowsURL[$i], $netwindows[$i])
Next


FileWriteLine($Save, @CRLF & "[Paint Recent File List]")
For $i = 1 To $c[0] Step + 1
    FileWriteLine($Save, $c[$i])
Next

FileWriteLine($Save, @CRLF & "[RecentDocs .avi]")
For $i = 1 To $d[0] Step + 1
    FileWriteLine($Save, $d[$i])
Next

FileWriteLine($Save, @CRLF & "[RecentDocs .bmp]")
For $i = 1 To $e[0] Step + 1
    FileWriteLine($Save, $e[$i])
Next

FileWriteLine($Save, @CRLF & "[RecentDocs .gif]")
For $i = 1 To $f[0] Step + 1
    FileWriteLine($Save, $f[$i])
Next

FileWriteLine($Save, @CRLF & "[RecentDocs .htm]")
For $i = 1 To $g[0] Step + 1
    FileWriteLine($Save, $g[$i])
Next
For $i = 1 To $h[0] Step + 1
    FileWriteLine($Save, $h[$i])
Next

FileWriteLine($Save, @CRLF & "[RecentDocs .jpg]")
For $i = 1 To $l[0] Step + 1
    FileWriteLine($Save, $l[$i])
Next

FileWriteLine($Save, @CRLF & @CRLF & "#################################################" & @CRLF & "[Firefox History]")
For $i = 1 To $HistURLFF[0] Step + 1
    FileWriteLine($Save, $HistURLFF[$i])
Next

FileWriteLine($Save, @CRLF & @CRLF & "#################################################" & @CRLF & "[Explorer History]")
For $i = 1 To $HistURL[0] Step + 1
    FileWriteLine($Save, $HistURL[$i])
Next
ToolTip("")
Does anyone know how to grab the URL from firefox a nice way?

Not Ctrl U WinGetTitle

Let me know how this works for you. It will take some time to run (30 seconds for me)

Anyone want to add Opera to this?

EDIT

Added Recent Media Files's to the output!

Please help me find more locations in the reg.

Edited by mikeytown2

Share this post


Link to post
Share on other sites



Update

Added Recent Media Files's to the output

Thats cool - I never thought you could do that with AutoIT - this is a very powerful scripting/programming language. I cannot wait to dig into your code and look at what and how you did what you did. Thanks for sharing.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Thats cool - I never thought you could do that with AutoIT - this is a very powerful scripting/programming language. I cannot wait to dig into your code and look at what and how you did what you did. Thanks for sharing.

Did this code change?

I am now getting ERROR:

(140) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

_ArrayAdd($netwindowsURL, StringLeft($t[2], 80))

_ArrayAdd($netwindowsURL, StringLeft(^ ERROR


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0