From 44142e8b25b811b19dcde6e0e97be186163aa0d0 Mon Sep 17 00:00:00 2001 From: "SPRINX0\\prochazka" Date: Thu, 5 Sep 2024 11:05:15 +0200 Subject: [PATCH] added info to trial payload --- .../api/src/utility/hardwareFingerprint.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/api/src/utility/hardwareFingerprint.js b/packages/api/src/utility/hardwareFingerprint.js index c944ffe3..167bbf11 100644 --- a/packages/api/src/utility/hardwareFingerprint.js +++ b/packages/api/src/utility/hardwareFingerprint.js @@ -1,13 +1,17 @@ const axios = require('axios'); const os = require('os'); const crypto = require('crypto'); +const platformInfo = require('./platformInfo'); -async function getPublicIp() { +async function getPublicIpInfo() { try { - const resp = await axios.default.get('https://api.ipify.org?format=json'); - return resp.data.ip || 'unknown-ip'; + const resp = await axios.default.get('https://ipinfo.io/json'); + if (!resp.data?.ip) { + return { ip: 'unknown-ip' }; + } + return resp.data; } catch (err) { - return 'unknown-ip'; + return { ip: 'unknown-ip' }; } } @@ -28,7 +32,7 @@ function getMacAddress() { } async function getHardwareFingerprint() { - const publicIp = await getPublicIp(); + const publicIpInfo = await getPublicIpInfo(); const macAddress = getMacAddress(); const platform = os.platform(); const release = os.release(); @@ -36,7 +40,10 @@ async function getHardwareFingerprint() { const totalMemory = os.totalmem(); return { - publicIp, + publicIp: publicIpInfo.ip, + country: publicIpInfo.country, + region: publicIpInfo.region, + city: publicIpInfo.city, macAddress, platform, release, @@ -61,6 +68,11 @@ async function getPublicHardwareFingerprint() { hash, payload: { platform: fingerprint.platform, + city: fingerprint.city, + country: fingerprint.country, + region: fingerprint.region, + isDocker: platformInfo.isDocker, + isElectron: platformInfo.isElectron, }, }; }