Git Product home page Git Product logo

pyforti's Introduction

PyForti (BETA)

Network automation module for FortiGate firewalls.

This script is firstly designed to make user operations easier and automated on Fortigate firewalls. Tested on Fortigate 60E v6.0.0 and Fortigate 200D v5.6.3 with Python 3.6.4. Special thanks to Eczacıbaşı Bilişim company which helped me with the testing process.

Any helpful comment, advice and contribution would be most appreciated.

Download

  • Open "Git Bash" and type:

git clone https://github.com/GnyEser/pyforti.git

Requirements

paramiko 2.6.0

pip install paramiko

Example Use:

    from pyforti import Forti
    fw = Forti(ip(str), port(int), username(str), password(str))
    conn = fw.connect()
    fw.get_user_groups(conn)                   # Returns the user groups on the device as a list.
    fw.create_user_group(conn, "TestGroup")    # Creates a user group named "TestGroup" and returns the user group and command output as a dict.

Functions:

conn = connect(vdom = "")
  • Connects to the created Forti class device. If a vdom name is declared, also enters to the config mode of the vdom. Returns the paramiko connection which must be passed in every other function as an argument.
get_users_from_group(conn, user_group(str))  # Name of the user group to get users inside.
  • Returns users in the passed user group as a python list.
get_user_groups(conn)
  • Returns each user groups' names as a python list.
get_users(conn)
  • Returns user names as a python list.
create_user(conn, username(str), password(str), tfa="disable")
  • Creates a user with the specified username, password and two factor authentication type.
  • tfa = "disable"/ "fortitoken"/ "email"/ "sms"
create_user_group(conn, groupname(str))
  • Creates a user group with setting firewall as the group type. Returns the user group name as a dict.
add_user_to_group(conn, user_group(str), username(str))
  • Adds the given user into the specified user group and returns the group name and user name as a dict.
remove_user_from_group(conn, user_group(str), username(str))
  • Removes the specified user from the specified user group and returns the group name and user name as a dict.
change_hostname(conn, hostname(str))
  • Changes the hostname of the device to the passed string.
check_connection(conn)
  • Checks if the connection is still up. Returns true if up, and false if down.
get_arp_table(conn)
  • Returns the arp table as a string.
set_dns(conn, primary(str), secondary(str))
  • Sets primary and secondary DNS addresses.
show_interfaces(conn)
  • Runs 'get system interface physical' command and returns the output as a string.

Publish date: 27.06.2019

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.