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

Designing a COM Virus

Let's exploit a simple COM file.

Christopher Lamb user avatar by
Christopher Lamb
CORE ·
Nov. 27, 18 · Tutorial
Like (1)
Save
Tweet
Share
4.89K Views

Join the DZone community and get the full member experience.

Join For Free

COM executables on Windows bring back the good old days when executable formats were much less complicated than they are today. Back then, these kinds of programs didn't need a loader; they didn't even use DLLs. All they did was get loaded into memory and execute. That made them easy to understand and easy to exploit.

So let's exploit one.

We're going to write a simple COM file virus on DOS. This virus is going to hook COM files and then look for similar files to infect. We're going to base our work on Ludwig's Little Black Book of Computer Viruses, and hopefully, we're going to simplify a bit and create a disabling trigger.

Before we get started coding anything, let's identify exactly what we'd need and how this kind of virus is designed. First, we're going to create a simple COM file target. I've gone over how to create a DOS VMWare image, and those do have COM files we'll want to infect too, but let's start with a simple target file so that it's easy to see where the code's injected and how the COM file is modified. So we need a workstation (VMWare DOS image) and a target COM file. We also want to use a disabling trigger — I'm intending to use a file for this, that if it's resident in the directory the COM infector is targeting, the COM infector will stop infecting targets. We'll also use good hygiene on our VMWare image so that we don't trash it or let the virus out. Ideally, you'd be working on a non-Windows platform with VMWare installed, in which you run your DOS image. We'll take a snapshot of the image prior to starting work and work off that snapshot so that we always have an uninfected rollback.

So let's sum this up. We will:

  • Develop a target COM file

  • Implement a disabling trigger

  • Initially, only infect COM files in the local directory

  • Run VMWare on a non-Windows platform to prevent escapes

  • Only work on snapshots of the base image, so we can always roll back to an uninfected DOS image.

We're writing the virus in assembly, so it's much easier if we develop a block diagram of the virus' functionality as an initial design. This is a very abstract representation of the program's functionality and doesn't begin to address how we're going to do these things, but it does define what we want to do:

Image title

Figure1: Virus Design

Green indicates a start state, red an end state, yellow a control state, and blue a standard virus execution. Basically, we want the virus code to run on COM program startup, check the local directory for COM files to infect, infect those files if they're present, and then resume program execution.

There's a couple of places we can place our trigger, too. I'm going to place it prior to the scan, resuming regular program execution if the disabling trigger isn't there.

Now that we have an idea of what we want the virus to do, we can start to build it.

Component Object Model

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Unlocking the Power of Polymorphism in JavaScript: A Deep Dive
  • How To Generate Code Coverage Report Using JaCoCo-Maven Plugin
  • Spring Boot Docker Best Practices
  • Promises, Thenables, and Lazy-Evaluation: What, Why, How

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: