-
Notifications
You must be signed in to change notification settings - Fork 0
/
populateDB.js
275 lines (241 loc) · 10.6 KB
/
populateDB.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
async function getGeneratedFingerprints() {
const response = await fetch('fingerprint.json')
return response.json();
}
async function fetchGeneratorData() {
const response = await fetch('https://raw.githubusercontent.com/apify/fingerprint-generator/master/src/data_files/fingerprint-network-definition.json')
return response.json();
}
let index = document.getElementById("index").value
console.log("INDEX", index)
function getRandomBoolean() {
return Math.random() < 0.5; // Returns true with 50% probability
}
function addRandomSuffixWithProbability(inputString) {
const suffixProbabilities = {
"slimerjs": 0.01,
"headless": 0.01,
"electron": 0.01
};
let random;
random = Math.random();
let selectedSuffix = "";
for (const suffix in suffixProbabilities) {
if (random < suffixProbabilities[suffix]) {
selectedSuffix = suffix;
break;
} else {
random -= suffixProbabilities[suffix];
}
}
return inputString + selectedSuffix;
}
function getRandomElementFromArray(array) {
const randomIndex = Math.floor(Math.random() * array.length);
return array[randomIndex];
}
function getRandomBrowser() {
const browsers = ["unknown", "chrome", "firefox", "opera", "safari", "internet_explorer", "wechat", "edge"];
const randomIndex = Math.floor(Math.random() * browsers.length);
return browsers[randomIndex];
}
function getRandomRenderingEngine() {
const renderingEngines = ["unknown", "chromium", "gecko", "webkit"];
const randomIndex = Math.floor(Math.random() * renderingEngines.length);
return renderingEngines[randomIndex];
}
function getRandomEvalLength() {
const lengths = [33, 37, 39];
const randomIndex = Math.floor(Math.random() * lengths.length);
return lengths[randomIndex];
}
function getRandomArray() {
const probability = 0.01;
if (Math.random() < probability) {
return [];
} else {
return [["lang"]];
}
}
function getRandomBooleanTrue() {
return Math.random() < 0.99;
}
function getRandomBooleanFalse() {
return Math.random() > 0.99;
}
function getRandomWeightedNumber() {
const maxNumber = 30;
const exponent = 3; // Adjust the exponent to control the distribution shape
// Generate a random number with a weighted distribution
const weightedRandom = Math.pow(Math.random(), exponent);
// Scale and round to get a number between 0 and maxNumber
return Math.floor(weightedRandom * (maxNumber + 1));
}
function getRandomVendor() {
const probabilityBrianPaul = 0.01;
const entities = [
"Google Inc.",
"WebKit",
"Apple Computer, Inc.",
"Unknown"
];
if (Math.random() < probabilityBrianPaul) {
return "Brian Paul";
} else {
const randomIndex = Math.floor(Math.random() * entities.length);
return entities[randomIndex];
}
}
function getRandomRenderer() {
const probabilityMesaOffScreen = 0.001;
const graphicsInfoOptions = [
"Intel(R) HD Graphics.",
"WebKit WebGL",
"ANGLE (Intel, Mesa Intel(R) Xe Graphics (TGL GT2), OpenGL 4.6)",
"Unknown",
"Mozilla"
];
if (Math.random() < probabilityMesaOffScreen) {
return "Mesa offScreen";
} else {
const randomIndex = Math.floor(Math.random() * graphicsInfoOptions.length);
return graphicsInfoOptions[randomIndex];
}
}
function extractScreenInfo(inputString) {
const regex = /"innerHeight":(\d+),"outerHeight":(\d+),"outerWidth":(\d+),"innerWidth":(\d+)/;
const match = inputString.match(regex);
if (match) {
const [, innerHeight, outerHeight, outerWidth, innerWidth] = match.map(Number);
return {
innerHeight,
outerHeight,
outerWidth,
innerWidth
};
} else {
return {
innerHeight: 0,
outerHeight: 0,
outerWidth: 0,
innerWidth: 0
}; // Return null or any other value if the pattern is not found
}
}
const generatorData = fetchGeneratorData()
const fingerprints = getGeneratedFingerprints()
generatorData.then(generatorData => {
fingerprints.then(fingerprints => {
for (let i = 0; i < 1000; i++) {
const botPromise = import('https://openfpcdn.io/botd/v1').then((Botd) =>
Botd.load()
);
console.log(index)
let jsonData = {
bot: false,
android: false,
appVersion: "",
browserEngineKind: "",
browserKind: "",
distinctiveProps: [],
documentElementKeys: [],
documentFocus: false,
evalLength: 0,
functionBind: "",
languages: [],
mimeTypesConsistent: false,
notificationPermissions: false,
pluginsArray: false,
pluginsLength: 0,
productSub: 0,
process: 0,
rtt: 0,
userAgent: "",
webDriver: false,
webGlVendor: "",
webGlRenderer: "",
windowExternal: "",
innerHeight: 0,
innerWidth: 0,
outerHeight: 0,
outerWidth: 0
}
botPromise
.then((bot) => {
bot.components.android.value = getRandomBooleanFalse();
bot.components.appVersion.value = addRandomSuffixWithProbability(fingerprints[index].fingerprint.navigator.appVersion);
bot.components.browserEngineKind.value = getRandomRenderingEngine();
bot.components.browserKind.value = getRandomBrowser();
bot.components.documentFocus.value = getRandomBoolean();
bot.components.evalLength.value = getRandomEvalLength();
bot.components.languages.value = [fingerprints[index].fingerprint.navigator.languages];
bot.components.mimeTypesConsistent.value = getRandomBooleanTrue();
bot.components.notificationPermissions.value = getRandomBoolean();
bot.components.pluginsArray.value = getRandomBooleanTrue();
bot.components.pluginsLength.value = fingerprints[index].fingerprint.pluginsData.plugins.length;
bot.components.productSub.value = fingerprints[index].fingerprint.navigator.productSub;
bot.components.rtt.value = getRandomBooleanFalse() ? -1 : Math.floor(Math.random() * 251);
bot.components.userAgent.value = fingerprints[index].fingerprint.navigator.userAgent;
bot.components.webDriver.value = getRandomBooleanFalse();
bot.components.webGL.value.vendor = getRandomVendor();
bot.components.webGL.value.renderer = getRandomRenderer();
let screenInfo = extractScreenInfo(getRandomElementFromArray(generatorData.nodes[17].possibleValues));
bot.components.windowSize.value.innerHeight = screenInfo.innerHeight;
bot.components.windowSize.value.innerWidth = screenInfo.innerWidth;
bot.components.windowSize.value.outerHeight = screenInfo.outerHeight;
bot.components.windowSize.value.outerWidth = screenInfo.outerWidth;
jsonData.android = bot.components.android.value
jsonData.appVersion = bot.components.appVersion.value
jsonData.browserEngineKind = bot.components.browserEngineKind.value;
jsonData.browserKind = bot.components.browserKind.value;
jsonData.distinctiveProps = JSON.stringify(bot.components.distinctiveProps.value).split(",");
jsonData.documentElementKeys = bot.components.documentElementKeys.value;
jsonData.documentFocus = bot.components.documentFocus.value;
jsonData.evalLength = bot.components.evalLength.value;
jsonData.functionBind = bot.components.functionBind.value;
jsonData.languages = bot.components.languages.value;
jsonData.mimeTypesConsistent = bot.components.mimeTypesConsistent.value;
jsonData.notificationPermissions = bot.components.notificationPermissions.value;
jsonData.pluginsArray = bot.components.pluginsArray.value;
jsonData.pluginsLength = bot.components.pluginsLength.value;
jsonData.process = 0;
jsonData.productSub = bot.components.productSub.value;
jsonData.rtt = bot.components.rtt.value;
jsonData.userAgent = bot.components.userAgent.value;
jsonData.webDriver = bot.components.webDriver.value;
jsonData.webGlVendor = bot.components.webGL.value.vendor;
jsonData.webGlRenderer = bot.components.webGL.value.renderer;
jsonData.windowExternal = bot.components.windowExternal.value;
jsonData.innerHeight = bot.components.windowSize.value.innerHeight;
jsonData.innerWidth = bot.components.windowSize.value.innerWidth;
jsonData.outerHeight = bot.components.windowSize.value.outerHeight;
jsonData.outerWidth = bot.components.windowSize.value.outerWidth;
jsonData.bot = bot.detect().bot
const apiEndpoint = "http://localhost:8080/api/bot-data";
let headers;
headers = {
"Content-Type": "application/json",
};
// Make the POST request
fetch(apiEndpoint, {
method: "POST",
headers: headers,
body: JSON.stringify(jsonData),
}).then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
console.log("POSTED", i)
})
.then((data) => {
console.log("POST request successful!");
console.log("Response:", data);
})
.catch((error) => {
console.error("POST request failed:", error);
});
document.getElementById("index").value = index++
})
}
})
})