diff --git a/.gitignore b/.gitignore index 887a3d844..e85ac0261 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ package-lock.json report.*.json yarn-debug.log* yarn-error.log* +NOTES.md diff --git a/address.json b/address.json index 4243481e5..cbf0350ef 100644 --- a/address.json +++ b/address.json @@ -13,6 +13,9 @@ "getpolkadot.net": [ "14yHC3SsfvF6mDLG5co7hyX124hJmriUJA6oFHBVaqa8MUF5" ], + "kusama-wallet.com": [ + "H4hHhuhs1zWm1jAjj42VAr7VTc99yV3J9x3tXLTtD2GnMvD" + ], "polkadot-airdrop.info": [ "13DUJB2UFQYJNG8eAgvbPUDZowTnb45cq7EM7WvtkNksPMZW" ], diff --git a/packages/phishing/src/addrcheck.spec.ts b/packages/phishing/src/addrcheck.spec.ts index 30cbcc115..b981078a1 100644 --- a/packages/phishing/src/addrcheck.spec.ts +++ b/packages/phishing/src/addrcheck.spec.ts @@ -34,7 +34,7 @@ async function loopSome (site: string, matcher: () => Promise): } }); } catch (error) { - // ignore + // console.error(error); } await new Promise((resolve) => setTimeout(() => resolve(true), Math.floor((Math.random() * 750) + 1000))); @@ -54,7 +54,7 @@ function checkGetWallet (site: string): Promise<[string, string[]]> { }); } -// check a specific tag with attributes +// extract a specific tag from attributes function checkTag (url: string, tag: string, attr?: string): Promise<[string, string[]]> { const site = url.split('/')[2]; @@ -71,6 +71,22 @@ function checkTag (url: string, tag: string, attr?: string): Promise<[string, st }); } +// extract a specific attribute from a tag +function checkAttr (url: string, attr: string): Promise<[string, string[]]> { + const site = url.split('/')[2]; + + return loopSome(site, async (): Promise => { + const result = await (await fetchWithTimeout(url)).text(); + + const regex = new RegExp(`${attr}"[a-zA-Z0-9]+"`, 'g'); + const match = regex.exec(result); + + return match && match.length + ? [match[0].replace(new RegExp(attr, 'g'), '').replace(/"/g, '').trim()] + : null; + }); +} + // all the available checks function checkAll (): Promise<[string, string[]][]> { return Promise.all([ @@ -92,7 +108,9 @@ function checkAll (): Promise<[string, string[]][]> { 'https://polkadot-promo.info/' ].map((u) => checkTag(u, 'span', 'id="cosh"')), checkTag('https://dot4.org/promo/', 'p', 'class="payment-title"'), - checkTag('https://polkadotairdrop.com/address/', 'cool') + checkTag('https://polkadotairdrop.com/address/', 'cool'), + checkAttr('https://www.kusama-wallet.com/wallet.php', 'id="copyTarget" value=') + .then(([site, values]) => [site.replace('www.', ''), values]) ]); }