Ejemplo n.º 1
0
        public static Timezone Get(string hivePath)
        {
            ValueKey vk = ValueKey.Get(hivePath, @"ControlSet001\Control\TimeZoneInformation", "TimeZoneKeyName");
            TimeZone tz = TimeZone.CurrentTimeZone;

            return(new Timezone(System.Text.Encoding.Unicode.GetString(vk.GetData()), tz.StandardName, tz.DaylightName, tz.IsDaylightSavingTime(DateTime.Now)));
        }
Ejemplo n.º 2
0
        public static Shimcache[] GetInstancesByPath(string hivePath)
        {
            if (RegistryHeader.Get(hivePath).HivePath.Contains("SYSTEM"))
            {
                string   Key = @"ControlSet001\Control\Session Manager\AppCompatCache";
                ValueKey vk  = null;

                try
                {
                    vk = ValueKey.Get(hivePath, Key, "AppCompatCache");
                }
                catch
                {
                    try
                    {
                        Key = @"ControlSet001\Control\Session Manager\AppCompatibility";
                        vk  = ValueKey.Get(hivePath, Key, "AppCompatCache");
                    }
                    catch
                    {
                        throw new Exception("Error finding AppCompatCache registry value");
                    }
                }

                byte[] bytes = (byte[])vk.GetData();

                string arch = (string)ValueKey.Get(hivePath, @"ControlSet001\Control\Session Manager\Environment", "PROCESSOR_ARCHITECTURE").GetData();

                switch (BitConverter.ToUInt32(bytes, 0x00))
                {
                // Windows XP
                case WINXP_MAGIC:
                    return(GetDEADBEEF(bytes));

                // Server 2003, Windows Vista, Server 2008
                case NT5dot2_MAGIC:
                    return(GetBADC0FFE(bytes, arch));

                // Windows 7 and Server 2008 R2
                case NT6dot1_MAGIC:
                    return(GetBADC0FEE(bytes, arch));

                // Windows 8
                // Windows 8.1
                case WIN8dot1_MAGIC:
                    return(Get00000080(bytes));

                // Windows 10
                case WIN10_MAGIC:
                    return(Get00000030(bytes));

                default:
                    return(null);
                }
            }
            else
            {
                throw new Exception("Invalid SYSTEM hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hivePath"></param>
        /// <returns></returns>
        public static RecentDocs[] Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "NTUSER.DAT"))
            {
                string user  = RegistryHelper.GetUserHiveOwner(hivePath);
                byte[] bytes = RegistryHelper.GetHiveBytes(hivePath);
                string key   = @"Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs";

                NamedKey     RecentDocsKey = NamedKey.Get(bytes, hivePath, @"Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs");
                ValueKey     MRUListEx     = ValueKey.Get(bytes, hivePath, key, "MRUListEx");
                byte[]       MRUListBytes  = (byte[])MRUListEx.GetData(bytes);
                RecentDocs[] docs          = new RecentDocs[MRUListBytes.Length / 4];

                for (int i = 0; i < MRUListBytes.Length - 4; i += 4)
                {
                    if (i == 0)
                    {
                        docs[i / 4] = new RecentDocs(user, Encoding.Unicode.GetString((byte[])ValueKey.Get(bytes, hivePath, key, BitConverter.ToInt32(MRUListBytes, i).ToString()).GetData(bytes)).Split('\0')[0], RecentDocsKey.WriteTime);
                    }
                    else
                    {
                        docs[i / 4] = new RecentDocs(user, Encoding.Unicode.GetString((byte[])ValueKey.Get(bytes, hivePath, key, BitConverter.ToInt32(MRUListBytes, i).ToString()).GetData(bytes)).Split('\0')[0]);
                    }
                }

                return(docs);
            }
            else
            {
                throw new Exception("Invalid NTUSER.DAT hive provided to the -HivePath parameter.");
            }
        }
