使用PowerShell查看浏览器历史记录

3

我正在尝试创建一个脚本来检索所有浏览器历史记录,但问题在于我无法使用确切的链接和访问网站的日期时间。

有谁能帮帮我吗?

我已经尝试过这个页面,但仍然无法获取日期时间/完整链接信息。

用 Powershell 导出 Chrome 历史记录

function Get-ChromeHistory {
            $Path = "$Env:systemdrive\Users\$UserName\AppData\Local\Google\Chrome\User Data\Default\History"
            if (-not (Test-Path -Path $Path)) {
                Write-Verbose "[!] Could not find Chrome History for username: $UserName"
            }
            $Regex = '(htt(p|s))://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
            $Value = Get-Content -Path "$Env:systemdrive\Users\$UserName\AppData\Local\Google\Chrome\User Data\Default\History"|Select-String -AllMatches $regex |% {($_.Matches).Value} |Sort -Unique
            $Value | ForEach-Object {
                $Key = $_
                if ($Key -match $Search){
                    New-Object -TypeName PSObject -Property @{
                        User = $UserName
                        Browser = 'Chrome'
                        DataType = 'History'
                        Data = $_
                    }
                }
            }        
        }

实际结果: Chrome | 我的用户名 | https://www.stackoverflow.com/

期望结果: Chrome | 用户名 | 06/21/2019 11:05 | https://stackoverflow.com/questions/ask


2
您提供的代码仅从Chrome的历史记录SQLLite数据库中提取URL,而不是日期。如果您不使用SQLLite应用程序或其中一个库(例如System.Data.SQLite),将很难解析与URL相关联的日期。 - Rich Moss
1
请查看此扩展以获取.NET。您可以使用它与sqllite数据库进行交互。 - Maximilian Burszley
1个回答

2
除了SQLLite解析问题之外,上面的代码还有两个漏洞:$UserName没有指定,而且正则表达式只能找到HTTP URL。下面是一个经过修正的版本,可以获取HTTP和HTTPS顶级URL。不幸的是,它不包括资源路径,虽然你似乎想要它,但从SQLLite文件中可靠地获取不可能。文件中没有URL结尾的分隔符。"最初的回答"
function Get-ChromeHistory {
    $Path = "$Env:SystemDrive\Users\$Env:USERNAME\AppData\Local\Google\Chrome\User Data\Default\History"
    if (-not (Test-Path -Path $Path)) {
        Write-Verbose "[!] Could not find Chrome History for username: $UserName"
    }
    $Regex = '(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
    $Value = Get-Content -Path $path | Select-String -AllMatches $regex |% {($_.Matches).Value} |Sort -Unique
    $Value | ForEach-Object {
        $Key = $_
        if ($Key -match $Search){
            New-Object -TypeName PSObject -Property @{
                User = $env:UserName
                Browser = 'Chrome'
                DataType = 'History'
                Data = $_
            }
        }
    } 
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接