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

Extract browser cookies support even if the application browser is running. #222

Closed
Prisoner2-6-7 opened this issue Jun 10, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@Prisoner2-6-7
Copy link

Prisoner2-6-7 commented Jun 10, 2023

Describe the bug
Use ./hack-browser-data -vv paste result here
[NOTICE] [browser.go:51,pickChromium] find browser Microsoft Edge success
[NOTICE] [browser.go:53,pickChromium] find browser microsoft_edge_default success
[NOTICE] [browser.go:47,pickChromium] find browser Chromium failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser Vivaldi failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser QQ failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser Brave failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser Yandex failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser 360speed failed, profile folder does not exist
[NOTICE] [browser.go:51,pickChromium] find browser Chrome success
[NOTICE] [browser.go:53,pickChromium] find browser chrome_default success
[NOTICE] [browser.go:47,pickChromium] find browser Chrome Beta failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser Opera failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser OperaGX failed, profile folder does not exist
[NOTICE] [browser.go:47,pickChromium] find browser CocCoc failed, profile folder does not exist
[NOTICE] [browser.go:91,pickFirefox] find browser firefox Firefox failed, profile folder does not exist
[INFO] [chromium_windows.go:35,GetMasterKey] microsoft_edge_default initialized master key success
[NOTICE] [browsingdata.go:71,Output] output to file results/microsoft_edge_default_localstorage.csv success
[NOTICE] [browsingdata.go:71,Output] output to file results/microsoft_edge_default_extension.csv success
[NOTICE] [browsingdata.go:71,Output] output to file results/microsoft_edge_default_history.csv success
[NOTICE] [browsingdata.go:71,Output] output to file results/microsoft_edge_default_download.csv success
[NOTICE] [browsingdata.go:71,Output] output to file results/microsoft_edge_default_cookie.csv success
[ERROR] [main.go:60,func1] open C:\Users\Prisoner-Test\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies: The process cannot access the file because it is being used by another process.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x82837b]

goroutine 1 [running]:
hack-browser-data/internal/browingdata.(*Data).Output(0xc000179420?, {0xa174b9, 0x7}, {0xc00027d690, 0xe}, {0xa12217?, 0x0?})
/source/internal/browingdata/browsingdata.go:51 +0x7b
main.Execute.func1(0xc000140240?)
/source/cmd/hack-browser-data/main.go:62 +0x23e
github.com/urfave/cli/v2.(*App).RunContext(0xc000041ba0, {0xa9bf48?, 0xc00001a0b8}, {0xc0000303e0, 0x2, 0x2})
/go/pkg/mod/github.com/urfave/cli/v2@v2.4.0/app.go:322 +0x97c
github.com/urfave/cli/v2.(*App).Run(...)
/go/pkg/mod/github.com/urfave/cli/v2@v2.4.0/app.go:224
main.Execute()
/source/cmd/hack-browser-data/main.go:73 +0x7f6
main.main()
/source/cmd/hack-browser-data/main.go:24 +0x17

Desktop (please complete the following information):

  • OS Name: windows 10
  • Browser Name: Chrome
  • Browser Version: 114.0.5735.106
    --

[ERROR] [main.go:60,func1] open C:\Users\Prisoner-Test\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies: The process cannot access the file because it is being used by another process.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x82837b]

goroutine 1 [running]:
hack-browser-data/internal/browingdata.(*Data).Output(0xc0004378f0?, {0xc00001a100, 0x7}, {0xc000416670, 0xe}, {0xc00001a0e0?, 0x0?})
/source/internal/browingdata/browsingdata.go:51 +0x7b
main.Execute.func1(0xc000144240?)
/source/cmd/hack-browser-data/main.go:62 +0x23e
github.com/urfave/cli/v2.(*App).RunContext(0xc000041ba0, {0xa9bf48?, 0xc00001a118}, {0xc000102000, 0x8, 0x8})
/go/pkg/mod/github.com/urfave/cli/v2@v2.4.0/app.go:322 +0x97c
github.com/urfave/cli/v2.(*App).Run(...)
/go/pkg/mod/github.com/urfave/cli/v2@v2.4.0/app.go:224
main.Execute()
/source/cmd/hack-browser-data/main.go:73 +0x7f6
main.main()
/source/cmd/hack-browser-data/main.go:24 +0x17

