Page 1 of 1

Python Tool

PostPosted: Wed Apr 08, 2015 7:50 am
by Zemuse
Hi guys,

New here but some of you may like this... A little proof of concept i wrote, i found this site when googling it. I am going to leave what it does up to you to determine. Feel free to take it if you have a need for it. Python 2.7 and Scapy.


Code: Select all
from scapy.all import *
import sys

def raid(pkts):
    try:
        if pkts[0][TCP].dport >= int(sys.argv[1]) and pkts[0][TCP].dport <= int(sys.argv[2]):
            retpkt = eval(pkts[0].command())
            retpkt[Ether].src, retpkt[Ether].dst = pkts[0].dst, pkts[0].src
            retpkt[IP].src, retpkt[IP].dst = pkts[0][IP].dst, pkts[0][IP].src
            retpkt[TCP].sport, retpkt[TCP].dport = pkts[0][TCP].dport, pkts[0][TCP].sport
            retpkt[TCP].flags, retpkt[TCP].seq, retpkt[TCP].ack = "SA", 1,1
            print "[!]",pkts[0][IP].src,"----->", pkts[0][IP].dst+":",pkts[0][TCP].dport, "Requested by", pkts[0][IP].src
            print "[!]",pkts[0][IP].dst,"<-----", pkts[0][IP].src+":",pkts[0][TCP].dport, "Open for Business"

            sendp(retpkt, verbose=False)
            return
    except:
        pass
   
if __name__ == "__main__":
       
        try:
            sys.argv[1]
        ## Removed, is a giveaway ##
        except:
            sys.exit()

        try:
            sys.argv[2]
        ## Removed, is a giveaway ##
        except:
            sys.exit()

        ## Add exceptions list ###

        if os.getuid() != 0:
            print "[!] Please run as root."
            sys.exit()
           
       ## Main ##
           
        pkts= sniff(prn=raid)