• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Python
  • License
    GNU Lesser Genera...
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple script to extract policies from a FortiGate configuration file to CSV

fgpoliciestocsv

Description

A collection of simple scripts to extract policies, groups, addresses and services from a FortiGate configuration file to CSV

Features

The fgpoliciestocsv script extracts policies and comes in two languages : Perl and Python.
The Python one was originally a simple port of the Perl one developped by Sebastian Knoop-Troullier aka firewallguru and published on his blog http://firewallguru.blogspot.fr/2014/04/exporting-firewall-rules-to-csv.html

Three other scripts fggroupstocsv, fgaddressestocsv, fgservicestocsv have been added to extract groups, addresses (IPv4 unicast only for now) and services ; and only come in Python.

Usage

Python version

Pass the configuration file to the scripts with the -i option.
The processed output is available in the policies-out.csv, addresses-out.csv, groups-out.csv, services-out.csv (default) or in the specified file with the -o option.

Perl version

Pass the configuration file to the script this is the only supported argument.
The processed output is available in the policies-out.csv file.

Options

Python

$ python fgpoliciestocsv.py -h
Usage: fgpoliciestocsv.py [options]

Options:
  -h, --help            show this help message and exit

  Main parameters:
    -i INPUT_FILE, --input-file=INPUT_FILE
                        Partial or full Fortigate configuration file. Ex:
                        fgfw.cfg
    -o OUTPUT_FILE, --output-file=OUTPUT_FILE
                        Output csv file (default ./policies-out.csv)
    -s, --skip-header   Do not print the csv header
    -n, --newline       Insert a newline between each policy for better
                        readability
    -d DELIMITER, --delimiter=DELIMITER
                        CSV delimiter (default ";")
    -e INPUT_ENCODING, --input-encoding=INPUT_ENCODING
                        Input file encoding (default "utf-8")
    -f OUTPUT_ENCODING, --output-encoding=OUTPUT_ENCODING
                        Output file encoding (default "utf-8-sig" to make it
                        easily viewable with MS Excel)

Perl

$ perl fgpoliciestocsv.pl <configuration_file.cfg>

Example

$ cat example.cfg
config firewall policy
     edit 1
         set srcintf "internal"
         set dstintf "wan1"
             set srcaddr "all"
             set dstaddr "all"
         set action accept
         set schedule "always"
             set service "ANY"
         set logtraffic-app disable
         set webcache enable
         set nat enable
     next
end

$ python fgpoliciestocsv.py -i example.cfg

$ cat policies-out.csv
id;srcintf;dstintf;srcaddr;dstaddr;action;schedule;service;logtraffic-app;webcache;nat
1;internal;wan1;all;all;accept;always;ANY;disable;enable;enable

Notes

For a policy, an empty value in the action column might mean deny, as this is implicit in a FortiGate configuration file.

Requirements

  • Python >= 2.7
  • Perl

Copyright and license

fgpoliciestocsv is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. fgpoliciestocsv is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with fgpoliciestocsv. If not, see http://www.gnu.org/licenses/.

Fortinet holds every rights about the FortiGate brand. I'm not affiliated nor employed by them.

Credits

  • Sebastian Knoop-Troullier aka firewallguru
  • Landry Minoza aka hobgoblinsmaster
  • AngelOfTerror

More Repositories

1

thc-hydra-windows

The great THC-HYDRA tool compiled for Windows
Shell
922
star
2

impacket-examples-windows

The great impacket example scripts compiled for Windows
898
star
3

webscreenshot

A simple script to screenshot a list of websites
Python
653
star
4

androwarn

Yet another static code analyzer for malicious Android applications
HTML
473
star
5

nmaptocsv

A simple python script to convert Nmap output to CSV
Python
381
star
6

CrackMapExecWin

The great CrackMapExec tool compiled for Windows
PowerShell
247
star
7

sqldeveloperpassworddecryptor

A simple script to decrypt stored passwords from the Oracle SQL Developer IDE
Python
104
star
8

jnianalyzer

A simple tool to help finding JNI calls in a x86/ARM disassembly listing
Python
80
star
9

weblogicpassworddecryptor

A simple script to decrypt stored passwords from Oracle WebLogic Server configuration files
30
star
10

mimicertz

A minimal safe version of mimikatz to only allow the export of non-exportable Windows certificates
C
25
star
11

patator-windows

The great patator tool compiled for Windows
24
star
12

tgcd-windows

The great TCP Gender Changer (tgcd) tool compiled for Windows
14
star
13

rclonedeobscure

A simple script to decrypt obscured/encrypted passwords from rclone
Python
14
star
14

openocd-windows-buspirate

The great opencd tool compiled for Windows with Bus Pirate support
13
star
15

tibcopasswordrevealer

A simple script to decrypt mangled and obfuscated passwords from Tibco EMS
Python
12
star
16

dnsdumps

Various DNS dumps (daily new domains, FQDNs, etc.)
Python
11
star
17

proxy-selector-firefox-addon

The latest Proxy Selector addon file for Firefox
9
star
18

thc-amap-windows

The great THC-AMAP tool compiled for Windows
9
star
19

GhostPack-compiled

The great GhostPack tools compiled
6
star
20

ikat-on-kali-v2

A simple tutorial to enable iKAT Desktop on Kali v2
6
star
21

third-parties-version-history

A collection of version history for common third-party tools
Python
5
star
22

misc_hookons_avec_javasnoop

Java
5
star
23

jdwp-shellifier-windows

The great jdwp-shellifier tool compiled for Windows
5
star
24

adecadeofinfosectools

Code, details and output datasets of the study
5
star
25

GPartedPlusPlus

GParted++ (GPartedPlusPlus) is the original GParted Live image with several additions
4
star
26

red.flag.domains-publications

https://red.flag.domains publications enriched
Python
4
star
27

dotfiles

My personal dotfiles and scripts
Vim Script
4
star
28

mobilenetworkip

IP addresses of various mobile networks
Shell
3
star
29

some_termux_packages_history

Archive of old versions of some Termux packages
3
star
30

webtorrent-checker-scraper

A simple script to scrape results of WebTorrent Checker (https://checker.openwebtorrent.com)
Python
1
star
31

zmapproject_binaries

All the great tools from the ZMap Project in compiled versions
Roff
1
star
32

geoipbulk

A simple python script to retrieve some useful information such as location and occurence number for a provided IP list
1
star
33

kalicustom

Some customized Kali builds (VMDK, ISO)
Shell
1
star