Sunday, February 1, 2015

Fortigate how to dumpsa information IPSEC

A cool command that's available from the cli  for IPSEC SA ids,   dumpsa

e.g

diag vpn   tunnel  dumpsa


Why this command is great, it only show you SA related details for all active tunnels. A simple command to get the SPI for in/out and  by  the defined phase2 configurations.


e.g ( if the ipsec tunnel is up  details similar to this will be present)


Pretty  & everything you need outside of packet tx/rcv and bytes sent/received has been provided.
  •    IPSEC-PH2  details
  •    SPI
  •    cipher type
  •    src/dst subnets
  •    phase2 name
  •    ipsec key-life 

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

    ^    ^
=( #  # )=
      @
      /   \

A secure simple radius password generation using openssl and gpg

Here's a bash-script that can be tweak'd  to generate various  radius passwords types.  When I first built this script many years back, my goals where to have a  hands-off password generator for dumping users accounts into a radius user db file.

1st here's the various types of  radius passwords that most radius servers supports.


We will generate a simple salted MD5 password  that would be applied to our  radius servers user_db using a salt. The script is an replacement for the local-user-shell and is launched in the user directory with a limited read/write/execute permissions.

For our radius password creator, we have a default ssh-login and I always like to go the extra steps and prevent SCP access if available on the unix server.

       user=passwordmaker 

       password=M@keP@ss!

So in our process, the radius-admin mails the enrollee via his/her email with the account details after the user account has been created. 

Than the user at convenience will ssh into the server at ip_address   a.b.c.d with the above username+ password and make his/her password. This password will be mailed to the radius server at a collection inbox securely.

Since the password was made with 10 characters and a equal random salt size, this generate a very hard to hack or  & protections from brute-force/hybrid  attacks.


Here's the /etc/password  details for the user  passwordmaker



Now the script is very simple and  basic. You can tweak it to meet your organizational requirements and policies. It only requires openssl and gpg as add-on packages which most common linux distro have installed by default.


#!/bin/bash

#  modified  Aug2 2014 rev 1.4
#  ken Felix @ hyperfeed.com
#

#   rev 1.0  JAN08-2007 original
#   rev 1.1 APRIL09-2008 fixed a few else ifs
#   rev 1.1 MAY02-2010  changed date and added the $USER variable
#   rev 1.2 NOV21-2009  changed from unsalted md5 , & to salt-md5
#  rev 1.3 MAY12-2013 increased the salt to 10characters and changed to openssl due to internal 
#  audit
#  rev 1.4 AUG0-2014 included the password matching and more cleanup work due to user failures
#

#  This script helps for building our users radius password. It reads the input from the user
#  It requires the user to generate a 10 letter or more character password string and then we will 

#  hash the string and salt it with a random salt of 10 characters
#


USER=" RADIUS_USER @ hyperfeed dot com "
#


echo "Hello,  new or existing "$USER".  This script will generate your encrypted hash for radius authentication against the IT cisco/juniper/A10/AristaNetwork gear. This will allow you access to the routers, switchs, SLB &  our Juniper m7/Js"


# gather username for the window domain user 
#
echo -n "Enter your username which is the same as your windowslogin named and press <ENTER>: "
read name


#
# gather password

echo -n " Please enter a 10 character  password that and press <ENTER>: "
read  passworda

#
# gather password again for the match

echo
echo -n " Please re-enter your 10 character password again and  press <ENTER>: "
read  passwordb

# random salt variable depends on urandom adjust accordingly to your OS

#
salt=`dd if=/dev/urandom bs=1 count=48  2>/dev/null | base64`
 

# todays date
DATE=`date +%G%m%d%T`

#

# for password length checking
SIZE=${#passworda}





#
# if name was not set exit ( we have to know the username )

if [ -z $name ]

   then

   echo " Please provide a valid username and try again. Good Bye! "
   exit

#
# if password is NOT 10 or more exit


elif [ "$SIZE"  -lt 10 ];

   then

   echo
   echo " Your Password needs to be at least 10 characters or more, including  aA-zZ and 1 number , 1 UPPERCASE and 1 special charcter  ( # $ ! ) "
   echo

   echo "Good Bye!"

#
# if passwords don't match , then exit
 

elif [ $passworda == $passwordb ]; then

  echo " I'm generating your encrypted passwords for the provided username of  $name "
  echo

  echo " please wait "

        (openssl passwd -1 -salt `echo $salt`  $passworda |  gpg -e -r radiusteam@localhost -a  | mail -s "$DATE $name"  radiusadmin )

  echo " "
  echo " "
  echo  " For the username that you  provided <$name> I've created your RADIUS password . The  password will be mail to the radius_admin at radiusadmin@hyperfeed.com ".
  echo " "

  echo " If you have any questions please contact the above email address."
  echo
  echo "!!!!!!!!PLEASE WAIT 24 HOURS FOR NEW PASSWORDS TO BE DEPLOYED!!!!!!!!"
  echo " "
  echo " Thank you and Good Bye!"

elif  [ $passworda != $passwordb ]
  then
   echo " "
   echo " $name  the two passwords doesn't match, please try again. Thanks & GoodBye!"
   exit

else

  echo "Good Bye!"

fi


The radius system admin will decrypted the  password and then install  this radius-user salted+password into  the radius server account db or text file.


e.g ( a typical user account )


"myusernameXYZ SMD5-Password := "$1$IElaqnTN$SmrPwX5hjDh4SAt5eqbAQ1"
 
 
The <radiusadmin> is a mailaliases  that encompass  the radius_systems_admin or other various system admins.

The email would look something like the following that's received at the radiusadmin inbox


All of the radius_administrators have read access to the gpg private-key and can decrypt the message .

Future goals are;

  > To deploy string validation for characters aA-zZ and digits  ( 0-9 ) and i would like to use  a few special characters .  If the user doesn't deploy At least 1 capitalize, 1 digits and 1 special character, than we reject them with a error message echo to the screen

  > And I would like to automate this by dumping the  hash+salted  password directly into a mysql instance via the cli if the user account exists


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

    ^    ^
=( &  # )=
      @
      /   \

cisco ASA 5558-X slot0 and slot1 ( beware )

I learned something interesting about the  cisco ASA 5558-X chassis & that I thought was interesting;

Please reference this image from cisco website of a typical 5558-X chassis.

http://www.cisco.com/c/en/us/td/docs/security/asa/hw/maintenance/5585guide/5585Xhw/overview.html#pgfId-1100238



The hw-module slot1 which encompass the  IPS  also carries the GIGE interfaces gi 1/0-7 and the 10GIGE interfaces as well 1/8-9.

Shutting down the hw-module slot1 will  "DROP" all interfaces in slot1 and not just the  IPS modules.

Take a look at these show outputs;




And the available hardware module commands


1: So the meer issuing of a hw-module #1 shutdown, actually shutdown the  whole slot1 and NOT just the IPS


2: A issuing of a hw-module #1 reload, will not disturb any GIGE interfaces on slot#1


I found this interesting while diagnostic and debugging a  buggy IPS module. I have a case open with TAC over these issues. They are looking into it a trying to determine if this is normal behavior.




I found it funny cisco won't let you shutdown slot#0, but  they allow slot#1 , and it will bring all interfaces on that slot down including the IPS module that I was trying to trouble shoot.

http://socpuppet.blogspot.com/2015/01/asa-ips-modules-reloads-732-e4.html


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

    ^    ^
=( #  # )=
      @
      /   \

Alternative means for gaining access to Sonus SBC 5110 cli of the console for ConnexIP

Here's alternative  means for gaining access to the  "ConnexIP linux" console cli. You can gain  attempt to use the KVM over IP via the BMC or even use the  serial console interface on the chassis, just be aware that interface settings is 115200, N, 8, 1

But an alternative is to ssh into the BMC as root or any other local bmc account and issues a "solssh" cmd.

e.g ( solssh )



The 2nd alternative is to  ssh into the EMA cli access and use the "unhide  debug" cmd with the password "sonus1" followed by a "dsh" cmd to gain an active shell.

You will still be prompt for the user linuxadmin  password  after after the execution of the dsh command this password by default is "sonus"

e.g ( using unhide debug )




Ken Felix
NSE ( Network Security Expert) and Route/Switching Engineer.
kfelix  -----a----t---- socpuppets ---dot---com

    ^     ^
=(  *  * )=
        o 
       /  \

Fortinet Support Forum

I was recently made aware by the open support community that I'm a  top contributor for Q3/4-2014.

https://forum.fortinet.com/tm.aspx?m=119131



I was surprised to see this, and the fact that they rewarded me with a fortiStore gift purchase credit. This why Fortinet is such and outstanding group , and for the security engineers working in the security sectors & communities.

The support forum has grown, very well behaved and good tips/tricks/pointers are pass around on a daily basis.

I've been closely involved with  fortinet going back to  FortiOS  2.8 and the mid 2006 years.


https://forum.fortinet.com/


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

    ^    ^
=( #  # )=
      @
      /   \

Monday, January 19, 2015

Dead Gateway detect fortigate

In a multiple ISP uplink and w/static routes, you need a means to control how to "swack" ( telco lingo for switching ) to the 2nd ISP2 when the main ISP1 is down. Gateway detect is the means for  this.

Take a look at this simple diagram;






So we want ISP1 to be our primary and ISP2 to be in play if ISP#1 is down. Here's one way to  manipulated with static routes

config router static
   config router static
    edit 10

        set device "wan1"
        set gateway 1.1.1.1

        set priority  90
    next
    edit 11


        set device "wan1"
        set gateway 2.2.2.1

        set priority 100 
    next


NOTE: Any routes other than blackhole routes on a fortigate can have the priority set. The lower value is preferred if you have 2 matching routes.

So now we can set the dead gateway detect

config router gwdetect
    edit "wan1"
        set failtime 100
        set interval 30
            set server "1.1.1.1"            
        set source-ip 1.1.1.2
    next
end


NOTE:you will adjust the interval and failtime values to suit your needs and to encompass any flapping. You can be aggressive or less-aggressive in your interval and failtime

So if 1.1.1.1 ( ISP1  )  becomes unreachable  ( link down, excessive packet loss, etc......) , the stand-by floating route at  2.2.2.1 with a priority of  100 will populate the  fortigate router information base.

You can validate  gwdetect via  the follow show cmd

 get router info gwdetect

wan1:
    proto ping, interval 30, failtimes 100, state up
    1.1.1.1 (1.1.1.2 ): state (up)



You can use protocols similar to juniperSRX probe or cisco IP SLA ( icmp/udp/tcp ) and you don't have to use the next-hop as the target, it could be a device 1-2-3 or more hops aways.


NOTE: please ensure you have the correct policies for traffic allowance outbound for the 2nd ISP#2 link.


Ken Felix
NSE ( Network Security Expert) and Route/Switching Engineer.
kfelix  -----a----t---- socpuppets ---dot---com

    ^     ^
=(  *  * )=
        o 
       /  \

nV ASR IOS-XR vrf ( Satellite Network Virtualization (nV) System )

I was researching some unresolved VRFs interface  and found this vrf that I had no clue as  to why it was present until I did some deep researching.


  RP/0/RSP0/CPU0:CORE01#show vrf all
  Mon Jan 18 12:33:46.168  CST
  VRF                  RD                  RT                         AFI   SAFI    
  **nVSatellite        not set           
  Management           not set           
  RP/0/RSP0/CPU0:CORE01#


If you have the following  package install    {  disk0:asr9k-9000v-nVx.x.x } , the above vrf will be created automatically by IOS-XR.  And the following internal interface will be crafted and bound to that VRF.


  show vrf **nVSatellite  det
  Mon Jan 18 12:34:00.498 CST

  VRF **nVSatellite; RD not set; VPN ID not set
  VRF mode: Regular
  Description not set
  Interfaces:
    nV-Loopback0
  Address family IPV4 Unicast
    No import VPN route-target communities
    No export VPN route-target communities
    No import route policy
    No export route policy
  Address family IPV6 Unicast
    No import VPN route-target communities
    No export VPN route-target communities
    No import route policy
    No export route policy


You can find more information at the following Satellite NetworkVirtualizationSystem at the following link;

http://www.cisco.com/c/en/us/td/docs/routers/crs/software/crs_r5-2/nV/configuration/guide/b_nv_cg52xcrs/b_nv_cg52xcrs_chapter_00.html#concept_83ED4DF362ED48CD9A938AC20BC2E7D4


Ken Felix
NSE ( Network Security Expert) and Route/Switching Engineer.
kfelix  -----a----t---- socpuppets ---dot---com

    ^     ^
=(  *  * )=
        o 
       /  \