Compare commits
10 Commits
c864d2e625
...
ed11b2d15d
| Author | SHA1 | Date | |
|---|---|---|---|
|
ed11b2d15d
|
|||
|
a9ee81c3c4
|
|||
|
e96d3092f5
|
|||
|
b7c9ff1c68
|
|||
|
8b64852e34
|
|||
|
90a9b31d07
|
|||
|
184546335d
|
|||
|
52ea928c86
|
|||
|
3c60b4fe84
|
|||
|
94ef11a0c8
|
@@ -2,6 +2,7 @@ FROM node:lts-alpine
|
||||
USER node
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV production
|
||||
ENV TZ Europe/Warsaw
|
||||
COPY --chown=node:node index.mjs ./
|
||||
EXPOSE 3000
|
||||
CMD ["node", "./index.mjs"]
|
||||
|
||||
24
LICENSE
Normal file
24
LICENSE
Normal file
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org/>
|
||||
50
index.mjs
50
index.mjs
@@ -1,23 +1,43 @@
|
||||
import { createServer } from 'node:http';
|
||||
import { clearInterval, setInterval } from 'node:timers';
|
||||
import { setTimeout } from 'node:timers';
|
||||
|
||||
const msg = 'Relax, take it easy! For there is nothing that we can do.';
|
||||
const minDelay = 3000;
|
||||
const maxDelay = 5000;
|
||||
const delayDiff = maxDelay - minDelay;
|
||||
const randomDelay = () => Math.floor(Math.random() * delayDiff + minDelay);
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
console.log(
|
||||
`Caught ${req.headers['x-forwarded-for']} on ${req.method} ${req.url}`
|
||||
);
|
||||
|
||||
let msg = ':) you are an idiot hahahahaha :)';
|
||||
const connOpenDate = new Date();
|
||||
const dateText = connOpenDate.toLocaleString('pl');
|
||||
const scannerIP = req.headers['x-forwarded-for'];
|
||||
const host = req.headers['x-forwarded-host'];
|
||||
const endpoint = `${req.method} ${req.url}`;
|
||||
let charIdx = 0;
|
||||
let intervalId = setInterval(() => {
|
||||
if (charIdx === msg.length) {
|
||||
charIdx = 0;
|
||||
res.write('\n');
|
||||
} else {
|
||||
res.write(msg[charIdx++]);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
res.once('close', () => clearInterval(intervalId));
|
||||
console.log(`[${dateText}] ${scannerIP} targeted ${host} on ${endpoint}`);
|
||||
|
||||
const hang = () => {
|
||||
if (res.closed) return;
|
||||
else if (charIdx === msg.length) res.end('\n');
|
||||
else res.write(msg[charIdx++]);
|
||||
|
||||
setTimeout(hang, randomDelay());
|
||||
};
|
||||
|
||||
hang();
|
||||
|
||||
res.once('close', () => {
|
||||
const connCloseDate = new Date();
|
||||
const timeDiff = connCloseDate.getTime() - connOpenDate.getTime();
|
||||
const dateText = connCloseDate.toLocaleString('pl');
|
||||
const diffText = new Date(timeDiff).toISOString().substring(14, 19);
|
||||
|
||||
const hangResult =
|
||||
charIdx === msg.length ? 'received the message' : 'aborted connection';
|
||||
|
||||
console.log(`[${dateText}] ${scannerIP} ${hangResult} after ${diffText}`);
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(3000);
|
||||
|
||||
Reference in New Issue
Block a user