HomeLabs

How I Recovered a Lost Password Using a Simple Python Hash Cracker

🧩 Quick Overview Repository: Hash-CrackerLanguage: Python We’ve all been there — you’re trying to log into an old account, and you realize you’ve forgotten the password. It’s frustrating, but what if you don’t have the option to reset it and you’re stuck with just the hashed version of your password? Well, that’s exactly what happened to me recently, and I decided to solve it with a little help from Python. Let me walk you through how I recovered a forgotten password using a simple Python script to crack the hash. 💻 The Situation I was going through some old project files and stumbled upon a password manager I made years ago. I had stored the passwords in a database, but here’s the catch — they were all hashed. The password for my admin account was stored as an MD5 hash: admin_password_hash = ec0e2603172c73a8b644bb9456c1ff6e This was great back then for keeping things secure (sort of), but now, I couldn’t remember the original password. I figured that since I knew a handful of passwords I used back in the day — like “batman”, “password123”, and “qwerty” — I could try to crack the hash using a basic technique: brute-force. 🔨 The Hash Cracker Script ⚙️ How does it work? I prepared a wordlist (a simple text file) with my common passwords, like this: I then ran the script to crack the hash. Here’s how it went: python hash_cracker.py And the result? Wordlist file opened successfully.[+] Password found: batman Just like that, I had the original password back! Why It Matters? Understanding how to crack a hash using tools like a Python hash cracker is more than just a fun coding challenge — it has real-world applications. Hashing is a fundamental concept in cybersecurity, widely used to protect sensitive information, like passwords. However, when passwords are forgotten, being able to reverse a hash and recover the password can be a game-changer. The ability to crack hashes helps illustrate the vulnerabilities that might exist in systems that rely solely on hashing without proper security measures, like salting or key stretching. By understanding the mechanics of hash cracking, developers, security professionals, and even everyday users can better appreciate the importance of strong password practices and secure systems. Whether you’re recovering your own password or learning about password security, this knowledge is essential for building safer digital environments.

How I Recovered a Lost Password Using a Simple Python Hash Cracker Read More »

Windows PE Header Parser (C++ Project)

🧠 What It Does This project is a simple C++ program that parses and prints key information from a Windows Portable Executable (PE) file — such as notepad.exe. Repository: Windows-PE-Header-ParserLanguage: C++ By inspecting the DOS and NT headers, the program extracts metadata used in reverse engineering and malware analysis: 🪄 What Are “Magic Bytes”? Magic bytes are the first few bytes of a file, used to identify its format. The initials “MZ” refer to Mark Zbikowski, one of the original developers of the MS-DOS executable format. These bytes are always found at the very beginning of the file and are crucial for confirming the file type. 📊 Sample Output: 🔧 How It Works (Overview): 🗂️ 1. File Mapping: Instead of reading the file byte by byte, the program uses Windows memory-mapped file APIs to load the entire executable into memory. Here’s what each function does: 📌 Why it matters: This approach is faster and lets you work with the file as a block of memory, which is perfect for binary structure parsing. 📜 2. DOS Header Parsing: At the very start of every PE file is the DOS Header. The program reads the first two bytes of the file to verify they are 0x4D 0x5A — which corresponds to ‘MZ’ in ASCII. 📌 Why it matters: Validating the DOS header ensures we’re working with a proper executable before going deeper. 📍 3. NT Header Location: Within the DOS header, there’s a field called e_lfanew. This gives the offset in the file where the NT Headers (the real “PE” structure) begin. 📌 Why it matters: The DOS header is just a stub. The real meat — entry point, section table, etc. — lives in the NT headers, and this tells us where to look. 🧩 4. PE Header Parsing: Once the program has the address of the NT headers, it reads key fields like: These values come from specific sub-structures inside the NT headers, like IMAGE_FILE_HEADER and IMAGE_OPTIONAL_HEADER. 📌 Why it matters: These values are essential for reverse engineers, malware analysts, or anyone trying to understand how a Windows program behaves under the hood. 🔗 View on GitHub: https://github.com/JasonEiler/Windows-PE-Header-Parser

Windows PE Header Parser (C++ Project) Read More »

Reverse Engineering: File Create, Access, and Modify Times

