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

jsleak backend dev #14

Merged
merged 3 commits into from
Apr 14, 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
2 changes: 2 additions & 0 deletions src/main/db/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface ProjectDetails {
domain: string;
subfinder?: JobDetails;
screens?: JobDetails;
extraLinks?: JobDetails;
findSecrets?: JobDetails;
params?: JobDetails;
liveDomains?: JobDetails;
archive?: JobDetails;
Expand Down
62 changes: 62 additions & 0 deletions src/main/jsleak/jsleak.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { execSync } from 'child_process';
import path from 'path';
import { CurrentOS, toolPath } from '../util';
import { PROJECT_DIR } from '../api/project';
import { connectJson } from '../db/connect';
import { countLines } from '../results/countResults';

export async function findSecret(outputDir: string = PROJECT_DIR): Promise<{
message: string;
success: boolean;
error: any;
}> {
const jsleak = toolPath('jsleak');
const command = `${CurrentOS() === 'win32' ? 'type' : 'cat'} ${path.join(outputDir, 'httpx_live_domains.txt')} | ${jsleak} -s
>> ${path.join(outputDir, 'secrets.txt')}`;
try {
execSync(command);
const numberOfUrls = await countLines(path.join(outputDir, 'secrets.txt'));
const db = connectJson(path.join(`${outputDir}/details.json`));
await db.update({
findSecrets: {
result: numberOfUrls,
run: true,
filePath: '',
date: new Date(Date.now()).toUTCString(),
},
});
return { message: 'Done', success: true, error: null };
} catch (error) {
console.error('Error occurred:', error);
return { message: 'Error', success: false, error };
}
}

export async function extraLinks(outputDir: string = PROJECT_DIR): Promise<{
message: string;
success: boolean;
error: any;
}> {
const jsleak = toolPath('jsleak');
const command = `${CurrentOS() === 'win32' ? 'type' : 'cat'} ${path.join(outputDir, 'httpx_live_domains.txt')} | ${jsleak} -l | findstr ".js"
>> ${path.join(outputDir, 'extra_links.txt')}`;
try {
execSync(command);
const numberOfUrls = await countLines(
path.join(outputDir, 'extra_links.txt'),
);
const db = connectJson(path.join(`${outputDir}/details.json`));
await db.update({
extraLinks: {
result: numberOfUrls,
run: true,
filePath: '',
date: new Date(Date.now()).toUTCString(),
},
});
return { message: 'Done', success: true, error: null };
} catch (error) {
console.error('Error occurred:', error);
return { message: 'Error', success: false, error };
}
}
11 changes: 11 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { liveSubDomains, screenwin } from './recon/httpx';
import { fetchJs, parameter, wwayback } from './recon/waybackurls';
import { returnFile } from './api/serve';
import { findSecret, extraLinks } from './jsleak/jsleak';

class AppUpdater {
constructor() {
Expand All @@ -43,6 +44,16 @@ ipcMain.handle('api-call', async (event, args) => {
return res;
});

ipcMain.handle('find-secrets', async (event, args) => {
const { projectName } = args[0];
const res = findSecret(`${PROJECT_DIR}/${projectName}`);
return res;
});
ipcMain.handle('extra-links', async (event, args) => {
const { projectName } = args[0];
const res = extraLinks(`${PROJECT_DIR}/${projectName}`);
return res;
});
ipcMain.handle('subfinder-process', async (event, args) => {
const { domain, projectName } = args[0];
const res = subFinder(domain, `${PROJECT_DIR}/${projectName}`);
Expand Down
1 change: 0 additions & 1 deletion src/main/recon/httpx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export async function liveSubDomains(outputDir: string = PROJECT_DIR): Promise<{
return { message: 'Error', success: false, error };
}
}
liveSubDomains(`${PROJECT_DIR}/kroking`);
export async function screenwin(outputDir: string = PROJECT_DIR): Promise<{
message: string;
success: boolean;
Expand Down
Loading