Unit III Malicious Code and Defense Techniques
Unit III Malicious Code and Defense Techniques
and Defense
Techniques
Agenda
• Self-Replicating Malicious code
• Evading detection and Elevating Privileges
• Rootkits – Spyware
• Token Kidnapping
• Virtual Machine detection
• Defense techniques :
• Memory Forensics – Honey pots – Malicious code Naming – Automated
Malicious Code Analysis System- Intrusion Detection System
- Discovery
- Replication
- Payload
Examples
The first recorded IBM PC-based virus, called the “Brain,” debuted in
January 1986. The Brain copied itself into a floppy disk’s boot sector,
the space on the floppy disk used to run code when the system starts.
Once in memory, it attempted to copy itself to other floppy disks; the
main side effect of an infection was a change to the volume label to “(c)
Brain.”
In 1987, the Jerusalem virus and its variants began infecting systems.
This virus resided in memory and infected all executable files (.com
and .exe) on the system. When a user opened an infected file, the virus
deleted the infected file.
Types of Computer
Boot Sector Virus Viruses
- damages or controls the boot sector on the drive,
rendering the machine unusable.
Web Scripting Virus-Most browsers have defenses against malicious
web scripts, but older, unsupported browsers have vulnerabilities
allowing attackers to run code on the local device.
Browser Hijacker-A computer virus that can change the settings on
your browser will hijack browser favorites, the home page URL
Resident Virus-A virus that can access computer memory and sit
dormant until a payload is delivered is considered a resident virus.
Polymorphic Virus-Each time the code runs, it executes slightly
differently, and typically every time it moves to a new machine, its code
will be slightly different
File Infector Virus-computer virus is activated when the system boots
or the program runs, affects critical OS related files
Multipartite Virus-programs spread across a network by copying
themselves or injecting code into critical computer resources.
Macro Virus-macros that can be used to download additional malware
Security against virus
• Check whether it’s a Resident or Non-Resident virus?
• A nonresident virus infects other files only when the infected file runs.
• A resident virus differs by loading itself into memory and continuing to run
after the infected file closes
• Resident virus can be : fast infectors and slow infectors.
• Worms typically have two roles.
• The first is to spread to additional computers
• secondary task known as a payload.
• A worm’s payload is what the attacker programs the worm to accomplish after it
spreads.
• This can include distributed denial of service (DDoS) attacks, spam distribution,
cyber crime, or anything else the attacker chooses.
• E-mail worms spread by sending a message designed to entice the recipient into
clicking a link or downloading an attachment that contains a copy of the worm.
• Network worms, which often spread without any user interaction, can infect many
computers in a very short amount of time. (purpose – guessing passwords,
intrusion etc)
• Eg: Blaster (2003) -spread through a vulnerability in the Microsoft Windows RPC interface
• USB worms configure the infected drives to execute the worm as soon as an
unsuspecting user plugs it into a computer.
• Worms can spread between mobile devices by sending copies of themselves
attached to short message service (SMS)
Mitigation of Worms
• administrators must protect systems from all propagation
techniques
• Use antivirus products to scan incoming e-mails and IMs for
malicious links.
• Disable autorun functionality for USB devices.
• Apply patches for vulnerabilities in network services in a timely
manner
• Disable access to P2P networks.
• Educate users on the dangers of worms that use social-
engineering technique
Evading Detection and Elevating
Privileges
• Defense evasion is a technique used by hackers to bypass or evade
the defenses of a target system. In cybersecurity, defense evasion
refers to any attempt to avoid detection or prevention by antivirus
software, intrusion detection systems, or other security measures.
• Disabling security tools
• Masquerading (tricked file type, scheduled tasks, renamed hacking
software, etc.)
• Obfuscating malicious code
• Privilege escalation is the act of evading established access and
authorization controls in an enterprise network to gain elevated
privileges and access critical network assets.
• Escalation may happen in Horizontal or Vertical(privilege elevation)
means
What is this
Obfuscation?
• Literal Meaning of Obfuscation:
• The word ‘obfuscation' refers to the concept of concealing
the meaning of communication by making it more
confusing and harder to interpret.
• Code Obfuscation:
• Code obfuscation is the generation or alteration of source
code and/or object code in such a way that it is easy for
the computer to comprehend but considerably difficult to
reverse engineer.
Reverse Engineering
Code
• Normal Engineering:
Dude writes code -> compiles -> binary
• Reverse Engineering:
dude gets the binary -> Uses powerful tools (e.g IDA Pro
tool) to gain knowledge about program -> Gets to know code
structure, control flow, and valuable assets, keys, algorithms
How can Obfuscation Help
• Types of Obfuscation:
• Code Structure Obfuscation
• Data Obfuscation
• Control Obfuscation
At each stage of the boot process, there are places for malicious
code to make changes that will cause it to run after a reboot.
• BIOS / CMOS
• is executed at the very beginning of system boot
• Some viruses and Trojans modify this flash memory to ensure that the BIOS starts up the
malicious code or hides its existence
• MBR
• is read shortly after the BIOS loads and before the operating system boots.
• some malicious code modifies the master boot record(MBR). Eg:Torpig MBR Rootkit
• Hypervisor
• a program that loads before the operating system and virtualizes hardware calls, such as
is done by Vmware
• Hypervisors allow malicious code to continue running after a “soft” reboot, during which
power is not cut to the system, but not after “hard” reboots or a full shutdown of the
system.
• Legacy Text Files
• For malicious code to instruct win.ini or system.ini to run it on startup, the code simply
adds a few lines to either file
• [windows] Run=malware.exe
Detecting Autostart Entries
• variety of tools available to help researchers detect the use of these
persistent methods
• GMER - to detect and remove rootkits
• Autoruns -shows which programs are configured to run at system
startup.
• Hijackthis - is a common means of detecting changes that malicious
code are likely to make
• msconfig - is a utility that Windows includes and allows easy
configuration of several common startup locations.
Rootkits
• A common rootkit definition is a type of malware program
that enables cyber criminals to gain access to and
infiltrate data from machines without being detected.
• A rootkit is a tool that allows actors to retain their administrative (or root)
privileges and to hide their activity.
• A rootkit achieves stealth by modifying the way a user program receives
information from the operating system.
• Rootkits often modify processes or modify the system to falsify and hide
information.
• give the attacker remote control, and remain hidden
for a long period of time.
• The simplest and earliest rootkits replaced system utilities (like ls) to
change their functionalities and hide certain files.
• More complex rootkits have similar goals, providing a way for
attackers to hide files or processes with certain attributes
• Categories:
• User mode - may target only a single process at a time to hide information
• Kernel mode - target the entire system and can hide information from all
sources t
Different Types of Rootkits in
cyber security
Firmware rootkits allow hackers to easily install malware on a memory chip on a target
Firmware Rootkits computer’s motherboard, infect the target computer’s hard drive or system BIOS, and
intercept data written to the hard drive.
Hackers use application rootkits to replace the target user’s computer’s default files
Application Rootkits with rootkit files that disrupt the working of default applications. It is difficult to detect
a rootkit in an application because the infected application looks and works fine.
In a memory rootkit, the hacker hides the rootkit in the RAM of the target user’s
computer, which makes it easy for the hacker to perform malicious activities in the
Memory Rootkits
background, but this rootkit has a short lifespan because the RAM is a volatile memory
due to which it lost all its data when the power is turned off.
The kernel is first loaded into memory when the OS is loaded and remains there until the
OS is shut down again. Using a kernel-mode rootkit, hackers attack the core of the target
Kernel mode Rootkits user’s computer’s operating system, the kernel. In rootkit kernel mode, hackers can
change the functionality of the operating system simply by adding their own programs,
making it easy for hackers to steal the personal information of targeted users.
User Mode Rootkits
• User mode rootkits are able to hide
information by targeting a user’s
running processes.
• The rootkit can hook critical
functions of a process by altering the
process’s import address table (IAT)
or by injecting a dynamic link library
(DLL) or other code into the memory
of a running process
Kernel Mode Rootkits
• Stealthier rootkits will attempt to load into the
kernel to influence critical memory structures and
avoid detection
• kernel mode rootkit may make changes to critical
kernel memory structures to hook and alter
certain kernel mode function calls on the system.
• (SSDT) is one target in kernel memory that the
rootkit may try to hook.
• SSDT- address lookup table for system API calls
• Modifying address in SSDT -> replace normal
functionality with that of rootkit that hides
information
Rootkit Protection and Removal
• Rootkits hide on a system and try to leave a very small footprint for
administrators to find
• Many anti-rootkit tools that attempt to detect rootkits
• General Procedure:
• Backup vital data
• Boot in safe mode
• Use different rootkit scan tools
• Example: GMER
Spyware
• spyware describes a class of malware based on the functionality of its
payload
• Named because of its main intention of monitoring (spying on) a user’s
activity without the user’s consent
• To be a spyware – Program should lack an End User License Agreement
(EULA) or a privacy policy
• overall goal is to steal information
• Information stolen from spyware-infected systems can include typed
keys, form data, e-mail addresses, credentials, certificates, pictures and
videos from attached Web cams, audio from an attached microphone,
documents, software licenses, network activity, and cookies.
Is keyloggers are a spyware?