Category Archives: Python

Create self signed root CA certificate with the help of python using openssl

#Following script will create a self signed root ca cert. from OpenSSL import crypto, SSL from os.path import join import random CN = input(“Enter the common name of the certificate you want: “) pubkey = “%s.crt” % CN #replace %s … Continue reading

Posted in Python | Tagged , , , , , | Leave a comment

XML parsing with python

Consider the following xml file: <?xml version=”1.0″?> <config version=”6.1.0″ urldb=”paloaltonetworks”> <mgt-config>     <users>       <entry name=”admin”>         <phash>********</phash>         <permissions>           <role-based>             <superuser>yes</superuser>           </role-based>         </permissions>       </entry>     </users>   </mgt-config> </config> Root of the above xml … Continue reading

Posted in Python | Tagged , , | Leave a comment

Python script to take telnet of CISCO device

Take telnet of a cisco router/switch and execute commands: import os import telnetlib host  = “10.50.243.28” user  = “username” password = “cisco” telnet  = telnetlib.Telnet(host) telnet.read_until(‘Password: ‘, 3) telnet.write(password + ‘r’) telnet.write(‘enable’ + ‘rn’) telnet.write(‘cisco’ + ‘rn’) telnet.write(‘term len 0’ … Continue reading

Posted in Python | Tagged , , , , | Leave a comment

Python script to get PAN-OS of Palo Alto Networks Firewall/Panorama

Following script can be used to pull PAN-OS of Palo Alto Networks firewall/Panorama. You have to generate your own key as it is dependent on your user name and password. import requests import urllib import xml.etree.ElementTree as ET firewall=range(50,88) urlhttp=”https://&#8221; … Continue reading

Posted in Python