Modul MTCSE
Modul MTCSE
Modul MTCSE
(MTCSE)
Riga, Latvia
March 7 - March 8, 2019
Schedule
KEY : MikroTikLab
AP
R1 R2 Rn
Wireless-Link
Ether-Link
Module 1
INTRODUCTION
What Security is all about?
NORMAL FLOW
Information Information
source destination
Security Threats / Attacks
INTERRUPTION
Information Information
source destination
INTERCEPTION
Information Information
source destination
Attacker
“an unauthorized 3rd party has gained access to an object, such as stealing
data, overhearing another's communication, etc.”
Security Threats / Attacks
MODIFICATION
Information Information
source destination
Attacker
FABRICATION
Information Information
source destination
Attacker
“additional data or activities are generated that would normally not exist, such
as adding a password to a system, replaying previously sent messages, etc.”
Threat / Attack Types
Interruption
Active Attacks /
Modification
Threats
Passive Attacks /
Interception
Threats
Security Mechanisms
Botnet
“Collection of software robots, or 'bots', that creates
an army of infected computers (known as ‘zombies') that are
remotely controlled by the originator”
What it can do :
• Send spam emails with viruses attached.
• Spread all types of malware.
• Can use your computer as part of a denial of service
attack against other systems.
Common Security Threats
What it can do :
• The most common and obvious type of DDoS attack occurs
when an attacker “floods” a network with useless
information.
• The flood of incoming messages to the target system
essentially forces it to shut down, thereby denying access to
legitimate users.
Common Security Threats
Hacking
“Hacking is a term used to describe actions taken by
someone to gain unauthorised access to a computer.”
What it can do :
• Find weaknesses (or pre-existing bugs) in your security
settings and exploit them in order to access your devices.
• Install a Trojan horse, providing a back door for hackers to
enter and search for your information.
Common Security Threats
Malware
“Malware is one of the more common ways to
infiltrate or damage your computer, it’s software that infects
your computer, such as computer viruses, worms, Trojan
horses, spyware, and adware.”
What it can do :
• Intimidate you with scareware, which is usually a pop-up message that
tells you your computer has a security problem or other false information.
• Reformat the hard drive of your computer causing you to lose all your
information.
• Alter or delete files.
• Steal sensitive information.
• Send emails on your behalf.
• Take control of your computer and all the software running on it.
Common Security Threats
Phishing
“Phishing is used most often by cyber criminals because
it's easy to execute and can produce the results they're looking for
with very little effort.”
What it can do :
• Trick you into giving them information by asking you to update,
validate or confirm your account. It is often presented in a
manner than seems official and intimidating, to encourage you to
take action.
• Provides cyber criminals with your username and passwords so
that they can access your accounts (your online bank account,
shopping accounts, etc.) and steal your credit card numbers.
Common Security Threats
Ransomware
“Ransomware is a type of malware that restricts
access to your computer or your files and displays a message
that demands payment in order for the restriction to be
removed.”
What it can do :
• Lockscreen ransomware: displays an image that prevents
you from accessing your computer.
• Encryption ransomware: encrypts files on your system's
hard drive and sometimes on shared network drives, USB
drives, external hard drives, and even some cloud storage
drives, preventing you from opening them.
Common Security Threats
Spam
“Spam is one of the more common methods of both
sending information out and collecting it from unsuspecting
people.”
What it can do :
• Annoy you with unwanted junk mail.
• Create a burden for communications service providers and
businesses to filter electronic messages.
• Phish for your information by tricking you into following links or
entering details with too-good-to-be-true offers and promotions.
• Provide a vehicle for malware, scams, fraud and threats to your
privacy.
Common Security Threats
Spoofing
“This technique is often used in conjunction with
phishing in an attempt to steal your information.”
What it can do :
• Sends spam using your email address, or a variation of
your email address, to your contact list.
• Recreates websites that closely resemble the authentic
site. This could be a financial institution or other site that
requires login or other personal information.
Common Security Threats
What it can do :
• Collect information about you without you knowing about it and
give it to third parties.
• Send your usernames, passwords, surfing habits, list of
applications you've downloaded, settings, and even the version
of your operating system to third parties.
• Change the way your computer runs without your knowledge.
• Take you to unwanted sites or inundate you with uncontrollable
pop-up ads.
Common Security Threats
Trojan Horses
“A malicious program that is disguised as, or embedded
within, legitimate software. It is an executable file that will install
itself and run automatically once it's downloaded.”
What it can do :
• Delete your files.
• Use your computer to hack other computers.
• Watch you through your web cam.
• Log your keystrokes (such as a credit card number you entered
in an online purchase).
• Record usernames, passwords and other personal information.
Common Security Threats
Virus
“Malicious computer programs that are often sent as an
email attachment or a download with the intent of infecting your
computer.”
What it can do :
• Send spam.
• Provide criminals with access to your computer and contact lists.
• Scan and find personal information like passwords on your
computer.
• Hijack your web browser.
• Disable your security settings.
• Display unwanted ads.
Common Security Threats
Worm
“A worm, unlike a virus, goes to work on its own
without attaching itself to files or programs. It lives in your
computer memory, doesn't damage or alter the hard drive and
propagates by sending itself to other computers in a network.”
What it can do :
• Spread to everyone in your contact list.
• Cause a tremendous amount of damage by shutting down
parts of the Internet, wreaking havoc on an internal network
and costing companies enormous amounts of lost revenue.
ROUTEROS
SECURITY
DEPLOYMENT
MikroTik as a Global Firewall Router
DATA CENTER
OFFICE
INTERNET
GUEST
MikroTik as a Global Firewall Router
Pro's
• Simple topology
• Easy to manage
Con's
• Single-point-of-failure
• Demands high resources
MikroTik as a Specific Router Firewall
DATA CENTER
OFFICE
INTERNET
GUEST
MikroTik as a Specific Router Firewall
Pro's
• Less resource consumption on each router
• Only focusing security firewall on each network
Con's
• Different network segment, different treatment
• Need to configure firewall differently on each router
• Possible to configure double firewall rules on one
another's routers
MikroTik as an IPS
DATA CENTER
OFFICE
INTERNET
GUEST
MikroTik as an IPS
Pros
• Clean firewall configuration on router, because all
firewall configuration already defined on an IPS (Intrusion
Prevention System) router
Cons
• A lot of resources will be needed to use RouterOS as an
IPS
MikroTik with IDS as a trigger
DATA CENTER
OFFICE
INTERNET
GUEST
IDS SERVER
MikroTik with IDS as a trigger
Pro's
• All firewall rules are made automatically by API from IDS
(Intrusion Detection System) server
Con's
• Additional device is needed to be triggered by the "bad"
traffic
• A powerful device is needed for mirroring all traffic from
networks
• Need special scripting for sending information to router
• Expensive
Module 2
FIREWALL
STATEFUL
FIREWALL
Stateful firewall
/interface ethernet
set [ find default-name=ether1 ] comment="To Internet" name=ether1-internet
set [ find default-name=ether2 ] comment="To Lan" name=ether2-Lan
/ip pool
add name=dhcp_pool0 ranges=192.168.11.2-192.168.11.254
/ip dhcp-server
add address-pool=dhcp_pool0 disabled=no interface=ether2-Lan name=dhcp1
Lab. ICMP tracking
/ip address
add address=192.168.11.1/24 interface=ether2-Lan network=192.168.11.0
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=ether1-internet
/system identity
set name=R1
Lab. ICMP tracking
Lab. ICMP tracking
Lab. ICMP tracking
/interface bridge
add fast-forward=no name=Lan
/interface ethernet
set [ find default-name=ether1 ] name=E1-ToInternet
/interface list
add name=WAN
add name=LAN
Lab. Securing areas
/ip pool
add name=dhcp_pool0 ranges=192.168.188.2-192.168.188.254
/ip dhcp-server
add address-pool=dhcp_pool0 disabled=no interface=Lan name=dhcp1
/ip address
add address=192.168.188.1/24 interface=Lan network=192.168.188.0
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=E1-ToInternet
/system identity
set name=R1
PACKET
FLOW
Packet flow
Packet flow
Packet flow
Packet flow
Packet flow
RAW
TABLE
RouterOS Default Configuration
• RAW table offer two chains - prerouting and
output
• The function of the RAW table is to process
the packets before the connection tracking,
significantly reducing load on CPU
• This is much more efficient.
RAW table chains
RAW table
RAW table. Drop packets
RAW table. Drop packets
RAW table. SYN flood attack
Please note the values of 1-500 are nominal and might need to be adjusted to allow legitmate
traffic to your site. The use of a whitelist could also be included with these rules
RAW table. TCP SACK Panic attack
/interface ethernet
set [ find default-name=ether1 ] name=E1-ToBridge
/ip address
add address=192.168.100.1/30 interface=E1-ToBridge
network=192.168.100.0
Lab. Only PPPoE Traffic
/interface pppoe-server server
add disabled=no interface=E1-ToBridge
/ppp secret
add local-address=10.100.100.1 name=test password=test \
remote-address=10.200.200.2 service=pppoe
/system identity
set name=R1
Lab. Only PPPoE Traffic
/interface ethernet
set [ find default-name=ether1 ] name=E1-ToBridge
/interface pppoe-client
add disabled=no interface=E1-ToBridge name=test password=test \
user=test
/ip address
add address=192.168.100.2/30 interface=E1-ToBridge \
network=192.168.100.0
Bridge Setup
/interface bridge
add name=bridge1
/interface ethernet
set [ find default-name=ether2 ] name=E2-ToR1
set [ find default-name=ether3 ] name=E3-ToR3
/system identity
set name=Bridge
ICMP FILTERING
What is ICMP Filtering
• Server IP – the IP server, the name of which will send the answer
the DHCP (xxx.xxx.xxx.xxx);
• Start IP – initiaIP, , issued to customers -address address range
(xxx.xxx.xxx.xxx);
• End IP – IP , issued to customers -address address range
(xxx.xxx.xxx.xxx);
• Time The Lease (secs) – The time in seconds for which the
address is given
• Time The Renew (secs) – The time in seconds how many clients
must renew the address lease
• Subnet Mask – Subnet mask for the clients (xxx.xxx.xxx.xxx);
• Router – router address issued to clients (xxx.xxx.xxx.xxx ,the
address of a fake router);
• DNS Server – DNS server provided to clients (xxx.xxx.xxx.xxx ,the
address of a fake DNS server);
• The Domain – a domain name in the local area network ( abc.def );
Preventing Rogue DHCP
• Enable DHCP Snooping on the switch
• Make port facing router as DHCP Snooping Trusted
• Binding Address and MAC for known clients
• RouterOS DHCP alert is ONLY sending information, not
stopping or preventing an attack.
DHCP Snooping enabled
https://wiki.mikrotik.com/wiki/Manual:Interface/Bridge#DHCP_Snooping_and_DHCP_Option_82
TCP SYN Attack
SYN
SYN-ACK
• These rules are stopping the tcp SYN attack, but still
affecting the CPU resources. (need more powerful router
for preventing)
UDP Flood Attack
• Certificate authority
• The trusted third party
• Trusted by both the owner of the certificate and the party
relying upon the certificate.
• Validation authority
• Registration authority
• For big CAs, a separate RA might be necessary to take some
work off the CA
• Identity verification and registration of the entity applying for a
certificate
• Central directory
CERTIFICATES
Certificates
• Public key certificates bind public key values to subjects
• A trusted certificate authority (CA) verifies the subject’s
identity and digitally sign each certificate
• Validates
• Has a limited valid lifetime
• Can be used using untrusted communications and can
be cached in unsecured storage
• Because client can independently check the certificate’s
signature
• Certificate is NOT equal to signature
• It is implemented using signature
• Certificates are static
• If there are changes, it has to be re-issued
Digital Certificates
• Certificate examples :
• X509 (standard)
• PGP (Pretty Good Privacy)
• Certificate Authority (CA) creates and digitally signs certificates
• To obtain a digital certificate, Alice must :
• Make a certificate signing request to the CA
• CA returns Alice’s digital certificate, cryptographically
binding her identity to public key :
• CertA = {IDA, KA_PUB, info, SigCA(IDA,KA_PUB,info)}
https://www.sslforfree.com
SSL For Free
SSL For Free
SSL For Free
Free of Charge Valid Certificates
“System > Certificate”: import both the “certificate.crt” and the “private.key”
Free of Charge Valid Certificates
Module 5
SECURING THE
ROUTER
PORT KNOCKING
What is Port Knocking
NB: Obscurity is not security - you should also use firewall rules
TUNNELING
THROUGH SSH
What is an SSH Tunnel
INTERNET
R1
L2TP/IPsec
Setup L2TP/IPsec Server
tcp connection
ssl negotiation
IP binding
SSTP tunnel
How the SSTP works
INTERNET
R1
SSTP
Self-signed Certificate
sstp
SSTP Server
Setup SSTP Client
Setup SSTP Client
Setup SSTP Client
IPsec
What is IPsec
Confidentiality
• By encrypting data
Integrity
• Routers at each end of a tunnel calculate the checksum or
hash value of the data
Authentication
• Signatures and certificates
• All these while still maintaining the ability to route through
existing IP Networks
The Benefits of IPsec
Key management
• IKE – session negotiation and establishment
• Sessions are rekeyed or deleted automatically
• Secret keys are securely established and authenticated
• Remote peer is authenticated through varying options
IPsec Modes
Transport Mode
• IPsec header is inserted into the IP packet
• No new packet is created
• Works well in networks where increasing a packet’s size could
cause an issue
• Frequently used for remote-access VPNs
IPsec Modes
Tunnel Mode
• Entire IP packet is encrypted and becomes the data component of a
new (and larger) IP packet.
• Frequently used in an IPsec site-to-site VPN
IPsec Architecture
Authentication Header (AH)
ESP Header : Comes before the encrypted data and its placement depends on
: whether ESP is used in transport mode or tunnel mode.
ESP Auth Data : This field contains an Integrity Check Value (ICV), computed
: in a manner similar to how the AH protocol works, for
: when ESP's optional authentication feature is used.
Encapsulating Security Payload (ESP)
• Uses IP protocol 50
• Provides all that is offered by AH, plus data confidentiality
• It uses symmetric key encryption
• Must encrypt and/or authenticate in each packet
• Encryption occurs before authentication
• Authentication is applied to data in the IPsec header as well
as the data contained as payload
Encapsulating Security Payload (ESP)
Encryption :
DES : 56-bit DES-CBC encryption algorithm;
3DES : 168-bit DES encryption algorithm;
AES : 128, 192 and 256-bit key AES-CBC encryption algorithm;
Blowfish : added since v4.5
Twofish : added since v4.5
Camellia : 128, 192 and 256-bit key Camellia encryption algorithm
: added since v4.5
Internet Key Exchanger (IKE)
The Internet Key Exchange (IKE) is a protocol that provides
authenticated keying material for Internet Security Association and Key
Management Protocol (ISAKMP) framework. There are other key
exchange schemes that work with ISAKMP, but IKE is the most widely
used one. Together they provide means for authentication of hosts and
automatic management of security associations (SA).
• “An IPsec component used for performing mutual authentication and
establishing and maintaining Security Associations.” (RFC 5996)
• Typically used for establishing IPSec sessions
• A key exchange mechanism
• Five variations of an IKE negotiation:
• Two modes (aggressive and main modes)
• Three authentication methods (pre-shared, public key encryption, and
public key signature)
• Uses UDP port 500
IKE Mode
Internet Key Exchanger (IKE)
Phase I
• Establish a secure channel (ISAKMP SA)
• Using either main mode or aggressive mode
• Authenticate computer identity using certificates or pre-shared
secret
Phase II
• Establishes a secure channel between computers intended for the
transmission of data (IPsec SA)
• Using quick mode
Internet Key Exchanger (IKE)
IKE Phase 1 (Main Mode)
R1 R2
– Public Address : – Public Address :
11.11.11.2/24 22.22.22.2/24
– Local Address : – Local Address :
192.168.1.0/24 192.168.2.0/24
Lab Setup
INTERNET
R1 R2
IPsec
Setup IPsec R1
/ip address
add address=11.11.11.2/24 interface=ether1-to-internet network=11.11.11.0
add address=192.168.1.1/24 interface=ether2-to-local network=192.168.1.0
Setup IPsec R1
/ip address
add address=22.22.22.2/24 interface=ether1-to-internet network=22.22.22.0
add address=192.168.2.1/24 interface=ether2-to-local network=192.168.2.0
Setup IPsec R2
Thank you
José Manuel Román Fernández Checa
and
Fajar Nugroho
for creating and sharing the initial version
of the MTCSE course materials.