0

我正在尝试创建一个 powershell 脚本来读取存储在 AppData\Local\Microsoft\Windows\WebCache\WebCache.dat 中的 IE 10/11 互联网历史记录。

我正在使用Managed Esent +- 与 .NET 中的 Win32 Jet api 交互。

我的问题是我永远无法真正打开数据库,因为当我调用 JetAttachDatabase 时会抛出 EsentPageSizeMismatchException。在对这个错误做了一些研究后,我发现 IE WebCache 的页面大小为 32K。当我尝试通过将 DatabasePageSize 系统参数设置为 0x8000 来纠正此问题时,JetInit 开始抛出相同的异常。

这是我的代码

#stop the things locking the database
stop-process -name taskhost
stop-process -name dllhost
#give powershell access to the interop dlls
add-type -path "$PSScriptRoot\ManagedEsent 1.6\Esent.Interop.dll"
$instance = [Microsoft.Isam.Esent.Interop.JET_INSTANCE]::Nil
#set page size
[Microsoft.Isam.Esent.Interop.api]::JetSetSystemParameter(
    $instance,
    [Microsoft.Isam.Esent.Interop.JET_SESID]::Nil,
    [Microsoft.Isam.Esent.Interop.JET_param]::DatabasePageSize,
    0x8000,
    $null
)
[Microsoft.Isam.Esent.Interop.Api]::JetCreateInstance([ref]$instance,"testing")
# init the instance, throws EsentPageSizeMismatchException if the page size is not default
[Microsoft.Isam.Esent.Interop.Api]::JetInit([ref]$instance) 
$sesid = [Microsoft.Isam.Esent.Interop.JET_SESID]::Nil
[Microsoft.Isam.Esent.Interop.Api]::JetBeginSession($instance,[ref]$sesid,$null,$null)
# throws EsentPageSizeMismatchException if page size is default
[Microsoft.Isam.Esent.Interop.api]::JetAttachDatabase(
   $sesid,
   "C:\Users\Administrator\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat",
   [Microsoft.Isam.Esent.Interop.AttachDatabaseGrbit]::ReadOnly
)
...

似乎 ESENT 引擎不喜欢具有非默认页面大小,但我已经搜索了互联网,似乎没有办法更改引擎页面大小。是什么导致了这个错误?

4

3 回答 3

0

如果您注意到,在一种情况下它会JetAttachDatabase因异常而失败,而JetInit在另一种情况下。

您确实是正确的,您需要设置 DatabasePageSize。 JetInit其实是个蹩脚的名字。它应该被称为类似JetInitAndReplayLogFiles. 它将查看日志目录(默认:“.”)中的事务日志文件(默认名称为 edb*.log),并在事务日志文件中重放操作。

您现在可能正在选择使用不同页面大小创建的其他事务日志文件。理论:您正在拾取edb*.log您在第一次尝试时无意创建的文件。

一些潜在的解决方案:

-cd 首先进入包含日志文件的目录。

- 更改 LogFileDirectory(您可以使用JetSetSystemParameterwithJET_param.LogFilePath或 wrapper class InstanceParameters.LogFileDirectory)。哦,您还需要设置InstanceParameters.BaseName为“v01”,因为这似乎是 webcache01.dat 文件使用的内容(影响“edb.log”与“v01.log”的名称)。

-esentutl.exe -r v01用于使数据库进入“干净关闭”状态,然后设置InstanceParameters.Recoveryfalse避免意外创建新的事务日志文件。我看到你已经附上了AttacheDatabaseGrbit.ReadOnly.

最后,我希望这只是出于好奇。从事 inetcache 工作的人可以随时更改实现细节。如果是出于取证目的,Microsoft 会协助执法机构的取证工作。

-马丁

于 2016-07-12T16:10:17.117 回答
0

就我而言,每次切换数据库时,我都必须手动进入 bin/Debug 文件夹并手动删除内容,然后再对其进行调试。我希望这对面临这个问题的人有所帮助。

于 2016-08-24T09:24:09.163 回答
0

您应该使用 JetGetDatabaseFileInfo() 来获得与 SetSetSystemParameter() 一起使用所需的页面大小

这是 C# 中的一个示例(嘿......这已经足够接近了,对吧?)

        int pageSize;
        JET_INSTANCE instance;
        JET_SESID sesId;

        // match the Page size
        Api.JetGetDatabaseFileInfo(databasePath, out pageSize, JET_DbInfo.PageSize);
        Api.JetSetSystemParameter(JET_INSTANCE.Nil, JET_SESID.Nil, JET_param.DatabasePageSize, pageSize, null);
于 2016-07-14T01:19:00.303 回答