Skip to content

[Bug]: Route.fetch: getaddrinfo ENOTFOUND ***.onion #2644

@pyNpy

Description

@pyNpy

Version

playwright 1.44.0 and 1.48.0

Steps to reproduce

the code like this:

class DarkVault:
        def handle_jquery_js_url(self, route:Optional[Route],request:Optional[Request] ):
            response = route.fetch(timeout=600000)
            text = response.text()
           #  replace jquery url 
            text = text.replace("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js%3C",
                                "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js")
            text = text.replace("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js<",
                            "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js")
            route.fulfill(response=response, body=text)
            pass
    pass
    pass

def test_demo_request_page(ransom_spider:Optional[DarkVault], remote_port:Optional[int]=9333)

   # in this html,  jquery.js  address is wrong
   # want to replace  response  text  : https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js%3C  to  https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js
   #
    start_url = "http://5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion/pwned.html"
    pass
    page1: Optional[Page] = None
    for pagelist in open_browser_pages_by_cdp(remote_debug_port=remote_port, page_count=1 ):
        try:
            (page1, ) = pagelist
            
            page1.route(url="**/*.html", handler= ransom_spider.handle_jquery_js_url)

            PwBrowserStatic.goto_url_by_ensuer_xpath(page1, start_url )
            
            pass
        except Exception as ex:
            print(ex)
            pass
        finally:
            try:
                # PwBrowserStatic.close_remote_page(page1)

                pass
            except:
                pass
        pass
    pass


the bugs like this:

Error occurred in event listener
Traceback (most recent call last):
  File "D:\python38\lib\site-packages\playwright\_impl\_page.py", line 297, in _on_route
    handled = await route_handler.handle(route)
  File "D:\python38\lib\site-packages\playwright\_impl\_helper.py", line 309, in handle
    raise e
  File "D:\python38\lib\site-packages\playwright\_impl\_helper.py", line 296, in handle
    return await self._handle_internal(route)
  File "D:\python38\lib\site-packages\playwright\_impl\_helper.py", line 332, in _handle_internal
    await handler_finished_future
  File "D:\python38\lib\site-packages\playwright\_impl\_helper.py", line 323, in _handler
    self.handler(route, route.request)  # type: ignore
  File "D:\python38\lib\site-packages\playwright\_impl\_impl_to_api_mapping.py", line 123, in wrapper_func
    return handler(
  File "**********DarkVault.py", line 232, in handle_jquery_js_url
    response = route.fetch(timeout=600000)
  File "D:\python38\lib\site-packages\playwright\sync_api\_generated.py", line 804, in fetch
    self._sync(
  File "D:\python38\lib\site-packages\playwright\_impl\_sync_base.py", line 115, in _sync
    return task.result()
  File "D:\python38\lib\site-packages\playwright\_impl\_network.py", line 457, in fetch
    return await self._connection.wrap_api_call(
  File "D:\python38\lib\site-packages\playwright\_impl\_connection.py", line 520, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: Route.fetch: getaddrinfo ENOTFOUND 5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion
Call log:
→ GET http://5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion/pwned.html
  -   user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
  -   accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
  -   accept-encoding: gzip,deflate,br
  -   dnt: 1
  -   upgrade-insecure-requests: 1



Expected behavior

if the code run ok , the js url in pwned.html , can be replaced .
like this :

"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js<"
->
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js"

Image

Actual behavior

  File "**********DarkVault.py", line 232, in handle_jquery_js_url
    response = route.fetch(timeout=600000)
  File "D:\python38\lib\site-packages\playwright\sync_api\_generated.py", line 804, in fetch
    self._sync(
  File "D:\python38\lib\site-packages\playwright\_impl\_sync_base.py", line 115, in _sync
    return task.result()
  File "D:\python38\lib\site-packages\playwright\_impl\_network.py", line 457, in fetch
    return await self._connection.wrap_api_call(
  File "D:\python38\lib\site-packages\playwright\_impl\_connection.py", line 520, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None

playwright._impl._errors.Error: Route.fetch: getaddrinfo ENOTFOUND 5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion 

Call log:
→ GET http:/***.onion/pwned.html
  -   user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
  -   accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
  -   accept-encoding: gzip,deflate,br
  -   dnt: 1
  -   upgrade-insecure-requests: 1

the bug description:
Route.fetch: getaddrinfo ENOTFOUND 5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion ,

it shows that maybe Route.fetch not use chrome to request the ***.onion ???

Additional context

the fact is that my chrome browser can access this website , "http://5vphklgizbimeq5l4yt274p533fgirhqnjhjuppcp2ibteavmro5fzad.onion/",

Image

Environment

- Operating System: [WINDOWNS-10]
- CPU: [AMD Ryzen 7 4800H with Radeon Graphics]
- Browser: [chrome version 130.0.6723.117]
- Python Version: [3.8]
- Other info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions