Protected Files
The use of file encryption is often still lacking in private
and business
matters. Even today, emails containing job applications, account statements, or contracts are often sent unencrypted. This is grossly negligent and, in many cases, even punishable by law. For example, GDPR demands the requirement for encrypted storage and transmission of personal data in the European Union. Especially in business cases, this is quite different for emails. Nowadays, it is pretty common to communicate confidential
topics or send sensitive
data by email
. However, emails are not much more secure than postcards, which can be intercepted if the attacker is positioned correctly.
More and more companies are increasing their IT security precautions and infrastructure through training courses and security awareness seminars. As a result, it is becoming increasingly common for company employees to encrypt/encode sensitive files. Nevertheless, even these can be cracked and read with the right choice of lists and tools. In many cases, symmetric encryption
like AES-256
is used to securely store individual files or folders. Here, the same key
is used to encrypt and decrypt a file.
Therefore, for sending files, asymmetric encryption
is used, in which two separate keys
are required. The sender encrypts the file with the public key
of the recipient. The recipient, in turn, can then decrypt the file using a private key
.
Hunting for Encoded Files
Many different file extensions can identify these types of encrypted/encoded files. For example, a useful list can be found on FileInfo. However, for our example, we will only look at the most common files like the following:
Hunting for Files
If we encounter file extensions on the system that we are not familiar with, we can use the search engines that we are familiar with to find out the technology behind them. After all, there are hundreds of different file extensions, and no one is expected to know all of them by heart. First, however, we should know how to find the relevant information that will help us. Again, we can use the steps we already covered in the Credential Hunting
sections or repeat them to find SSH keys on the system.
Hunting for SSH Keys
grep
: This is the command being used to search for patterns in files.-r
: This option tellsgrep
to search recursively through directories and their subdirectories.-n
: This option tellsgrep
to show the line numbers of matching lines in the output.-w
: This option ensures thatgrep
matches whole words only, meaning it will not match substrings within longer words."PRIVATE KEY"
: This is the patterngrep
is searching for. In this case, it's looking for the exact phrase "PRIVATE KEY"./*
: This specifies the starting point for the search. The/*
means thatgrep
will search through all files and directories in the root directory (/
).2>/dev/null
: This part redirects error messages (file descriptor 2) to/dev/null
, effectively suppressing them. This is useful when you want to avoid cluttering the output with errors, such as "Permission denied" messages that can occur when trying to read certain directories or files.|
: This is a pipe, which takes the output of the command on the left and uses it as input for the command on the right.grep ":1"
: This secondgrep
filters the output from the firstgrep
command, looking for lines that contain ":1". This indicates that it is looking for matches that occur on the first line of files.
In summary, the command is searching through all files starting from the root directory for the phrase "PRIVATE KEY" and displays only those occurrences that are found on the first line of the matching files
Most SSH keys we will find nowadays are encrypted. We can recognize this by the header of the SSH key because this shows the encryption method in use.
Encrypted SSH Keys
If we see such a header in an SSH key, we will, in most cases, not be able to use it immediately without further action. This is because encrypted SSH keys are protected with a passphrase that must be entered before use. However, many are often careless in the password selection and its complexity because SSH is considered a secure protocol, and many do not know that even lightweight AES-128-CBC can be cracked.
Cracking with John
John The Ripper
has many different scripts to generate hashes from files that we can then use for cracking. We can find these scripts on our system using the following command.
John Hashing Scripts
Protected Files
We can convert many different formats into single hashes and try to crack the passwords with this. Then, we can open, read, and use the file if we succeed. There is a Python script called ssh2john.py
for SSH keys, which generates the corresponding hashes for encrypted SSH keys, which we can then store in files.
Next, we need to customize the commands accordingly with the password list and specify our file with the hashes as the target to be cracked. After that, we can display the cracked hashes by specifying the hash file and using the --show
option.
Cracking SSH Keys
Cracking Documents
In the course of our career, we will come across many different documents, which are also password-protected to prevent access by unauthorized persons. Today, most people use Office and PDF files to exchange business information and data.
Pretty much all reports, documentation, and information sheets can be found in the form of Office DOCs and PDFs. This is because they offer the best visual representation of information. John provides a Python script called office2john.py
to extract hashes from all common Office documents that can then be fed into John or Hashcat for offline cracking. The procedure to crack them remains the same.
Cracking Microsoft Office Documents
Cracking PDFs
Last updated