Ejemplo n.º 4
0
        public static byte[] Get(string hivePath)
        {
            if (RegistryHeader.Get(hivePath).HivePath.Contains("SYSTEM"))
            {
                ValueKey vk    = ValueKey.Get(hivePath, @"ControlSet001\Control\Session Manager\AppCompatCache", "AppCompatCache");
                byte[]   bytes = vk.GetData();

                switch (BitConverter.ToUInt32(bytes, 0x00))
                {
                // Windows 5.2 and 6.0 (Server 2003, Vista, & Server 2008)
                case WINXP_MAGIC:
                    Console.WriteLine("XP");
                    break;

                case NT5_2_MAGIC:
                    Console.WriteLine("5.2");
                    break;

                case NT6_1_MAGIC:
                    Console.WriteLine("6.1");
                    break;

                default:
                    //Console.WriteLine("Default");
                    break;
                }

                return(bytes);
            }
            else
            {
                throw new Exception("Invalid SYSTEM hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hivePath"></param>
 /// <returns></returns>
 public static Timezone GetByPath(string hivePath)
 {
     if (RegistryHelper.isCorrectHive(hivePath, "SYSTEM"))
     {
         ValueKey vk = ValueKey.Get(hivePath, @"ControlSet001\Control\TimeZoneInformation", "TimeZoneKeyName");
         return(new Timezone((string)vk.GetData()));
     }
     else
     {
         throw new Exception("Invalid SYSTEM hive provided to -HivePath parameter.");
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// The ProcessRecord method calls TimeZone.CurrentTimeZone to return a TimeZone object.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (!(this.MyInvocation.BoundParameters.ContainsKey("Path")))
            {
                hivePath = @"C:\Windows\system32\config\SYSTEM";
            }

            ValueKey vk = ValueKey.Get(hivePath, @"ControlSet001\Control\TimeZoneInformation", "TimeZoneKeyName");
            TimeZone tz = TimeZone.CurrentTimeZone;

            WriteObject(new InvokeIR.PowerForensics.Artifacts.Timezone(System.Text.Encoding.Unicode.GetString(vk.GetData()), tz.StandardName, tz.DaylightName, tz.IsDaylightSavingTime(DateTime.Now)));
        } // ProcessRecord
Ejemplo n.º 7
0
 public static SecurityIdentifier Get(string hivePath)
 {
     if (RegistryHeader.Get(hivePath).HivePath.Contains("SAM"))
     {
         ValueKey vk = ValueKey.Get(hivePath, @"SAM\Domains\Account", "V");
         return(new SecurityIdentifier(vk.GetData(), (int)vk.DataLength - 0x18));
     }
     else
     {
         throw new Exception("Invalid SAM hive provided to -HivePath parameter.");
     }
 }
Ejemplo n.º 8
0
 public static SecurityIdentifier GetByPath(string hivePath)
 {
     if (RegistryHelper.isCorrectHive(hivePath, "SAM"))
     {
         ValueKey vk = ValueKey.Get(hivePath, @"SAM\Domains\Account", "V");
         return(new SecurityIdentifier((byte[])vk.GetData(), (int)vk.DataLength - 0x18));
     }
     else
     {
         throw new Exception("Invalid SAM hive provided to -HivePath parameter.");
     }
 }
Ejemplo n.º 9
0
 public static string GetByPath(string hivePath)
 {
     if (RegistryHelper.isCorrectHive(hivePath, "SAM"))
     {
         ValueKey vk    = ValueKey.Get(hivePath, @"SAM\Domains\Account", "V");
         byte[]   bytes = (byte[])vk.GetData();
         return(Helper.GetSecurityDescriptor(Helper.GetSubArray(bytes, bytes.Length - 0x18, 0x18)));
     }
     else
     {
         throw new Exception("Invalid SAM hive provided to -HivePath parameter.");
     }
 }
Ejemplo n.º 10
0
        public static Timezone Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "SYSTEM"))
            {
                ValueKey vk = ValueKey.Get(hivePath, @"ControlSet001\Control\TimeZoneInformation", "TimeZoneKeyName");
                TimeZone tz = TimeZone.CurrentTimeZone;

                return(new Timezone((string)vk.GetData(), tz.StandardName, tz.DaylightName, tz.IsDaylightSavingTime(DateTime.Now)));
            }
            else
            {
                throw new Exception("Invalid SYSTEM hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 11
0
        public static Timezone Get(string hivePath)
        {
            if (RegistryHeader.Get(hivePath).HivePath.Contains("SYSTEM"))
            {
                ValueKey vk = ValueKey.Get(hivePath, @"ControlSet001\Control\TimeZoneInformation", "TimeZoneKeyName");
                TimeZone tz = TimeZone.CurrentTimeZone;

                return(new Timezone(System.Text.Encoding.Unicode.GetString(vk.GetData()), tz.StandardName, tz.DaylightName, tz.IsDaylightSavingTime(DateTime.Now)));
            }
            else
            {
                throw new Exception("Invalid SYSTEM hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 12
0
        public static WordWheelQuery[] Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "NTUSER.DAT"))
            {
                string Key = @"Software\Microsoft\Windows\CurrentVersion\Explorer\WordWheelQuery";

                byte[] bytes = Registry.RegistryHelper.GetHiveBytes(hivePath);

                NamedKey nk = null;

                try
                {
                    nk = NamedKey.Get(bytes, hivePath, Key);
                }
                catch
                {
                    return(null);
                }

                ValueKey MRUList = ValueKey.Get(bytes, hivePath, Key, "MRUListEx");

                WordWheelQuery[] dataStrings = new WordWheelQuery[nk.NumberOfValues - 1];

                byte[] MRUListBytes = (byte[])MRUList.GetData(bytes);

                for (int i = 0; i < MRUListBytes.Length - 4; i += 4)
                {
                    uint   MRUValue     = BitConverter.ToUInt32(MRUListBytes, i);
                    string SearchString = null;
                    try
                    {
                        SearchString = (string)ValueKey.Get(bytes, hivePath, Key, MRUValue.ToString()).GetData(bytes);
                    }
                    catch
                    {
                        SearchString = Encoding.Unicode.GetString((byte[])ValueKey.Get(bytes, hivePath, Key, MRUValue.ToString()).GetData(bytes));
                    }
                    dataStrings[i / 4] = new WordWheelQuery(RegistryHelper.GetUserHiveOwner(hivePath), SearchString);
                }

                return(dataStrings);
            }
            else
            {
                throw new Exception("Invalid NTUSER.DAT hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hivePath"></param>
        /// <returns></returns>
        public static RunMRU[] Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "NTUSER.DAT"))
            {
                string user = RegistryHelper.GetUserHiveOwner(hivePath);
                string Key  = @"Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU";

                byte[] bytes = Registry.RegistryHelper.GetHiveBytes(hivePath);

                NamedKey RunMRUKey = null;
                ValueKey MRUList   = null;

                try
                {
                    RunMRUKey = NamedKey.Get(bytes, hivePath, Key);
                }
                catch
                {
                    return(null);
                }

                try
                {
                    MRUList = ValueKey.Get(bytes, hivePath, Key, "MRUList");
                }
                catch
                {
                    return(null);
                }

                RunMRU[] RunMRUStrings = new RunMRU[RunMRUKey.NumberOfValues - 1];

                byte[] MRUListBytes = (byte[])MRUList.GetData(bytes);

                for (int i = 0; i <= MRUListBytes.Length - 4; i += 4)
                {
                    string MRUValue = Encoding.ASCII.GetString(MRUListBytes).TrimEnd('\0');
                    RunMRUStrings[i / 4] = new RunMRU(user, (string)ValueKey.Get(bytes, hivePath, Key, MRUValue.ToString()).GetData(bytes));
                }

                return(RunMRUStrings);
            }
            else
            {
                throw new Exception("Invalid NTUSER.DAT hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hivePath"></param>
        /// <returns></returns>
        public static LastVisitedMRU[] Get(string hivePath)
        {
            if (RegistryHelper.isCorrectHive(hivePath, "NTUSER.DAT"))
            {
                string Key = @"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU";

                byte[] bytes = Registry.RegistryHelper.GetHiveBytes(hivePath);

                NamedKey nk = null;

                try
                {
                    nk = NamedKey.Get(bytes, hivePath, Key);
                }
                catch
                {
                    try
                    {
                        Key = @"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU";
                        nk  = NamedKey.Get(bytes, hivePath, Key);
                    }
                    catch
                    {
                        return(null);
                    }
                }

                ValueKey MRUList = ValueKey.Get(bytes, hivePath, Key, "MRUListEx");

                LastVisitedMRU[] dataStrings = new LastVisitedMRU[nk.NumberOfValues - 1];

                byte[] MRUListBytes = (byte[])MRUList.GetData(bytes);

                for (int i = 0; i < MRUListBytes.Length - 4; i += 4)
                {
                    uint MRUValue = BitConverter.ToUInt32(MRUListBytes, i);
                    dataStrings[i / 4] = new LastVisitedMRU(RegistryHelper.GetUserHiveOwner(hivePath), (string)ValueKey.Get(bytes, hivePath, Key, MRUValue.ToString()).GetData(bytes));
                }

                return(dataStrings);
            }
            else
            {
                throw new Exception("Invalid NTUSER.DAT hive provided to -HivePath parameter.");
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// The ProcessRecord instantiates a FileRecord objects that
        /// corresponds to the file(s) that is/are specified.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (!(MyInvocation.BoundParameters.ContainsKey("Key")))
            {
                key = null;
            }

            if (MyInvocation.BoundParameters.ContainsKey("Value"))
            {
                WriteObject(ValueKey.Get(path, key, val), true);
            }
            else
            {
                foreach (ValueKey vk in ValueKey.GetInstances(path, key))
                {
                    WriteObject(vk, true);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// The ProcessRecord instantiates a FileRecord objects that
        /// corresponds to the file(s) that is/are specified.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (ParameterSetName == "Path")
            {
                if (!(MyInvocation.BoundParameters.ContainsKey("Key")))
                {
                    key = null;
                }

                if (MyInvocation.BoundParameters.ContainsKey("Value"))
                {
                    WriteObject(ValueKey.Get(path, key, val));
                }
                else
                {
                    foreach (ValueKey vk in ValueKey.GetInstances(path, key))
                    {
                        WriteObject(vk);
                    }
                }
            }


            /*if (ParameterSetName == "Path")
             * {
             *  bytes = Helper.GetHiveBytes(path);
             * }
             *
             * NamedKey hiveroot = Helper.GetRootKey(bytes, path);
             *
             * NamedKey nk = hiveroot;
             *
             * if (MyInvocation.BoundParameters.ContainsKey("Key"))
             * {
             *  foreach (string k in key.Split('\\'))
             *  {
             *      foreach (NamedKey n in nk.GetSubKeys(bytes))
             *      {
             *          if (n.Name == k)
             *          {
             *              nk = n;
             *          }
             *      }
             *  }
             * }
             *
             * ValueKey[] values = nk.GetValues(bytes);
             *
             * if (MyInvocation.BoundParameters.ContainsKey("Value"))
             * {
             *  foreach (ValueKey v in values)
             *  {
             *      if (v.Name == val)
             *      {
             *          WriteObject(v);
             *      }
             *  }
             * }
             * else
             * {
             *  WriteObject(values);
             * }
             */
        }
Ejemplo n.º 17
0
        public static SecurityIdentifier Get()
        {
            ValueKey vk = ValueKey.Get(@"C:\Windows\system32\config\SAM", @"SAM\Domains\Account", "V");

            return(new SecurityIdentifier(vk.GetData(), (int)vk.DataLength - 0x18));
        }
Ejemplo n.º 18
0
        public static SecurityIdentifier Get(string hivePath)
        {
            ValueKey vk = ValueKey.Get(hivePath, @"SAM\Domains\Account", "V");

            return(new SecurityIdentifier(vk.GetData(), (int)vk.DataLength - 0x18));
        }