Initial commit

master
Kuba Orlik 2 years ago
commit 8f9cfd0817

1
.gitignore vendored

@ -0,0 +1 @@
/node_modules/

@ -0,0 +1,20 @@
const { spawn } = require("child_process");
module.exports = async function getISP(ip_address) {
return new Promise((resolve, reject) => {
const task = spawn("whois", [ip_address]);
let data = "";
task.stdout.on("data", (d) => {
data += d.toString();
});
task.on("close", () => {
resolve(
data
.split("\n")
.filter((l) => l.includes("role:"))
.join("|")
);
});
task.on("error", () => reject());
});
};

@ -0,0 +1,109 @@
const { getEmoji } = require("./number-to-emoji");
module.exports = function (id, card) {
return /* HTML */ `<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<head>
<meta charset="utf-8" />
<title>Hackowanie....</title>
</head>
<style>
.card {
border-radius: 4px;
padding: 4px;
}
</style>
<script>
window.$ = document.write.bind(document);
</script>
<style>
* {
font-family: monospace;
color: green;
background-color: black;
}
html {
font-size: 20px;
}
li {
display: none;
}
</style>
<img id="track" style="opacity:0" />
<script>
track.src = \`/track?id=${id}&DNT=\${navigator.doNotTrack}&lang=\${
navigator.language
}&res=\${
window.screen.width + "x" + window.screen.height
}&appCodeName=\${navigator.appCodeName}&appVersion=\${
navigator.appVersion
}&platform=\${navigator.platform}\`;
</script>
<body>
<h1>Trwa hackowanie telefonu....</h1>
<ul>
<li>ID ATAKU: <strong>${id}</strong></li>
<li>TWOJA KARTA TO: ${getEmoji(card)}</li>
<li>
<script>
$(navigator.appCodeName);
$(" ");
$(navigator.appVersion);
</script>
</li>
<li>
Obsługa Cookiesów włączona:
<script>
$(navigator.cookieEnabled);
</script>
</li>
<li>
CPU:
<script>
$(navigator.platform);
</script>
</li>
<li>
Do Not Track:
<script>
$(navigator.doNotTrack);
</script>
</li>
<li>
Język:
<script>
$(navigator.language);
</script>
</li>
<li>
Rozdzielczość ekranu:
<script>
$(window.screen.width + "x" + window.screen.height);
</script>
</li>
<li>
Hash zainstalowanych fontów:
<script>
$("ba69897483886f0d2b0afb6345b76c0c");
</script>
</li>
</ul>
</body>
<script>
async function sleep(timeout) {
return new Promise((resolve) => setTimeout(resolve, timeout));
}
(async function go() {
const lis = Array.from(document.querySelectorAll("li"));
for (const li of lis) {
li.style.display = "list-item";
await sleep(1000 + Math.random() * 1000);
}
})();
</script>
</html>`;
};

@ -0,0 +1,91 @@
var serve = require("koa-static");
const Koa = require("koa");
const Router = require("@koa/router");
const mount = require("koa-mount");
const { getCard, getEmoji } = require("./number-to-emoji");
const getISP = require("./get-isp");
const router = new Router();
// response
const app = new Koa();
const static = new Koa();
static.use(serve("./static"));
app.use(mount("/static", static));
const mainView = require("./index.html.js");
function* idgen() {
let i = 1;
while (true) {
yield i++;
}
}
const id = idgen();
const id_to_card = {};
router.get("/", async (ctx) => {
// stream data
ctx.set("content-type", "text/html");
const _id = id.next().value;
const _card = getCard();
id_to_card[_id] = _card;
ctx.body = mainView(_id, _card);
});
const tracks = [];
router.get("/track", async (ctx) => {
const ISP = await getISP(ctx.request.ip);
tracks.push({ ...ctx.query, ip: ctx.request.ip, ISP });
});
router.get("/stats", async (ctx) => {
ctx.set("content-type", "text/html");
console.log(tracks);
if (tracks.length === 0) {
ctx.body = /* HTML */ `<!DOCTYPE html>No tracks so far`;
return;
}
ctx.body = /* HTML */ `<!DOCTYPE html>
<html>
<head>
<title>Results</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
tr:hover {
background-color: #ddd;
}
</style>
</head>
<body>
<table>
<tr>
<th>Mark</th>
<th>Card</th>
${Object.keys(tracks[0])
.map((key) => `<th>${key}</th>`)
.join("")}
</tr>
${tracks
.map(
(track) => /* HTML */ `<tr>
<td><input type="checkbox" /></td>
<td>${getEmoji(id_to_card[track.id])}</td>
${Object.values(track)
.map((value) => `<td>${value}</td>`)
.join("")}
</tr>`
)
.join("")}
</table>
</body>
</html>`;
});
app.use(router.routes()).use(router.allowedMethods());
app.listen(3000);

@ -0,0 +1,42 @@
function pickRandom(array) {
return array[Math.floor(Math.random() * array.length)];
}
const colors = [
{ color: "black", emoji: "♣" },
{ color: "black", emoji: "♠" },
{ color: "red", emoji: "♥" },
{ color: "red", emoji: "♦" },
];
const numbers = "23456789JDAK";
const used_cards = [];
function* getCardGen() {
while (true) {
const color = pickRandom(colors);
const number = pickRandom(numbers);
const card = { ...color, number };
if (used_cards.includes(getEmoji(card))) {
continue;
}
used_cards.push(getEmoji(card));
yield card;
}
}
const cardGen = getCardGen();
function getCard() {
return cardGen.next().value;
}
function getEmoji(card) {
return /* HTML */ `
<span class="card" style="background-color: white; color: ${card.color}"
>${card.number}${card.emoji}</span
>
`;
}
module.exports = { getCard, getEmoji };

1084
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,17 @@
{
"name": "hacking-show",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@koa/router": "^10.1.1",
"koa": "^2.13.4",
"koa-mount": "^4.0.0",
"koa-static": "^5.0.0"
}
}
Loading…
Cancel
Save