H4ckForJob / dirmap

An advanced web directory & file scanning tool that will be more powerful than DirBuster, Dirsearch, cansina, and Yu Jian.一个高级web目录、文件扫描工具,功能将会强于DirBuster、Dirsearch、cansina、御剑。
GNU General Public License v3.0
3.12k stars 546 forks source link

[爬虫模式]扫描目标超时requests.exceptions.ConnectionError #11

Closed tlhszc closed 5 years ago

tlhszc commented 5 years ago

[+] Load target: http://testphp.vulnweb.com [+] Set the number of thread: 30 [+] Coroutine mode [+] Current target: http://testphp.vulnweb.com/
[] Launching auto check 404 [+] Checking with: http://testphp.vulnweb.com/eepsihlqlxihidaqrkujwqhpwiprvennpoqgombxfy [] Use recursive scan: No
[*] Use crawl mode Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn (self._dns_host, self.port), self.timeout, extra_kw) File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 57, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/local/lib/python3.7/dist-packages/gevent/_socketcommon.py", line 212, in getaddrinfo addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags) File "/usr/local/lib/python3.7/dist-packages/gevent/resolver/thread.py", line 65, in getaddrinfo return self.pool.apply(_socket.getaddrinfo, args, kwargs) File "/usr/local/lib/python3.7/dist-packages/gevent/pool.py", line 159, in apply return self.spawn(func, *args, *kwds).get() File "src/gevent/event.py", line 268, in gevent._event.AsyncResult.get File "src/gevent/event.py", line 296, in gevent._event.AsyncResult.get File "src/gevent/event.py", line 286, in gevent._event.AsyncResult.get File "src/gevent/event.py", line 266, in gevent._event.AsyncResult._raise_exception File "/usr/local/lib/python3.7/dist-packages/gevent/_compat.py", line 47, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/dist-packages/gevent/threadpool.py", line 281, in _worker value = func(args, kwargs) socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/usr/lib/python3.7/http/client.py", line 956, in send self.connect() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in connect conn = self._new_conn() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 168, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fbb2e5a1978>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='testphp.vulnweb.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbb2e5a1978>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/dirmap/lib/controller/engine.py", line 44, in scan bruter(target) File "/root/dirmap/lib/controller/bruter.py", line 505, in bruter payloads.all_payloads = scanModeHandler() File "/root/dirmap/lib/controller/bruter.py", line 348, in scanModeHandler response = requests.get(conf.url, headers=headers, timeout=5) File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='testphp.vulnweb.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbb2e5a1978>: Failed to establish a new connection: [Errno -2] Name or service not known'))

root@kali:~/dirmap#

H4ckForJob commented 5 years ago

@tlhszc 应该是访问网站超时导致的问题。爬虫未给出自定义超时选项,默认5秒超时,解决方案:

#找到dirmap\lib\controller\bruter.py文件,修改第348行timeout超时参数值为30秒。
#response = requests.get(conf.url, headers=headers, timeout=5)
response = requests.get(conf.url, headers=headers, timeout=30)