Category Archives: Python

Python script to ping ip in a subnet

from commands import getoutput from multiprocessing import Process from sys import exit class PING_SWEEP(object): def pinger(self, host_num): “””thread pinger function””” hostadrr = host.split(‘.’)[:-1]#removes . from user input hostadrr = ‘.’.join(hostadrr) + ‘.’ + repr(host_num) # adds . and last octet … Continue reading

Posted in Python | Leave a comment

Python script to print all hyper links on a URL

We can use this script to find all hyper links on a web page. This script can be used in reconnaissance. import urllib2 import re import sys #connect to a URL url= str(sys.argv[1]) website = urllib2.urlopen(url) #read html code html … Continue reading

Posted in Python | Leave a comment

Python How to

How to do error handling in python: try: b=kjk except Exception as e: print(e) output: name ‘kjk’ is not defined name ‘b’ is not defined  

Posted in Python | Tagged , , | Leave a comment

Python: What is

What is the difference between import and from x import y: With import x, you refer things in x like x.something. WIth from x import *, you refer things in x directly just as something.

Posted in Python | Tagged , | Leave a comment

Scapy basic on ubuntu 16.04

Scapy have two versions: Scapy v1.x.: Works with Python 2.4 Scapy v2.x.: If Scapy v2 version is <= 2.3.3 it needs Python 2.5, If Scapy v2 version is > 2.3.3 needs Python 2.7. How to install scapy: 1> To install … Continue reading

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

Python syntax with example

Python version 3.6.2: Python is an interpreted language. Statement grouping is done by indentation instead of beginning and ending brackets. Note Output is in blue. Comments in python: Use hash to enter comment in python. # Indexing of string: name=”abcdef” … Continue reading

Posted in Python | Leave a comment

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

Prerequisite: You need to install openssl package for python. Use following command to install openssl for python: pip install pyopenssl #Following script will create a self signed root ca cert. from OpenSSL import crypto, SSL from os.path import join import … Continue reading

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