A quick enum script in Python :)

#!/usr/bin/python
#-*- coding: utf-8 -*- #Quickfix for Nordic characters

import argparse
import os
import sys
import nmap
import subprocess
import pyfiglet
from colorama import Fore, Back, Style

def copy():
    print(Fore.RED)
    banner=pyfiglet.figlet_format("QuickScan 2")
    print(banner)
    print(Fore.CYAN + 'By NX - This email address is being protected from spambots. You need JavaScript enabled to view it.')
    print(Fore.WHITE + ' Run with Quickscan2.py -h')
    print(Style.RESET_ALL)


def sweep():
    print("Welcome to the Sweep function")
    ip=raw_input("Input first three network octets like 192.168.0. : ")
    for ping in range(1,255):
        address = ip + str(ping)
        res = subprocess.call(['ping', '-c 1', address])
    if res == 0:
        print("Ping ", address, "OK")
    elif res == 2:
        print("No answer from ", address,)
    else:
        print("Ping ", address, "fejlede !!")
    # Grooovy, it works !! :)
    
# It runs, Nmap's faster. Rewrite for multithreading ?
    # 
    
def root_check():
    if not os.geteuid()==0:
        sys.exit("This program requires ROOT. - Terminating...")

#QuickFix for keyInterrupt error. Not cool, but good enough.

class DevNull:
    def write(self, msg):
	pass
sys.stderr = DevNull()

#MAIN function
def main():

#Define parameter, basis
    parser = argparse.ArgumentParser()
    #parser.add_argument("echo", help="Test echo function, Prints first parameter")
    
    # First ping function
    parser.add_argument('-p', '--ping', type=str, help="Run ping", dest="ping")
    parser.add_argument('-s', '--sweep', help="Ping sweep", action="store_true", dest="sweep")
    parser.add_argument('-n', '--nmap', type=str, help="Run nmap scanning",dest="nmap")
    parser.add_argument('-f', '--fuld', type=str, help="Run extended Nmap scanning", dest="nmap_fuld")
    parser.add_argument('-d', '--dig', type=str, help="Dig HOST", dest="dig")
    parser.add_argument('-c', '--credits', help="Credits", action="store_true", dest="credits")
    
    #parse argumenter
    
    argu = parser.parse_args()

    if argu.ping:
        subprocess.call(['ping', '-c 4', argu.ping])

    if argu.nmap:
        subprocess.call(['nmap', '-sn', argu.nmap])

    if argu.nmap_fuld:
        subprocess.call(['nmap', '-A', argu.nmap_fuld])
        
    if argu.dig:
        subprocess.call(['dig', 'any', argu.dig])

    if argu.sweep:
        sweep()
    
    if argu.credits:
        copy()

#Lets rock :)
if __name__== "__main__":
    root_check()
    main()

My first real attempt at writing some stupid Python enum script. Not very pretty, or effective I know ;) It was basically for playing around with using arguments on the commandline, so it's veeery basic :)

 

You have no rights to post comments