コード例 #1
0
    def set(self, vdom=None, flt=''):

        params = {
            'src': sys_session.set_src,
            'dst': sys_session.set_dst,
            'dport': sys_session.set_dport
        }

        if not vdom:
            paramlist = ['diagnose sys session filter clear']
            for i in params:
                if params[i]:
                    paramlist.append(
                        'diagnose sys session filter {} {}'.format(
                            i, params[i]))
        elif validation.vdomval(self.sshclient, vdom):
            paramlist = [
                'config vdom', 'edit {}'.format(vdom),
                'diagnose sys session filter clear'
            ]
            for i in params:
                if params[i]:
                    paramlist.append(
                        'diagnose sys session filter {} {}'.format(
                            i, params[i]))

        paramlist.append('diagnose sys session list {}'.format(flt))

        try:
            commit(self.sshclient, paramlist)
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #2
0
    def set(self, vdom=None):

        params = {
            'source': auth_list.set_source,
            'policy': auth_list.set_policy,
            'user': auth_list.set_user,
            'group': auth_list.set_group,
            'method': auth_list.set_method
        }

        if not vdom:
            paramlist = ['diagnose firewall auth filter clear']
            for i in params:
                if params[i]:
                    paramlist.append(
                        'diagnose firewall auth filter {} {}'.format(
                            i, params[i]))
        elif validation.vdomval(self.sshclient, vdom):
            paramlist = [
                'config vdom', 'edit {}'.format(vdom),
                'diagnose firewall auth filter clear'
            ]
            for i in params:
                if params[i]:
                    paramlist.append(
                        'diagnose firewall auth filter {} {}'.format(
                            i, params[i]))

        paramlist.append('diagnose firewall auth list')
        try:
            commit(self.sshclient, paramlist)
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #3
0
    def set(self, dst, vdom=None):

        if not dst:
            print('PLEASE ENTER A DESTINATION VALUE!')
        else:
            params = {
                'source': exec_ping.set_src,
                'repeat-count': exec_ping.set_repeat,
                'data-size': exec_ping.set_size
            }

            if not vdom:
                paramlist = []
                for i in params:
                    if params[i]:
                        paramlist.append('execute ping-options {} {}'.format(
                            i, params[i]))
            elif validation.vdomval(self.sshclient, vdom):
                paramlist = ['config vdom', 'edit {}'.format(vdom)]
                for i in params:
                    if params[i]:
                        paramlist.append('execute ping-options {} {}'.format(
                            i, params[i]))

            paramlist.append('execute ping {}'.format(dst))
            try:
                commit(self.sshclient, paramlist)
            except:
                print('Incorrect VDOM/GLOBAL!')
コード例 #4
0
ファイル: disclose.py プロジェクト: supremeZ41D/gunslinger
def vdomfunc(sshclient, vdom, precomm, command):
    """To push commands into the FortiGate shell."""
    pushcomm = lambda x: sshclient.exec_command(x)
    if validation.globval(sshclient):
        stdin, stdout, stderr = pushcomm(command)
    elif validation.vdomval(sshclient, vdom) == True or vdom == 'global':
        command = precomm + command
        stdin, stdout, stderr = pushcomm(command)

    try:
        return stdout.readlines()
    except:
        print('Incorrect VDOM/GLOBAL!')
コード例 #5
0
    def set(self, vdom=None, flt='all'):

        if not vdom:
            paramlist = ['execute dhcp lease-clear {}'.format(flt)]
        elif validation.vdomval(self.sshclient, vdom):
            paramlist = [
                'config vdom', 'edit {}'.format(vdom),
                'execute dhcp lease-clear {}'.format(flt)
            ]

        try:
            commit(self.sshclient, paramlist)
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #6
0
    def set(self, vdom=None):

        if not vdom:
            paramlist = ['execute vpn sslvpn list']
        elif validation.vdomval(self.sshclient, vdom):
            paramlist = [
                'config vdom', 'edit {}'.format(vdom),
                'execute vpn sslvpn list'
            ]

        try:
            commit(self.sshclient, paramlist)
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #7
0
    def set(self, dst, vdom=None):

        if not vdom:
            paramlist = ['execute router clear ospf process']
        elif validation.vdomval(self.sshclient, vdom):
            paramlist = [
                'config vdom', 'edit {}'.format(vdom),
                'execute router clear ospf process'
            ]

        try:
            return paramlist
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #8
0
    def set(self, dst, port='', vdom=None):

        if not dst:
            print('PLEASE ENTER A DESTINATION VALUE!')
        else:
            if not vdom:
                paramlist = []
                paramlist.append('execute telnet {} {}'.format(dst, port))
            elif validation.vdomval(self.sshclient, vdom):
                paramlist = ['config vdom', 'edit {}'.format(vdom)]
                paramlist.append('execute telnet {} {}'.format(dst, port))

            try:
                commit(self.sshclient, paramlist)
            except:
                print('Incorrect VDOM/GLOBAL!')
コード例 #9
0
    def set(self,
            *args,
            vdom=None,
            method=None,
            server_name=None,
            username=None,
            password=None):

        if not method or not server_name or not username or not password:
            print(
                'METHOD, SERVER_NAME, USERNAME and PASSWORD have to be filled out!'
            )
        else:
            if not vdom:
                if 'chap' in args or 'pap' in args or 'mschap' in args or 'mschap2' in args:
                    paramlist = [
                        'diagnose test authserver {} {} {} {} {}'.format(
                            method, args[0], server_name, username, password)
                    ]
                else:
                    paramlist = [
                        'diagnose test authserver {} {} {} {}'.format(
                            method, server_name, username, password)
                    ]
            elif validation.vdomval(self.sshclient, vdom):
                if 'chap' in args or 'pap' in args or 'mschap' in args or 'mschap2' in args:
                    paramlist = [
                        'config vdom', 'edit {}'.format(vdom),
                        'diagnose test authserver {} {} {} {} {}'.format(
                            method, args[0], server_name, username, password)
                    ]
                else:
                    paramlist = [
                        'config vdom', 'edit {}'.format(vdom),
                        'diagnose test authserver {} {} {} {}'.format(
                            method, server_name, username, password)
                    ]

        try:
            commit(self.sshclient, paramlist)
        except:
            print('Incorrect VDOM/GLOBAL!')
コード例 #10
0
    def set(self, vdom=None, edit=None, option='print'):

        if not vdom:
            if not edit:
                print('PLEASE ENTER AN EDIT VALUE!')
            else:
                paramlist = ['diagnose firewall iprope 100004 {}'.format(edit)]
        elif validation.vdomval(self.sshclient, vdom):
            if not edit:
                print('PLEASE ENTER AN EDIT VALUE!')
            else:
                paramlist = [
                    'diagnose firewall iprope show 100004 {}\n'.format(edit)
                ]
                precomm = """config vdom
                edit {}
                """.format(vdom)
                command = paramlist[-1]
                stdout = vdomfunc(self.sshclient, vdom, precomm, command)
        try:
            return storeprint(stdout, option)
        except:
            print('Incorrect VDOM/GLOBAL!')