mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-04-22 02:08:00 +00:00
Bump dev deps (#3371)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
import fs from 'node:fs';
|
||||
|
||||
/** @typedef {{ allow: string[]; deny: string[]; }} AllList */
|
||||
|
||||
// muli-part domain codes and (hopefully) valid top-levels (all manual from list)
|
||||
const DOMS = [
|
||||
// county stuff
|
||||
@@ -15,6 +17,7 @@ const DOMS = [
|
||||
const MEDS = DOMS.map((d) => `medium.${d}`);
|
||||
|
||||
// get allow/deny lists
|
||||
/** @type {AllList} */
|
||||
const all = JSON.parse(fs.readFileSync('all.json', 'utf-8'));
|
||||
|
||||
// break the allow list into usable parts
|
||||
|
||||
+31
-16
@@ -2,13 +2,20 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import PinataSDK from '@pinata/sdk';
|
||||
// @ts-expect-error We are not defining our own types for this
|
||||
import cloudflare from 'dnslink-cloudflare';
|
||||
|
||||
/** @typedef {import('@pinata/sdk').default} PinataClient */
|
||||
|
||||
const SUB_DOMAIN = 'phishing';
|
||||
const DOMAIN = 'dotapps.io';
|
||||
const DST = 'build';
|
||||
const PINMETA = { name: `${SUB_DOMAIN}.${DOMAIN}` };
|
||||
const PINMETA = {
|
||||
name: `${SUB_DOMAIN}.${DOMAIN}`
|
||||
};
|
||||
|
||||
/** @type {PinataClient} */
|
||||
// @ts-expect-error For some reason we have issues here...
|
||||
const pinata = new PinataSDK({
|
||||
pinataApiKey: process.env.PINATA_API_KEY,
|
||||
pinataSecretApiKey: process.env.PINATA_SECRET_KEY
|
||||
@@ -16,10 +23,13 @@ const pinata = new PinataSDK({
|
||||
|
||||
async function wait (delay = 2500) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve(), delay);
|
||||
setTimeout(() => resolve(undefined), delay);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function pin () {
|
||||
const result = await pinata.pinFromFS(DST, { pinataMetadata: PINMETA });
|
||||
|
||||
@@ -30,32 +40,37 @@ async function pin () {
|
||||
return result.IpfsHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} exclude
|
||||
*/
|
||||
async function unpin (exclude) {
|
||||
// @ts-expect-error We can forgo the keyvalues field
|
||||
const result = await pinata.pinList({ metadata: PINMETA, status: 'pinned' });
|
||||
|
||||
await wait();
|
||||
|
||||
if (result.count > 1) {
|
||||
const hashes = result.rows
|
||||
.map((r) => r.ipfs_pin_hash)
|
||||
.filter((hash) => hash !== exclude);
|
||||
const hashes = result.rows
|
||||
.map((r) => r.ipfs_pin_hash)
|
||||
.filter((/** @type { string} */ hash) => hash !== exclude);
|
||||
|
||||
for (let i = 0; i < hashes.length; i++) {
|
||||
const hash = hashes[i];
|
||||
for (let i = 0; i < hashes.length; i++) {
|
||||
const hash = hashes[i];
|
||||
|
||||
try {
|
||||
await pinata.unpin(hash);
|
||||
try {
|
||||
await pinata.unpin(hash);
|
||||
|
||||
console.log(`Unpinned ${hash}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed unpinning ${hash}`, error);
|
||||
}
|
||||
|
||||
await wait();
|
||||
console.log(`Unpinned ${hash}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed unpinning ${hash}`, error);
|
||||
}
|
||||
|
||||
await wait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} hash
|
||||
*/
|
||||
async function dnslink (hash) {
|
||||
const records = [`_dnslink.${SUB_DOMAIN}.${DOMAIN}`];
|
||||
|
||||
|
||||
+61
-4
@@ -3,10 +3,17 @@
|
||||
|
||||
import fs from 'node:fs';
|
||||
|
||||
// @ts-expect-error @polkadot/dev scripts don't have .d.ts files
|
||||
import { mkdirpSync, rimrafSync } from '@polkadot/dev/scripts/util.mjs';
|
||||
|
||||
/** @typedef {{ allow: string[]; deny: string[]; }} AllList */
|
||||
|
||||
const KNOWN_URLS = ['telegra.ph', 'twitter.com', 'youtube.com'];
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
function sanitizeUrl (url) {
|
||||
return (
|
||||
url.includes('://')
|
||||
@@ -15,10 +22,14 @@ function sanitizeUrl (url) {
|
||||
).split('/')[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} list
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function filterSection (list) {
|
||||
return list
|
||||
.map((entry) => sanitizeUrl(entry))
|
||||
.reduce((filtered, entry) => {
|
||||
.reduce((/** @type {string[]} */ filtered, entry) => {
|
||||
!filtered.includes(entry) &&
|
||||
filtered.push(entry);
|
||||
|
||||
@@ -26,10 +37,19 @@ function filterSection (list) {
|
||||
}, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} list
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function sortSection (list) {
|
||||
return filterSection(list).sort((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} list
|
||||
* @param {string} url
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSubdomain (list, url) {
|
||||
const parts = url.split('.');
|
||||
|
||||
@@ -43,6 +63,10 @@ function isSubdomain (list, url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
function flattenUrl (url) {
|
||||
// currently we only check for plesk-page to flatten
|
||||
if (!url.endsWith('plesk.page')) {
|
||||
@@ -56,6 +80,10 @@ function flattenUrl (url) {
|
||||
: url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} list
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function rewriteSubs (list) {
|
||||
return filterSection(
|
||||
list
|
||||
@@ -64,12 +92,19 @@ function rewriteSubs (list) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string[]>} values
|
||||
* @returns {Record<string, string[]>}
|
||||
*/
|
||||
function sortAddresses (values) {
|
||||
return Object
|
||||
.entries(values)
|
||||
.map(([key, address]) => [sanitizeUrl(key), address])
|
||||
.map(
|
||||
/** @returns {[string, string[]]} */
|
||||
([key, addresses]) => [sanitizeUrl(key), addresses]
|
||||
)
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.reduce((all, [key, addresses]) => {
|
||||
.reduce((/** @type {Record<string, string[]>} */ all, [key, addresses]) => {
|
||||
if (!all[key]) {
|
||||
all[key] = [];
|
||||
}
|
||||
@@ -83,6 +118,11 @@ function sortAddresses (values) {
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {AllList} param0
|
||||
* @param {Record<string, string>} values
|
||||
* @returns
|
||||
*/
|
||||
function addSites ({ allow, deny }, values) {
|
||||
return Object
|
||||
.keys(values)
|
||||
@@ -94,10 +134,18 @@ function addSites ({ allow, deny }, values) {
|
||||
}, deny);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} file
|
||||
* @returns {any}
|
||||
*/
|
||||
function readJson (file) {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} file
|
||||
* @param {unknown} contents
|
||||
*/
|
||||
function writeJson (file, contents) {
|
||||
fs.writeFileSync(file, `${JSON.stringify(contents, null, '\t')}\n`);
|
||||
}
|
||||
@@ -117,8 +165,14 @@ function readMeta () {
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ date: string; url: string; }[]} meta
|
||||
*/
|
||||
export function writeMeta (meta) {
|
||||
/** @type {Record<string, { date: string; url: string; }[]>} */
|
||||
const months = {};
|
||||
|
||||
/** @type {string[]} */
|
||||
const index = [];
|
||||
|
||||
for (const item of meta) {
|
||||
@@ -139,11 +193,14 @@ export function writeMeta (meta) {
|
||||
writeJson('meta/index.json', index.sort((a, b) => b.localeCompare(a)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} deny
|
||||
*/
|
||||
function writeAllList (deny) {
|
||||
rimrafSync('all');
|
||||
mkdirpSync('all');
|
||||
|
||||
const avail = deny.reduce((avail, url) => {
|
||||
const avail = deny.reduce((/** @type {Record<String, string[]>} */ avail, url) => {
|
||||
const [top] = url.split('.').reverse();
|
||||
|
||||
if (!avail[top]) {
|
||||
|
||||
Reference in New Issue
Block a user