From 99d1de0e5b1938e96163b6ed35b66cf7a18230fe Mon Sep 17 00:00:00 2001 From: Immortal Date: Wed, 6 Mar 2024 16:58:35 +0330 Subject: [PATCH] deep search --- package-lock.json | 136 ++++++++++++++++++ package.json | 1 + public/css/style.css | 28 ++++ .../{useIPScanner.ts => useIPScanner.tsx} | 60 +++++++- src/pages/index.tsx | 9 ++ 5 files changed, 233 insertions(+), 1 deletion(-) rename src/hooks/{useIPScanner.ts => useIPScanner.tsx} (80%) diff --git a/package-lock.json b/package-lock.json index 7c04a7f..fb17a4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@serwist/precaching": "^8.4.4", "@serwist/sw": "^8.4.4", "axios": "^1.6.7", + "html-react-parser": "^5.1.8", "next": "^14.1.0", "react": "18.2.0", "react-dom": "18.2.0", @@ -2230,6 +2231,57 @@ "node": ">=6.0.0" } }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -2257,6 +2309,17 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-abstract": { "version": "1.22.5", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.5.tgz", @@ -3429,6 +3492,53 @@ "node": ">= 0.4" } }, + "node_modules/html-dom-parser": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-5.0.8.tgz", + "integrity": "sha512-vuWiX9EXgu8CJ5m9EP5c7bvBmNSuQVnrY8tl0z0ZX96Uth1IPlYH/8W8VZ/hBajFf18EN+j2pukbCNd01HEd1w==", + "dependencies": { + "domhandler": "5.0.3", + "htmlparser2": "9.1.0" + } + }, + "node_modules/html-react-parser": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-5.1.8.tgz", + "integrity": "sha512-oAXgUB4JYHFg4le3RQZtoge1TGMkwXSZPiWiexwdx3AuldgG+QEvbwMrscSViu90JNje3V4Zq5gCUSoTxa0W0A==", + "dependencies": { + "domhandler": "5.0.3", + "html-dom-parser": "5.0.8", + "react-property": "2.0.2", + "style-to-js": "1.1.10" + }, + "peerDependencies": { + "@types/react": "17 || 18", + "react": "0.14 || 15 || 16 || 17 || 18" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/htmlparser2": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "entities": "^4.5.0" + } + }, "node_modules/idb": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/idb/-/idb-8.0.0.tgz", @@ -3482,6 +3592,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/inline-style-parser": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.2.tgz", + "integrity": "sha512-EcKzdTHVe8wFVOGEYXiW9WmJXPjqi1T+234YpJr98RiFYKHV3cdy1+3mkTE+KHTHxFFLH51SfaGOoUdW+v7ViQ==" + }, "node_modules/internal-slot": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.7.tgz", @@ -5028,6 +5143,11 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "dev": true }, + "node_modules/react-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.2.tgz", + "integrity": "sha512-+PbtI3VuDV0l6CleQMsx2gtK0JZbZKbpdu5ynr+lbsuvtmgbNcS3VM0tuY2QjFNOcWxvXeHjDpy42RO+4U2rug==" + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -5674,6 +5794,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/style-to-js": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.10.tgz", + "integrity": "sha512-VC7MBJa+y0RZhpnLKDPmVRLRswsASLmixkiZ5R8xZpNT9VyjeRzwnXd2pBzAWdgSGv/pCNNH01gPCCUsB9exYg==", + "dependencies": { + "style-to-object": "1.0.5" + } + }, + "node_modules/style-to-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-1.0.5.tgz", + "integrity": "sha512-rDRwHtoDD3UMMrmZ6BzOW0naTjMsVZLIjsGleSKS/0Oz+cgCfAPRspaqJuE8rDzpKha/nEvnM0IF4seEAZUTKQ==", + "dependencies": { + "inline-style-parser": "0.2.2" + } + }, "node_modules/styled-jsx": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", diff --git a/package.json b/package.json index df20472..fa18883 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@serwist/precaching": "^8.4.4", "@serwist/sw": "^8.4.4", "axios": "^1.6.7", + "html-react-parser": "^5.1.8", "next": "^14.1.0", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/public/css/style.css b/public/css/style.css index 0860987..f5b09fe 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -185,6 +185,34 @@ label { float: right; } +.myToast { + float: left; +} +.myToast .myToastConfirm { + float: left; + width: 100%; + margin: 10px 0 0 0; +} +.myToast .myToastConfirm button { + float: right; + padding: 5px 15px; + border-radius: 3px; + width: auto; + -webkit-transition: .2s; + transition: .2s; +} +.myToast .myToastConfirm button[data-act="restart"] { + float: right; + background: #4b4b4b; +} +.myToast .myToastConfirm button[data-act="cancel"] { + float: right; + margin-left: 7px; +} +.myToast .myToastConfirm button:hover { + background: #616060; +} + footer { margin: 50px 0 20px 0; padding: 10px 0; diff --git a/src/hooks/useIPScanner.ts b/src/hooks/useIPScanner.tsx similarity index 80% rename from src/hooks/useIPScanner.ts rename to src/hooks/useIPScanner.tsx index 8292671..cf7386a 100644 --- a/src/hooks/useIPScanner.ts +++ b/src/hooks/useIPScanner.tsx @@ -2,6 +2,7 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; import { randomizeElements } from "~/helpers/randomizeElements"; import axiosWithSNI from "./axiosWithSNI"; +import {toast} from "react-hot-toast"; type ValidIP = { ip: string; @@ -106,7 +107,9 @@ export const useScannerStore = create()( }); }, increaseTestNo: () => { - set((state) => ({ testNo: state.testNo + 1 })); + set((state) => ({ + testNo: state.testNo + 1 + })); }, }), { @@ -168,6 +171,60 @@ export const useIPScanner = ({ allIps }: IPScannerProps) => { https: [443, 8443, 2053, 2083, 2087, 2096], }; + async function reStart() { + toast.dismiss('limitation'); + try { + const ips = state.ipRegex + ? allIps.filter((el) => new RegExp(state.ipRegex).test(el)) + : allIps; + + dispatch({ scanState: "scanning" }); + await testIPs(randomizeElements(ips)); + setToIdle(); + } catch (e) { + console.error(e); + } + } + + async function showToast() { + toast( + (currentToast) => ( + + In each search, only 150 IPs are evaluated. Do you want to search deeper? +
+
+ + +
+
+ ), + { + id: "limitation", + duration: Infinity, + position:"bottom-center", + style: { + borderRadius: '10px', + background: '#333', + color: '#fff', + }, + } + ); + } + async function testIPs(ipList: string[]) { let isSSL = false; if (state.sniValue !== '' && ports.https.includes(state.portValue)) { @@ -258,5 +315,6 @@ export const useIPScanner = ({ allIps }: IPScannerProps) => { ...state, startScan, stopScan, + showToast, }; }; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 8db0c8c..809ae31 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -37,6 +37,7 @@ const Home: NextPage = () => { tryChar, validIPs, setSettings, + showToast, } = useIPScanner({ allIps }); const isRunning = scanState !== "idle"; @@ -54,6 +55,14 @@ const Home: NextPage = () => { setLoaded(true); }, []); + useEffect(() => { + if ( testNo >= 150 ) { + showToast().then(r => { + // + }); + } + }, [showToast, testNo]); + /*const router = useRouter(); useEffect(() => { if (window.location.protocol === 'https:') {