Python Tool

A place to submit all custom code, scripts, and programs.
Forum rules
Do NOT post malicious code or programs. Please review all code posted in this forum before downloading or running any of the code or programs here.

Python Tool

Post by Zemuse on Wed Apr 08, 2015 7:50 am
([msg=87630]see Python Tool[/msg])

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)
Zemuse
New User
New User
 
Posts: 1
Joined: Wed Apr 08, 2015 7:41 am
Blog: View Blog (0)


Return to Custom Code

Who is online

Users browsing this forum: No registered users and 0 guests