kamene icon indicating copy to clipboard operation
kamene copied to clipboard

Automation - Too many open files

Open c0d3z3r0 opened this issue 9 years ago • 3 comments

When I run a large automation script I'll get this Exception


OSError Traceback (most recent call last) in () 1 for i in range(0,46): 2 for c in chars: ----> 3 if testChar(i, c): 4 flag = flag + c 5 print(c)

in testChar(pos, char) 2 ip_layer = sc.IP(dst="192.168.42.223") 3 icmp_layer = sc.ICMP(type=13, seq=pos, id=ord(char)) ----> 4 response = sc.sr1(ip_layer/icmp_layer, verbose=False) 5 raw = str(bytes(response[0][0][1])) 6 if re.search('->OK'd<-', raw):

/usr/local/homebrew/lib/python3.4/site-packages/scapy/sendrecv.py in sr1(x, filter, iface, nofilter, _args, *_kargs) 337 kargs["timeout"] = -1 338 s=conf.L3socket(filter=filter, nofilter=nofilter, iface=iface) --> 339 a,b=sndrcv(s,x,args,*kargs) 340 s.close() 341 if len(a) > 0:

/usr/local/homebrew/lib/python3.4/site-packages/scapy/sendrecv.py in sndrcv(pks, pkt, timeout, inter, verbose, chainCC, retry, multi) 71 timeout = None 72 ---> 73 rdpipe,wrpipe = os.pipe() 74 rdpipe=os.fdopen(rdpipe, "rb") 75 wrpipe=os.fdopen(wrpipe,"wb")

OSError: [Errno 24] Too many open files

c0d3z3r0 avatar Mar 28 '15 00:03 c0d3z3r0

The code I'm running:

import string
import scapy.all as sc
import re
import time
import sys
def testChar(pos,char):
    ip_layer = sc.IP(dst="192.168.42.223")
    icmp_layer = sc.ICMP(type=13, seq=pos, id=ord(char))
    response = sc.sr1(ip_layer/icmp_layer, verbose=False)
    raw = str(bytes(response))
    if re.search('OK\'d', raw):
        return True
    return False
flag=""
chars = string.ascii_lowercase + '_'
for i in range(0,46):
    time.sleep(5)
    for c in chars:
        if testChar(i, c):
            flag = flag + c
            print(c)
            continue

c0d3z3r0 avatar Mar 28 '15 00:03 c0d3z3r0

What is your open files limit? Have you tried increasing it? http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/

phaethon avatar Apr 24 '15 14:04 phaethon

I think the open files limit shouldn't be reached at all. Using the same code with python2 works without any problems. My limit is 12288

c0d3z3r0 avatar Apr 24 '15 14:04 c0d3z3r0