Category: Python

python requests: How to ignore invalid SSL certificates

python requests: How to ignore invalid SSL certificates

How to make an SSL web request with the python requests library and ignore invalid SSL certificates. Typically you would want the remote host to have a valid SSL certificate when making an https request but there are also some valid use cases where you need to ignore server SSL certs. One good example is when communicating with network devices such as local network equipment such as routers, access-points, wireless bridge radios, and IoT devices.

Read More Read More

JC’s Python News & Notes – July 2020

JC’s Python News & Notes – July 2020

This is a place for me to save Python related news, notes and code snippets that I find interesting. One post per month updated throughout. This is experimental, I hope I can find enough time to keep these posts going.

Last Updated: 7/13/2020

Read More Read More

Scapy DHCP listener in Python

Scapy DHCP listener in Python

This script listens for DHCP Request and Discover packets on the LAN using scapy.

A little background on the DHCP protocol

Hosts issue a DHCP Discover packet to destination 255.255.255.255 to request an IP Address assignment from a DHCP server. DHCP Discover, Request, Offer, Ack and Inform packets are sent as broadcasts, all hosts on the LAN receive these packets. Because of the nature of the protocol, no special port mirroring or tapping is required on the host that runs this script.

This script is the foundation for creating a passive network discovery tool. We can collect and store the Mac Address, Hostname, and IP Address all hosts configured for DHCP IP address assignment.

Read More Read More

Scapy ARP listener in Python

Scapy ARP listener in Python

This script listens for ARP request packets using scapy to learn the IP and Mac Address of LAN hosts.

A little background on the ARP protocol

ARP is the protocol that hosts use to discover the mac address of another LAN host. The initiating host asks “Who Has <IP Address>”, this request is transmitted as a broadcast ethernet packet to destination 00:00:00:00:00:00. Since the ARP request is sent as a broadcast, all hosts on the LAN receive and process this packet. Because of the nature of the protocol, no special port mirroring or tapping is required on the host that runs this script.

The host that has <IP Address> will reply back directly to the requester so we will not see that ARP reply packet unless our machine sent the initial ARP request.

This script is the foundation for creating a passive network discovery tool. We can collect and store the MAC Address, IP Address pairs for all hosts we hear communicating on the network.

Read More Read More

MikroTik RouterOS Automation with NAPALM

MikroTik RouterOS Automation with NAPALM

In this tutorial, we will explore using the NAPALM python module to query data from a MikroTik Router.

Before we begin, you are expected to have python3 and pip installed as well as access to a MikroTik router running RouterOS. NAPALM will attempt to connect to the router on the default API port of 8728. You will need to enable the API service which is found in IP | Services using winbox

Read More Read More

How to use pipenv in your python project

How to use pipenv in your python project

“goodbye requirements.txt, hello Pipfile”

In this article, I will introduce you to pipenv and show you how easy it is to use. pipenv removes the awkwardness of working with virtual environments and module dependencies. Once you spend 15 minutes with pipenv, you will realize the clarity and time savings it will bring to your python project.

Read More Read More

Python Tutorial: Get Temperature and other environmental data from a Dell PowerEdge Server using pysnmp

Python Tutorial: Get Temperature and other environmental data from a Dell PowerEdge Server using pysnmp

This python tutorial will teach you how to query the Dell PowerEdge temperature sensors via SNMP. Once OpenManage software is installed on a Dell server, a ton of information is made available via SNMP including…

Read More Read More