Skip to content

Instantly share code, notes, and snippets.

@pixdoet
Created August 18, 2022 09:19
Show Gist options
  • Save pixdoet/9540118d4ec4e3a12c20ad835477361e to your computer and use it in GitHub Desktop.
Save pixdoet/9540118d4ec4e3a12c20ad835477361e to your computer and use it in GitHub Desktop.
JS spam request function

Spam script

This is a script written in JS that can be used to create many requests at the same time.
Do note that this is a very easily blocked approach, and you should probably not do naughty stuff with this :P.

Usage

In node: npm install node-fetch node auto.mjs

On browsers: Open the browser console and copy and paste everything starting from line 8. I REPEAT, STARTING FROM LINE 8. There isn't anything that needs to be included in the browser.

Modifiying stuff

Modify the constants at the beginning of the script. To set additional headers, add them into the function.

Responses

The response code will be spitted out, along with some basic information on these codes.
For reference to these codes please refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

/**
* Please READ THE README FILE BEFORE ASKING ANYTHING
*
* Readme file located at ./README.md
*/
import fetch from 'node-fetch';
// BROWSER USERS START COPYING FROM HERE
const DEBUG = true;
const postData = `Lorem ipsum de loret si amem i eat ice cream for breakfast`;
const contentType = "application/json"
const referrer = "https://example.com";
const url = 'https://example.com';
const bufferTime = 1000;
setInterval(function () {
console.log("Is create new request");
var p = fetch(url, {
"credentials": "omit",
"headers": {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:103.0) Gecko/20100101 Firefox/103.0",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-GB,en;q=0.5",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "same-site",
"Pragma": "no-cache",
"Cache-Control": "no-cache"
},
"body": postData,
"referrer": referrer,
"method": "POST",
"mode": "cors"
});
p.then(
function (response) {
switch (response.status) {
case 200:
console.log("200 OK");
break;
case 404:
console.log("404 NOT FOUND");
break;
case 403:
console.log("403 FORBIDDEN");
break;
case 429:
console.log("429 TOO MANY REQUESTS");
break;
default:
console.log("HTTP ERROR OR REDIRECT");
break
}
if (DEBUG) {
console.log(response.status)
//console.log(response.body);
}
}
)
}, bufferTime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment