Binary Padding

Adversaries may use binary padding to add junk data and change the on-disk representation of malware. This can be done without affecting the functionality or behavior of a binary, but can increase the size of the binary beyond what some security tools are capable of handling due to file size limitations.

Binary padding effectively changes the checksum of the file and can also be used to avoid hash-based blocklists and static anti-virus signatures. The padding used is commonly generated by a function to create junk data and the appended to the end or applied to sections of malware. Increasing the file size may decrease the effectiveness of certain tools and detection capabilities that are not designated or configured to scan large files. This may also reduce the likelihood of being collected for analysis. Public file scanning services, such as VirusTotal, limits the maximum size of an uploaded file to be analyzed.

Example:

I will use a simple Python Script to make an EXE file bigger than what it normally is and try to evade some defenses, a simple demo here is that usually these AV products have a limit to file scanning if 15MB files so let us make it a little bigger.

Above you see the payload with a 7kb file size, very fast to detect and scan

With the tool I selected my payload and gave it the option of being 20 MB in file size

Let's see the file size

Now I will move the payload to the Workstation and check that its original functionality hasn't changed

Nope

This demo is just to understand that by padding and making our executable bigger AV Scanners don't check these files properly or simply skip them. It can be a bunch of garbage strings and bytes but it won't affect our payloads functionality.

Last updated