Module 9
Module 9
Malwares
Ansh Bhawnani
Malware Concepts
Module 9
1. Introduction to
Malwares
Module 9
Introduction to Malwares
Module 9
1. Introduction to
Viruses
Module 9
Introduction to Viruses
Module 9
Stages of a Virus Lifetime
Module 9
Phases of a Virus
▰ Dormant phase: The virus program is into the system but idle, eventually be
activated by the "trigger" which states which event will execute the virus.
▰ Propagation phase: The virus starts propagating, that is multiplying and
replicating itself. The virus places a copy of itself into other programs or into
certain system areas on the disk.
▰ Triggering phase: A dormant virus moves into this phase when it is activated, and
will now perform the function for which it was intended.
▰ Execution phase: This is the actual work of the virus, where the "payload" will be
released. It can be destructive such as deleting files on disk, crashing the system,
or corrupting files or relatively harmless such as popping up humorous or political
messages on screen.
13
4. Working of a Virus
Module 9
Working of a Virus
▰ Infection Phase: In the infection phase, the virus replicates itself and attaches to
an .exe file in the system.
15
Working of a Virus
▰ Attack Phase:
▻ Viruses are programmed with trigger events to activate and corrupt
systems.
▻ Some viruses infect each time they are run and others infect only when a
certain predefined condition is met such as user's specific task, a day, time,
or a particular event.
16
Working of a Virus
17
Working of a Virus
Module 9
Indications of a Virus attack
▰ False Positives: However, not all glitches can be attributed to virus attacks.
21
Indications of a Virus attack
Module 9
Types of Viruses
25
Types of Viruses
26
Types of Viruses
▰ Macro Viruses
▻ Macro viruses infect files created by Microsoft Word or Excel.
▻ Most macro viruses are written using macro language Visual Basic for
Applications (VBA).
▻ Macro viruses infect templates or convert infected documents into template
files, while maintaining their appearance of ordinary document files.
28
Types of Viruses
▰ Cluster Viruses
▻ Cluster viruses modify directory table entries so that it points users or
system processes to the virus code instead of the actual program.
▻ There is only once copy of the virus on the disk infecting all the programs in
the computer system.
▻ It will launch itself first when any program on the computer system is
started and then the control is passed to actual program.
29
Types of Viruses
▰ Stealth/Tunneling Viruses
▻ These viruses evade the anti-virus software by intercepting its requests to
the operating system.
▻ A virus can hide itself by intercepting the anti-virus software's request to
read the file and passing the request to the virus, instead of the OS.
▻ The virus can then return an uninfected version of the file to the anti-virus
software, so that it appears as if the file is "clean".
30
Types of Viruses
▰ Encryption Viruses
▻ This type of virus uses simple encryption to encipher the code.
▻ The virus is encrypted with a different key for each infected file.
▻ AV scanner cannot directly detect these types of viruses using signature
detection methods.
31
Types of Viruses
▰ Polymorphic Code
▻ Polymorphic code is a code that mutates while keeping the original
algorithm intact.
▻ To enable polymorphic code, the virus has to have a polymorphic engine
(also called mutating engine or mutation engine).
▻ A well-written polymorphic virus therefore has no parts that stay the same
on each infection.
32
Types of Viruses
▰ Metamorphic Viruses
▻ Metamorphic Viruses: Metamorphic viruses rewrite themselves completely
each time they are to infect new executable.
▻ Metamorphic Code: Metamorphic code can reprogram itself by translating
its own code into a temporary representation and then back to the normal
code again.
▻ Example: For example, E32/Simile consisted of over 14000 lines of
assembly code, 90% of it is part of the metamorphic engine.
33
Types of Viruses
34
Types of Viruses
35
Types of Viruses
▰ Companion/Camouflage Viruses
▻ A Companion virus creates a companion file for each executable file the
virus infects.
▻ Therefore, a companion virus may save itself as notepad.com and every
time a user executes notepad.exe (good program), the computer will load
notepad.com (virus) and infect the system.
36
Types of Viruses
▰ Shell Viruses
▻ Virus code forms a shell around the target host program's code, making
itself the original program and host code as its sub-routine.
▻ Almost all boot program viruses are shell viruses.
37
Types of Viruses
38
Types of Viruses
▻ Intrusive Viruses: Intrusive viruses overwrite the host code partly or completely with
the viral code.
40
Types of Viruses
Module 9
Worms
▰ Computer worms are malicious programs that replicate, execute, and spread
across the network connections independently without human interaction.
▰ Most of the worms are created only to replicate and spread across a network,
consuming available computing resources; however, some worms carry a
payload to damage the host system.
▰ Attackers use worm payload to install backdoors in infected computers, which
turns them into zombies and creates botnet; these botnets can be used to carry
further cyber attacks.
43
1. Worm vs. Virus
Module 9
Worm vs. Virus
▰ Replicates on its own: A worm is a special type of malware that can replicate
itself and use memory, but cannot attach itself to other programs.
▰ Spreads through the Infected Network: A worm takes advantages of file or
information transport features on computer systems and spread through the
infected network automatically but a virus does not.
45
Worm vs. Virus
46
Trojans
Module 9
1. What is a Trojan?
Module 9
What is a Trojan?
49
What is a Trojan?
50
2. How Hackers use
Trojans?
Module 9
How Hackers use Trojans?
Module 9
Common Ports Used by Trojans
54
4. How to Infect
Systems Using a
Trojan
Module 9
How to Infect Systems Using a Trojan
▻ A genuine application:
▻ File name: chess.exe
▻ Wrapper data: Executable file
▰ Create a wrapper using wrapper tools to install Trojan on the victim's computer.
▻ petite.exe, Graffiti.exe, EliteWrap
▻ bind the Trojan executable to legitimate files
▰ Propagate the Trojan.
▻ Email
▰ Execute the dropper.
▰ Execute the damage routine. 57
How to Infect Systems Using a Trojan
▰ Wrappers
▻ A wrapper binds a Trojan executable with an innocent looking .EXE
application such as games or office applications.
▻ genuine-looking .EXE application
▻ The two programs are wrapped together into a single file.
▻ When the user runs the wrapped EXE, it first installs the Trojan in the
background and then runs the wrapping application in the foreground.
▻ Attackers might send a birthday greeting that will install a Trojan as the user
watches, for example, a birthday cake dancing across the screen.
58
How to Infect Systems Using a Trojan
▰ Crypters
▻ Crypter is a software which is used by hackers to hide viruses, keyloggers or
tools in any kind of file so that they do not easily get detected by antiviruses.
▻ AIO UFD Crypter
▻ Hidden Sight Crypter
▻ Galaxy Crypter
▻ Criogenic Crypter
▻ Heaven Crypter
▻ SwayzCryptor
59
5. Exploit Kits
Module 9
Exploit Kits
Module 9
Evading Antiviruses
▰ Break the Trojan file into multiple pieces and zip them as single file.
▰ ALWAYS write your own Trojan, and embed it into an application.
▰ Change Trojan's syntax:
▻ Convert an EXE to VB script
▻ Change .EXE extension to .DOC.EXE, .PPT.EXE or .PDF.EXE (Windows hide
"known extensions", by default, so it shows up only .DOC, .PPT and .PDF)
▰ Change the content of the Trojan using hex editor and also change the checksum
and encrypt the file.
▰ Never use Trojans downloaded from the web (antivirus can detect easily)
63
7. Types of Trojans
Module 9
Types of Trojans
65
Types of Trojans
▰ Defacement Trojans
▻ Resource editors allow to view, edit, extract, and replace strings, bitmaps,
logos and icons from any Windows program.
▻ It allows you to view and edit almost any aspect of a compiled Windows
program, from the menus to the dialog boxes to the icons and beyond.
▻ They apply User-styled Custom Application (UCA) to deface Windows
application.
▻ Example of calc.exe Defaced is shown here.
66
Types of Trojans
67
Types of Trojans
▰ Botnet Trojans
▻ Botnet Trojans infect a large number of computers across a large
geographical area to create a network of bots that is controlled through a
Command and Control (C&C) center.
▻ Botnet is used to launch various attacks on a victim including denial-of-
service attacks, spamming, click fraud, and the theft of financial
information.
68
Types of Trojans
69
Types of Trojans
71
Types of Trojans
▰ FTP Trojans
▻ FTP Trojans install an FTP server on the victim's machine, which opens FTP
ports.
▻ An attacker can then connect to the victim's machine using FTP port to
download any files that exist on the victim's computer.
72
Types of Trojans
▰ VNC Trojans
▻ VNC Trojans starts a VNC Server daemon in the infected system (victim).
▻ Attacker connects to the victim using any VNC viewer.
▻ Since VNC program is considered a utility, this Trojan will be difficult to detect using
anti-viruses.
▰ VNC Trojan: Hesperbot
▻ Hesperbot is a banking Trojan that creates a hidden VNC server to which the attacker
can remotely connect.
▻ As VNC does not log the user off like RDP, the attacker can connect to the
unsuspecting victim's computer while they are working.
73
Types of Trojans
▰ HTTP/HTTPS Trojans
▻ Bypass Firewall: HTTP Trojans can bypass any firewall and work in the
reverse way of a straight HTTP tunnel.
▻ Spawn a Child Program: They are executed on the internal host and spawn a
child at a predetermined time.
▻ Access the Internet: The child program appears to be a user to the firewall
so it is allowed to access the Internet.
74
Types of Trojans
75
Types of Trojans
76
Types of Trojans
▰ ICMP Tunneling
▻ Covert channels are methods in which an attacker can hide the data in a
protocol that is undetectable.
▻ They rely on techniques called tunneling, which allow one protocol to be
carried over another protocol.
▻ ICMP tunneling uses ICMP echo-request and reply to carry a payload and
stealthily access or control the victim's machine.
77
Types of Trojans
78
Types of Trojans
▰ E-banking Trojans
▻ e-banking Trojans intercept a victim's account information before it is
encrypted and sends it to the attacker's Trojan command and control center.
▻ It steals victim's data such as credit card related card no., CVV2, billing
details, etc. and transmits it to remote hackers using email, FTP, IRC, or
other methods.
▻ TAN Grabber (Transaction Authentication Number)
▻ HTML Injection
▻ Form Grabber
▻ ZeuS, SpyEye, Citadel Builder and Ice IX 79
Types of Trojans
80
Types of Trojans
▰ Notification Trojans
▻ Notification Trojan sends the location of the victim's IP address to the
attacker.
▻ Whenever the victim's computer connects to the Internet, the attacker
receives the notification.
81
Ransomware
Module 9
Ransomware
83
1. Types of
Ransomware
Module 9
Types of Ransomware
▰ Scareware: Poses as security software or tech support. Not responding to this will
not do anything except lead to more pop-ups.
▰ Screenlockers: Completely lock a user out of their computer.
▰ Encrypting ransomware: The attacker will gain access to and encrypt the victim’s
data and ask for a payment to unlock the files.
▰ Doxware: Attacker may also threaten to publish your data online if the victim does
not pay a ransom.
▰ Mobile ransomware: Affects mobile devices.
▰ The victims also get a warning that if the demanded sum is not paid by a specific
date, the private key required to unlock or decrypt files will be destroyed.
85
2. Case Study:
WannaCry
Module 9
WannaCry Ransomware
▰ In May 2017, WannaCry was able to infect and encrypt more than a quarter million
systems globally.
▰ It used asymmetric encryption. During the thick of the week in which WannaCry
was most virulent, only about $100,000 in bitcoin was transferred.
▰ No accounts have been known to be recovered even after Payment
▰ The damages caused have exceeded $1 billion.
▰ 20% of businesses that chose to pay the ransom demanded of them didn't receive
their files back.
87
WannaCry Ransomware
88
3. Case Study:
Cryptolocker
Module 9
Cryptolocker Ransomware
▰ Perhaps the first example of a attack that used public-key encryption widely
spread
▰ A Trojan horse that was active on the internet from September 2013 through May
of the following year.
▰ Demanded payment in either Bitcoin or a prepaid voucher, and experts generally
believed that the RSA cryptography was used
▰ In May 2014, however, a security firm gained access to a command-and-control
server used by the attack and recovered the encryption keys used in the attacks.
90
Ransomware
91
4. Ransomware
Families
Module 9
Ransomware Families
▰ Ransomware Family:
▻ TeslaCrypt
▻ SimpleLocker
▻ WannaCry
▻ NotPetya
▻ Locky
93
Ransomware Families
▰ Ransomware Family:
▻ Cryptorbit Ransomware
▻ CryptoLocker Ransomware
▻ CryptoDefense Ransomware
▻ CryptoWall Ransomware
▻ Police-themed Ransomware
94
5. How to remove
Ransomwares
Module 9
How to remove Ransomwares
96
Malware Detection
Module 9
Malware Detection
99
Malware Detection
102
Malware Detection
103
Malware Detection
105
Malware Detection
107
Malware Detection
▰ Code Emulation:
▻ In code emulation techniques, the anti-virus executes the malicious code inside a
virtual machine to simulate CPU and memory activities.
▻ This techniques is considered very effective in dealing with encrypted and
polymorphic viruses if the virtual machine mimics the real machine.
▰ Heuristic Analysis:
▻ Heuristic analysis can be static or dynamic.
▻ In static analysis the anti-virus analyses the file format and code structure to
determine if the code is viral.
▻ In dynamic analysis the anti-virus performs a code emulation of the suspicious
code to determine if the code is viral.
109
Malware Analysis
Module 9
1. Prerequisites
Module 9
Malware Analysis
113
2. Analysis
Procedure
Module 9
Malware Analysis
▰ Record network traffic information using the connectivity and log packet
content monitoring tools such as NetResident and TCPView.
▰ Determine the files added, processes spawned, and changes to the registry with
the help of registry monitoring tools such as RegShot.
▰ Collect the following information using debugging tools such as OllDbg and
ProcDump:
▻ Service requests and DNS tables information
▻ Attempts for incoming and outgoing connections
116
3. Ransomware
Analysis:
CryptoLocker
Module 9
Malware Analysis
118
Malware Analysis
119
Malware Analysis
▰ Encryption Technique:
▻ The malware uses an AES algorithm to encrypt the files. The malware first
generates a 256 bit AES key and this will be used to encrypt the files.
▻ In order to be able to decrypt the files, the malware author needs to know
that key.
▻ To avoid transmitting the key in clear text, the malware will encrypt it using
an asymmmetric key algorithm, namely the RSA public/private key pair.
▻ This encrypted key is then submitted to the C&C server.
120
Malware Analysis
▰ Once the system is compromised, the malware displays the below mentioned
warning to the user and demand ransom to decrypt the files.
▰ It maintains the list of files which was encrypted by this malware under the
following registry entry
▻ HKEY_CURRENT_USER\Software\CryptoLocker\Files
▰ On execution, this malware binary copies itself to %AppData% location and
deletes itself using a batch file
▻ %AppData%\{2E376276-3A5A-0712-2BE2-FBF2CFF7ECD5}.exe
121
Countermeasures
Module 9
1. Malwares
(Trojans, Viruses,
Worms, Backdoors)
Module 9
Countermeasures
▰ Install anti-virus software that detects and removes infections as they appear.
▰ Generate an anti-virus policy for safe computing and distribute it to the staff.
▰ Pay attention to the instructions while downloading files or any programs from
the Internet.
▰ Update the anti-virus software regularly.
▰ Avoid opening the attachments received from an unknown sender as viruses
spread via e-mail attachments.
▰ Possibility of virus infection may corrupt data, thus regularly maintain data back
up.
125
Countermeasures
126
Countermeasures
▰ Schedule regular scans for all drives after the installation of anti-virus software.
▰ Do not accept disks or programs without checking them first using a current
version of an anti-virus program.
▰ Ensure the pop-up blocker is turned on and use an Internet firewall.
▰ Run disk clean up, registry scanner and defragmentation once a week.
▰ Turn on the firewall if the OS used is Windows XP.
▰ Run anti-spyware or adware once in a week.
▰ Do not open the files with more than one file type extension.
127
2. Ransomware
Module 9
How to prevent Ransomware Attacks
▰ Do not pay the ransom. Even if the ransom is paid, there is no guarantee that you
will be able to regain access to your files.
▰ Restore any impacted files from a known good backup.
▰ Do not provide personal information when answering an email, unsolicited phone
call, text message or instant message.
▰ Use reputable antivirus software and a firewall. Do employ content scanning and
filtering on your mail servers.
▰ Do make sure that all systems and software are up-to-date with relevant patches.
▰ Make sure you use a trustworthy Virtual Private Network (VPN) when accessing
public Wi-Fi.
129
HACKING
Is an art, practised through a creative mind.
130