daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. import ssl
  3. import xml.etree.ElementTree as ET
  4. import getpass
  5. import sys
  6.  
  7. global firewallip
  8. firewallip = ""
  9.  
  10. def request(paloinput, firewallip, apikey):
  11.     response  = requests.get("https://"+(firewallip)+"//api/?type=op&cmd="+(paloinput)+"&key="+apikey, verify=False, stream=True)
  12.     global root
  13.     root = ET.fromstring(response.content)
  14.  
  15.  
  16. def printxml():
  17.     for child in root.iter('*'):
  18.         childname = child.tag
  19.         childvalue = child.text
  20.         print(childname, childvalue)
  21.  
  22. def main():
  23.     global firewallip
  24.     if firewallip == "":
  25.         firewallip = raw_input("Enter Firewall IP: ")
  26.     apikey = raw_input("Enter API api key: ")
  27.     paloinput = raw_input("Enter X-Path: ")
  28.     request(paloinput, firewallip, apikey)
  29.     printxml()
  30.     sys.exit()
  31.  
  32. def generate(firewallip, username, password):
  33.      response = requests.get("https://"+(firewallip)+"/api/?type=keygen&user="+(username)+"&password="+(password), verify=False, stream=True)
  34.      global root
  35.      root = ET.fromstring(response.content)
  36.      printxml()
  37.      print("---------------------")
  38.  
  39. choice = raw_input("Do you need to generate an API key? [y/n]: ")
  40.  
  41. while True:
  42.     if choice == "y":
  43.         firewallip = raw_input("Enter firewall IP ")
  44.         username = raw_input("Enter username ")
  45.         password = getpass.getpass('Password:')
  46.         generate(firewallip, username, password)
  47.         main()
  48.     elif choice == "n":
  49.         main()
  50.     else:
  51.         print("Invalid input")
  52.         choice = "y"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top