Skip to content

Instantly share code, notes, and snippets.

@CyberClarence
Created September 29, 2024 03:31
Show Gist options
  • Save CyberClarence/c61b848ae5f91e80cefde13b730401ac to your computer and use it in GitHub Desktop.
Save CyberClarence/c61b848ae5f91e80cefde13b730401ac to your computer and use it in GitHub Desktop.
function generateRandomIPv6() {
const getRandomHexSegment = () => Math.floor(Math.random() * 0x10000).toString(16).padStart(4, '0'); // Generates a random 4-digit hexadecimal segment
// Generate 8 segments and join them with colons
return `${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}`;
}
(async () => {
let requestCount = 0; // Initialize request count
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); // Delay function
while (true) {
const requests = Array.from({ length: 5 }, async (_, i) => {
const index = requestCount + i; // Calculate the current request index
const randomHex = require("crypto").randomBytes(64).toString('hex'); // Generate a random 64-byte hex string
const randomIPv6 = generateRandomIPv6(); // Generate a random IPv6 address
const urlWithParam = `https://zzz/stress-test?x=${index}&random=${randomHex}`; // Append index and random hex to the URL
try {
await fetch(urlWithParam, {
method: 'GET', // Use GET or adjust as necessary
headers: {
'X-Forwarded-For': randomIPv6, // Use random IPv6 in the header
},
});
} catch (error) {
// Handle error silently or perform some other action if needed
// console.error(`Error on request ${index + 1} (x=${index}, random=${randomHex}, IPv6=${randomIPv6}):`, error.message);
}
});
// Wait for all requests in the current batch to finish
await Promise.all(requests);
// Increment the request count by 5
requestCount += 5;
// Wait 1 second before sending the next batch
await delay(1000); // 1 second delay between batches
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment