简体   繁体   English

使用Perl在注册表中解析Microsoft Office 2013 MRU列表

[英]Parsing Microsoft Office 2013 MRU Lists in Registry using Perl

I am currently trying to parse the keys in a Windows 7 registry containing the MRU lists for Microsoft Office 2013. However when I attempt to run the Perl script in RegRipper it says the plugin was not successfully run. 我当前正在尝试解析Windows 7注册表中的注册表项,该注册表包含Microsoft Office 2013的MRU列表。但是,当我尝试在RegRipper中运行Perl脚本时,它说插件未成功运行。 Im not sure if there is a syntax error in my code or if it is unable to parse the registry as I have it written. 我不确定我的代码中是否存在语法错误,或者它无法像我编写的那样无法解析注册表。 The biggest problem is that one of the keys is named after the user's LiveId (it appear as LiveId_XXXXXXX) and this changes from user to user so i would like this plugin to work no matter what the user's LiveId is. 最大的问题是,其中一个键是根据用户的LiveId命名的(它显示为LiveId_XXXXXXX),并且这在用户之间会发生变化,因此无论用户的LiveId是什么,我都希望此插件正常工作。 Thanks! 谢谢!

my $reg = Parse::Win32Registry->new($ntuser);
    my $root_key = $reg->get_root_key;
    # ::rptMsg("officedocs2013_File_MRU v.".$VERSION); # 20110830 [fpi] - redundant
    my $tag = 0;
    my $key_path = "Software\\Microsoft\\Office\\15.0";
    if (defined($root_key->get_subkey($key_path))) {
        $tag = 1;
    }

    if ($tag) {
        ::rptMsg("MSOffice version 2013 located.");
        my $key_path = "Software\\Microsoft\\Office\\15.0";            
        my $of_key = $root_key->get_subkey($key_path);
        if ($of_key) {
# Attempt to retrieve Word docs
            my $word_mru_key_path = 'Software\\Microsoft\\Office\\15.0\\Word\\User MRU';
            my $word_mru_key = $of_key->get_subkey($word_mru_key_path);
            foreach ($word_mru_key->get_list_of_subkeys())
    {
        if ($key->as_string() =~ /LiveId_\w+/)
        {
            $word = join($key->as_string(),'\\File MRU');
            ::rptMsg($key_path."\\".$word);
            ::rptMsg("LastWrite Time ".gmtime($word_key->get_timestamp())." (UTC)");
            my @vals = $word_key->get_list_of_values();
                if (scalar(@vals) > 0) {
                    my %files

# Retrieve values and load into a hash for sorting          
                    foreach my $v (@vals) {
                        my $val = $v->get_name();
                        if ($val eq "Max Display") { next; }
                        my $data = getWinTS($v->get_data());
                        my $tag = (split(/Item/,$val))[1];
                        $files{$tag} = $val.":".$data;
                    }
# Print sorted content to report file           
                    foreach my $u (sort {$a <=> $b} keys %files) {
                        my ($val,$data) = split(/:/,$files{$u},2);
                        ::rptMsg("  ".$val." -> ".$data);
                    }
                }
                else {
                    ::rptMsg($key_path.$word." has no values.");
                }

            else {
                ::rptMsg($key_path.$word." not found.");
            }
            ::rptMsg("");                                                                        
        }
    }  

The regex 正则表达式

LiveId_(\w+)

will grab the string after LiveId_ and you can reference it with a \\1 like this 会抢后的字符串LiveId_ ,你可以用引用它\\1这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM