Week4: MITM attacks

Explain what is ARP poisoning and how authors propose to detect it.

In ARP (Address resolution procotol) poisoning attacker sends forged ARP replies (false IP and mac address) to a victim. This way ARP cache is compromised and all traffic is redirected to attacker and he or she can read and even alter packages. Authors proposes method, in which all hosts in network has unique IP address based on host’s mac address. This way all packages can be verified and malicious ARP reply in cache can be identified and deleted.

Explain what kind of DNS security threats there are, and how presented S-DNS works?

Most common threat is cache poisoning attack. DNS messages are sent clear text and unauthenticated so queries can be sniffed and malicious data can be injected. Less feasible threat is DNS spoofing to gain injected records by attacker. S-DNS is proposed to decrease the probability of success of DNS spoofing and cache poisoning. Decreasing the success probability of DNS spoofing and cache poisoning by thwarting man-inthemiddle attacks and preventing them from gaining any advantage from intercepted DNS queries and replies. Method adds and additional resource records for query message and reply message with a private key generator. Method is supposed to be backward compatible.

Explain what is SSL/TLS protocol.

Secure Sockets Layer and Transport Layer Security are protocols in cryptography. They provide communications security in networks. They are being used in lots of applications like browsers, email and instant messaging. You might have heard of SSL certificates in securing data transfer between client and server when browsing the Web.

Explain what is SSL MITM attack and explain the main results of SSL/TLS vulnerability scanning in Japan.

SSL man-in-the-middle attack is exploiting renegotiation between server and client. This renegotiation is for updating for updating algorithm and key information accepted by both peers. Over 40% of japanese government servers are vulnerable against the SSL/TLS renegotation DOS attack and almos 37% of sites uses 1024bit or less RSA keys.

Read about ArpWatch and explain how it works.

Arpwatch is an open source computer software program that helps you to monitor Ethernet traffic activity (like Changing IP and MAC Addresses) on your network and maintains a database of ethernet/ip address pairings. It produces a log of noticed pairing of IP and MAC addresses information along with a timestamps, so you can carefully watch when the pairing activity appeared on the network. It also has the option to send reports via email to an network administrator when a pairing added or changed.

ARP cache script

You need to install Scapy first

Then let's import what we need from scapy.all import Ether, ARP, srp, sniff, conf

Then we need a function that given an IP address, it makes an ARP request and retrieves the real MAC address the that IP address:

def get_mac(ip):

""" Returns the MAC address of ip, if it is unable to find it for some reason, throws IndexError """

p = Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip)

result = srp(p, timeout=3, verbose=False)[0] return result[0][1].hwsrc

After that, the sniff() function that we gonna use, takes a callback (or function) to apply to each packet sniffed, let's define it:

def process(packet):

# if the packet is an ARP packet if packet.haslayer(ARP):

# if it is an ARP response (ARP reply) if packet[ARP].op == 2: try:

# get the real MAC address of the sender real_mac = get_mac(packet[ARP].psrc)

# get the MAC address from the packet sent to us response_mac = packet[ARP].hwsrc

# if they're different, definetely there is an attack if real_mac != response_mac: print(f"[!] You are under attack, REAL-MAC: {real_mac.upper()}, FAKE-MAC: {response_mac.upper()}") except IndexError:

# unable to find the real mac

# may be a fake IP or firewall is blocking packets pass

Playing with Yersinia

I installed yersinia on bob-vm: $ sudo apt-get install yersinia I checked bob-vm dhcp leases: $ cat /var/lib/dhcp/dhclient.enp0s3.leases I opened pfsense admin panel in alice-vm and navigated to Status -> DHCP Leases. Here I might see some action. I took a peek in yersinia’s help: $sudo yersinia -h I started yersinia in graphic mode: $sudo yersinia -G I navigated to DHCP-tab and clicked “Launch attack”. I selected “sending DISCOVER packet” and clicked OK. Almost immediately my hosts CPU usage went south. There were no new leases though. After waiting few minutes I navigated to Status->Dashboard to see how pfsense is reacting. CPU usage was constantly almost 100%. However network works quite well and pfsense stays alive. I stopped the attack after 20 minutes by clicking Exit on yersinia. Afterwards I checked pfsense’s logs and found out there were lots of DHCPDISCOVER’s from lots of different (spoofed) mac addresses.

Propose simple countermeasures against all MITM attacks explained in this tutorial.

ARP poisoning can be detected with matching mac and IP addresses. So I would use a spoofing detection tool. Against DNS spoofing there are at least few countermeasures. I would keep my resolver safe and private and enable DNSSEC to verify/sign requests. SSL MITM: I would use stronger encryption with good algorithm to secure my SSL connection. And if there is detected intrusion I would revoke all SSL certificates in that server and resign new ones. And of course every server has it’s own unique certificate, always. For DHCP spoofing I would setup a trusted DHCP server which only can process DHCP replies. And for extra of all above I would always secure my SSH. Restricting access to only an admin VLAN and using only keys with passphrases.

VPN stuff

Explain what is X.509 and its relation to Public Key Infrastructure (PKI).

X.509 is a cryptographic standard. It defines format of public key in public and private key -pair encryption. Public key can be validated with a certificate. PKCS7 is a PKI standard for X.509.

Why X.509 trust model is complex?

Current X.509 trust model has three entities: authority, holder and relying party. Here authority is the one which makes things complex. If there would be only one authority party relying party would be in direct contact with authority party situation would be different. And each authority has it’s own certificate management process. Public key infrastructure is the spice which makes this whole system complex. Explain how this paper tries to make it easier. The paper proposes model which has a role of certificate authority recommender. This way relaying parties has only one expert to rely on. Job of this expert is also to evaluate objectively certificate authorities.

Compare cryptography algorithms RSA and DSA. Which one is better? What are their pros and cons?

DSA and RSA are based on solving different difficult mathematical problems, namely discrete logarithms for DSA and integer factorization for RSA. Since neither of these problems have efficient solutions, the security of the algorithms is more or less equal.

DSA is faster in the signature generation phase, but slower in validation. Since validation usually happens way more often than generation, RSA wins in efficiency. To same extent, DSA is faster in encryption but slower in decryption, and since the same data may be decrypted multiple times, RSA wins again.

What is Diffie-Hellman key, what is its purpose in PKI?

Diffie–Hellman key exchange uses public and private keys to establish secure communications over a public channel. Communicating parties pick public and private keys. The public keys are shared between the parties and can be combined with each other's private keys to decipher a common secret. It is built in such a way that finding this common secret without the private keys is practically impossible, which is why communications encrypted with this secret are secure.

The PKI manages this encryption scheme via certificates, which assert public keys to identities.

What is HMAC signature, what is its purpose in PKI?

HMAC is a hash-based message authentication code. It is calculated with some cryptographic hash function using a secret key and a message. In PKI, HMAC is not used to encrypt the message itself, but instead to check its authenticity.

VPN tunnel

The main difference is obviously that data is encrypted. At Wireshark, packet capture shows that in the latter all communication has taken place through the VPN tunnel and the data transfer protocol is OpenVPN and within it UDP, while in the first TCP and HTTP protocol.

Image
Image
Image
Image

Configure OpenVPN server

Webser: do re-direct

echo 1 > /proc/sys/net/ipv4/ip_forward

Modify server.conf

/etc/openvpn/server.conf

Add line there:

push "redirect-gateway def1"

This makes all the traffic to go VPN tunnel.

Make webserver’s iptables so that packets from subnet 10.8.0.0/24 go to network interface enp0s3

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o enp0s3 -j MASQUERADE

GPG issues

Check for gpg help

$ gpg –help Generate private key

$ gpg –gen-key

I selected RSA and RSA keys, 2048bit, non-expiring keys and confirmed selections. I added “Alice” as real name, alice@wonderland.com as email and did not provide any comments. I confirmed these selections. Password I provided is “alice” for the sake of simplicity. Next I randomly typed keyboard and moved mouse to generate random bytes, then import key

$ gpg –keyserver keyserver.ubuntu.com –recv-keys B0B9D9E4

After this step I can see that correct key was imported. Let’s check fingerprint also:

$ gpg –fingerprint B0B9D9E4 And it matches. Next I signed imported key

$ gpg –sign-key B0B9D9E4 I checked once again values, confirmed and submitted my password.

After downloading files I verified their signatures:

$ gpg –verify leipajuusto.txt.asc

$ gpg –verify soccer.jpg.sig

$ gpg –verify backdoor.exe.sig It appears that soccer.jpg was not signed by Ties327 (no public key found).

Signature verification: Image

These are the current permissions for this document; please modify if needed. You can always modify these permissions from the manage page.