Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error on browser hijacking - chrome:// and chrome-extension:// #837

Open
xavier268 opened this issue Mar 20, 2023 · 1 comment
Labels
question Questions related to rod

Comments

@xavier268
Copy link

xavier268 commented Mar 20, 2023

Rod Version: v0.112.6

The code to demonstrate your question

     func main() {

    // Open browser, ensure login on a private https site ...
c := sdk.LoadConfig()
defer c.CloseBrowser()
c.Login()

    // hijack everything and trace ...
router := c.Browser().HijackRequests()
router.MustAdd("", trace)
go router.Run()
defer router.Stop()

    // sleep, to let me manually trigger a download, and trace what happens.
time.Sleep(10 * time.Minute)
   }

    // a basic trace function
    func trace(ctx *rod.Hijack) {
fmt.Printf(">>>\tRequest  : %s\n", ctx.Request.URL().String())
err := ctx.LoadResponse(http.DefaultClient, true)
if err != nil {
	fmt.Printf("******\tERROR : %v\n", err)
	fmt.Printf("%#v\n", *ctx.Response)
}

hh := ctx.Response.Headers()
for _, h := range hh {
	fmt.Printf("\t\tResponse : %v\n", h)
}
  }

What you got

When I navigate the site, I "trace" the requests and response as expected, and evything is fine.

Then, when I manually trigger the download button in the browser, i get the follwing unexpected error :

 >>>     Request  : chrome://resources/css/text_defaults_md.css
 >>>     Request  : chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.css
 ******  ERROR : Get "chrome://resources/css/text_defaults_md.css": unsupported protocol scheme "chrome"
 ******  ERROR : Get "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.css": unsupported protocol scheme "chrome-     extension"
 >>>     Request  : chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/main.js
 ******  ERROR : Get "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/main.js": unsupported protocol scheme "chrome-extension"
 rod.HijackResponse{payload:(*proto.FetchFulfillRequest)(0xc00036aa10), fail:(*proto.FetchFailRequest)(0xc000302ae0)}
 >>>     Request  : chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js
 rod.HijackResponse{payload:(*proto.FetchFulfillRequest)(0xc000129880), fail:(*proto.FetchFailRequest)(0xc00012b340)}
 rod.HijackResponse{payload:(*proto.FetchFulfillRequest)(0xc00036a9a0), fail:(*proto.FetchFailRequest)(0xc000302a60)}
 ******  ERROR : Get "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js": unsupported protocol scheme "chrome-extension"
rod.HijackResponse{payload:(*proto.FetchFulfillRequest)(0xc0002f6070), fail:(*proto.FetchFailRequest)(0xc0002b2320)}

In addition, when the router is hijacking, the download is not happeniing any more, whereas when no hijacking is installed, the manual downlod works perfectly on the rod chromium browser.

Obviously, the download seems to trigger a "pdf-viewer" extension, which in turn, does the actual download.

What you expected to see

I would expect :

  • First and foremost, such a router to be fully transparent (except possibly for timing ...) and NOT prevent the download button from operating normally and downloading into the browser,
  • Then, to be able at least to capture the raw response, even if the protocol or format is not recognized.

What have you tried to solve the question

I tried :

  • to intercept the network exchange with both the in-browser web developpement tools ( both chrome and firefox cannot see/record what is happenning when I push the download button )
  • to see whats going on at network level with wireshark/ncap, but obviously, everything is TLS encrypted ... so, no luck !

Any hint on how I could capture, intercept and record what's happening, getting rid of that error ?
Unfortunately, I cannot share the actual site which is private and requires my personnal login.

@xavier268 xavier268 added the question Questions related to rod label Mar 20, 2023
@xavier268 xavier268 changed the title Unexpected error on browser hijacking Unexpected error on browser hijacking - chrome:// and chrome-extension:// Mar 20, 2023
@ysmood
Copy link
Collaborator

ysmood commented Mar 20, 2023

#395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants