DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Executable Formats and How To Exploit Them

Want to learn more about COM executable formats? Check out this tutorial where we take a look at the executable formats and how to exploit them!

Christopher Lamb user avatar by
Christopher Lamb
CORE ·
Oct. 27, 18 · Tutorial
Like (5)
Save
Tweet
Share
6.45K Views

Join the DZone community and get the full member experience.

Join For Free

COM executable formats were very simple and very elegant. They were just bags of instructions the computer would execute, placed after the program segment prefix in DOS. There was no relocation, no code analysis, or reordering tricks — none of the kinds of things we've come to expect from today's convoluted and confusing formats. That made them very susceptible to malware, of course, but it also allowed programs to be smaller and easier to understand. I'll show you what I mean.

So, I've written two programs that do the exact same thing. One is compiled into a COM file, the other into a DOS EXE. The assembly code looks like this:

Image title

When compiled, the COM file is a whopping 20 BYTES (!), while the EXE is 536 bytes. The binary code generated, just to compare:

Image title

The COM file, to the left, just contains instructions. The EXE file, to the right, contains instructions (at the end of the file), relocation, and program information in the first 28 bytes of the file. And, there's a whole lot of empty space that doesn't get used. Note: if you look at 0x08 and 0x09, you'll see that these bytes store the value 0x0020 (Remember: PCs were little endian then, too). This is the number of 16-byte paragraphs reserved for the header, which brings you to the beginning of the executable code, at address 0x0000200. This information gives you if you're writing a virus, all you need to know to have some idea where you can stuff code for later execution. COM files are easy to infect, and DOS EXE files (or MZ EXE files, named after the magic number in the first two bytes of the file) are just slightly more difficult.

Executable

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Microservices Discovery With Eureka
  • How To Check Docker Images for Vulnerabilities
  • How Observability Is Redefining Developer Roles
  • What Is a Kubernetes CI/CD Pipeline?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: