CH 3
CH 3
1
The Registry
2
Definition
• The registry is a database file or presentation that is
used by all windows operating systems that
followed Win95.
• The registry is used by the Windows OS to store
hardware and software configuration information,
user preferences and setup information.
• The correct registry is essential for correct windows
performance and functioning, this is why the
registry is usually attacked by viruses and other
malicious software.
3
Registry vs. File System
• The registry is analogous to a file system.
File system:
▪ Folders
▪ Files
Registry:
▪ Keys
▪ Keys have inside them either other keys or name/value
pairs which correspond to object name and content.
4
Registry Structure
5
Registry Structure
• Registry has five top level branches or Hives:
▪ HKEY_CLASSES_ROOT
✓ COM server info, file associations, shortcuts
▪ HKEY_CURRENT-USER
✓ Logged in user name, desktop, start menu
▪ HKEY_LOCAL_MACHINE
✓ Hardware, software, preferences for all users
▪ HKEY_USERS
✓ Individual preferences for each user, represented by Security ID
(SID)
▪ HKEY_CURRENT_CONFIG
✓ Links to part of HKEY_LOCAL_MACHINE for current hardware
▪ HKEY_DYN_DATA
✓ Links to part of HKEY_LOCAL_MACHINE for PlugAndPlay
6
Registry Value Types
• REG_BINARY
▪ Raw binary data
• REG_DWORD
▪ 32 bit integers – often representing bools
• REG_SZ
▪ string
• REG_EXPAND_SZ
▪ Expandable string
• REG_MULTI_SZ
▪ Container for null seperated strings
7
COM Registry Entry
8
Exporting and Importing
• In RegEdit select a key
• File Export
• Provide filespec info in resulting save dialog
9
Registry Content
• The registry holds critical information about the
system, the users of the system, and installed
applications:
• Operating System version number, build number, and
registered user.
• Informaiton for every properly installed application,
• Information about the computer’s processor type and
system memory.
• User-specific information (home directory, app.
preferences)
• Security informaiton such as user account names.
• Installed services
• Mapping from file names to programs/executables.
• Mapping network addressees to host machine names.
10
Registry Programming interface
• The registry programming interface holds a list of
functions that can be divided into:
▪ Key management (browse, add, remove keys) and includes:
✓ RegOpenKeyEx : opens a key and gives you a handle to it.
✓ RegEnumKeyEX : provides an enumerator over a key content.
✓ CreateKeyEX : creates a new key.
✓ RegDeleteKey : deletes a key.
• NOTE: these are the basic and most used functions, you
can find the whole interface functions on
http://msdn.microsoft.com.
11
RegOpenKeyEx
• LONG RegOpenKeyEx( HKEY hKey, LPCTSTR lpSubKey,
DWORD ulOptions, REGSAM samDesired, PHKEY phkResult).
12
RegEnumKeyEx
• LONG RegEnumKeyEx(HKEY hKey, DWORD dwIndex, LPTSTR lpName,
LPDWORD lpcName, LPDWORD lpReserved, LPTSTR lpClass, LPDWORD lpcClass,
PFILETIME lpftLastWriteTime );
15
RegEnumValue
• LONG RegEnumValue( HKEY hKey, DWORD dwIndex,
LPTSTR lpValueName, LPDWORD lpcValueName,
LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData,
LPDWORD lpcbData);
16
RegSetValueEx
• LONG RegSetValueEx( HKEY hKey, LPCTSTR lpValueName,
DWORD Reserved, DWORD dwType, const BYTE* lpData,
DWORD cbData);
17
RegQueryValueEx
• LONG RegQueryValueEx( HKEY hKey, LPCTSTR
lpValueName, LPDWORD lpReserved, LPDWORD lpType,
LPBYTE lpData, LPDWORD lpcbData );
18
Complete Registry interface
Below is a list of all the registry
functions:
– RegCloseKey – RegReplaceKey
– RegOpenKey – RegEnumKeyEx
– RegConnectRegistry – RegRestoreKey
– RegOpenKeyEx – RegEnumValue
– RegCreateKey – RegSaveKey
– RegQueryInfoKey – RegFlushKey
– RegCreateKeyEx – RegSetKeySecurity
– RegQueryMultipleValues – RegGetKeySecurity
– RegDeleteKey – RegSetValue
– RegQueryValue – RegLoadKey
– RegDeleteValue – RegSetValueEx
– RegQueryValueEx – RegNotifyChangeKeyValue
– RegEnumKey – RegUnLoadKey
19
Network Address Translation
(NAT)
20
Private Network
• Private IP network is an IP network that is not directly
connected to the Internet
21
Private Addresses
H1 H2 H3 H4
10.0.1.1 10.0.1.1
Private network 1 Private network 1
Internet
R1 128.195.4.119 128.143.71.21 R2
213.168.112.3
H5
22
Network Address Translation
(NAT)
• NAT is a router function where IP addresses (and
possibly port numbers) of IP datagrams are replaced at
the boundary of a private network
23
Basic operation of NAT
24
Pooling of IP addresses
• Scenario: Corporate network has many hosts but
only a small number of public IP addresses
• NAT solution:
▪ Corporate network is managed with a private address
space
▪ NAT device, located at the boundary between the
corporate network and the public Internet, manages a
pool of public IP addresses
▪ When a host from the corporate network sends an IP
datagram to a host in the public Internet, the NAT device
picks a public IP address from the address pool, and
binds this address to the private address of the host
25
Pooling of IP addresses
Private Internet
network
Private Public
Address Address
10.0.1.2
26
Supporting migration between network service
providers
• Scenario: In CIDR, the IP addresses in a corporate network are
obtained from the service provider. Changing the service provider
requires changing all IP addresses in the network.
• NAT solution:
▪ Assign private addresses to the hosts of the corporate network
▪ NAT device has static address translation entries which bind the
private address of a host to the public address.
▪ Migration to a new network service provider merely requires an
update of the NAT device. The migration is not noticeable to the
hosts on the network.
Note:
▪ The difference to the use of NAT with IP address pooling is that the
mapping of public and private IP addresses is static.
27
Supporting migration between network service
providers
28
IP masquerading
• Also called: Network address and port translation
(NAPT), port address translation (PAT).
• Scenario: Single public IP address is mapped to
multiple hosts in a private network.
• NAT solution:
▪ Assign private addresses to the hosts of the corporate
network
▪ NAT device modifies the port numbers for outgoing
traffic
29
IP masquerading
Private Public
Address Address
10.0.1.2/2001 128.143.71.21/2100
10.0.1.3/3020 128.143.71.21/4444
30
Load balancing of servers
• Scenario: Balance the load on a set of identical
servers, which are accessible from a single IP
address
• NAT solution:
▪ Here, the servers are assigned private addresses
▪ NAT device acts as a proxy for requests to the server
from the public network
▪ The NAT device changes the destination IP address of
arriving packets to one of the private addresses for a
server
▪ A sensible strategy for balancing the load of the servers is
to assign the addresses of the servers in a round-robin
fashion.
31
Load balancing of servers
32
Concerns about NAT
• Performance:
▪ Modifying the IP header by changing the IP address
requires that NAT boxes recalculate the IP header
checksum
▪ Modifying port number requires that NAT boxes
recalculate TCP checksum
• Fragmentation
▪ Care must be taken that a datagram that is fragmented
before it reaches the NAT device, is not assigned a
different IP address or different port numbers for each of
the fragments.
33
Concerns about NAT
• End-to-end connectivity:
▪ NAT destroys universal end-to-end reachability of hosts
on the Internet.
▪ A host in the public Internet often cannot initiate
communication to a host in a private network.
▪ The problem is worse, when two hosts that are in a
private network need to communicate with each other.
34
Concerns about NAT
• IP address in application data:
▪ Applications that carry IP addresses in the payload of the
application data generally do not work across a private-
public network boundary.
▪ Some NAT devices inspect the payload of widely used
application layer protocols and, if an IP address is
detected in the application-layer header or the
application payload, translate the address according to
the address translation table.
35
NAT and FTP
FTP client FTP server
public address: public address:
128.143.72.21 128.195.4.120
H1 H2
PORT 128.143.72.21/1027
RETR myfile
36
NAT and FTP
Private network Internet
H1 H2
PORT 10.0.1.3/1027 PORT 128.143.72.21/1027
37
NAT and FTP
Private network Internet
H1 H2
PASV PASV
38
Configuring NAT in Linux
• Linux uses the Netfilter/iptable package to add
filtering rules to the IP module
To application From application
filter nat
INPUT OUTPUT
Yes filter
OUTPUT
Destination No filter
is local? FORWARD
nat nat
PREROUTING POSTROUTING
(DNAT) (SNAT)
Incoming Outgoing
datagram datagram
39
Configuring NAT with iptable
• First example:
iptables –t nat –A POSTROUTING –s 10.0.1.2
–j SNAT --to-source 128.143.71.21
• Pooling of IP addresses:
iptables –t nat –A POSTROUTING –s 10.0.1.0/24
–j SNAT --to-source 128.128.71.0–128.143.71.30
• ISP migration:
iptables –t nat –R POSTROUTING –s 10.0.1.0/24
–j SNAT --to-source 128.195.4.0–128.195.4.254
• IP masquerading:
iptables –t nat –A POSTROUTING –s 10.0.1.0/24
–o eth1 –j MASQUERADE
• Load balancing:
iptables -t nat -A PREROUTING -i eth1 -j DNAT --to-
destination 10.0.1.2-10.0.1.4
40
Dynamic Host Configuration
Protocol (DHCP)
41
Dynamic Assignment of IP addresses
• Dynamic assignment of IP addresses is desirable
for several reasons:
▪ IP addresses are assigned on-demand
▪ Avoid manual IP configuration
▪ Support mobility of laptops
42
Solutions for dynamic assignment of IP addresses
43
BOOTP
• BOOTstrap Protocol (BOOTP)
✓ From 1985
✓ Host can configure its IP parameters at boot time.
✓ 3 services.
– IP address assignment.
– Detection of the IP address for a serving machine.
– The name of a file to be loaded and executed by the client machine (boot
file name)
▪ Not only assign IP address, but also default router, network mask,
etc.
▪ Sent as UDP messages (UDP Port 67 (server) and 68 (host))
▪ Use limited broadcast address (255.255.255.255):
✓ These addresses are never forwarded
44
Introduction
• DHCP is s a network service that enables host
computers to be automatically assigned settings
from a server.
▪ Computers configured to be DHCP clients have no
control over the settings they receive from the DHCP
server.
▪ The configuration is transparent to the computer's user.
• The most common settings provided by a DHCP
server to DHCP clients include:
▪ IP address and Subnet Mask
▪ IP address of the default-gateway to use
▪ IP addresses of the DNS servers to use
45
Introduction…
• However, a DHCP server can also supply
configuration properties such as:
▪ Host Name: Eg. www, mail, …
▪ Domain Name: Eg. wu.edu.et, aau.edu.et
▪ Time Server: ntp
▪ Print Server
• Advantages of using DHCP includes:
▪ Changes to the network need only be changed at the
DHCP server.
▪ It is also easier to integrate new computers into the
network.
▪ Conflicts in IP address allocation are also reduced.
46
How DHCP works?
• Manual allocation (MAC address)
▪ Using DHCP to identify the unique hardware address of each
network card connected to the network.
▪ Continually supplying a constant configuration each time the
DHCP client makes a request to the DHCP server using that
network device.
▪ This ensures that a particular address is assigned
automatically to that network card, based on it's MAC
address.
• Dynamic allocation (address pool)
▪ The DHCP server will assign an IP address from a pool of
addresses (sometimes also called a range or scope) for a
period of time or lease.
▪ This way, the clients will be receiving their configuration
properties dynamically and on a "first come, first served“ basis
47
How DHCP works….
▪ When a DHCP client is no longer on the network for a
specified period, the configuration is expired and
released back to the address pool for use by other DHCP
Clients.
• Automatic allocation
▪ The DHCP automatically assigns an IP address
permanently to a device, selecting it from a pool of
available addresses.
▪ DHCP is used to assign a temporary address to a client,
but a DHCP server can allow an infinite lease time.
48
DHCP Server Configuration
• DHCP Server configuration on ‘ubuntu’ follows the
following steps:
▪ Installation of the dhcp service (dhcpd)
sudo apt-get install isc-dhcp-server
Note: Edit the /etc/dhcp/dhcp.conf file to change the default confituration.
▪ Configuration
✓ Most commonly, what you want to do is assign an IP address randomly.
This can be done with settings as follows:
# minimal sample /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.150 192.168.1.200;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "mydomain.example";
}
49
Configuration….
▪ This will result in the DHCP server giving clients an IP
address from the range 192.168.1.150-192.168.1.200.
▪ It will lease an IP address for 600 seconds if the client
doesn't ask for a specific time frame.
▪ Otherwise the maximum (allowed) lease will be 7200
seconds.
▪ The server will also "advise" the client to use
192.168.1.254 as the default-gateway
▪ 192.168.1.1 and 192.168.1.2 as its DNS servers.
• After changing the config file you have to restart
the dhcpd:
▪ sudo /etc/init.d/isc-dhcp-server restart
50
Name Server and Configuration
• The Domain Name System (DNS) is a distributed
database.
▪ This allows local control of the segments of the overall
database, yet the data in each segment is available across
the entire network through a client-server scheme.
• DNS's distributed database is indexed by domain
names.
▪ Each domain name is essentially just a path in a large
inverted tree, called the domain name space.
• DNS's tree can branch any number of ways at each
intersection point, or node.
51
Name Server …
• The depth of the tree is limited
to 127 levels.
▪ Each node in the tree has a text
label (without dots) that can be up
to 63 characters long.
▪ A null (zero-length) label is
reserved for the root.
▪ Domain names are always read
from the node toward the root,
with dots separating the names in
the path.
▪ When the root node's label
appears by itself, it is written as a
single dot (.) for convenience.
52
Name Server …
▪ DNS requires that sibling nodes have
different labels.
▪ Restriction guarantees that a domain
name uniquely identifies a single node
in the tree.
53
Name Server…
• The domain name of a
domain is the same as the
domain name of the node
at the very top of the
domain.
• So for example, the top of
the purdue.edu domain is
a node named
purdue.edu
54
Name Server…
• Any domain name in the
subtree is considered a
part of the domain.
• Because a domain name
can be in many subtrees,
it can also be in many
domains.
• For example, the domain
name pa.ca.us is part of
the ca.us domain and also
part of the us domain
55
Internet Domain Name Space
• The original top-level domains divided the Internet domain name space
organizationally into seven domains:
▪ com
✓ Commercial organizations, such as Hewlett-Packard (hp.com), Sun Microsystems (sun.com),
and IBM (ibm.com).
▪ edu
✓ Educational organizations, such as Wollega University (wu.edu) and Purdue University
(purdue.edu).
▪ gov
✓ Government organizations, such as INSA (insa.gov) and the Ministry of Foreign Affairs
(mfa.gov).
▪ mil
✓ Military organizations, such as the U.S. Army (army.mil ) and Navy (navy.mil ).
▪ net
✓ Organizations providing network infrastructure, such as EthioTelecom (ethiotelecom.net)
and UUNET (uu.net).
▪ org
✓ Formerly, noncommercial organizations, such as the Electronic Frontier Foundation (eff.org ).
Like net, however, restrictions on org were removed in 1996.
▪ int
✓ International organizations, such as NATO (nato.int).
56
Delegation
• Decentralize administration in DNS is achieved
through delegation.
▪ An organization administering a domain can divide it
into subdomains.
▪ Each of those subdomains can be delegated to other
organizations.
▪ An organization becomes responsible for maintaining all
the data in that subdomain.
▪ It can freely change the data, and even divide up its
subdomain into more subdomains and delegate those.
57
Delegation…
▪Not all organizations delegate
away their whole domain.
▪A domain may have several
delegated subdomains and also
contain hosts that don't belong in
the subdomains.
▪For example, the Wollega
University has a campus at Gimbi
and Nekemte. So it might have a
gimbi.wu.edu.et subdomain and a
nekemte.wu.edu.et subdomain.
58
Name Servers and Zones
• The programs that store information about the
domain name space are called name servers.
• Name servers generally have complete information
about some part of the domain name space (a
zone), which they load from a file or from another
name server.
▪ The other name server is called Forwarder.
• The name server is then said to have authority for
that zone. Name servers can be authoritative for
multiple zones, too.
59
Zones…
• All top-level domains, and
many domains at the
second level and lower,
such as berkeley.edu and
hp.com, are broken into
smaller, more manageable
units by delegation.
• These units are called
zones.
60
Zone Data Files
• Most entries in zone data files are called DNS
resource records.
• DNS lookups are case-insensitive, so you can enter
names in your zone data files in uppercase,
lowercase, or mixed case.
▪ Commonly all lowercase is used.
61
Types of DNS Resource Records
• SOA record
▪ Indicates authority for this zone (Start Of Authority)
• NS record
▪ Lists a name server for this zone
• A record
▪ Name-to-address mapping
• PTR records
▪ Address-to-name mapping
• CNAME records
▪ Canonical name (for aliases)
• MX records
▪ Records for Mail Exchange server
62
Example
✓ ; ; NS Record;
wu.edu.et. IN NS ns1.wu.edu.et
wu.edu.et. IN NS ns2.wu.edu.et
✓ ;; Mail Exchange
wu.edu.et. IN MX mail.wu.edu.et
✓ ;;A Records
intranet.wu.edu.et. IN A 10.5.100.9
medsims.wu.edu.et. IN A 10.5.100.56
✓ ; ; PTR Addresses
9.100.5.102.in-addr.arpa. IN PTR intranet.wu.edu.et.
56.100.5.10.in-addr.arpa. IN PTR medsims.wu.edu.et
✓ ; ; Aliases
medicine.wu.edu.et. IN CNAME medsims.wu.edu.et.
63
Resolver
• Resolvers are the clients that access name servers.
Programs running on a host that need information
from the domain name space use the resolver.
• The resolver handles the following tasks:
▪ Querying a name server
▪ Interpreting responses (which may be resource records
or an error)
▪ Returning the information to the programs that
requested it
64
Name Space Resolution
• Name servers are adept at retrieving data from the
domain name space.
• They have to be, given the limited intelligence of
most resolvers.
• Not only can they give you data from zones for
which they're authoritative, they can also search
through the domain name space to find data for
which they're not authoritative.
• This process is called name resolution or simply
resolution.
65
Resolution…
• Because the namespace is structured as an inverted
tree, a name server needs only one piece of
information to find its way to any point in the tree:
▪ The domain names and addresses of the root name
servers
▪ A name server can issue a query to a root name server for
any domain name in the domain name space, and the
root name server starts the name server on its way.
66
Resolution Process
67
Adding More Name Servers
• Primary and Slave Name Servers
▪ In large networks it is a good idea to define name servers
and give them authority.
✓ Primary Name Server is Authoritative
✓ Secondary Name Server is active when Primary NS fails
• Caching Only Name Servers
▪ The name implies that the only function this server
performs is looking up data and caching it.
▪ They are not authoritative for any zones (except
0.0.127.in-addr.arpa).
68
BIND
• BIND (Berkeley Internet Name Domain) is the
default name server for Linux OS.
• Installation and Configuration:
▪ Update your server and Install BIND on it. Execute the
following commands one by one.
$sudo apt-get update
$sudo apt-get install bind9 bind9utils bind9-doc
▪ Before proceeding you can optionally set bind9 to IPv4
mode.
$sudo nano /etc/default/bind9
▪ Add "-4" to the OPTIONS variable. Then save and exit. It
should look like the following:
OPTIONS="-4 -u bind"
69
Proxy Servers
Part of an overall Firewall strategy
Sits between the local network and the external network
◦ Originally used primarily as a caching strategy to minimize outgoing
Opaque – the local party must configure client software to use the
proxy
client software must be proxy-aware software
Netscape proxy server is opaque
72
Circuit Level Proxies
Since some protocols require a real connection between
the client and server, a regular proxy can’t be used
◦ Windows Media Player, Internet Relay Chat (IRC), or Telnet
Circuit-level proxy servers were devised to simplify matters.
◦ Instead of operating at the Application layer, they work as a "shim" between
the Application layer and the Transport layer, monitoring TCP handshaking
between packets from trusted clients or servers to untrusted hosts, and vice
versa. The proxy server is still an intermediary between the two parties, but
this time it establishes a virtual circuit between them.
By using SOCKS (RFC 1928) this can be done
◦ SOCKS defines a cross-platform standard for accessing circuit-level proxies
◦ SOCKS Version 5 also supports both username/password (RFC 1929) and API-
based (RFC 1961) authentication. It also supports both public and
private key encryption.
◦ SOCKS 5 is capable of solving this problem by establishing TCP
connections and then using these to relay UDP data.
73
SOCKS basedProxying
RFC 1928
Not a true application layer proxy
SOCKS protocol provides a framework for developing secure
communications by easily integrating other security technologies
SOCKS includes two components
◦ SOCKS server
implemented at the application layer
◦ SOCKS client
implemented between the application and transport layers
The basic purpose of the protocol is to enable hosts on one side of a
SOCKS server to gain access to hosts on the other side of a SOCKS
Server, without requiring direct IP- reachability.
Copies packet payloads through the proxy
74
Socks Architecture
75
Socks Functionality
76
Advantages
Terminates the TCP connection before relaying to target
host (in and out)
Hide internal clients from external network
Blocking of dangerous URLs
Filter dangerous content
Check consistency of retrieved content
Eliminate need for transport layer routing between networks
Single point of access, control and logging
77
Disadvantages
Single point of failure
if the proxy dies , no one can get to the external network
Client software must usually be designed to use a proxy
Proxies must exist for each service
Doesn’t protect the OS
proxies run at the application level
Usually optimized for performance rather than security
78
End
79