How to disguise an executable file as a PDF file

Tr0jan_Horse

Moderator
Staff member
MODERATOR
ULTIMATE
PREMIUM
MEMBER
Joined
Oct 23, 2024
Messages
304
Reaction score
8,793
Deposit
0$
1747700372602.png
Imagine that you are a pentester hired to check the security of the company's internal network. You need to find out if employees can fall for the bait and open malicious files. Disguising the malware as an innocuous PDF, you send it by phishing mailing list or share it. If an employee clicks on the file, you will gain access to their system, demonstrating the vulnerability of the company's security. Next, I'll show you how to create such a fake PDF file and use it in a pentest.

Substitution of the PDF file icon to run the executable file

Here is the C++ code for creating a PDF shortcut and icon. The program creates a Windows shortcut (.lnk file) on the desktop. The shortcut points to the executable file (in this case, calc.exe ) and uses a custom icon.

The tool includes the necessary Windows API functions, Shell API, ATL classes, and C++ standard libraries. The CreateShortcut function accepts three parameters: TargetPath, Shortcut Path, and iconPath. It creates a shortcut that points to the TargetPath and saves it as a shortcut with the specified iconPath.

The program initializes the COM library to use COM objects, creates a ShellLink object (ishellink), which is used to set the properties of the shortcut, sets the path to the target file and the location of the icon, and then saves the shortcut to disk using the IPersistFile interface. After completing the operations, the program initializes the COM library.

To use this tool, you need to change two lines and recompile the application in C++.
1747700488396.png
This is how the shortcut and icon will look on the desktop.:
1747700544617.png
The PDF virus label

This is how the shortcut and icon will look in Windows Explorer.:
1747700555834.png
File Properties:
1747700588677.png

Properties of the virus label

Conclusion

The article examined the technique of disguising files under the PDF icon, a method used to deceive users and launch viruses or other malicious files. By manipulating the appearance of the file, we significantly increase the chances that an unsuspecting user will click on it, thereby compromising their system. This method can be effective for pentesters.

Disguising a malicious file as a PDF and distributing it through phishing emails or shared folders can help identify security weaknesses in an organization's network.
 
Top Bottom