In today’s exercise, we’re Reverse Engineering: File Create, Access, and Modify Times 🧩 Quick Overview In this investigation, we will: Introduction to File Timestamps: Definition of Timestamps in Forensics: In malware analysis, file timestamps offer clues about the origin, activity, and behavior of potentially malicious files. They represent critical moments in a file’s lifecycle, enabling analyst’s to reconstruct the timeline of a system compromise. Importance in Malware Analysis and Reverse Engineering: Types of Timestamps: Creation Time: What it Represents: The creation time marks when the file was first written to disk in its current form. This could vary depending on the operating system. In Practice: In some cases, copying a file might reset the creation time, as it’s considered a new file in the new location. Uses: I believe it’s useful for identifying when files were first added to a system or storage, often relevant in auditing and forensics. Access Time: What it Represents: The last time the file was accessed or opened, even if no changes were made. How it Works: Reading or executing a file updates the access time. Modification Time: What it Represents: The last time the file’s contents were modified. In Practice: This timestamp changes only when the file’s contents are altered. Uses: Essential for version control, data integrity, and determining when a file was last actively worked on. Viewing File Timestamps in Different Operating Systems Windows In Windows, you can view timestamps by right-clicking a file, selecting Properties, and checking the Details tab. Alternatively, use the Command Prompt: Linux/Unix: Let’s Dive Into a Live stat Command Demo: I’m jumping into my Kali Linux instance on VirtualBox, and I’m currently in the examples directory. Let’s start by running the “ls” command. After we will use the command “file hello.c” and we can see it’s a C source code, ASCII text. Now using the command “ls -l” will show us the last modified time of the files in the directory and we can see it was modified May 1st at 19:36 which is 7:36 PM. We can also use the stat command to view the modified time, along with the access and change times. As you can see, the access time was 19:43:26 — that’s 7:43 p.m. and 26 seconds. These timestamps are much more precise than what you get with the “ls” command. You can clearly see the modify time and the change time as well. Now let’s go ahead and modify the hello.c file. We can do that by using the “vi hello.c” command. The vi editor is a text editor that comes pre-installed on most Linux systems. It lets you view and edit files directly from the terminal. Once you’re inside vi, the file opens in command mode by default. To start editing the file, press “i” on your keyboard — this switches you into insert mode, where you can type and make changes to the file just like in any other text editor. “When you’re done editing, press Esc to exit insert mode, then type “:wq” and hit Enter to save and quit. If you want to quit without saving, type “:q!” and press Enter.” Now, let’s run the stat command. You’ll notice that the access, modify, and change times all update to the time when I made the modification. This is important to know that when we modify the time we also change the access time. Remember the access time is when we read the file. So if I wanted to I can just look at this file or read this file by using “vi” and I’m not going to make any changes with inside this file. We’ve just opened it within vim. And if I escape and quit and do the stat command. You can see that the last access time has changed, but the modified time hasn’t — that’s because we didn’t actually change the contents of the file. The change time also remains the same, since we didn’t rewrite the file to disk, move it, or copy it elsewhere. However, because we did read and access the file, the access time was updated. This shows how each of these timestamps serves a specific purpose and why they’re important to understand. Now let’s move the file by renaming it. I’ll use the command: “mv hello.c helloOne.c.” The “mv” command in Linux is used to move or rename files. In this case, since both the source and destination are in the same directory, we’re effectively just renaming hello.c to helloOne.c. Let’s use the stat command to take a look at how the timestamps have changed. You’ll notice that the change time for hello.c is different — that’s because we modified the file’s metadata by renaming it. However, we didn’t alter the contents of the file, so the modify time remains the same as before. This demonstrates how important these timestamps are. For example, reverse engineers and malware analysts often rely on them to build timelines or to analyze the behavior of malware as it interacts with itself and other files.

Reverse Engineering: File Create, Access, and Modify Times Read More »

Incident Response Exercise 3: Investigating a New Attack with Obfuscation

In today’s exercise, we’re tasked with investigating an incident related to two previous investigations from last week. Threat Intel has reported that the same actor has targeted our network again. This time, the actor has added additional layers of obfuscation, including the use of compromised infrastructure, HTTPS, and password-protecting ZIP files. 🧩 Scenario Overview We received an alert for a suspicious IP address, but there was no additional context or information related to the alert. In this investigation, we will: Step 1: Confirm the Time Frame of the PCAP Our first step is to confirm that the PCAP file we received corresponds to the correct time frame. To do this, we’ll use the capinfos command, which will provide us with detailed metadata about the PCAP file, including the start and end times of the capture. Run the following command on the PCAP file: capinfos <path_to_pcap_file> The output of this command will give us several important details, including: We need to confirm that the start time and end time match the reported suspicious activity timeline. If they match, we can proceed to analyze the content of the PCAP for any signs of malicious activity. If the times don’t match, we may need to investigate further or request additional data from the SOC team. 🖥️ Step 2: OSINT Research on IP Address Once we’ve confirmed the correct time frame, our next task is to investigate the IP address (185.199.109.133) using OSINT. This research helps us understand the reputation of the IP and whether it is associated with any known malicious activity. To begin, we can use services like Whois, VirusTotal, and AbuseIPDB to gather more context on the IP. Run the following query on VirusTotal to see if this IP has been flagged: https://www.virustotal.com/gui/search/185.199.109.133 You may find information about the IP’s associations with malicious activity such as: If the IP is flagged, it adds more context to our investigation. If not, we will need to analyze the PCAP file more closely for other signs of malicious behavior. Nothing overly malicious; however, it is known that threat actors host malware on file sharing sites, including GitHub. 🦈Step 3: Analyze the PCAP Using Wireshark Now that we’ve confirmed the time frame and researched the IP, we’ll move on to the PCAP analysis using Wireshark. Wireshark is a powerful tool that allows us to capture and analyze network traffic in great detail. Filter for the Suspicious IP Address: The first step is to filter the traffic to focus on the suspicious IP. In Wireshark, use the following filter to display only packets from or to 185.199.109.133: ip.addr == 185.199.109.133 This filter will show all traffic involving this IP address. Look for the following types of activity: Once we’ve identified any suspicious packets, we can drill down into their details to further analyze the activity. We then look for other suspicious IP addresses and protocols on WireShark. If FTP is being used, we can extract the file being transferred from the PCAP by: Extract the file exfilled by filtering the pcap by “ftp-data”. After we follow the TCP Stream. The “PK” identifies the file as being a zip file. We then select the show data as “raw” and save the file as “transferredfile.zip” 🔓 Step 4: Cracking Password-Protected Zip Files Let’s try to unzip the file from the command line. unzip transferredfile.zip The file is password protected. Now let’s see if we can crack the password using zip2John and John. After we will use John to crack the hashfile.txt created above. I first use this command to crack the file password: john –wordlist=/usr/share/wordlists/rockyou.txt hashfile.txt Next, we will use this command to show the password: john –show hashfile.txt The password has been successfully cracked and it’s called “batman” Then we use the cracked password “batman” to unzip the file and observe the contents. Use this command to unzip using the password: unzip -P batman transferredfile.zip What are those files? Let’s navigate to the “gamedata” directory and run the file command against the file named “History” cd gamedata cd History As seen above, “History” is a SQLite database. Browser data on chromium browsers, such as Chrome and Edge, is stored as SQLite databases. This includes the browser history. Using sqlite3 list the tables in the database by using this command: sqlite3 History “.tables” Then we can type the sqlite3 command below to dump the urls table to a csv file: sqlite3 -header -csv History “SELECT * FROM urls;” > urls.csv After we can type the command below to read the first 25 lines of the urls table. cat urls.csv | head -25 This confirms that the “History” file is browser history. Opening the systeminfo.txt file confirms it is the result of the systeminfo command ran on the victim system. cat systeminfo.txt 📊 Step 5: Endpoint Analysis Using Splunk In addition to network traffic analysis, it’s important to correlate the findings with endpoint data. In this case, we’ll use Splunk to analyze Sysmon logs for any endpoint activity related to the suspicious IP address. After conducting PCAP analysis, we can use the information discovered to pivot through event logs using Splunk. Pivot on the date/time of the connection to the suspicious IP address discovered from the PCAP. We can use “UtcTime” field for the accurate time of activity. An easy way to view the events for the specific UTCTime is to do a table using the following SPL. source=”15Jan_2024_Exercise_Splunkdata.csv” sourcetype=”csv”| table _time, UtcTime, EventCode, event_description, file_path,TargetImage,ParentCommandLine, Message As seen below, several interesting events jump out. We can now pivot back to Wireshark at the time that itunes.ps1 was created 23:30:05.650 and see that was the same time there was a connection to githubusercontent.com. We can also cross reference the time of creation for gamedata.zip (23:30:19.324) and the beginning of the FTP session less than one second later. To look closer at the registry entries add EventCode 13 to the query. source=”15Jan_2024_Exercise_Splunkdata.csv” sourcetype=”csv” EventCode=13| table _time, UtcTime, EventCode, event_description, file_path,TargetImage,ParentCommandLine, Message We see 7zip running (which zipped the gamedata

Incident Response Exercise 3: Investigating a New Attack with Obfuscation Read More »

Incident Response Exercise 2: Analyzing a Malicious IP Alert

In this incident response exercise, we’re tasked with investigating a suspicious alert triggered by a connection to a potentially malicious IP address: 146.185.170.222. The investigation involves analyzing a PCAP file using Wireshark and utilizing Splunk for endpoint analysis to uncover the nature of the threat. Whether you’re learning incident response or exploring cybersecurity analysis, this breakdown aims to provide insight into the investigative process behind such alerts. 🧩 Scenario OverviewThe alert originated from the SOC shift lead, who assigned the task of investigating an alert for a malicious IP address (146.185.170.222). The provided PCAP file contains the activity in question. Our objectives for this exercise are: 1: Confirming the PCAP Time Frame Using the capinfos tool, we verify the time frame of the PCAP file to ensure it aligns with the alert’s timestamp. This command provides metadata about the PCAP file, including the start and end times of the capture. 2: OSINT Research on IP Address 146.185.170.222 To better understand the nature of this IP, we performed open-source intelligence (OSINT) research using platforms like VirusTotal. Question 1. Is there published OSINT on the IP address? Yes Question 2. If so, what? The results were alarming — the IP has been associated with several high-profile malware families, including: These are well-known banking trojans and loaders often used in financially motivated cyberattacks and ransomware campaigns. Specifically, VirusTotal reported connections to: This strongly indicates that 146.185.170.222 is part of a known malicious infrastructure, and any communication with it should be treated as a serious threat. 3: Analyzing the PCAP with Wireshark Opening the PCAP file in Wireshark, we filter traffic related to the IP address: 146.185.170.222 Question 3. Was there a successful connection to the suspicious IP address? Yes Question 4. Was malware downloaded? Yes Question 5. If so, what is the name of the malicious file? Exfil.ps1 and Keylogger.ps1 What is the SHA256 Hashes of the files? Question 6. What does the malware do? Steals and exfils browser history, system information, and keylogger information’s. Question 7. Was there any information stolen? Yes Question 8. If so, how was information exfiltrated? FTP 4: Utilize Splunk for Endpoint Analysis Question 9. What was the file that caused the connection to the malicious IP address? Invoice.ps1 By pivoting off of evidence found in the PCAP — particularly a file named Exfil.ps1 — we crafted a simple SPL query in Splunk to trace back the activity: Question 10. What is the persistence mechanism for Exfil? Registry Run key. Using the same SPL as previously used, we can see Exfil.ps1 being written to the CurrentVersion\Run key. Question 11. What is the persistence mechanism for Keylogger? Registry Run Key. Question 12. How is data exfilled? Zipped and exfilled via FTP. We see the file being exfilled in the pcap. Pivoting from Exfil.zip discovered in the pcap, we see the file creation, with the following SPL: Additionally, we see the code for Exfil.ps1 from the pcap and see that it is writing the system info and the browser history to the directory \Windows\Temp\Exfil folder. Then we see it zipping the directory. Attack Overview: The downloader (Invoice.ps1) downloads two malicious PowerShell files, Exfil.ps1 and Keylogger.ps1. The Exfil file steals browser history, system information, and keylogger results and zips them up in a file and uses FTP to exfil the file. Keylogger installs a keylogger that writes the results to a .txt file. The downloader establishes persistence by writing to the Run key to start Keylogger.ps1 and Exfil.ps1 each time the user logs in to the system. The downloader PowerShell is shown below. The code for Exfil.ps1 is shown below.

Incident Response Exercise 2: Analyzing a Malicious IP Alert Read More »

Investigating a Malicious Connection: Incident Response Exercise 1

🔍 Introduction In this incident response exercise, we are tasked with investigating a suspicious alert triggered by a connection to an IP address flagged as potentially malicious: 100.38.242.113. The investigation involves analyzing a PCAP file using Wireshark and utilizing Splunk for endpoint analysis to uncover what happened during the attack. Whether you’re learning incident response or exploring cybersecurity analysis, I hope this breakdown helps you understand the investigative mindset behind alerts like these. 🧩 Scenario OverviewThe alert came from the SOC team for a connection to a known malicious IP address: 100.38.242.113. The goal of this exercise was to: Step 1: PCAP AnalysisTo begin the investigation, we first confirm that the PCAP file provided corresponds to the correct timeframe. This can be done using the capinfos tool to view the capture’s metadata and verify timestamps. Open-Source Intelligence (OSINT) on the Malicious IP Address:Next, we perform some OSINT research on the IP address 100.38.242.113. A quick search reveals the IP address is associated with Qakbot, a notorious banking Trojan. This information gives us a significant lead into the type of attack we’re dealing with. Question 1. Is there published OSINT on the IP address? Yes Question 2. If so, what? Associated with Qakbot. Wireshark Analysis:Once we’ve identified the IP address as malicious, we filter the PCAP for traffic involving 100.38.242.113 in Wireshark. We quickly determine that there was indeed a successful connection to this IP address. The malware that was downloaded from this connection was named shell.txt, which had been disguised as a .txt file to bypass security filters. Upon closer inspection, the file was actually a .bat file. It appears that the attackers used a technique to evade detection by renaming the malicious file. Question 3. Was there a successful connection to the suspicious IP address? Yes Question 4. Was malware downloaded? Yes File Export and Hashing:By analyzing the PCAP further, we managed to carve out the shell.bat file, extract its SHA256 hash, and analyze its behavior. The malware sets up a reverse shell, connecting the victim’s system back to the attacker’s machine for remote access. Question 5. If so, what is the name of the malicious file? shell.txt (shell.bat) Question 6. What is the SHA256 Hash of the file? Step 2: Malware BehaviorOnce executed, the shell.bat file initiates a PowerShell script that establishes a reverse TCP connection back to the attacker’s server. From there, the attacker can execute commands remotely on the victim’s machine. Some commands seen in the captured traffic include: Question 8. Was there any information stolen? Yes, enumeration took place. Step 3: Splunk AnalysisThe next step is to pivot through event logs using Splunk, where we search for logs related to the downloaded shell.txt file. By querying the data, we uncover the file path and confirm the file’s unusual extension change, which raises questions about the attacker’s evasion tactics. And This enumeration provides valuable information about the target system, which could help attackers decide their next steps, such as deploying more malware or establishing a command-and-control. Question 9. What file was the cause of the connection to the malicious IP address? GiftCard.bat File Path and Parent Process:Using Splunk’s search query, we track down the file’s location on the system. We also observe that the parent process responsible for downloading the file was powershell.exe, a legitimate Windows process that was weaponized by the attacker to execute malicious code. Conclusion: The Impact of the AttackThe investigation uncovers several key findings: The cause of the connection to the suspicious IP address was determined to be the execution of a .bat file that triggered the download of the reverse shell, exploiting a gap in real-time protection settings on the victim’s machine. This incident highlights the importance of proper endpoint protection and detection mechanisms to prevent malware from executing on vulnerable systems. Final Thoughts:Incident response exercises like this are invaluable for learning how to track down and analyze attacks in a controlled environment. By leveraging tools like Wireshark for packet analysis and Splunk for log analysis, cybersecurity professionals can develop a thorough understanding of attack techniques and improve response times in real-world incidents.

Investigating a Malicious Connection: Incident Response Exercise 1 Read More »