Monday, November 4, 2019

FortiOS config grabber using the API and cURL

As you probably know, I like curl and here's a simple configuration grabber than will work on Fortigates that has a API_USER.

https://en.wikipedia.org/wiki/CURL


This script will pull the complete configuration in a multi-vdom setup. And is simple and effective at grabbing a in-the-clear configuration from a fortigate using a API call

"/api/v2/monitor/system/config/backup/"

The basic meat of my script has the following, you can customize to meet your requirements.



SOCPUP1>cat fgtcfggrabber.sh 
#/bin/bash
# socpups  http://socpuppet.blogspot.com/
# rev 1.0  July 2 2019 test in fortiOS 6.Xs versions
#

# check for help

if [ "$1" == "-h" ]; then
  echo "Usage: scriptname hostname token_key "
  echo ""
  echo "Example:  <scriptname.sh> 193.0.2.88 MyBigLongAPI_KeyHereBlahBlahBlah"
  # bye bye 
  exit 0
fi

# check if no value set for cli 

if [ -z "$1" ]; then
  echo "Please provide hostname and key"
  echo "Use  -h  to see usage  example!"
  exit 0
fi



# grab confgurations from fortigate appliance that has API  
# NET-SEC Engineer "kfelix@socpuppets.com" Ken Felix
#
#  API_USER must have access write to FGT and vdoms

# set date for curl to write the file name

D=`date +%F_%T%S`

curl  -k -o $1_$D.conf  -H  "Authorization: Bearer $2" "https://$1/api/v2/monitor/system/config/backup/?scope=global&amp;access_token=$2"


exit 



The script will dump the configuration out via curl into the named filed






You can play around with the script to suit your needs and desires. You could probably apply the same API_KEY and for loop the scripts against a set of FGT on a cron job to grab the configurations like daily/weekly/monthly.

Other options would be to redirect to mail and sendmail the configuration file to a mail-list or user




Upon execution, the output would be direct to the systemmail.

 








NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \


Monday, October 28, 2019

Howto reduce BGP capabilities advertisements FortiOS

FortiOS has this weird behavior that by default it advertises ipv6 capabilities to any neighboring bgp router, even if you're not using ipv6 for that bgp-neighbor. You can get the list of capabilities sent via "get router info bgp neighbor" command executed from the cli

To disable the advertisement of ipv6 to a bgp-neighbor you will need to disable this capability from the cli per each neighbor


e.g





Here's a before and after screenshot of a neighbor output once the above command has been set to disable



As you can see the output is reduced and eliminates ipv6 advertisements. You can read more at one of my early posted blog

http://socpuppet.blogspot.com/2013/05/bgp-capabilities.html











NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \


Wednesday, October 23, 2019

Fortigate dialup vpn ipsec from a 2nd Fortigate

FortiOS supports IPSEC dialup where a Fortigate is the dialup device that uses  a username/password with the PSK

The ciscoASA had this function for many years under easyVPN


Here's a basic view;




The light-blue firewall is connecting to the firewall on the left both of these are fortigates but in reality it could have been a FGT to any other dynamic dialup.


Here's the dark blue firewall cfg





We have a user defined and local usergroup named remote-fgts


FWF  # show user group remote-fgts 
config user group
    edit "remote-fgts"
        set member "remote-fgt"
    next
end

FWF # show user local remote-fgt 
config user local
    edit "remote-fgt"
        set type password
        set passwd-time 2019-08-11 18:01:01
        set passwd ENC bK70ALGrYzvTd/7+Das6DdQZpGUaUuq9+wZQGVb6P8A5xfQbrcBKPBlyGs4WrQ3NfGCUMPZsB4adzXg706DgkN3OYryXHub2eb1uvHO62m5M7F7n6AyKUmUPILCeFVyXNsMb1QShc5OqRx9oH2xNoUodDHeZWr6ca6cu1RZ84XM1/O/hxDm+DK1mMkSdFeaYD8x70g==
    next

end



The remote firewall configuration of the firewall in the right of the screenshot will use the correct username/password in its configuration







Note: always double-check the username and password for correctness if you see authentication error or using an external authenticator.


The cmd:   diag vpn ike gateway will show you details and the user that did authenticate






As you can see username "remote-fgt" authenticated. We can also double-check the phase2 details





to secure the dialup firewalls it best to set localid and peerids for both of the peers, in the below example we are defining a fqdn type set a ipsecremotes for the localid and remote peerid.


















NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \

Tuesday, October 22, 2019

Jumpcloud MFA and RADIUS gotcha

MFA with  Jumpcloud is easy to do, but be advised of issues with OTP expiration and the OTP still be honored.

1st a typical jumpcloud radius-server cfg for a fortiOS device
reference one of my many previous blog on this

http://socpuppet.blogspot.com/2017/03/using-jump-cloud-radius-for-fortimail.html



/* A FortiOS cfg example



config user radius
    edit "jcradius"
        set server "18.204.0.31"
        set secret ENC H0YE6EqYG0W9AB1uXPbAsKwQIAS9IxYI7T4v3VOjBj9f89U0RfmDfbD6U47dU6DD+3YidfbkGvtwzFYhCFsSQY8DodYhtsFiyKBBN1t6unIGH+ZlgB/MQaFOx/ncbNnyTk6D4RObIKj3BSGd9DbEr2jm4Vv+w6/nXa/Y64pCq6cZWpdQfRr4EylK+A5zD4r/XiCnetQ==
        set radius-port 1812
    next
end



Okay, that's easy and we can test via the "diag test authserver radius-direct" cmd from the cli. Here's where it gets funky. I continue to authenticate with the same OTP and over a period that was almost 2mins. Finally, the previous OTP was not accepted for my usernamed "mfa" as you can see with the "Access-Reject" message




Even the user-portal login exhibits the same behavior upon my testing.








And  OTP 125738 for "mfa" user has long expired  ( see OTP value #861102 ) , but  I can still login with the now expired OTP  60secs later and after a new OTP has been generated.







Interesting, a new OTP that has expired is still granted access for at least 1+ min or more even tho the Google OTP is 30secs TTL. I have not seen this issue in Entrust IdenityGuard , Okta, RSA,etc......



So jumpcloud has granted the OTP upto the next-plus-next OTP cycle.


e.g

OTP . 123 456--30sec --->  expired, 

          new OTP 667 788----30secs later expired, 
                    
                                  new OTP 788 928--30sec expired, 

                                                 and now previous OTP 123 456  is now not honor some 60seconds plus the original expiration.


So this violates two functions and rules within OTP usage for MFA authentication

1: A OTP is good for 30secs ( +-  a few secs ) 

2: A QTP becomes invalid after a successful login ( prevent reuse or the continual use.....the OT in OTP is suppose to mean "One Time" ! )










NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \








Monday, October 21, 2019

GRE KeepAlives Fortios

In this case we will display a basic GenericRoutingEncapsulation tunnel cfg for FortiOS and JunOS





FGT GRE cfg with KeepAlives set for 10 second interval and 20 failures



We also configured the GRE1 interface with layer3 details

config system interface
    edit "GRE1"
        set vdom "root"
        set ip 192.0.2.129 255.255.255.255
        set allowaccess ping
        set type tunnel
        set remote-ip 192.0.2.130 255.255.255.255
        set snmp-index 13
        set interface "wan1"
    next

end


A juniper SRX with no KeepAlives enabled




KeepAives does not need to be set on both ends. A Non GRE-keepAlive device will respond back.














NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \







Thursday, October 17, 2019

BFD fortiagte and junos firewalls

Both the Juniper SRX and Fortigate support BFD. This uses a udp port 3784 and helps identify one-way failures.

On the fortigate the cfg is simple, you need to enable it globally, and under system interface. You have to enable the  bfd per each routing peer ( BGP in my case )


cfg


show sys settings | grep bfd
    set bfd enable

show sys interface GCM | grep bfd
        set bfd enable


config router bgp
    set as 5706
    set ebgp-multipath enable
    config neighbor
        edit "192.168.127.1"
            set bfd enable
            set remote-as 65001
        end       




Junos device it's even simpler, just enable it per each bgp neighbor

set protocols bgp group FGT bfd-liveness-detection minimum-interval 1000 



To validate;

FortiOS



JunOS





It's recommended NOT to run bfd and graceful restart at the same time. 
                   bfd supports authentication on Junos but not in FortiOS



If you suspect bfd is not working or not being sent use the diag sniffer cmd

e.g


   diag sniffer packet <interfacename> "port 3784"












NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \


Forcepoint SMC policy push

Installing a firewall policy on a NGFW does not break any local sessions. Here's an example of ZERO-TEST-policy push and my ssh was not closed.





When I logged out and tried to login, my connection is refused due to the policy rule set









NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \