Network Security Notes from PPT Course:
- Whois is a query response protocol for querying the domain registrar's database
Whois runs on TCP port 43
Whois is helpful in determining the Nameservers of a domain
Nameservers store all DNS related information
DNS:
Definition: is a protocol for resolving IP address to domain names
Purpose: a database or directory to map IPs to names
DNS Structure:
Resource Record
TTL: determines the Start of Authority records
Record Class
- Internet, Choas, Hesiod
DNS Records:
A: maps IP addresses to hostnames
PTR: Pointer maps hostnames to IP addresses
CNAME: maps alias hostnames to the domain . Every domain name have multiple aliases, these aliases are kept in CNAME file
MX: specifies for mail servers that accept emails
SOA: first in the zone file, it defines values for the zone such as serial number and expiration timeouts. There is only one SOA per zone
Reverse Lookup takes IP address and determines the sub domains and hostnames connected to the IP
Zone Transfer
- Zone Transfers are misconfigurations on the server. They should be ONLY enabled to a trusted IP
- when querying for zone transfer in a domain, it should return an error if configured properly. if returns the copy of the DNS database means the server is misconfigured
DNS Enumeration
- Concept:
Purpose:
Tools:
- NSlookup is a command line tool to query for the domain name
When enumerating a DNS MX record, keep in mind that the lowest the number the highest preferrable for mail services
The most common number is 5 and 10
Netblock is range of IP address
Autonomous System: is made of one or more net block ranges. Ex: ISPs have autonomous systems while small corporation have net blocks
ICMP Ping Sweeps: send requests to the hosts. if the hosts are alive, they send ICMP reply
Most of the new devices and machines nowadays turn off the ICMP pings for security purposes. Also, they are no longer reliable for checking live hosts
if Nmap runs ICMP scan from the same network, Nmap by default runs arp scan instead of ICMP. Diabling arp within the command will run the ICMP scan. --disable-arp-ping or --ip-scan
DNS ports are TCP 53 and UDP 53
Three way Handshake:
Header contains:
Sequence Number
Acknowledgment Number
SYN and ACK flags
Step 1: the client sens a request packet with SYN flag and set a random sequence number
Step 2: The server responses with a response packet set with SYN and ACK flags, along with random sequence number. Ack number is plus one of the sequence number of the SYN packet
Step 3: When the synchronization is done, the client sends an acknowledgment packet to announce the end of the connection
TPC/IP vs UDP: TCP is a reliable protocol as it relies on confirmation of packet receiving. While with UDP protocol confirmation is not essential
Port 0 is reserved for TCP and 1 for UDP
Ports Status:
OPEN: SYN-ACK: means the port is open
Close:
Filtered: the status is not clear as there is firewall rules that prevents the accurate results
HPING:
Hping is crafting packet tool designed to send customized packet to the target machine
SA flag indicated that the port is open
RA flag indicate that the port is close
Running ping sweep indicate an active scan on the network.
Scanning random ports, can appear as a normal TCP request
SYN scan is the best starting scan. It can perform half-open scan to know the port status of the machine
The SYN scan sends syn packet to open up the communication. if the response is SYN/ACK means the port is open and if RST the port is close
If no response was received, it means the port is close
-sT [TCP scan]: is a full TCP scan
UDP scanning is also important as there are services that run on UDP such DNS, SNMP, DHCP
UDP Scans are slow and difficult to coduct, but important as TCP scans
UDP scan process:
Step 1: send a query
Step 2: if the port is open a response query is sent back and if not ICMP packet is sent instead
Step 3: ICMP is sent to close the communication
Idle scanning or Zombie scanning : is a device on the network that does not send or receive packets on the network
Zombie scanning pre-requisites:
The host should not send or receive traffic that might mess with IP ID number
Finding a zombie device, is looking for a host that increases the IP ID incrementally
Identifying Zombie host can be done by using nmap OS scan with verbose switch to see if the host sends incremental IP IDs. Seeing incremental IDs by 1 means that the host does not send or receive packets
if the port is open, the zombie host increments the IP ID by 2, and if port is close. the host increments the IP ID by 1
When using nmap to perform Idle scanning (zombie), make sure to pick an open port on the zombie host
The purpose of zombie scan is (hiding the original IP address of the scan). The target machine will the IP address of the zombie machine and not the original scan source. (stealthy scanning)
TCP packets are tagged with 6 flags:
SYN
PUSH
ACK
RST
FIN
URG
Null, XMAS, FIN scans exploits the loophole on TCP connection to differentiate between open or closed ports
Banner grabbing is scanning technique to identify the running services on the host machine
Banner Grabbing Tools: NETCAT, TELNET
Firewall Evasion Techniques:
Fragmentation: fragment the packet to bypass the firewall
Decoy : sending a large amount of traffic from different spoofed IP addresses for evasion
In order of the decoy to work, all the decoys should be up and running
They should be set randomly otherwise they can be detectable
Timing : this technique uses timing mechanism in order to slow down the scan
T1: Paranoid
T2: Sneaky
T3: Polite
T4 : Aggressive
T5 : Insance
Source Ports: The purpose of this technique is exploiting poor firewall protection by directing traffic use one of the allowed ports
NetBIOS: is a service that allows different systems to communicate over LAN. The communication is in a form of share files, printers , folders and remote procedure calls [Network Basic Input Output System]
NetBIOS ports : UDP 137, 138 | TCP 139
NetBIOS Enumeration
SNMP : Simple Network Management Protocol is a protocol for exchanging management information between network devices
In SNMP protocol, there is a manager and agents. The agents either wait for information from the manager or send traps to to the manager. Traps are critical information about the network devices status
SNMP Commands:
Read : monitoring the network devices
Write: configure the network devices
Trap: is used to send events information to the monitoring system
Traversal Operation: determined variables a specific device support
SNMP receives a general message on UDP 161 and a trap on 162
SNMP community string : public and private
Public : for reading only
Private : allows access to write rights
SNMP community string is a form secure authentication in SNMP
SMB: Server Message Block is a protocol for sharing files and folders
MIBs [Managment Information Base] is a collection of definitions which define properties of the managed objects on the device. It is a database of information
SNMP attacks:
Flooding the network through initiating DOS attack
Community : Use default community strings
Brute force: using a tool to brute force to guess the community string in order to gain access to the system
SNMP v1 and v2 use clear text communication. While SNMP v3 use some sort of encryption but still consider vulnerable
Wireshark is a network packet analysis tool.
Sniffing packets is not allowed If the network is protected. In other words, wireshark cannot be used to analyze the
packets if there are filters show only traffic generated from your machine Only
Hub propagate signals to all ports instead of one specific port. It operates on Layer 1
Switch operates on layer 2 . Packets are forwarded to a specific destination
Promiscuous Mode is receiving and handling all the packets on the segment regardless the MAC address
Sniffing Action :
Active Sniffing: Injecting packets
MAC Flooding : flooding the CAM table of a switch to redirect the packets. CAM table [Content Address Memory Table ] is a table contains port number, MAC address and TTL
ARP Poisoning : stealthy technique more covert than MAC flooding, it is commonly used in Man-In-Middle attack. The process mainly depends on redirecting traffic of the target machine to the attacker machine
Passive Sniffing : Wireshark
ARP : Address Resolution Protocol matches IP address (layer 3) with MAC address (layer 2)
ARP has two types of packets, ARP request and ARP reply
Gratuitous ARP request
Gratuitous ARP reply
ARP Poisoning : works on the poisoning the cache of the host machines in the network
There are two types of ARP poisoning :
Host Poisoning : sending ARP replies to both parts of the communication
Gateway Poisoning : Sending ARP replies as the default gateway of the network
Denial of Service can occur of the attacker machine forwards packets slowly
ARP poisoning is a type of attack in which a malicious actor sends falsified ARP (Address Resolution Protocol) messages over a local area network. This results in the linking of an attacker’s MAC address with the IP address of a legitimate computer or server on the network. Once the attacker’s MAC address is connected to an authentic IP address, the attacker will begin receiving any data that is intended for that IP address
DHCP is a UDP based protocol for assigning IP addresses dynamically .
When a new device enters the network, it sends DHCP discovery packet on UDP 67
DHCP Spoofing: is intercepting the traffic by pretending to be a DHCP server with longer lease time. During the spoofing, the attacker machine broadcasts a DHCPOFFER packet on the network, to fool hosts on the network thinking the server is the default gateway. once the client is connected, the traffic will go through the rogue DHCP server first, then the real gateway
ACL is a table that tells a computer operating system which access rights each user has to a particular system object, such as a file directory or individual file
Exploitation is act of take advantage of a vulnerability in the system
Most exploits are divided by :
Client side exploits
Remote Exploits
Local Privilege Exploits Escalation
Metasploit is an exploitation framework
Windows Authentication Protocols :
LM
NTLM
NTLMv2
Kerbros
Client-side exploit requires some type of user interaction such as: clicking a link, opening a file, etc.
Client-side exploits can be installed applications, browser plugins,emails
Remote Procedure Call: When a computer program calls a function or routine to execute in another computer on the shared network
There are two types of privilege escalation :
Vertical : is moving from lower privileged user to a root or administrator
Horizontal : gaining access to another user of the same level of privilege
In order to keep the session alive, migration to a different process will keep the connection open
It is important to note that the migration into another process has the same level of privileges as the current session
Migration to another process happens first thing after the exploitation for keeping persistent connection with the compromised machine
UAC: User Access Control is a security technique used by Windows to prevent automatic execution of programs. This technique allows the user to have the ability whether to execute it or not.
UAC is enabled in Windows Vista and above by default. XP is the only OS is not enabled by default
Linux Privilege Escalation can be either through uploading the exploit and compiling on the target machine or compile the exploit on the attacker machine then upload it to the target machine.
When compiling the exploit consider the architecture of the targeted system in order for the exploit to work
Privilege escalation can be accomplish through exploiting :
OS vulnerabilites
Cracking the root/admin credentials
Injecting the DLL or replaced with malicious ones
Manipulating processes that have high level access
Land Attack: works by sending a packet ti a vulnerable system, set with the source and destination IP address of the vulnerable system. This type of attack creates Denial of Service condition