This is a training file virus for Linux.
GNU General Public License v.2.
To get acquainted with the work of binary files, loading and linking processes.
Infects the first ELF file located in the same directory.
$ cp -r ./src/. ./
$ make
$ ./virus
- Install Emacs - orgmode (part of Emacs) need for generate code files from literate source file
- Press Alt+x and type
org-babel-tangle
elisp-function (you can just pressC-c C-v t
instead) to generate source code files. Will be generated:- source code of virus
- several victim’s source code.
If you skip this step, you can get generated files from
src
folder. Copy this files to root folder of project. - make
- run virus: ./virus - Don’t worry it’s work only in current directory
- Go to section How it works and how I see it
- Learn russian (becouse it`s a hacker’s language like assembler and leetspeak)
- Open literate source and read it
- Contribute (Pull Requests are welcome)
Select any target binary file. You need to make sure that the infection
actually took place. If this is the case, the file’s entry point will be changed.
This is the entry point of the target hello
before the file was
infected:
$ readelf -h hello | grep Адрес
Адрес точки входа: 0x400550
Run target file to be sure that it works:
$ ./hello
Hello world!
Current local time and date: Tue Mar 2 02:35:00 2021
Run virus, ypu will see the log of infection: which files thw virus tried to infect and which file was finaly infected.
$ ./virus
asm file: infection try
hello file: infection try
hello is successfully infected
So looks the entry point of hello
after infection:
$ readelf -h hello | grep Адрес
Адрес точки входа: 0x802b28
Run infected file to be sure, that it wasn’t broken by infection:
$ ./hello
asm file: infection try
hello file: infection try
.#ex2.txt file: infection try
final_version.org file: infection try
hello_stripped file: infection try
hello_stripped is successfully infected
Hello world!
Current local time and date: Tue Mar 2 02:30:18 2021
You see infection log, which file was infcted by hello
and printing
prinf
’s strings of target’s code.
Infection was successfull.
Remember, that virus infects the nearest file to him. That’s why may be your target will not be infected after virus run. Just keep running virus again and finaly your target will be infected.
The Project use utilitys ELFkickers, which source code was taken from here http://www.muppetlabs.com/~breadbox/software/elfkickers.html and may be used and modified according to GNU GPL v.2
all
- runs all targets listed below with the exception ofclean
virus
- compilesvirus
, if its sourse file code existssstrip
- compiles utilitys ELFkickersvictims
- compiles all target file for infection twice to makesstrip
of each duplicatesstripped_victims
delets the Section Table Headers from each duplicate. So we habe to types of target files: with and without secrion headersclean
- deletes all binaty files
- folders with utilitys ELFkickers, which has utility
sstrip
- file
index.org
, which is full documentation and explanation of virus code and infection process. Also it expanes basic theory about ELF format, loading and linking process. - makefile, which compiles all binary files: virus, its tarhets and utilitys ELFkickers