This article is a pretty wild ride into the world of ethical hacking, showing how a seemingly innocent Microsoft Office document can be turned into a powerful tool for remote code execution. I discuss the entire process, from creating a malicious payload to embedding it in a Word document and, finally, tricking a target into opening it.

Cooking Up the Payload with MSFVenom

The first thing we need is our malicious code, or “payload.” The video shows how to create this using a tool called MSFVenom. It’s like a recipe for a digital Trojan horse. Here’s a breakdown of the ingredients:

  • msfvenom: This is the master tool for generating our payload.
  • -p Windows/shell_reverse_tcp: This tells MSFVenom that we want a “reverse shell” for Windows. This means that once the victim opens our document, their computer will connect back to us, giving us control.
  • LHOST: This is our IP address, the “return address” for the connection.
  • LPORT: This is the specific “door” or port that we’ll be listening on for the connection.
  • -b: This is a clever trick to avoid “bad characters” that might be flagged by antivirus software.
  • -e x86/shikata_ga_nai: This is an “encoder” that scrambles our payload to make it even harder for antivirus software to detect.
  • -f hta-psh: This tells MSFVenom to format our payload as an HTML application with a PowerShell script inside.
  • -o: This is just the name of our output file.

Once we run this command, MSFVenom spits out our payload, ready for the next step.

Making the Payload Office-Friendly

Now, here’s the tricky part. We can’t just dump this payload into a Word document. Microsoft Office macros use a language called Visual Basic for Applications (VBA), and it has some limitations. To get around this, we need to chop up our payload into smaller, bite-sized pieces.

The video below shows how to use a simple Python script to split the payload into 50-line segments. This makes it “Visual Basic friendly” and ready to be inserted into our Word document.

Planting the Bomb in a Word Macro

Now it’s time to create our Trojan horse. We open up a new Word document and head over to the “Macros” section. We create a new macro, which opens up the Visual Basic editor.

Here, we paste in our chopped-up payload. But there’s one more crucial ingredient we need to add: a line of code that tells the computer to execute our payload using the Windows Script Host.

Saving the Malicious Document

We’re almost there! But we can’t just save this as a regular Word document. We need to save it in a special format that allows macros to run. The video below recommends saving it as a “.doc” file (Word 97-2003 Document) to make it look less suspicious.

The Art of Social Engineering

Now, here’s where the real magic happens. We can’t just send this file to someone and expect them to open it. We need to use “social engineering” to trick them.

The video below emphasizes the importance of creating a believable story. We need to study our target, gather information about them, and then craft a convincing email that looks like it’s from a trusted source. The document itself should also contain some dummy text that aligns with our story to avoid raising suspicion.

Finally, we set up a “listener” on our own computer. When the victim opens our malicious document, the macro runs, and we get a connection back to their computer, giving us full control. The video shows the host navigating the victim’s file system, proving that the attack was a success.

Video Walk-through

About the Author

Mastermind Study Notes is a group of talented authors and writers who are experienced and well-versed across different fields. The group is led by, Motasem Hamdan, who is a Cybersecurity content creator and YouTuber.

View Articles