Learn how to use MD5 checksums to determine if a file contains malware.
MD5 checksums are often used in the malware community as a means of determining if a file contains malware, and, if so, what kind of malware it contains.
You can use a Windows and Kali Linux machine for this lab.
The first step to finding the MD5 checksums of a file is to download the Hashtab tool via the following link:
This tool will calculate the MD5 checksum for every file on our PC. We are able to view these checksums by right-clicking on a file and selecting Properties. Once you have this tool installed, you will notice a new tab on this window called File Hashes, where we can view the different hashes for this file. Download the free tool from the link above before moving on to the next steps.
Once we have this tool installed, we can begin checking files on our Windows machine to determine if they contain any malware. To do this, we will right-click on a target file, select properties, and, in the new window that pops up, click on the File Hashes tab.
Here, we can view the CRC32, MD5, and SHA1 hash for the file in question.
This program can also support some other hash mechanisms. Now, let’s add SHA-256 and SHA-512 support to our program.
Open a random file, then right-click on the MD5 hash and copy it to your clipboard.
Once this is done, navigate to the following site:
Paste the hash file into the search box here and hit enter. This site will now run the MD5 hash through a number of different Antivirus libraries containing the most common MD5 checksums for known malware.
If we picked a random file from our PC, we likely receive no response from the webpage, indicating that there is no malware in the file selected.
Now, copy this MD5 hash below and paste it into the same search box:
This is the MD5 checksum for a common piece of Trojan malware. You will notice a number of alerts on the webpage this time.
This is an example of how to test a random file to see if it has malware. This is also one of the first steps an Antivirus will take when scanning a fie. It will create the MD5 Checksum of the file in question and compare it to a massive database of known MD5 checksums of malicious files.
Let’s work on a real case. We will download a malware to our Kali Linux machine and compare its MD5 hash from VirusTotal database:
First of all, let us remind you that such files are shared for educational purposes and should not be copied to production machines.
Open a browser on your Kali machine and go to the following address: https://dasmalwerk.eu/
Here, countless real malware is shared as zipped files for educational purposes. Each zip file is protected with a password to prevent accidental opening, which is by default: “infected”.
Let’s pick a random Trojan on this page; “Dropped: Trojan.AgentWDCR.PZW” is the one we selected. Download this file to the “Downloads” directory on our Kali machine by clicking the download link.
Now, we will unzip the downloaded file. Open a terminal screen then type these commands:
When asked for a password, enter word: infected
Now, we have a malicious windows executable file. We can get more details about this file with the “file” command:
PE32 executable (GUI) Intel 80386, for MS Windows, UPX compressed
Now, we will calculate the MD5 hash of our unzipped file and query it in VirusTotal:
Paste this MD5 hash to VirusTotal’s query page.
Now, if we find a suspicious file in our system, we know how to query if it is harmful. Moreover, we do not need to export this file or run an antivirus. In databases such as VirusTotal, it is possible to query against more than one antivirus library at once.