A
A
Alexander Marginal2019-04-09 18:41:38
JavaScript
Alexander Marginal, 2019-04-09 18:41:38

How to generate hash in fingerprint2?

Now at work I have the task of making an antifrod script that will detect process automation through all sorts of chrome headless and similar things.
I use fingerprint2.js + UAParser + a couple of my own things to accurately add a couple more values ​​​​to the array received from the fingerprint.
The fingerprint uses fuzzyhash, that is, when you change one or two parameters, the hash should differ slightly, as they say in the articles.
For me, all other things being equal on the same computer, chrome, safari, firefox and chrome headless show completely different hashes. Is this normal or am I doing something wrong?
How to make sure that when you change the browser, the hash does not change so much?
Now it's happening like this

Fingerprint2.get({
    fonts: {extendedJsFonts: true},
    preprocessor: (key, value) => {
        if (key == "userAgent") {
            const parser = new UAParser(value);
            return parser.getOS().name + ' ' + parser.getBrowser().name;
        }
        return value
    },
}, components => {
    this.infoArray = components;
    //...добавляем свои значения в this.infoArray...
    this.createHash(this.infoArray);
});


createHash(components) {
    const values = components.map(pair => {return pair.value}).join('');
    this.setProp('values', Fingerprint2.x64hash128(values, 31));
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2019-07-26
@xmoonlight

You don't do anything at all!
To prevent headless crawlers, you need to use a behavioral filter and rules on the server side.
FP2 is needed to identify the thin client (browser) when creating an access/authorization token. If the token is stolen from the cookies, then on the other client the fingerprint will be different and you will not be able to log in with this token.
Let me explain on the "fingers": I reassign (/replace/delete) your js-functions in headless to my own (through the introduction of a local script immediately after loading the page) and all your work is in vain.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question