Skip to content

Commit

Permalink
fix the rules length and add possibility to have a wildcard rule to u…
Browse files Browse the repository at this point in the history
…se them all
  • Loading branch information
ScriptSathi committed Jul 30, 2023
1 parent 2500ad4 commit 7a071fb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 225 deletions.
2 changes: 1 addition & 1 deletion hashkitty-server/src/lib/API/RouteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export class RouteHandler {
): void => {
try {
const listString = FsUtils.listFileInDir(Constants.rulesPath);
const list = this.buildListBase(listString);
const list = this.buildListBase(['* (All Rules)', ...listString]);
this.getFileInDirResp(res, list);
} catch (e) {
this.getFileInDirResp(res, [], Constants.rulesPath, e);
Expand Down
19 changes: 12 additions & 7 deletions hashkitty-server/src/lib/API/Sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,18 @@ export class Sanitizer {
for (const ruleFileName of rules) {
try {
if (ruleFileName.length > 0) {
const files = FsUtils.listFileInDir(Constants.rulesPath);
const fileHasBeenFound = files.find(file => {
return file === ruleFileName;
});
if (!fileHasBeenFound) {
fileExists = false;
this.setError('wrongData', 'rules');
const isWildCardRule = ruleFileName.includes('*');
if (isWildCardRule) {
rules = ['* (All Rules)'];
} else {
const files = FsUtils.listFileInDir(Constants.rulesPath);
const fileHasBeenFound = files.find(file => {
return file === ruleFileName;
});
if (!fileHasBeenFound) {
fileExists = false;
this.setError('wrongData', 'rules');
}
}
}
} catch (error) {
Expand Down
215 changes: 0 additions & 215 deletions hashkitty-server/src/lib/ORM/Factory.ts

This file was deleted.

2 changes: 1 addition & 1 deletion hashkitty-server/src/lib/ORM/entity/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Options {
@JoinColumn({ name: 'wordlist_id', referencedColumnName: 'id' })
wordlistId?: number;

@Column('varchar', { name: 'rule_name', default: '' })
@Column('text', { name: 'rule_name', default: '' })
rules?: string;

@Column('varchar', { name: 'potfile_name', default: '' })
Expand Down
10 changes: 9 additions & 1 deletion hashkitty-server/src/lib/hashcat/HashcatGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class HashcatGenerator {
if (this.task.options.rules) {
flags.push({
key: 'rulesFile',
value: this.task.options.rules.split(','),
value: this.createRulesPaths(this.task.options.rules.split(',')),
});
}
if (this.task.options.workloadProfileId) {
Expand All @@ -140,6 +140,14 @@ export class HashcatGenerator {
return this.buildFlags(flags);
}

private createRulesPaths(rules: string[]): string[] {
const hasWildCardRule = rules.some(rule => rule.includes('*'));
if (hasWildCardRule) {
rules = FsUtils.listFileInDir(Constants.rulesPath);
}
return rules.map(rule => path.join(Constants.rulesPath, rule));
}

private prepareRestoreFlags(): CmdData[] {
const flags = this.defaultFlags;
const restoreFlag: PartialCmdData = { key: 'restore' };
Expand Down

0 comments on commit 7a071fb

Please sign in to comment.