Digital Forensics: Attacking SAM and Extracting Hashes With 7z
Welcome back, cyberwarriors!
The article on DeadMatter was really popular and relevant for many of you. DeadMatter works with LSASS and finds artifacts related to active or recently active sessions. But sometimes you need SAM hashes during a pentest.
Today weβre using 7z to find and pull the hives. Itβs very common to find and it has raw disk access to fetch what we need without triggering the EDR. You can basically call it a living off the land technique due to its widespread presence. There are other ways to extract hashes, but most of them are well known and monitored. Some hackers rely on VSS and it works fine in some environments, but detecting VSS abuse isnβt hard. Itβs a beginner level of complexity. VSS leaves very specific traces in the logs when you use it. Native Windows binaries get blocked outright and finding forensic tools already sitting on an endpoint is uncommon.
Credit where itβs due, Jonas Lyk shared this approach.
Extracting Hives
To make it work, you need to start 7z as Administrator, otherwise it just fails. Then you type \\.\ in the path bar and itβll show you the drives.

Here we need PhysicalDrive0. You canβt copy it off the C:\ drive, because itβs locked by the system.

Inside youβll see the partitions on the physical drive. Usually 1.ntfs has the structure of your C:\. 0.ntfs has $MFT, $J and the other files you want for a deeper dive.Β

System hives live in Windows\System32\config

Select the hives you need and copy them to a folder. Weβre only pulling SAM and SYSTEM here, but you can get SOFTWARE, $MFT, $J, and NTUSER.DAT if youβre doing behavioral analysis. We covered that in our article showing how much you can find out about a user after a compromise. Behavioral analysis is also useful in pentesting. NTUSER.DAT shows a lot about how the sysadmins use their machines.

File size shows the hives arenβt empty. Now we can move them to Kali and extract the hashes.
kali > impacket-secretsdump -sam SAM -system SYSTEM LOCAL

We got all the local user hashes. If LAPS isnβt enabled (in a lot of environments it isnβt), thereβs a good chance the admin hash is identical across many machines. Some admins donβt even know LAPS exists, others are scared to turn it on because theyβre not in control of the password rotation. Either way, SAM alone can be enough to compromise the whole domain.
Terminal
This approach hits a wall in the terminal. 7z can only parse physical disks and NTFS partitions through the File Manager GUI. The CLI version still canβt open nested partitions and throws an error every time. So the GUI is the only way you can pull it off.
There are forensics tools that do it in the terminal (AxiomSecret, RawCopy, etc.) but thatβs a story for another day.
Summary
Many successful attacks use LOL techniques or signed tools. This approach is creative and 7z is already sitting on plenty of machines. Even if itβs not, bringing it over isnβt suspicious.
It wonβt get you LSASS hashes, but the SAM hashes alone can be enough to compromise a companyβs entire infrastructure. We showed that in our SCADA article, where the SCADA machine stored cleartext passwords in memory and password reuse helped us with the rest of the infrastructure during the pentest. LAPS isnβt hard to set up and it can close this door, so spend some time learning it.
If you like what weβre doing here and want to get started in Digital Forensics or advance your skills, we recommend our training for both beginners and more experienced students.
The post Digital Forensics: Attacking SAM and Extracting Hashes With 7z first appeared on Hackers Arise.






