mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-07-23 02:35:45 +00:00
Generic addr matching via constructed regex (#91)
This commit is contained in:
@@ -62,26 +62,19 @@ function checkGetWallet (ours: Record<string, string[]>, site: string): Promise<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared between claimpolka.live & polkadots.network
|
// check a specific tag with attributes
|
||||||
function checkTrnsctin (ours: Record<string, string[]>, site: string, url: string): Promise<string | null> {
|
function checkTag (ours: Record<string, string[]>, url: string, tag: string, attr?: string): Promise<string | null> {
|
||||||
|
const site = url.split('/')[2];
|
||||||
|
|
||||||
return loopSome(ours, site, async (): Promise<string[] | null> => {
|
return loopSome(ours, site, async (): Promise<string[] | null> => {
|
||||||
const result = await (await fetch(url)).text();
|
const result = await (await fetch(url)).text();
|
||||||
const match = result.match(/<p id="trnsctin">(.*?)<\/p>/g);
|
|
||||||
|
|
||||||
|
// /<p id="trnsctin">(.*?)<\/p>/g
|
||||||
|
const match = new RegExp(`<${tag}${attr ? ` ${attr}` : ''}>(.*?)</${tag}>`, 'g').exec(result);
|
||||||
|
|
||||||
|
// /<\/?p( id="trnsctin")?>/g
|
||||||
return match && match.length
|
return match && match.length
|
||||||
? match.map((v) => v.replace(/<\/?p( id="trnsctin")?>/g, '').trim())
|
? match.map((v) => v.replace(new RegExp(`</?${tag}${attr ? `( ${attr})?` : ''}>`, 'g'), '').trim())
|
||||||
: null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// shared between polkadotlive.network & polkadot-airdrop.org
|
|
||||||
async function checkRealAddr (ours: Record<string, string[]>, site: string, url: string): Promise<string | null> {
|
|
||||||
return loopSome(ours, site, async (): Promise<string[] | null> => {
|
|
||||||
const result = await (await fetch(url)).text();
|
|
||||||
const match = result.match(/<span class="real-address">(.*?)<\/span>/g);
|
|
||||||
|
|
||||||
return match && match.length
|
|
||||||
? match.map((v) => v.replace(/<\/?span( class="real-address")?>/g, '').trim())
|
|
||||||
: null;
|
: null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,40 +91,18 @@ describe('addrcheck', (): void => {
|
|||||||
const results = await Promise.all([
|
const results = await Promise.all([
|
||||||
checkGetWallet(ours, 'polkadot.center'),
|
checkGetWallet(ours, 'polkadot.center'),
|
||||||
checkGetWallet(ours, 'polkadot-event.com'),
|
checkGetWallet(ours, 'polkadot-event.com'),
|
||||||
checkTrnsctin(ours, 'polkadotlive.network', 'https://polkadotlive.network/block-assets/index.html'),
|
checkTag(ours, 'https://polkadotlive.network/block-assets/index.html', 'p', 'id="trnsctin"'),
|
||||||
checkTrnsctin(ours, 'polkadots.network', 'https://polkadots.network/block.html'),
|
checkTag(ours, 'https://polkadots.network/block.html', 'p', 'id="trnsctin"'),
|
||||||
checkRealAddr(ours, 'claimpolka.live', 'https://claimpolka.live/claim/index.html'),
|
checkTag(ours, 'https://claimpolka.live/claim/index.html', 'span', 'class="real-address"'),
|
||||||
checkRealAddr(ours, 'polkadot-airdrop.org', 'https://polkadot-airdrop.org/block/index.html'),
|
checkTag(ours, 'https://polkadot-airdrop.org/block/index.html', 'span', 'class="real-address"'),
|
||||||
loopSome(ours, 'polkadotairdrop.com', async (): Promise<string[] | null> => {
|
checkTag(ours, 'https://polkadotairdrop.com/address/', 'cool'),
|
||||||
const result = await (await fetch('https://polkadotairdrop.com/address/')).text();
|
checkTag(ours, 'https://polkadot-get.com/', 'span', 'id="cosh"'),
|
||||||
const match = result.match(/<cool>(.*?)<\/cool>/g);
|
checkTag(ours, 'https://dot4.org/promo/', 'p', 'class="payment-title"')
|
||||||
|
|
||||||
return match && match.length
|
|
||||||
? match.map((v) => v.replace(/<\/?cool>/g, '').trim())
|
|
||||||
: null;
|
|
||||||
}),
|
|
||||||
loopSome(ours, 'polkadot-get.com', async (): Promise<string[] | null> => {
|
|
||||||
const result = await (await fetch('https://polkadot-get.com/')).text();
|
|
||||||
const match = result.match(/<span id="cosh">(.*?)<\/span>/g);
|
|
||||||
|
|
||||||
return match && match.length
|
|
||||||
? match.map((v) => v.replace(/<\/?span( id="cosh")?>/g, '').trim())
|
|
||||||
: null;
|
|
||||||
}),
|
|
||||||
loopSome(ours, 'dot4.org', async (): Promise<string[] | null> => {
|
|
||||||
const result = await (await fetch('https://dot4.org/promo/')).text();
|
|
||||||
const match = result.match(/<p class="payment-title">(.*?)<\/p>/g);
|
|
||||||
|
|
||||||
return match && match.length
|
|
||||||
? match.map((v) => v.replace(/<\/?p( class="payment-title")?>/g, '').trim())
|
|
||||||
: null;
|
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const missing = results.filter((site) => !!site);
|
const missing = results.filter((site) => !!site);
|
||||||
|
|
||||||
missing.length && console.error(`Discrepancies found on ${missing.join(', ')}`);
|
missing.length && console.error(`Discrepancies found on ${missing.join(', ')}`);
|
||||||
|
|
||||||
expect(missing).toHaveLength(0);
|
expect(missing).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user