FortiSIEM is a highly flexible solution providing a wide collection of inbuilt Remediation Scripts, integrating FortiSOAR Playbooks or giving the user the ability to create his own custom remediation scripts.
Predefined and custom FortiSIEM scripts can be invoked on-demand (manually) or automatically when the incident happens. A common situation for using remediation scripts includes blocking sources and/or destinations IP address for reported attacks or suspicious activities (ex. port scanning activities, communication with a C&C server, botnets, etc.).
These situations can also be addressed in an easy and reliable way by using a new remediation method based on a FortiSIEM publishing script leveraging Fortinet Security Fabric External Connectors and/or 3rd party NGFW Connectors.
Main advantages of this method:
- One single publishing script can be used to integrate multiple and different FGT FOS versions and/or 3rd party firewall devices
- Sources and/or Destinations IP address can be extracted from FortiSIEM Incident XML file and published in a HTML/txt file format in order to be easily fetched by Firewalls and used in specific policy rules
- In case of a firewall firmware upgrade or configuration change, there is no need to update the FortiSIEM script
- Less computing resources needed, as there is no need to initiate and handle SSH sessions with each specific FortiGate or 3rd party Firewall
- Fast and easy deployment within Fortinet environment by copying the script on FortiSIEM Supervisor and using FortiManager to configure FortiGate Security Fabric External Connectors
- Sources or Destinations IP address can be fetched from FortiSIEM incidents and used by Firewalls to enforce different policy rules (with block or allow actions)
- This method might be extended to use Hash and URL lists (not just IP address lists)
Download:
- src_ip.py: python script for extracting Source IP Address from Incident XML file and publish it on
/var/www/html/src_ip.html
file hosted by FortiSIEM Supervisor
- dst_ip.py: python script for extracts Destination IP Address from Incident XML file and publish it on
/var/www/html/dst_ip.html
file hosted by FortiSIEM Supervisor
- Additional tools (useful only for advanced testing purposes):
Implementation:
- Configure FortiSIEM Supervisor
- Connect to Supervisor console (ex. using SSH)
- Install pathlib library (this will be used by the script while automatically creating the IP lists html file):
- #
cd /usr/local
- #
pip2.7 install pathlib
- Create a local folder by running the following commands:
- Copy the src_ip.py script file to the previously created folder or build the file from scratch using vi editor, by running the following commands::
- #
> src_ip.py
- #
vi src_ip.py
(insert the script code in the file and save it)
- src_ip.py script extracts Source IP Address from Incident XML file. If Destination IP Address are needed you have to copy/create the "dst_ip.py" script file.
- Run the sript using #
python src_ip.py
command. Upon running this command, HTML file lists will be automatically created, and the script will become executable with admin rights (this way the admin user will be able to trigger/run the script from the web GUI). Ignore the console messages after running the “#python src_ip.py” CLI command. If Destination IP Address are needed you have to run the "dst_ip.py" script file.
- HTML list file will be automatically created in the /var/www/HTML folder
- HTML list file will have a similar name as the script name (for example running script "src_ip.py" creates a "src_ip.HTML" file
- Configure FortiGate Security Fabric External Connectors
- Connect to FortiManager GUI and select "Security Fabric View":
![MessageImages_7845ab20e6344186bb8d8a4753180d9e.png MessageImages_7845ab20e6344186bb8d8a4753180d9e.png](/t5/image/serverpage/image-id/15237i098BE20729B6BA20/image-size/large?v=v2&px=999)
- Create a New Fabric Connector:
![MessageImages_a40f2993ce874959a89c1c4b93ed2b54.png MessageImages_a40f2993ce874959a89c1c4b93ed2b54.png](/t5/image/serverpage/image-id/15002i87034EBB2779F197/image-size/large?v=v2&px=999)
- Fill in the "URI of external resources" filed with supervisor FQDN or IP address followed by the generated HTML file list name (ex.https://fortisiem.com/src_ip.html):
![MessageImages_f9d3b97ea68e41978d07e7bb8fddf883.png MessageImages_f9d3b97ea68e41978d07e7bb8fddf883.png](/t5/image/serverpage/image-id/15421iFEC3DE1A32950085/image-size/large?v=v2&px=999)
- Press the "OK" button and check if the newly created Threat Feed is listed in the "Connectors" section:
![MessageImages_e3679a97b1ab49d1a6563ca89e2db118.png MessageImages_e3679a97b1ab49d1a6563ca89e2db118.png](/t5/image/serverpage/image-id/15701iB44BAC04D172D728/image-size/large?v=v2&px=999)
- Configure appropriate Policy Rules using the newly created Fabric Connector List:
![MessageImages_01b8a833641747478ddab1d7d25a6032.png MessageImages_01b8a833641747478ddab1d7d25a6032.png](/t5/image/serverpage/image-id/15007i900AF65E689FD70E/image-size/large?v=v2&px=999)
- Use FortiManager Install Wizard to Install the Policy(during this process, Fortinet Security Fabric Exteral Connectors will be configured on FortiGate Firewalls):
![MessageImages_7e449e0f96e84650aac00e27f3749efb.png MessageImages_7e449e0f96e84650aac00e27f3749efb.png](/t5/image/serverpage/image-id/15619iA3E5CF252850C369/image-size/large?v=v2&px=999)
Testing Options
You can test this new remediation method using inbuild FortiGate demo alerts and FortiSIEM inbuild Rules or (if more control is needed), you can use custom Logs/Alerts, Parsers, Rules and Notification Policies.
1). Ad-hoc remediation test using inbuild FortiGate demo alerts and inbuild FortiSIEM Rules
- Configure FortiGate to send logs to FortiSIEM. Configuration guidelines are available at: https://docs.fortinet.com/document/fortisiem/6.4.0/external-systems-configuration-guide/751381/forti...
- Access FortiGate CLI and run: #
diagnose log test
to generate test events![MessageImages_710cc3be13a1449ca664c9bc321db51a.png MessageImages_710cc3be13a1449ca664c9bc321db51a.png](/t5/image/serverpage/image-id/15460iAA93D5DC7B47C38B/image-size/large?v=v2&px=999)
- Connect to FortiSIEM “Incident tabs” and select Incident “Account Locked: Network Device”
![MessageImages_fec2e28faf6d4bb69ec21b9c811d8538.png MessageImages_fec2e28faf6d4bb69ec21b9c811d8538.png](/t5/image/serverpage/image-id/15288iE6948DEE23A35D1C/image-size/large?v=v2&px=999)
- Select Actions > Remediate Incident
![MessageImages_22d66660bd1f4085a3d68d4da269f6c6.png MessageImages_22d66660bd1f4085a3d68d4da269f6c6.png](/t5/image/serverpage/image-id/15747i1B97B7ADACFE5BD3/image-size/large?v=v2&px=999)
- Remediate Incident using src_ip.py publishing script
![MessageImages_142fb250451148f6891502278d3c5c7e.png MessageImages_142fb250451148f6891502278d3c5c7e.png](/t5/image/serverpage/image-id/15063iE3EDE1F3035C8792/image-size/large?v=v2&px=999)
- Check if the Incident Source IP address (1.1.1.1) is fetched by FortiGate External Connectors
![MessageImages_2fb86ac297b2436cbab343bd96b24e82.png MessageImages_2fb86ac297b2436cbab343bd96b24e82.png](/t5/image/serverpage/image-id/15028i3AB4E296A4BF2FD9/image-size/large?v=v2&px=999)
2). Automatic remediation test based on sample logs and custom Parsers, Rules and Notification Policies
- Edit "send_syslog.py" script and replace "192.168.0.25" IP address with your Supervisor/Collector IP address
- Create a FortiSIEM custom parser (to pars the "syslog_msg.txt" logs) using the "TestEventParser_A.xml" file as a reference. More info about working with parser in FortiSIEM is available at: https://help.fortinet.com/fsiem/6-4-0/Online-Help/HTML5_Help/Configuring_parsers.htm
- Create a new FortiSIEM Rule using as a reference the "Allerting_Rule_Event_Type_A.xml" file. More info about creating a custom Rule is available at https://help.fortinet.com/fsiem/6-4-0/Online-Help/HTML5_Help/Rules.htm
- Create a new FortiSIEM Notification Policy based on previously created Rule and the needed remediation script (ex. src_ip.py). More info about creating a Notification Policy is available at: https://help.fortinet.com/fsiem/6-4-0/Online-Help/HTML5_Help/Notification_Settings.htm.
![MessageImages_a6e3afd987e14a5aabae43571ea261c6.png MessageImages_a6e3afd987e14a5aabae43571ea261c6.png](/t5/image/serverpage/image-id/15743i8108CFF700F64240/image-size/large?v=v2&px=999)
- Connect to Supervisor/Collector or 3rd party computer (the one used in step 1) and run the "python send_syslog.py" command to generate the testing syslog messages (and corresponding Incidents):
- Check if the generated logs (based on fake IP address written in "syslog_msg.txt" file) are being properly received and parsed by FortiSIEM. You can import the Report_Event_Type_A.xml file and run it as a built-in search, using "Table" or "Link Graph" view options (more information about using FortiSIEM Analytics and Reports as a built-in search is available at https://help.fortinet.com/fsiem/6-4-0/Online-Help/HTML5_Help/Running_a_built-in_search.htm:(
![MessageImages_8b6ab8fa3c6749ada8e21ad7d8c7ef8d.png MessageImages_8b6ab8fa3c6749ada8e21ad7d8c7ef8d.png](/t5/image/serverpage/image-id/15722i92FBCB58D8A10B47/image-size/large?v=v2&px=999)
![MessageImages_4c2ad7f99f6e4721a46f14d37ecf539a.png MessageImages_4c2ad7f99f6e4721a46f14d37ecf539a.png](/t5/image/serverpage/image-id/15199i2FED6318BDBA270A/image-size/large?v=v2&px=999)
- Check if Incidents based on Type A Events are correctly reported in "Incidents" tab:
![MessageImages_2e926f7178374e4cbb86132b9e2d8c51.png MessageImages_2e926f7178374e4cbb86132b9e2d8c51.png](/t5/image/serverpage/image-id/15168iCA960616D918D2A9/image-size/large?v=v2&px=999)
- Check if Fortinet Security Fabric Connectors correctly receives the same IP address lists on all existing Firewalls. Connect on protected Workstations (behind Firewalls) and test (ex. using ping/traceroute/tracepath) if policy enforcement works according to your firewall rules.
![MessageImages_656439064da94441a663cf081f89caed.png MessageImages_656439064da94441a663cf081f89caed.png](/t5/image/serverpage/image-id/15545iBDA50A83F46BAF8E/image-size/large?v=v2&px=999)
- Check if the IP address received by HQ FortiGate firewall (ex. HQ_FGT1 listed bellow) are identical to those used in "send_syslog.txt" file
![MessageImages_8e799af024044d8a930af14ce26df00d.png MessageImages_8e799af024044d8a930af14ce26df00d.png](/t5/image/serverpage/image-id/15699i17A428A651C3E199/image-size/large?v=v2&px=999)
- Check if the IP address received by branch FortiGate firewall (ex. FCT_Branch_1 listed bellow) are identical to those used in "send_syslog.txt" file:
![MessageImages_044e0103d8644f9aadc5057d6c6688e2.png MessageImages_044e0103d8644f9aadc5057d6c6688e2.png](/t5/image/serverpage/image-id/15390iD1DE56E986F551CC/image-size/large?v=v2&px=999)
- Check if the IP address received by the second branch FortiGate firewall (ex. FGT_Branch_2 listed bellow) are identical to those used in "send_syslog.txt" file:
![MessageImages_0db1144abcf24552bb0b28d437552649.png MessageImages_0db1144abcf24552bb0b28d437552649.png](/t5/image/serverpage/image-id/15711iA521F473BBE16A55/image-size/large?v=v2&px=999)
Miscellaneous:
- Delays must be taken into consideration depending on FGT External Connectors refresh rate. Delays are measured from the moment FSM publishes the IP address list until FGT fetches it.
![MessageImages_32a5e845bc5b4d3994601aacf1c31290.png MessageImages_32a5e845bc5b4d3994601aacf1c31290.png](/t5/image/serverpage/image-id/15068iD50F41ABBB969E2E/image-size/large?v=v2&px=999)
- HTTP basic authentication should be considered when configuring FortiGate External Connectors
- IP Lists expires could be implemented using an additional scheduled script (to automate deletion of IP address from the list)
- This method might be extended to use(publish) Hash and URL lists (not just IP address lists)