Additional context
Add any other context about the problem here.

@Prisoner2-6-7 Prisoner2-6-7 added the bug Something isn't working label Jun 10, 2023
@moonD4rk moonD4rk self-assigned this Jun 10, 2023
@98games
Copy link

98games commented Jun 14, 2023

我也遇到了这个问题

@saucer-man
Copy link

+1

@sheepdog0x3e
Copy link

When the file C:\Users\Prisoner-Test\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies is locked by other process, the following code will throw this error: [ERROR] [main.go:60,func1] open C:\Users\Prisoner-Test\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies: The process cannot access the file because it is being used by another process.

utils/fileutil/fileutil.go line98-108

func CopyFile(src, dst string) error {
	s, err := os.ReadFile(src)   // The programe can't read Cookies because the file is locked by other process
	if err != nil {
		return err
	}
	err = os.WriteFile(dst, s, 0o600)
	if err != nil {
		return err
	}
	return nil
}

Maybe its better to handle this case by skipping reading files, not throw errors.
@moonD4rk

@moonD4rk
Copy link
Owner

Maybe its better to handle this case by skipping reading files, not throw errors. @moonD4rk

Yes, it could be the issue. I will release a major update in the coming weeks and this particular ISSUSE will be resolved at the same time.

@sheepdog0x3e
Copy link

BTW, I wonder why don't you throw errors in place so you can keep the actual line number for debugging? It took me quite a while to adrress this issue.

Finally I came up with a temp work around by commenting out these lines of code:

browingdata/browingdata.go

func (d *Data) addSources(items []item.Item) {
	for _, source := range items {
		switch source {
		case item.ChromiumPassword:
			d.sources[source] = &password.ChromiumPassword{}
		// case item.ChromiumCookie:
		// 	d.sources[source] = &cookie.ChromiumCookie{}
		case item.ChromiumBookmark:
			d.sources[source] = &bookmark.ChromiumBookmark{}
		......
		}
	}
}

PS: It will leave a file called cookie in the working directory. You must delete the file mannually when done.

@moonD4rk
Copy link
Owner

@sheepdog0x3e Yep, it seems that the reason is that the temporary Cookie files were not deleted. On which platform did this ISSUSE occur? Windows or macOS?

@sheepdog0x3e
Copy link

@sheepdog0x3e Yep, it seems that the reason is that the temporary Cookie files were not deleted. On which platform did this ISSUSE occur? Windows or macOS?

Windows.

@sheepdog0x3e
Copy link

The core reason for this issue is the file C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies is locked by some process and the program doesn't have the priv to open this file.

I tried to copy this file mannually by using windows' copy /b "C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies" ".\cookie", but I got Process cannot access file because it is being used by another process.

So I comment //case item.ChromiumCookie to skip reading Chrome's cookies and delete the temp file cookie manually.

(I find out that I can comment this line out then the program will not try to parse cookie. And I don't have to delete the temp file either)

var DefaultChromium = []Item{
	ChromiumKey,
	ChromiumPassword,
	// ChromiumCookie,
	ChromiumBookmark,
	ChromiumHistory,
	ChromiumDownload,
	ChromiumCreditCard,
	ChromiumLocalStorage,
	ChromiumSessionStorage,
	ChromiumExtension,
}

Maybe you should check if you have the priv to open target files first, if not, then continue to parse next item .

@moonD4rk
Copy link
Owner

@sheepdog0x3e Thanks Bro. The temporary solution is to disable ChromiumCookie in DefaultChromium . I will fix this issue as soon as possible.

@98games
Copy link

98games commented Jul 31, 2023

作者大哥,什么时候能解决这个问题

@moonD4rk
Copy link
Owner

moonD4rk commented Jan 9, 2024

Discuss the specific solution to this issue in this ISSUSE. 👇

#243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants
@moonD4rk @saucer-man @Prisoner2-6-7 @sheepdog0x3e @98games and others