Thursday, August 7, 2014

fortigate connectivity diagnostic steps

A doctor who looks at a patient has to perform some diagnostics and probably in a certain order.


The same applies with a fortigate firewall.  Here's a  few tips on that order;


1: Validate the Routing table 


Yes, sounds stupid but a lot of person fail to do just this. You can use any of the following;

ping ( not ideal due to they could be blocked )
traceroute ( more ideal but any path on the trace could fail to respond )

NOTE: This also validates the interfaces and next-hop gateways are up.

2:  Conduct a packet sniffer  ( diag sniffer packet )


Simple do you see traffic matching the 2 objects ( SRC & DST address )? You can do this from the command line on most fortigates and depending on OS version  from  the WebGUI.
 
3: diag debug flow


Almost always you want to conduct a simple diagnostic debug flow. This will validate the fwpolicy and traffic matching the policy ID
reference one of my earlier posts; http://socpuppet.blogspot.com/2013/03/flow-diagnostic-fortigate.html
  The above 3 tips, will save a lot of time and provide a quicker resolution imho.


 Ken Felix
 Freelance Network & Security Engineer
 kfelix -a--t- socpuppets ---d--o--t--- com

   ^      ^
=( !   ! )=
       o 
      /  \

Using ip sla and eem for tracking a route

In ths post we will  look at a means for tracking a default route learned by ospf and generation of a syslog alert for when  the route disappears

The cisco EEM and IP SLA are being together to clear our route-table. In the core network, we have 2 exits one path being preferred by ospf-metrics


1st we write a simple IP SLA ,  this is the heart of our check ;

!
ip sla 200
 icmp-echo 10.10.11.254
 frequency 3
 timeout 600
 threshold 100

!

Next we active it & set a track ;

!
ip sla schedule 200 start-time now life forever
!
track  200 ip sla 200
!

Finally we build a  cisco eem applet that will generates a log msg if the gateway is lost;

!
event manager applet Default_Gone
 event track 200 state any
 action 1.0 syslog msg "ping to outside gw has died, ospf-neighbor is probably gone or down"
!


You can use other  action  items like reset the router ospf or clear ospf neighbor or install  another path route.

Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( #  # )=
      @
      /   \


How to use tshark to determine how much logging for a remote syslog server

In this example, I will demo a few tricks for determining syslog traffic rates. Why would you do  this? For a few reasons, to determine how much bandwidth is actually being used for logging and how much data is being sent. This helps in capacity planning for data storage and any bandwidth usage concerns.


To do this, we need to use tshark with the -z and io stats options. You will need to determine your IO sampler rate interval for measurements and you can get creative and set various display filters for for filtering ;  log facility or levels & even the log messages content.

example 1; let's look at how much log traffic is being collected for this particular syslog server over a 60 secs  duration and with 5 second intervals.


tshark -a duration:60 -q -z io,stat,5 -R syslog port 514

This breaks down to ;

run  tshark for 60secs
operate in quiet mode & display nothing till we finish
used io,stats collection in 5 secs intervals
only for syslog  services
and port 514 


The above would generate  output showing the bytes  and pps ( frames )  for the 5 seconds intervals;

( sample output )
 ===================================================================
IO Statistics
Interval: 5.000 secs
Column #0:
                |   Column #0  
Time            |frames|  bytes
000.000-005.000       12      1407
005.000-010.000       22      1856
010.000-015.000       9       1428
015.000-020.000       0         0
020.000-025.000       0         0
025.000-030.000       0         0
030.000-035.000       8       980
035.000-040.000       0         0
040.000-045.000       7      1240
045.000-050.000       8       1579
===================================================================



example 2; let's look at how much log traffic is being collected on this syslog server  and over 60 secs and with 5 second intervals, but this time we will apply a display filter to look for a certain message

 tshark -a duration:60  -q -z io,stats,5  -R 'syslog.msg contains FE-3KD3R11000037' port 514


The above tshark cli strings will show me how much logging is present from my fortimail server with serial#  FE-3KD3R11000037  & over 60secs within 5sec interval.

 ( sample output )
===================================================================
IO Statistics
Interval: 5.000 secs
Column #0:
                |   Column #0   
Time            |frames|  bytes 
000.000-005.000       1       442
005.000-010.000       0         0
010.000-015.000       6      2239
015.000-020.000       6      2273
020.000-025.000       2       700
025.000-030.000       2       842
030.000-035.000       1       428
035.000-040.000       3       798
040.000-045.000      13      3841
045.000-050.000       1       434
===================================================================


example 3; let's look at doing the same but now we want to know a certain facility and how much traffic for that syslog facility

You can use the following for determining the facility #;
http://en.wikipedia.org/wiki/Syslog#Facility_levels


tshark -a duration:60  -R  'syslog.facility==19' -q -z io,stat,5 port 514

( sample output )
===================================================================
IO Statistics
Interval: 5.000 secs
Column #0:
                |   Column #0   
Time            |frames|  bytes 
000.000-005.000       28       4898
005.000-010.000       29       4388
010.000-015.000       0         0
015.000-020.000       0         0
020.000-025.000       14      3388
025.000-030.000       0         0
030.000-035.000       0         0
035.000-040.000       2       1697
===================================================================


example 4; let's look at doing the same but now we want to know a certain syslog  level and how much traffic for that syslog level  ( informational  ) and for  60secs with a 1 sec interval

 tshark -n -a duration:60  -R  'syslog.level==6' -qz io,stat,1  port 514

 ( sample output )
 ===================================================================
IO Statistics
Interval: 1.000 secs
Column #0:
                |   Column #0  
Time            |frames|  bytes
000.000-001.000       6      2224
001.000-002.000       1         234
002.000-003.000       1         239
003.000-004.000       0         0
004.000-005.000       0         0
005.000-006.000       0         0
006.000-007.000       0         0
007.000-008.000       0         0
008.000-009.000       0         0
009.000-010.000       0         0
010.000-011.000       0         0
011.000-012.000       1         239
012.000-013.000       0         0
013.000-014.000       0         0
014.000-015.000       0         0
015.000-016.000       2       378
016.000-017.000       10     2777
017.000-018.000       3      1158
018.000-019.000       1       427
( output shorten)



Final  example; let's get creative and measure traffic for a particular host and at  1sec interval for informational  and ssh2 request for src network 10.8.23

tshark -n -R '(syslog.level==5) and (syslog.msg contains SSH)' -q -z io,stat,1 -a duration:60  port 514

With  MS or other tools you can easily import the data collection based on your interval and types of syslog details to build  graphs similar to the below

( example ssh logging traffic graphic from one data center over 60seconds )





Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=(  !  ! )=
      @
      /   \

Wednesday, August 6, 2014

To count or not count cisco style

In this post we will look at the cisco count option. This command can be use with most show commands and does exactly what it  say? Count


Example 1, you want to get a count of how many down interfaces on a switch;

show int status | count notconnect
Number of lines which match regexp = 22

SW1#

Example 2, you need to get a count of how many username are defined in the configuration file;

SW1#show run | count username
Number of lines which match regexp = 4

SW1#

Example 3, how many down states for interface in the current log buffer  ( great btw for when  your in a ServiceProvider  Role and you manager ask how many things just went down )


SW1#show log |  count down|GigabitEthernet.*down
Number of lines which match regexp = 12

SW1#

NOTE: you could get creative and use date modifiers if per-se you are looking for down even at a certain time

SW1#show log | count  05:34.*GigabitEthernet.*down
Number of lines which match regexp = 2

SW1#

note: The above will show all gigabit ethernets interfaces that went down at  hour of 5:34. In a SP arena you would most like just do the following;


Example 4, counting down interfaces that happen during a time

SW1#show log | count  05:34.*down                
Number of lines which match regexp = 2

SW1#

note: This is a great method to get  the total devices down for incident reports or massive tickets and can be very helpful for ticket controls & with correct information


Example 5, you need to know the # of interfaces in a vlan and need to know how many interface are in that vlan.

SW1#show int status |  count  295 | exc Gi
Number of lines which match regexp = 48

SW1# 
 


Example 6, counting the number of port-channel interfaces

SW1#show run | cou interface.*Port-chann

Number of lines which match regexp = 8

SW1#


Counting in cisco IOS  has hundred of examples and options & is simple as 1-2-3, how you would use it, totally  depends on how creative you can get. 

So get out and start counting something  ;)


Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( #  # )=
      @
      /   \

More 5.2GA woes

Here's something in 5.2GA that a lot person are complaining about. Disk logging has been eliminated from most  SMB models. Here's a snippet from the release notes;




Okay that includes pretty much every  fortigate mode from a  20 to 100.   Now here's the funny part, they installed a disk for  most of these models, but you can't even use it.


So that's a waste of a 16GB SSD disk imho




So what I found very funny and strange; "the execute disk format command" still exists. And when you execute it; "the units hangs & requires a hard reboot"

Here's some screen shot of a FWF60D




And here's what the  fnsysctl output shows me





And  here's the execution of the format command



Upon execution of the above, the unit will halt & requires a hard power-cycle to recover. I really wish disk logging would come back and if they are going to eliminate it, they should eliminate the disk and the commands from the OS.

You can follow my  previous posting on 5.2GA woes here;

http://socpuppet.blogspot.com/2014/07/more-fortinet-fortios-52-ga-upgrades.html

Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( #  # )=
      @
      /   \

Tuesday, August 5, 2014

Meraki MX60W vrs Fortigate FWF60D

I'm a proud new owner of a MX60W model from Meraki.

I won  this device in a rally-auction and would like to compare it to a fortigate  FWW60D wireless model. Now keep in mind; "  the cheaper and low performing fortigates like a;  30 or 40 models, also out does the  Meraki MX60 "


I put together a table of comparative features that you might want to consider b4 buying one
 ( MX60 ).  I think your money could be better spent on a fortigate and you will gain a lot more


Now on the bright side of things, the reporting from the meraki is very superior. Actually it's superior to a fortigate imho.

Application awareness and fingerprinting looks very nice also. I hate that you need  a license to get any of these  features, but this is how cisco makes money.

With the low power usage and noise generation, this series of firewall is geared for installation  a sale kiosk inside of a mall or small storefront.

The pricing make the devices afford for most business, but you can do way better & cheaper with a sonicwall for example. Some of the features  might be over-kill for a soho or small-business


Who really need  IPS in a SOHO, or most advance security features?






Ken Felix
Security and Network  Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(    :  : )=
         o
      /     \



Saturday, August 2, 2014

How to write IPS signature to block email to user with a Fortigate

In this blog we will use a ascii text to hex creator,  and then build a IPS signature to block emails sent that contains the user email address. The ascii2hex creator will help with writing the rule.


1st here's a link to a simple online  ascii-2-hex creator.

http://www.rapidtables.com/convert/number/ascii-to-hex.htm

 2nd the user we craft will be  the following; kenfelix@socpuppets.com

Okay now that's out if the way, let look  at the steps.


1: the  email message will have the lines  for <username@domain.com> so for my  user above we will use the following;

for <kenfelix@socpuppets.com>

2: so that means in our ascii-2hex creator we will need to know the  hex values. Each ascii character will generatet a 2 value in hex.

3:So  the line  the for <kenfelix@socpuppets.com>  will create the following;

66 6f 72 20 3c 6b 65 6e 66 65 6c 69 78 40 73 6f 63 70 75 70 70 65 74 73 2e 63 6f 6d 3e


4: for writing the signature, we will need to remove the white spaces. This will result in the following below.


666f72203c6b656e66656c697840736f63707570706574732e636f6d3e

 5: now we write the signature with the match pattern being our hex string that we crafted with the ascii2hex creator.

config ips custom

 edit "EmailBlockKenfelix
        set signature "F-SBID( --attack_id 1183;  --revision 1; --name \"BlockMailKenFelix\"; --service SMTP; --protocol tcp; --tcp_flags A; --pattern |666f72203c6b656e66656c697840736f63707570706574732e636f6d3e| ; --no_case; --flow from_client;)"
    

end



So now you can build a IPS sensor and apply this custom signature within your  IPS sensor. Select the appropiate action ( block pass rest) and logging  to include or not include packet-log

You can get creative and write the same thing but block maybe emails from a particular sender 's email address.

e.g ( if the sender was kenfelix@socppupets.com )

The ascii  line to match would be from  <kenfelix@socpuppets.com> and hex values ;

66 72 6f 6d 20 20 3c 6b 65 6e 66 65 6c 69 78 40 73 6f 63 70 75 70 70 65 74 73 2e 63 6f 6d 3e




note: you can use the unix  command od as alternative.

e.g echo -n "from  <kenfelix@socpuppets.com>" | od -t x1 -A n




keypoints to take away

  • writings IPS signatures for fortigates firewalls, requires creative thinking
  • you can block on the To: recipient or/and Copied recipients
  • this rule would be ineffective for SMTP/S connections
  • try to write rules to be efficient ( match on the following; TCpflag, offset/depth, specifics for the pattern )


Ken Felix
Security and Network  Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(   -   - )=
         o
      /     \