Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results #6

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"clsx": "^2.1.0",
"electron-debug": "^3.2.0",
"electron-log": "^4.4.8",
"electron-serve": "^1.3.0",
"electron-updater": "^6.1.4",
"lucide-react": "^0.330.0",
"react": "^18.2.0",
Expand Down
10 changes: 10 additions & 0 deletions src/main/api/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fs from 'fs';
import path from 'path';
import { defaultToolObj } from '../util';
import { connectJson } from '../db/connect';

export const PROJECT_DIR = path.join(__dirname, '../../../projects');

Expand Down Expand Up @@ -81,3 +82,12 @@ export function projectDetails(projectName: string) {
throw new Error('a7aa');
}
}

export function projectDetailss(projectName: string) {
try {
const db = connectJson(`${PROJECT_DIR}/${projectName}/details.json`);
return db.read();
} catch (error) {
throw new Error('a7aa');
}
}
20 changes: 20 additions & 0 deletions src/main/db/connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable import/prefer-default-export */
import { PathLike } from 'fs';
import { JSONDB } from './core/node';
import { JobDetails } from '../types';

export interface ProjectDetails {
name: string;
domain: string;
recon?: {
subfinder?: JobDetails;
screens?: JobDetails;
params?: JobDetails;
liveDomains?: JobDetails;
};
}

export function connectJson<_T = ProjectDetails>(path: PathLike) {
const db = new JSONDB<_T>(path);
return db;
}
22 changes: 22 additions & 0 deletions src/main/db/core/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable import/prefer-default-export */
export class BrowserDB {
private filePath: string;

constructor(filePath: string) {
this.filePath = filePath;
}

async read(): Promise<any | null> {
try {
const response = await fetch(this.filePath);
if (!response.ok) {
throw new Error('Failed to fetch data');
}
return await response.json();
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error reading data:', error);
return null;
}
}
}
44 changes: 44 additions & 0 deletions src/main/db/core/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-disable no-console */
/* eslint-disable import/prefer-default-export */
import { PathLike } from 'fs';
import fs from 'fs/promises';

export class JSONDB<T> {
private filePath: PathLike;

constructor(file: PathLike) {
this.filePath = file;
}

async read(): Promise<T | null> {
try {
const data = await fs.readFile(this.filePath, 'utf-8');
return JSON.parse(data) as T;
} catch (error) {
console.error('Error reading file:', error);
return null;
}
}

async update(updates: Partial<T>): Promise<void> {
try {
const existingData = await this.read();
if (existingData === null) {
console.error('No data found to update');
return;
}
const updatedData = { ...existingData, ...updates };
await fs.writeFile(this.filePath, JSON.stringify(updatedData, null, 2));
} catch (error) {
console.error('Error updating file:', error);
}
}

async delete(): Promise<void> {
try {
await fs.unlink(this.filePath);
} catch (error) {
console.error('Error deleting file:', error);
}
}
}
7 changes: 7 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
createJsonFile,
createProjectDir,
projectDetails,
projectDetailss,
readDirectoryNames,
} from './api/project';
import { liveSubDomains, screenwin } from './recon/httpx';
Expand Down Expand Up @@ -76,6 +77,12 @@ ipcMain.on('get-project-details', async (event, args) => {
event.returnValue = data;
});

ipcMain.handle('get-project-detailss', async (event, args) => {
const projectName = args[0];
const data = projectDetailss(projectName);
return data;
});

ipcMain.on('list-projects', async (event) => {
const dirs = readDirectoryNames();
event.returnValue = dirs;
Expand Down
3 changes: 2 additions & 1 deletion src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export type Channels =
| 'waybackurls-archive'
| 'waybackurls-js'
| 'waybackurls-parameter'
| 'get-project-details';
| 'get-project-details'
| 'get-project-detailss';

const electronHandler = {
ipcRenderer: {
Expand Down
22 changes: 18 additions & 4 deletions src/main/recon/subfinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import util from 'util';
import { exec } from 'child_process';
import path from 'path';
import { toolPath } from '../util';
import { PROJECT_DIR, appendDateToJson } from '../api/project';
import { resultFromStd, toolPath } from '../util';
import { PROJECT_DIR } from '../api/project';
import { connectJson } from '../db/connect';

const execAsync = util.promisify(exec);

Expand All @@ -29,8 +30,21 @@ export async function subFinder(
}

try {
await execAsync(command);
appendDateToJson(outputDir, { subFinder: true });
const res = await execAsync(command);
const domainsFound = resultFromStd(res.stderr, /\bFound (\d+) subdomains?/);
const db = connectJson(path.join(`${outputDir}/details.json`));
await db.update({
recon: {
subfinder: {
result: parseInt(domainsFound, 10),
run: true,
filePath: '',
date: new Date(Date.now()).toUTCString(),
},
},
});
console.log(await db.read());
// appendDateToJson(outputDir, { subFinder: true });
return { message: 'Done', success: true, error: '' };
} catch (error: any) {
return { message: 'Error', success: false, error };
Expand Down
8 changes: 8 additions & 0 deletions src/main/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PathLike } from 'fs';

export type JobDetails = {
run: boolean;
filePath: PathLike;
result?: number | string;
date: string;
};
8 changes: 8 additions & 0 deletions src/main/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ export function createDirIfNotExist(outputDir: string, dirname: string) {
export function defaultToolObj(): { run: boolean; resulCount: number } {
return { run: false, resulCount: 0 };
}

export function resultFromStd(text: string, regex: RegExp) {
const matches = text.match(regex);
if (matches && matches.length > 1) {
return matches[1];
}
return '';
}
14 changes: 14 additions & 0 deletions src/renderer/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactNode } from 'react';


export type DashboardMenu = {
href: string;
title: string;
Expand All @@ -11,7 +12,20 @@ export type jobLoaders = {
state: boolean;
};

export type JobDetails = {
run: boolean;
filePath: string;
result?: number | string;
date: string;
};

export type ProjectDetails = {
name: string;
domain: string;
recon?: {
subfinder?: JobDetails;
screens?: JobDetails;
params?: JobDetails;
liveDomains?: JobDetails;
};
};
22 changes: 21 additions & 1 deletion src/renderer/views/project/recon.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect, useState } from 'react';
import {
Card,
CardContent,
Expand All @@ -11,8 +12,20 @@ import HttpxScreensJob from './jobs/httpxScreens';
import WaybackurlsArchiveJob from './jobs/waybackurlsArchive';
import WaybackurlsJsJob from './jobs/waybackurlsJs';
import WaybackurlsParameterJob from './jobs/waybackurlsParameter';
import { ProjectDetails } from '../../types';

export default function Recon() {
const [details, setDetails] = useState<ProjectDetails>();
const getDetails = async () => {
const res = await window.electron.ipcRenderer.invoke(
'get-project-detailss',
'onboardbase',
);
setDetails(res);
};
useEffect(() => {
getDetails();
}, []);
return (
<div className="flex flex-col gap-4">
<h1 className="font-bold text-3xl">Initiate Recon Attacks</h1>
Expand All @@ -26,7 +39,14 @@ export default function Recon() {
domain
</CardDescription>
</CardHeader>
<CardContent className="flex justify-end">
<CardContent className="flex justify-between">
{details && (
<div className="flex flex-col space-x-2">
<h1 className="flex flex-col font-semibold">
Last Run <span>{details.recon?.subfinder?.date}</span>
</h1>
</div>
)}
<SubFinderJob />
</CardContent>
</Card>
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,11 @@
"@types/node" "*"
xmlbuilder ">=11.0.1"

"@types/prop-types@*":
version "15.7.11"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.11.tgz#2596fb352ee96a1379c657734d4b913a613ad563"
integrity sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==

"@types/qs@*":
version "6.9.11"
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.11.tgz#208d8a30bc507bd82e03ada29e4732ea46a6bbda"
Expand Down Expand Up @@ -2394,6 +2399,11 @@
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==

"@types/scheduler@*":
version "0.16.8"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff"
integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==

"@types/semver@^7.3.12", "@types/semver@^7.5.0":
version "7.5.7"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.7.tgz#326f5fdda70d13580777bcaa1bc6fa772a5aef0e"
Expand Down Expand Up @@ -4197,6 +4207,11 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"

csstype@^3.0.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==

damerau-levenshtein@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7"
Expand Down Expand Up @@ -4671,6 +4686,11 @@ [email protected]:
lazy-val "^1.0.5"
mime "^2.5.2"

electron-serve@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/electron-serve/-/electron-serve-1.3.0.tgz#94f7fbdc398d1f187f0ebeb4630b2d03acb83d59"
integrity sha512-OEC/48ZBJxR6XNSZtCl4cKPyQ1lvsu8yp8GdCplMWwGS1eEyMcEmzML5BRs/io/RLDnpgyf+7rSL+X6ICifRIg==

electron-to-chromium@^1.4.668:
version "1.4.673"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.673.tgz#1f077d9a095761804aec7ec6346c3f4b69b56534"
Expand Down
Loading