Home > Security Tips > Threat Monitor > Windows registry forensics: Investigating system-wide settings
Security Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

THREAT MONITOR

Windows registry forensics: Investigating system-wide settings


Ed Skoudis, Contributor
10.01.2008
Rating: -4.83- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This great command-line tool [reg.exe] can be used locally or against remote systems to dump whole sections of the registry recursively. 
Previously I looked at various important items in the registry that investigators could analyze to determine recent actions of the user currently logged onto the machine. We focused specifically on the portion of the registry referred to as "HKCU," which stands for "Hive Key Current User." This month, we'll analyze various system-wide settings specified in the HKLM (Hive Key Local Machine) section of the registry, which are also very useful for forensics investigators.

Included in several versions of Microsoft Windows -- XP Professional, Vista, Server 2003 and Server 2008 -- is the reg.exe command, which allows a query or update of information in the registry. This great command-line tool can be used locally or against remote systems to dump whole sections of the registry recursively.

Auto-start registry keys
Investigators can benefit by pulling data from three important registry keys that control some of the auto-start behavior of Windows boxes: the "Run" registry keys. When a user logs on locally to a system, programs identified in the settings of these registry keys are automatically executed:

HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKLM\Software\Microsoft\Windows\CurrentVersion\Runonce
HKLM\Software\Microsoft\Windows\CurrentVersion\RunonceEx

Many malware specimens (as well as a lot of legitimate programs) run every time the system starts up by adding an entry to these registry locations. Query these locations using the reg command as follows:

C:\> reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
C:\> reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Runonce
C:\> reg query HKLM\Software\Microsoft\Windows\CurrentVersion\RunonceEx

Because a typical Windows machine may have a half dozen or more legitimate entries here, a forensics investigator will need to separate the good from the malicious by diligently researching each discovered item. This can be done via Web searches and/or by grabbing a copy of unusual autostart programs for further analysis.

When querying these or other items from HKLM (or HKU, where user account and related information is stored), use the reg command against a remote Windows machine across the network with Windows Server Message Block (SMB) connections. Unfortunately, the reg tool works remotely only for items in HKLM and HKU. It can't pull data from other hives in the registry, including the HKCU items we looked at last month. This forces forensics investigators to pull HKCU data by running commands locally on the target machine.

To query HKLM and HKU remotely with the reg command, the Remote Registry service must be started on the target machine, which is activated by default on many versions of Windows (other than Vista). Start by setting up an SMB session with the target using administrator credentials:

C:\> net use \\[TargetIPaddr] /u:[AdminName]

Enter the password for that admin user when prompted, then, with that session open, use the reg command to query items in HKLM as follows:

C:\> reg query \\[TargetIPaddr]\HKLM\Software\Microsoft\Windows\CurrentVersion\Run

USB drive & iPod history
Beyond these autostart keys, the registry also remembers information about every USB token ever plugged into the system. I've worked on a number of cases in which I needed this information. To query for all tokens that have ever been plugged into the Windows machine, run this command:

C:\> reg query HKLM\System\currentcontrolset\enum\usbstor /s

More information
Learn more built-in commands for Windows system analysis.

Has your system been hacked? Check out these built-in commands to help you find out.
Note that we've included "/s" at the end of this reg command, which tells the machine to pull information recursively from all items in the registry below the branch specified. This command could generate a lot of data, so the investigator might want to pipe it through the more command (| more) or even save the results to a file (> results.txt) for inspection later. The command's output will include a summary of each device's manufacturer and version number, indicated after "Disk&Ven" in the output. Right after that Disk&Ven item is a unique integer ID number assigned to each USB device, which can help investigators determine if the USB device in question has ever been connected to that machine. By plugging the USB token into another Windows machine and querying the same information, it's possible to compare the output of the command on the two boxes to see if the same USB token was installed in both of them.

Alternatively, suppose an investigator wants to look for specifics about an iPod device that may or may not have been connected to a machine. He or she can run the same reg command, this time piping its output through the find command to look for the string "ipod," as follows:

C:\> reg query HKLM\System\currentcontrolset\enum\usbstor /s | find /i "ipod"

Note that we've used the find command with the /i option to make it case insensitive.

Identifying network interfaces
To pull the IP address and related configuration information for all network interfaces on the device, run this command:

C:\> reg query hklm\system\currentcontrolset\services\tcpip\parameters\interfaces /s

Some immensely useful output of this command -- beyond the IP address, netmask, default gateway and DNS server -- is the "LeaseObtainedTime" parameter, a hexadecimal number. This value indicates when the local machine received its DHCP information, which often occurs when the system first boots up or joins a network. With this data, an investigator has an idea of when a given machine first engaged in network activity, information that is useful in building timelines for cases.

The hexadecimal number of LeaseObtainedTime represents the seconds that have transpired since 12:00 a.m. on Jan. 1, 1970, the beginning of the Unix Epoch. For example, my current "LeaseObtainedTime" is 0x4856d93a. I convert the lower-case d and a to capitals, then look up that time (4856D93A) with the free calculator at http://dan.drydog.com/unixdatetime.html that converts the seconds in hex to actual dates. In this example, my computer obtained its lease on June 16, 2008, at 9:20:58 a.m. That date is relative to the current clock on the computer whose registry we've queried, so it's also useful for investigators to pull the current time and date, which they can do using:

C:\> time /t & date /t

Because the output time is in HH:MM form, to make further sense of it, investigators will need to know the time zone of the machine, which they can pull with the command:

C:\> reg query hklm\system\currentcontrolset\control\timezoneinformation

Windows firewall commands
Another helpful query is the configuration of the built-in Windows personal firewall, which can be accessed by running the following command:

C:\> reg query hklm\system\controlset001\services\sharedaccess\parameters\firewallpolicy /s

This output shows the ports the firewall allows through the programs it lets communicate on the network, plus a myriad of other configuration settings. Thus, investigators may be able to determine whether a computer attacker disabled the firewall or reconfigured it to allow access for nefarious activities. For similar information in a better-parsed fashion, an investigator could alternatively run:

C:\> netsh firewall show config

Conclusion
While we've looked at some of the most useful items I've relied on in past investigations, the registry is chock full of additional helpful items. I encourage readers to continue their journey through the Windows registry, looking for additional useful queries, relying on a healthy combination of the powerful reg command, the public documentation available from sources such as Microsoft (though sometimes scanty), and hunches and insights.

About the author:
Ed Skoudis is a SANS instructor and a founder and senior security consultant with Intelguardians, a Washington, DC-based information security consulting firm. His expertise includes hacker attacks and defenses, the information security industry and computer privacy issues. In addition to Counter Hack Reloaded, Ed is also the author of Malware: Fighting Malicious Code. He was also awarded 2004-2007Microsoft MVP awards for Windows Server Security, and is an alumnus of the Honeynet Project. As an expert on SearchSecurity.com, Ed answers your questions related to information security threats.


Rate this Tip
To rate tips, you must be a member of SearchSecurity.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Threat Monitor
How to detect system management mode (SMM) rootkits
Weaponizing Kaminsky's DNS discovery
Debian: A niche OS with a not-so-niche security flaw
Web advertising exploits: Protecting Web browsers and servers
Ransomware: How to deal with advanced encryption algorithms
Hidden endpoints: Mitigating the threat of non-traditional network devices
Protecting exposed servers from Google hacks (and Google 'dorks')
Countermeasures against targeted attacks in the enterprise
Windows registry forensics guide: Investigating hacker activities
More built-in Windows commands for system analysis

Monitoring Network Traffic and Network Forensics
Wireshark tutorial: How to sniff network traffic
Product Review: Altor Networks' Virtual Network Security Analyzer (VNSA) 1.0
Screencast: Catching network traffic with Wireshark
Windows registry forensics guide: Investigating hacker activities
More built-in Windows commands for system analysis
Is security improved when the number of Internet gateways is reduced?
Screencast: Using Nessus to scan for vulnerabilities
What are the pros and cons of shaping P2P packets?
Built-in Windows commands to determine if a system has been hacked
How will the centralized logging of network flow data benefit an enterprise?

Windows XP and Server Security
Microsoft patches critical XML Core Services flaw
Inside MSRC: Microsoft addresses XML Core Services flaw, RPC flaw
New malware exploits Microsoft RPC flaw
Microsoft to patch critical Windows flaw
Microsoft sees OS flaws drop, application breaches rise
Microsoft to release urgent security patch
Microsoft releases Windows patch to stop worm attack
Are there software tools that can automate the server hardening process?
Microsoft patches Active Directory, Internet Explorer flaws
Inside MSRC: Microsoft issues advice for critical server flaws

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
computer forensics  (SearchSecurity.com)
Einstein  (SearchSecurity.com)
footprinting  (SearchSecurity.com)
information signature  (SearchSecurity.com)
intrusion detection  (SearchSecurity.com)
network forensics  (SearchSecurity.com)
port scan  (SearchSecurity.com)
probe  (SearchSecurity.com)
promiscuous mode  (SearchSecurity.com)
snoop server  (SearchSecurity.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Research Solutions for Network Security, Access Control and Security Threats
More Security Resources for Resellers, VARs and OEMs
TechTarget Security Media
Information Security View this month\\'s issue and subscribe today.
Information Security Decisions Apply online for free conference admission.
SearchSecurity.com
HomeNewsMagazineMultimediaWhite PapersLearningAdviceTopicsEventsAbout Us

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts