Tag Archives: python

[python]Simple tcp client

So here’s the simple code: So first create an object client, the attributes are IPV4 (socket.AF_INET) and tcp (socket.SOCK_STREAM). Use the send method to send http request, must send the msg in bytes, hence the b. Advertisements

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

[python]Intrusive python: Reacting with interactive prompt with pexpect

Ok, I am reading some stuffs about brute forcing ssh server. So here is a python module that deals with possible interactive prompts. The target server is a cisco router, I have put in all possible expected prompts.Such as: 1. … Continue reading

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

[python]Intrusive python with nmap

So i was trying some simple script to invoke nmap with python. So here is a python command line version. The python script takes in two types of arguments: a. target host b. target port/ports. the port if more than … Continue reading

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

[python]Exception handling with pan-python

pan.xapi has its own error handling, so on previous post i updated the code with exception handling. I actually tested with wrong credential, I could see the http 403 forbidden error raised. Which is good, as I would know what … Continue reading

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

[python]Create firewall objects with Palo Alto API

This is a code example to demonstrate the use of Palo Alto API. Suppose I need to create pool.ntp.org firewall objects. Here’s the code sample: The result look like this:

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

[python]Create and update object groups

I am experimenting a real life example, when server is created the hostname and ip address are assigned by an orchestrator. The orchestrator will then call the python script and pass the hostname to be object entry name and ip … Continue reading

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

[python]Trying the operation command api in Palo Alto Firewall

This code sample uses requests and beautifulsoup4 modules to manipulate data extracted with PA’s REST API. PA only supports xml though. The requests is to use the GET method when calling REST API, the beautifulsoup4 is to easily extract the … Continue reading

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