Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sred:laborator_2._cbac_and_zbf [2020/11/06 23:07]
horia.stoenescu [Exercies]
sred:laborator_2._cbac_and_zbf [2022/10/30 20:53] (current)
horia.stoenescu Added pointers for exercises
Line 4: Line 4:
  
 === Story === === Story ===
-In our basic topology scenario, due to small budget our company still uses the old Cisco equipment for routing and filtering, but this time the second branch closed and added instead a visitor network (may be used by people that come at interview). After seeing some attacks done in our internal network like DoS, we decided to test different approaches: started with TCP intercept, continuing with CBAC and in the end implemented successfully ​the better security solution - zone based firewall (ZBF).+In our basic topology scenario, due to small budget our company still uses the old Cisco equipment for routing and filtering, but this time the second branch closed and added instead a visitor network (may be used by people that come at interview). After seeing some attacks done in our internal network like DoS, we decided to test different approaches: started with TCP intercept, continuing with CBAC and in the end implemented successfully ​better security solution - zone based firewall (ZBF)
 + 
 +<note tip> 
 +[[https://​curs.upb.ro/​2022/​pluginfile.php/​346995/​mod_resource/​content/​1/​sred_lab2_stateful_firewall_updated.pdf|Here]] you can find the presentation for lab2. There are made comparisons between each feature and what is the road from simple ACLs to a basic firewall solution. 
 +</​note>​ 
 + 
 +=== Local host prerequisites === 
 +If you have a Windows/​MacOS machine, you need to install on it [[https://​www.realvnc.com/​en/​connect/​download/​viewer/​windows/​|vnc viewer]] to access the Linux/​Firewall machines and [[https://​www.chiark.greenend.org.uk/​~sgtatham/​putty/​latest.html|putty]] for Cisco routers/​switches.  
 +You can also check this client side pack from Eve-ng for [[https://​www.eve-ng.net/​index.php/​download/#​DL-WIN|Windows]] and [[https://​www.eve-ng.net/​index.php/​download/#​DL-OSX|MacOS]]. 
 + 
 +For Linux OS, you can use Remmina or Remote Desktop Viewer (both should be already installed). Check this link also: [[https://​remmina.org/​how-to-install-remmina/​|Remmina install]].
  
 === Lab infra === === Lab infra ===
Line 12: Line 22:
  
 You have to do the following: You have to do the following:
 +
 +- create a new node for the attacker (see [[https://​ocw.cs.pub.ro/​courses/​sred/​setup_lab_remote#​create_a_new_node|here]] a tutorial), remove connection router - client2 and attach this new machine
  
 - add IPs for network between the server and the network equipment (use range 1.1.1.0/24) - add IPs for network between the server and the network equipment (use range 1.1.1.0/24)
Line 29: Line 41:
 **server** and **client1** - eve:eve (with sudo access) **server** and **client1** - eve:eve (with sudo access)
  
-**cisco_7200** - enable ​passwd: cisco +**cisco_7200** - no enable ​password added
- +
-**Mapping ip-student**:​ check your machine ip [[https://​curs.upb.ro/​mod/​url/​view.php?​id=84844|here]]+
 </​note>​ </​note>​
  
 ==== Stateful firewall implementations ==== ==== Stateful firewall implementations ====
  
-=== 1. TCP intercept ===+=== t1. TCP intercept ===
 This first scenario is just for getting used to [[https://​www.paloaltonetworks.com/​cyberpedia/​what-is-a-denial-of-service-attack-dos|DoS]] attacks in our topology and hping3 command. Suppose that an attacker (called Trudy) wants to make a server unavailable using a SYN flood attack (which is fairly easy to create). This is done by sending TCP segments with SYN flag and no intention to complete the handshake. The server hangs by waiting for these connections to be finished until the timeout expires, but creates problems with legitimate TCP connections which can be denied. ​ This first scenario is just for getting used to [[https://​www.paloaltonetworks.com/​cyberpedia/​what-is-a-denial-of-service-attack-dos|DoS]] attacks in our topology and hping3 command. Suppose that an attacker (called Trudy) wants to make a server unavailable using a SYN flood attack (which is fairly easy to create). This is done by sending TCP segments with SYN flag and no intention to complete the handshake. The server hangs by waiting for these connections to be finished until the timeout expires, but creates problems with legitimate TCP connections which can be denied. ​
  
Line 50: Line 60:
  
 - **watch**: the disadvantage of intercept is that most of the times the router does this mitm for fair clients and adds overhead. A solution can be watch mode, which is a reactive approach that is monitoring connections,​ keeping track of half-open ones. Again, after a timeout (default 30 seconds) if a connection is not completed, the router sends a RST to server to remove it. This will remove all unwanted incompleted connections and allows legitimate ones to complete. - **watch**: the disadvantage of intercept is that most of the times the router does this mitm for fair clients and adds overhead. A solution can be watch mode, which is a reactive approach that is monitoring connections,​ keeping track of half-open ones. Again, after a timeout (default 30 seconds) if a connection is not completed, the router sends a RST to server to remove it. This will remove all unwanted incompleted connections and allows legitimate ones to complete.
 +
 +If the high threshold value is exceeded, then the timeout is reduced by half (in default case, to 15 seconds). The connections have the state SYNSENT at start, then if the server responds with SYN-ACK the state is changed to SYNRCVD and firewall is waiting for client to send the ACK in order to finish the 3-way handshake.
  
 In this lab, we will use [[https://​linux.die.net/​man/​8/​hping3|hping3]] to simulate the attack. On server machine we have SimpleHTTPServer up and running on port 8080.  In this lab, we will use [[https://​linux.die.net/​man/​8/​hping3|hping3]] to simulate the attack. On server machine we have SimpleHTTPServer up and running on port 8080. 
Line 133: Line 145:
 </​code>​ </​code>​
  
-=== 2. CBAC ===+Example state watch-mode (with only 1 SYN packet sent from kali): 
 +<​code>​ 
 +# attacker sends 1 SYN packet to server on port 8080 
 +root@kali:# hping3 -n -c 1 -d 120 -S -w 64 -p 8080 1.1.1.2  
 +# at start, the connection is saved with SYNSENT 
 +Router#sh tcp intercept connections  
 +Incomplete:​ 
 +Client ​               Server ​               State    Create ​  ​Timeout ​ Mode 
 +3.3.3.2:​14482 ​        ​1.1.1.2:​8080 ​         SYNSENT ​ 00:00:00 00:00:30 W 
 +# then, the server responds with SYN+ACK and the connection is updated 
 +Router#sh tcp intercept connections 
 +Incomplete:​ 
 +Client ​               Server ​               State    Create ​  ​Timeout ​ Mode 
 +3.3.3.2:​1626 ​         1.1.1.2:​8080 ​         SYNRCVD ​ 00:00:03 00:00:26 W 
 +# at last, after the timeout, the connection is removed and a RST is sent to server 
 +Router#sh tcp intercept connections  
 +Incomplete:​ 
 +Client ​               Server ​               State    Create ​  ​Timeout ​ Mode 
 + 
 +</​code>​ 
 + 
 +<​note>​ 
 +Check [[http://​www.employees.org/​univercd/​Feb-1998/​CiscoCD/​cc/​td/​doc/​product/​software/​ios112/​intercpt.htm#​xtocid2436922|here]] for a full documentation regarding TCP intercept. 
 +</​note>​ 
 + 
 +<note important>​ 
 +Before continuing with CBAC and ZBF, head to [[https://​ocw.cs.pub.ro/​courses/​sred/​laborator_2._cbac_and_zbf#​exercies|exercises]] section and solve e1 and e2. 
 +</​note>​ 
 + 
 +=== t2. CBAC ===
 <note important>​ <note important>​
-Before ​continuing ​with CBAC, make sure to delete old tcp intercept configuration:​+Before ​starting ​with CBAC, make sure to delete old tcp intercept configuration:​
 <​code>​ <​code>​
 cisco_7200(config)#​no ip tcp intercept list cisco_7200(config)#​no ip tcp intercept list
Line 145: Line 186:
 CBAC stands for **Context-Based Access Control** and represents a feature of Cisco products that is used for verifying protocol of application layer and dynamic modification of firewall rules that are based on it.  CBAC stands for **Context-Based Access Control** and represents a feature of Cisco products that is used for verifying protocol of application layer and dynamic modification of firewall rules that are based on it. 
  
-Using this feature, the number of connections opened by outside machines can be limited (to stop a DoS attack). This task proposes to create a CBAC rule that is used for monitoring TCP connections and added on outbound interface to UbuntuVM ​(traffic to that machine). ​+Using this feature, the number of connections opened by outside machines can be limited (to stop a DoS attack). This task proposes to create a CBAC rule that is used for monitoring TCP connections and added on outbound interface to server ​(traffic to that machine). ​
  
 It provides 4 main functions: It provides 4 main functions:
Line 218: Line 259:
 </​note>​ </​note>​
  
-=== 3. ZBF ===+<note important>​ 
 +Before continuing with the last feature, ZBF, head to [[https://​ocw.cs.pub.ro/​courses/​sred/​laborator_2._cbac_and_zbf#​exercies|exercises]] section and solve e3 and e4. 
 +</​note>​ 
 + 
 +=== t3. ZBF ===
 A big drawback of the solution presented above is that it can become very complex when there is need to manage multiple interfaces. Also, it does not offer rules per host or network, all being bound to inbound or outbound traffic. **Zone based firewall** (or ZBF) is the next proposed security solution. ​ A big drawback of the solution presented above is that it can become very complex when there is need to manage multiple interfaces. Also, it does not offer rules per host or network, all being bound to inbound or outbound traffic. **Zone based firewall** (or ZBF) is the next proposed security solution. ​
  
Line 357: Line 402:
 Try to send a GET request to server. Does it work? Try to send a GET request to server. Does it work?
  
-=== 4. Extra ZBF ===+=== t4. Extra ZBF ===
  
 To allow access to DMZ for http (web servers) for VISITOR and LAN zones, there is need to create a class-map for matching only HTTP traffic and a policy-map to allow data inspection. To allow access to DMZ for http (web servers) for VISITOR and LAN zones, there is need to create a class-map for matching only HTTP traffic and a policy-map to allow data inspection.
Line 372: Line 417:
 cisco_7200(config-pmap)#​class HTTP-ONLY-CMAP cisco_7200(config-pmap)#​class HTTP-ONLY-CMAP
 cisco_7200(config-pmap-c)#​inspect ​ cisco_7200(config-pmap-c)#​inspect ​
 +</​code>​
 +
 +Remove the old policy-map from zone-pair VISITOR-TO-DMZ (1 can be attached per pair):
 +<​code>​
 +cisco_7200(config)#​zone-pair security VISITOR-TO-DMZ ​        
 +cisco_7200(config)#​no service-policy type inspect VISITOR-TO-DMZ-PMAP
 </​code>​ </​code>​
  
Line 448: Line 499:
 *Oct 30 17:​26:​44.711:​ %FW-2-BLOCK_HOST:​ (target:​class)-(VISITOR-TO-DMZ:​HTTP-ONLY-CMAP):​Blocking new TCP connections to host 1.1.1.2 for 1 minute (half-open count 4 exceeded). *Oct 30 17:​26:​44.711:​ %FW-2-BLOCK_HOST:​ (target:​class)-(VISITOR-TO-DMZ:​HTTP-ONLY-CMAP):​Blocking new TCP connections to host 1.1.1.2 for 1 minute (half-open count 4 exceeded).
 </​code>​ </​code>​
 +
 +<​note>​
 +Suppose we have in VISITOR area another user. After sending a DoS attack for kali to server, the access to host is blocked so no other users can access it (kali and the other one).
 +</​note>​
  
 ==== Exercies ==== ==== Exercies ====
Line 477: Line 532:
 </​code>​ </​code>​
  
-Open the connection (before all entries expire - in 15 secs) from client1, send some messages and check the connection from router:+Open the connection (before all entries expire - in 30 secs) from client1, send some messages and check the connection from router:
 <​code>​ <​code>​
 cisco_7200#​sh tcp intercept connections ​ cisco_7200#​sh tcp intercept connections ​
Line 490: Line 545:
  
 From server, check if it received client1'​s messages. From server, check if it received client1'​s messages.
 +
 +<​note>​
 +This IOS version is a bit buggy, as the timeout has firstly the default value to 0, then after some seconds (see the create time), is [15 seconds - create_time]. Then, after those 15 seconds passed, it is assigned with 15 seconds, so the total time is 30 seconds for keeping a connection.
 +</​note>​
  
 === e3. [2p] Back to business === === e3. [2p] Back to business ===
sred/laborator_2._cbac_and_zbf.1604696838.txt.gz · Last modified: 2020/11/06 23:07 by horia.stoenescu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0