Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 6a0b031

Browse files
committed
Release 0.9.1
1 parent 1c80378 commit 6a0b031

File tree

16 files changed

+46
-18
lines changed

16 files changed

+46
-18
lines changed

applications/client/src/store/graphql/BeaconModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class BeaconModel extends ExtendedModel(BeaconModelBase, {}) {
6767

6868
@computed get computedBeaconName(): string {
6969
const meta = this.meta[0]?.current;
70-
if (!meta) return this.beaconName;
70+
if (!meta) return this.displayName ?? this.beaconName;
7171
const {
7272
// id,
7373
// pid,
@@ -77,7 +77,7 @@ export class BeaconModel extends ExtendedModel(BeaconModelBase, {}) {
7777
// listener, // 'http';
7878
} = meta;
7979
// return [process, username].join(' · '); // <- TODO!
80-
return [username].join(' · ');
80+
return [this.displayName ?? this.beaconName, username].filter(Boolean).join(' · ');
8181
}
8282

8383
@computed get computedName(): string {

applications/server/src/machines/parser.machine.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { exec, execFile } from 'child_process';
1010
import path from 'path';
1111
import type { GraphQLContext } from '../types';
1212
import { parserService } from './parser.service';
13+
import { escapeFilePath } from '@redeye/parser-core';
1314

1415
type ParserContext = {
1516
queuedCampaigns: { campaignId: string; parserName: string }[];
@@ -172,7 +173,15 @@ type ParsingScriptArgs = {
172173
};
173174
const invokeParsingScript = ({ projectDatabasePath, loggingFolderPath, maxProcesses }: ParsingScriptArgs) => {
174175
return new Promise<void>((resolve, reject) => {
175-
const args = [`campaign`, `-d`, projectDatabasePath, `-p`, loggingFolderPath, `-t`, `${maxProcesses - 1}`];
176+
const args = [
177+
`campaign`,
178+
`-d`,
179+
escapeFilePath(projectDatabasePath),
180+
`-p`,
181+
escapeFilePath(loggingFolderPath),
182+
`-t`,
183+
`${maxProcesses - 1}`,
184+
];
176185

177186
const execCallBack = (error: unknown, stdout: unknown, stderror: unknown) => {
178187
if (error || stderror) {

applications/server/src/machines/parser.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import * as readline from 'node:readline';
2222
import path from 'path';
2323
import { getRuntimeDir } from '../util';
2424
import type { ParserInfo, ParserOutput } from '@redeye/parser-core';
25-
import { createLoggerInstance, ParserMessageTypes, getParserPrefixAndMessage } from '@redeye/parser-core';
25+
import {
26+
createLoggerInstance,
27+
ParserMessageTypes,
28+
getParserPrefixAndMessage,
29+
escapeFilePath,
30+
} from '@redeye/parser-core';
2631
import type { ChildProcess } from 'child_process';
2732
import { exec, execFile } from 'child_process';
2833
import type { EndpointContext, EntityManager } from '../types';
@@ -105,7 +110,7 @@ async function parsePaths(em: EntityManager, path: string, parserName: string) {
105110
beacons: {},
106111
operators: {},
107112
};
108-
const data = await invokeParser<ParserOutput>(parserName, ['parse-campaign', `--folder`, path]);
113+
const data = await invokeParser<ParserOutput>(parserName, ['parse-campaign', `--folder`, escapeFilePath(path)]);
109114
if (data.servers) {
110115
for (const parsedServer of Object.values(data.servers)) {
111116
created.servers[parsedServer.name] =

applications/server/src/routes/parserFileValidation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { EndpointContext } from '../types';
33
import { withTempDir } from '../util';
44
import path from 'path';
55
import { invokeParser } from '../machines/parser.service';
6+
import { escapeFilePath } from '@redeye/parser-core';
67

78
export function parserFileValidation(app: Router, context: EndpointContext) {
89
app.post<{ parserName: string }, any, Express.Request>('/parser/:parserName/validate-files', async (req, res) => {
@@ -18,7 +19,7 @@ export function parserFileValidation(app: Router, context: EndpointContext) {
1819
return await invokeParser(parserName, [
1920
'validate-files',
2021
'--folder',
21-
path.join(dir, rootDir[0]).replace(/(\s+)/g, '\\$1'),
22+
escapeFilePath(path.join(dir, rootDir[0])),
2223
]);
2324
});
2425
return res.send(validated);

applications/server/src/routes/uploadCampaign.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function uploadCampaign(app: Router, context: EndpointContext) {
9696

9797
const logFiles = Array.isArray(req.files.file) ? req.files.file : [req.files.file];
9898
const em = await connectToProjectEmOrFail(campaignId, context);
99-
const parentDir = path.resolve(getRootPath(), 'campaign', campaignId);
99+
const parentDir = path.resolve(getRootPath(), 'campaign', campaignId, 'logs');
100100
for (const logFile of logFiles) await logFile.mv(path.join(parentDir, logFile.name.replace(/:/gi, '/')));
101101
const servers: Server[] = [];
102102
const newServers = JSON.parse(req.body.servers as unknown as string);

applications/server/src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const getDbPath = (databaseMode: DatabaseMode): string => {
3131
};
3232

3333
export const getDatabaseFolderPath = (campaignId: string, databaseMode: DatabaseMode): string =>
34-
`${getDbPath(databaseMode)}/campaign/${campaignId}`;
34+
path.resolve(getDbPath(databaseMode), 'campaign', campaignId);
3535

3636
export const getFullCampaignDbPath = (campaignId: string, databaseMode: DatabaseMode): string =>
37-
`${getDatabaseFolderPath(campaignId, databaseMode)}/db.redeye`;
37+
path.resolve(getDatabaseFolderPath(campaignId, databaseMode), 'db.redeye');

docs/parser-guide/Create Parser Guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ Now that we've gone over how to identify what data to extract and how to format
408408
import fileSystem from 'fs';
409409

410410
function parseLogFile() {
411-
const logFile = fileSystem.readFileSync(`${process.argv[4]}/c2-log-files.txt`, 'utf8'); // Read the log file from the path passed in the command
411+
const logPath = process.argv[4].replaceAll('"', ""); // Get the path and remove the quotes around it
412+
const logFile = fileSystem.readFileSync(`${logPath}/c2-log-files.txt`, 'utf8'); // Read the log file from the path passed in the command
412413
const lines = logFile.split('\n'); // Split the log file into lines
413414
const output = {
414415
// Create an empty object to store our output

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "redeye",
33
"productName": "RedEye",
4-
"version": "0.9.0",
4+
"version": "0.9.1",
55
"private": true,
66
"workspaces": [
77
"applications/**",

parsers/brute-ratel-parser/src/parse-campaign.command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export const registerCampaignCommand = (program: Command) => {
1010
const campaignCommand = program.command('parse-campaign');
1111
campaignCommand.option(
1212
'-f, --folder </absolute/path/to/folder>',
13-
'The folder containing a Brute Ratel campaign, includes autosave.profile and logs folder'
13+
'The folder containing a Brute Ratel campaign, includes autosave.profile and logs folder',
14+
(value) => value.replaceAll('"', '')
1415
);
1516

1617
campaignCommand.action(campaignCommandAction);

parsers/brute-ratel-parser/src/validate-files.command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const registerValidateFilesCommand = (program: Command) => {
1313
const validateFilesCommand = program.command('validate-files');
1414
validateFilesCommand.option(
1515
'-f, --folder </absolute/path/to/folder>',
16-
'A folder containing the Brute Ratel log files'
16+
'A folder containing the Brute Ratel log files',
17+
(value) => value.replaceAll('"', '')
1718
);
1819
validateFilesCommand.action(async (options) => {
1920
writeParserMessage(ParserMessageTypes.Data, await validate(options));

0 commit comments

Comments
 (0)