Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import ssl
- import xml.etree.ElementTree as ET
- import getpass
- import sys
- global firewallip
- firewallip = ""
- def request(paloinput, firewallip, apikey):
- response = requests.get("https://"+(firewallip)+"//api/?type=op&cmd="+(paloinput)+"&key="+apikey, verify=False, stream=True)
- global root
- root = ET.fromstring(response.content)
- def printxml():
- for child in root.iter('*'):
- childname = child.tag
- childvalue = child.text
- print(childname, childvalue)
- def main():
- global firewallip
- if firewallip == "":
- firewallip = raw_input("Enter Firewall IP: ")
- apikey = raw_input("Enter API api key: ")
- paloinput = raw_input("Enter X-Path: ")
- request(paloinput, firewallip, apikey)
- printxml()
- sys.exit()
- def generate(firewallip, username, password):
- response = requests.get("https://"+(firewallip)+"/api/?type=keygen&user="+(username)+"&password="+(password), verify=False, stream=True)
- global root
- root = ET.fromstring(response.content)
- printxml()
- print("---------------------")
- choice = raw_input("Do you need to generate an API key? [y/n]: ")
- while True:
- if choice == "y":
- firewallip = raw_input("Enter firewall IP ")
- username = raw_input("Enter username ")
- password = getpass.getpass('Password:')
- generate(firewallip, username, password)
- main()
- elif choice == "n":
- main()
- else:
- print("Invalid input")
- choice = "y"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement