browserforge icon indicating copy to clipboard operation
browserforge copied to clipboard

Persistent Fingerprints Using Files

Open 34892002 opened this issue 9 months ago • 9 comments

Hi, I need to save the generated fingerprint to a file such that I could load it back later to the browser. Is there a way to dump and load the fingerprint to/from a file?

thanks.

34892002 avatar Apr 07 '25 08:04 34892002

The code written like this is invalid.

if os.path.exists(fingerprint_path):
        with open(fingerprint_path, 'r', encoding='utf-8') as f:
            data = json.load(f)

        fingerprint = Fingerprint(
            screen=ScreenFingerprint(**data['screen']),
            navigator=NavigatorFingerprint(**data['navigator']),
            headers=data['headers'],
            videoCodecs=data['videoCodecs'],
            audioCodecs=data['audioCodecs'],
            pluginsData=data['pluginsData'],
            battery=data['battery'],
            videoCard=VideoCard(**data['videoCard']) if data.get('videoCard') else None,
            multimediaDevices=data['multimediaDevices'],
            fonts=data['fonts'],
            mockWebRTC=data.get('mockWebRTC', False),
            slim=data.get('slim', False)
        )
    else:
        fingerprint = fg.generate()
        fingerprint_dict = json.loads(fingerprint.dumps())
        with open(fingerprint_path, 'w', encoding='utf-8') as f:
            json.dump(fingerprint_dict, f, ensure_ascii=False, indent=4)

34892002 avatar Apr 07 '25 08:04 34892002

you can use pickle.dump and pickle.load

xmmw avatar Jun 05 '25 05:06 xmmw

json dump does not support dataclass

xmmw avatar Jun 05 '25 05:06 xmmw

https://github.com/daijro/browserforge/pull/35

techinz avatar Jun 26 '25 21:06 techinz

@techinz Hey. Thanks for the pr. correct me if I'm wrong, but when load up creepjs , it keeps rotating different FP ID, albeit with the same device type. When using regular chromium, that ID remains the same.

edit: It seems like if one is using camoufox, many browserforge attributes will simply be ignored, and swapped out with a random value

fingerprint (Optional [Fingerprint]):
Use a custom BrowserForge fingerprint. Note: Not all values will be implemented.
If not provided, a random fingerprint will be generated based on the provided
`os&s os & screen constraints.

kqvanity avatar Sep 04 '25 21:09 kqvanity

@techinz Hey. Thanks for the pr. correct me if I'm wrong, but when load up creepjs , it keeps rotating different FP ID, albeit with the same device type. When using regular chromium, that ID remains the same.

edit: It seems like if one is using camoufox, many browserforge attributes will simply be ignored, and swapped out with a random value

fingerprint (Optional [Fingerprint]): Use a custom BrowserForge fingerprint. Note: Not all values will be implemented. If not provided, a random fingerprint will be generated based on the provided `os&s os & screen constraints.

Yeah, later I noticed that it works weird and I found some other way to persist fingerprints. I think there is no good way to do it atm.

techinz avatar Sep 09 '25 01:09 techinz

@techinz Vlad, share please your experience on how you managed to achieve a persist fingerprints. I am also looking for a solution.

artemrts avatar Sep 09 '25 04:09 artemrts

@techinz Vlad, share please your experience on how you managed to achieve a persist fingerprints. I am also looking for a solution.

I don't really remember and not sure if it worked, but it was something like that:

fingerprint_file = os.path.join(user_data_path, "fingerprint.json")

if os.path.exists(fingerprint_file):
    opts = json.load(open(fingerprint_file))
else:
    opts = launch_options(headless=...,
                          proxy=...,
                          geoip=True,

                          user_data_dir=user_data_path
                          )
    json.dump(opts, open(fingerprint_file, "w"), indent=2)

camoufox = AsyncCamoufox(
    persistent_context=True,
    from_options=opts,

    i_know_what_im_doing=True
)

techinz avatar Sep 09 '25 13:09 techinz

@techinz I know this)) I am about of content of fingerprint.json. I am looking for parameters example.

artemrts avatar Sep 09 '25 16:09 artemrts