maurosoria / dirsearch

Web path scanner
12.09k stars 2.31k forks source link

TypeError: a bytes-like object is required, not 'str' #81

Closed jjruiz closed 6 years ago

jjruiz commented 6 years ago

Error:

Traceback (most recent call last):
  File "dirsearch.py", line 38, in <module>
    main = Program()
  File "dirsearch.py", line 34, in __init__
    self.controller = Controller(self.script_path, self.arguments, self.output)
  File "dirsearch/lib/controller/Controller.py", line 135, in __init__
    self.wait()
  File "dirsearch/lib/controller/Controller.py", line 334, in wait
    self.fuzzer.start()
  File "dirsearch/lib/core/Fuzzer.py", line 80, in start
    self.setupScanners()
  File "dirsearch/lib/core/Fuzzer.py", line 56, in setupScanners
    self.defaultScanner = Scanner(self.requester, self.testFailPath, "")
  File "dirsearch/lib/core/Scanner.py", line 44, in __init__
    self.setup()
  File "dirsearch/lib/core/Scanner.py", line 61, in setup
    self.dynamicParser = DynamicContentParser(self.requester, firstPath, firstResponse.body, secondResponse.body)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 16, in __init__
    self.generateDynamicMarks(firstPage, secondPage)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 33, in generateDynamicMarks
    self.cleanPage = self.removeDynamicContent(firstPage, self.dynamicMarks)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 96, in removeDynamicContent
    page = re.sub(r'(?s){0}.+$'.format(re.escape(prefix)), prefix.replace('\\', r'\\'), page)
TypeError: a bytes-like object is required, not 'str'
maurosoria commented 6 years ago

I pushed a possible fix. Try fix_75 branch. I need feedback to fixing this problem

git clone https://github.com/maurosoria/dirsearch -b fix_75

Thanks

jjruiz commented 6 years ago

Thank you for your response.

Applying that fix I get the following error:

Traceback (most recent call last):
  File "dirsearch.py", line 38, in <module>
    main = Program()
  File "dirsearch.py", line 34, in __init__
    self.controller = Controller(self.script_path, self.arguments, self.output)
  File "dirsearch/lib/controller/Controller.py", line 135, in __init__
    self.wait()
  File "dirsearch/lib/controller/Controller.py", line 334, in wait
    self.fuzzer.start()
  File "dirsearch/lib/core/Fuzzer.py", line 80, in start
    self.setupScanners()
  File "dirsearch/lib/core/Fuzzer.py", line 56, in setupScanners
    self.defaultScanner = Scanner(self.requester, self.testFailPath, "")
  File "dirsearch/lib/core/Scanner.py", line 44, in __init__
    self.setup()
  File "dirsearch/lib/core/Scanner.py", line 61, in setup
    self.dynamicParser = DynamicContentParser(self.requester, firstPath, firstResponse.body, secondResponse.body)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 16, in __init__
    self.generateDynamicMarks(firstPage, secondPage)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 33, in generateDynamicMarks
    self.cleanPage = self.removeDynamicContent(firstPage, self.dynamicMarks)
  File "dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 86, in removeDynamicContent
    encoding = chardet.detect(page)['encoding']
NameError: name 'chardet' is not defined
maurosoria commented 6 years ago

Run a git pull and try again

maurosoria commented 6 years ago

?????

zerodaykb commented 6 years ago

I had same error. On branch fix_75 there is:

File "dirsearch.py", line 38, in <module>
    main = Program()
  File "dirsearch.py", line 34, in __init__
    self.controller = Controller(self.script_path, self.arguments, self.output)
  File "/my_private_absolute_path/dirsearch/lib/controller/Controller.py", line 135, in __init__
    self.wait()
  File "/my_private_absolute_path/dirsearch/lib/controller/Controller.py", line 334, in wait
    self.fuzzer.start()
  File "/my_private_absolute_path/dirsearch/lib/core/Fuzzer.py", line 80, in start
    self.setupScanners()
  File "/my_private_absolute_path/dirsearch/lib/core/Fuzzer.py", line 57, in setupScanners
    self.scanners['/'] = Scanner(self.requester, self.testFailPath, "/")
  File "/my_private_absolute_path/dirsearch/lib/core/Scanner.py", line 44, in __init__
    self.setup()
  File "/my_private_absolute_path/dirsearch/lib/core/Scanner.py", line 61, in setup
    self.dynamicParser = DynamicContentParser(self.requester, firstPath, firstResponse.body, secondResponse.body)
  File "/my_private_absolute_path/dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 16, in __init__
    self.generateDynamicMarks(firstPage, secondPage)
  File "/my_private_absolute_path/dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 33, in generateDynamicMarks
    self.cleanPage = self.removeDynamicContent(firstPage, self.dynamicMarks)
  File "/my_private_absolute_path/dirsearch/thirdparty/sqlmap/DynamicContentParser.py", line 91, in removeDynamicContent
    suffix = suffix.decode(encoding, errors='replace')
AttributeError: 'NoneType' object has no attribute 'decode'
maurosoria commented 6 years ago

I've just pushed a possible patch for that bug. I can't reproduce the error, so I'm not sure it will work...

zerodaykb commented 6 years ago

It works. :)

maurosoria commented 6 years ago

Finally ! :)