From 17e50d72945638654c9267363175dfc4bbba37ac Mon Sep 17 00:00:00 2001 From: gpascal123 Date: Wed, 8 Oct 2025 11:08:48 +0200 Subject: [PATCH 1/2] - Created a Link in the cracked column, which directed users to the cracked hashes. - Removed the total cracks in the tasks table. --- .../tables/base-table/base-table.component.ts | 2 +- .../hashes-table/hashes-table.component.ts | 5 ++++ .../hashlists-table.component.ts | 20 +++++++++++++++- .../tasks-table/tasks-table.component.ts | 3 +-- .../core/_datasources/hashes.datasource.ts | 9 +++++++ .../hashlists/hashes/hashes.component.html | 2 +- src/app/hashlists/hashes/hashes.component.ts | 24 +++++++++---------- 7 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/app/core/_components/tables/base-table/base-table.component.ts b/src/app/core/_components/tables/base-table/base-table.component.ts index 63dd20408..9f0fc658f 100644 --- a/src/app/core/_components/tables/base-table/base-table.component.ts +++ b/src/app/core/_components/tables/base-table/base-table.component.ts @@ -153,7 +153,7 @@ export class BaseTableComponent { const isSupertask = wrapper.taskType === TaskType.SUPERTASK; const link: HTTableRouterLink = { - label: wrapper.cracked.toLocaleString() + '/' + wrapper.hashlist.hashCount.toLocaleString(), + label: wrapper.cracked.toLocaleString(), routerLink: isSupertask ? null : ['/hashlists', 'hashes', 'tasks', wrapper.tasks[0].id], tooltip: isSupertask ? 'Please access the cracked hashes via the row\'s context menu "show subtasks"' : undefined }; diff --git a/src/app/core/_components/tables/hashes-table/hashes-table.component.ts b/src/app/core/_components/tables/hashes-table/hashes-table.component.ts index 218779333..9966fa9cd 100644 --- a/src/app/core/_components/tables/hashes-table/hashes-table.component.ts +++ b/src/app/core/_components/tables/hashes-table/hashes-table.component.ts @@ -24,6 +24,7 @@ import { formatUnixTimestamp } from '@src/app/shared/utils/datetime'; export class HashesTableComponent extends BaseTableComponent implements OnInit, OnDestroy { @Input() id: number; @Input() dataType: string; + @Input() filterParam: string; tableColumns: HTTableColumn[] = []; dataSource: HashesDataSource; @@ -37,6 +38,10 @@ export class HashesTableComponent extends BaseTableComponent implements OnInit, if (this.id) { this.dataSource.setId(this.id); this.dataSource.setDataType(this.dataType); + + if (this.filterParam) { + this.dataSource.setFilterParam(this.filterParam); + } } this.dataSource.loadAll(); } diff --git a/src/app/core/_components/tables/hashlists-table/hashlists-table.component.ts b/src/app/core/_components/tables/hashlists-table/hashlists-table.component.ts index 3ae1de624..4b3b54490 100644 --- a/src/app/core/_components/tables/hashlists-table/hashlists-table.component.ts +++ b/src/app/core/_components/tables/hashlists-table/hashlists-table.component.ts @@ -23,6 +23,7 @@ import { HashlistsDataSource } from '@datasources/hashlists.datasource'; import { HashListFormatLabel } from '@src/app/core/_constants/hashlist.config'; import { FilterType } from '@src/app/core/_models/request-params.model'; +import { formatPercentage } from '@src/app/shared/utils/util'; @Component({ selector: 'app-hashlists-table', @@ -101,7 +102,7 @@ export class HashlistsTableComponent extends BaseTableComponent implements OnIni id: HashlistsTableCol.CRACKED, dataKey: 'cracked', icon: (hashlist: JHashlist) => this.renderCrackedStatusIcon(hashlist), - render: (hashlist: JHashlist) => this.renderCrackedHashes(hashlist, false), + routerLink: (hashlist: JHashlist) => this.renderCrackedHashesLink(hashlist), isSortable: true, export: async (hashlist: JHashlist) => this.renderCrackedHashes(hashlist, true) }, @@ -366,4 +367,21 @@ export class HashlistsTableComponent extends BaseTableComponent implements OnIni } return of(links); } + + /** + * Show count of cracked hashes its percentage value + * @param hashlist - hashlist object to show count for + * @return observable array containing the link to render + * @private + */ + private renderCrackedHashesLink(hashlist: JHashlist): Observable { + const links: HTTableRouterLink[] = []; + if (hashlist) { + links.push({ + routerLink: ['/hashlists', 'hashes', 'hashlists', hashlist.id + '?cracked'], + label: `${hashlist.cracked} (${formatPercentage(hashlist.cracked, hashlist.hashCount)})` + }); + } + return of(links); + } } diff --git a/src/app/core/_components/tables/tasks-table/tasks-table.component.ts b/src/app/core/_components/tables/tasks-table/tasks-table.component.ts index 99beee877..8327c0709 100644 --- a/src/app/core/_components/tables/tasks-table/tasks-table.component.ts +++ b/src/app/core/_components/tables/tasks-table/tasks-table.component.ts @@ -176,8 +176,7 @@ export class TasksTableComponent extends BaseTableComponent implements OnInit, O dataKey: 'cracked', routerLink: (wrapper: JTaskWrapper) => this.renderCrackedLinkFromWrapper(wrapper), isSortable: true, - export: async (wrapper: JTaskWrapper) => - wrapper.cracked + '/' + wrapper.hashlist.hashCount.toLocaleString() + '' + export: async (wrapper: JTaskWrapper) => wrapper.cracked + '' }, { id: TaskTableCol.AGENTS, diff --git a/src/app/core/_datasources/hashes.datasource.ts b/src/app/core/_datasources/hashes.datasource.ts index 435267c91..c936cf8e9 100644 --- a/src/app/core/_datasources/hashes.datasource.ts +++ b/src/app/core/_datasources/hashes.datasource.ts @@ -13,6 +13,7 @@ import { BaseDataSource } from '@datasources/base.datasource'; export class HashesDataSource extends BaseDataSource { private _id = 0; private _dataType: string; + private _filterparam: string; setId(id: number): void { this._id = id; @@ -22,6 +23,10 @@ export class HashesDataSource extends BaseDataSource { this._dataType = type; } + setFilterParam(filterparam: string): void { + this._filterparam = filterparam; + } + loadAll(query?: Filter): void { this.loading = true; @@ -52,6 +57,10 @@ export class HashesDataSource extends BaseDataSource { params.addFilter({ field: 'chunkId', operator: FilterType.EQUAL, value: this._id }); } else if (this._dataType === 'hashlists') { params.addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: this._id }); + + if (this._filterparam) { + params.addFilter({ field: 'isCracked', operator: FilterType.EQUAL, value: true }); + } } const hashes$ = this.service.getAll(SERV.HASHES, params.create()); diff --git a/src/app/hashlists/hashes/hashes.component.html b/src/app/hashlists/hashes/hashes.component.html index 38a3fbf16..3f71bf987 100644 --- a/src/app/hashlists/hashes/hashes.component.html +++ b/src/app/hashlists/hashes/hashes.component.html @@ -13,7 +13,7 @@

+ diff --git a/src/app/hashlists/hashes/hashes.component.ts b/src/app/hashlists/hashes/hashes.component.ts index def06e369..5399fd135 100644 --- a/src/app/hashlists/hashes/hashes.component.ts +++ b/src/app/hashlists/hashes/hashes.component.ts @@ -1,5 +1,4 @@ import { DataTableDirective } from 'angular-datatables'; -import { Subject } from 'rxjs'; import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; @@ -37,28 +36,23 @@ export class HashesComponent implements OnInit, OnDestroy { // Component Properties editMode = false; editedIndex: number; - edited: any; // Change to Model // View type and filter options whichView: string; - titleName: any; + titleName: string; + filterParam: string; // Filtering and Display Properties crackPos: any = true; - cracked: any; filtering = ''; filteringDescr = ''; displaying = ''; displayingDescr = ''; - matchHashes: any; // ViewChild reference to the DataTableDirective @ViewChild(DataTableDirective) dtElement: DataTableDirective; - dtTrigger: Subject = new Subject(); - dtOptions: any = {}; - constructor( private unsubscribeService: UnsubscribeService, private titleService: AutoTitleService, @@ -114,7 +108,7 @@ export class HashesComponent implements OnInit, OnDestroy { }); } - getRouterLink(): any[] { + getRouterLink(): (string | number)[] { switch (this.whichView) { case 'chunks': return ['/tasks/show-tasks/', this.editedIndex, 'edit']; @@ -138,7 +132,13 @@ export class HashesComponent implements OnInit, OnDestroy { */ loadHashes(): void { this.route.params.subscribe((params: Params) => { - this.editedIndex = Number(params['id']); + if (params['id'].includes('?')) { + const split = params['id'].split('?'); + this.editedIndex = Number(split[0]); + this.filterParam = split[1]; + } else { + this.editedIndex = Number(params['id']); + } }); this.route.data.subscribe((data) => { @@ -150,7 +150,7 @@ export class HashesComponent implements OnInit, OnDestroy { data: response.data, included: response.included }); - this.titleName = chunk.id; + this.titleName = String(chunk.id); }); break; @@ -181,7 +181,7 @@ export class HashesComponent implements OnInit, OnDestroy { } // Update query parameters and trigger updates - onQueryp(name: any, type: number) { + onQueryp(name: string, type: number) { let query = {}; if (type == 0) { query = { display: name }; From 4616ac7657390bd937555b2d93e226913f7e7c4e Mon Sep 17 00:00:00 2001 From: gpascal123 Date: Wed, 8 Oct 2025 11:14:24 +0200 Subject: [PATCH 2/2] Tests fixed. --- .../tables/base-table/base-table.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/core/_components/tables/base-table/base-table.component.spec.ts b/src/app/core/_components/tables/base-table/base-table.component.spec.ts index 4107fce8d..dbac73912 100644 --- a/src/app/core/_components/tables/base-table/base-table.component.spec.ts +++ b/src/app/core/_components/tables/base-table/base-table.component.spec.ts @@ -128,7 +128,7 @@ describe('BaseTableComponent', () => { const mockWrapper = { id: 1, cracked: 100, taskType: 1, hashlist: { hashCount: 100 } } as JTaskWrapper; component.getCrackedLinkFromWrapper(mockWrapper).subscribe((links) => { expect(links.length).toBe(1); - expect(links[0].label).toBe('100/100'); + expect(links[0].label).toBe('100'); expect(links[0].routerLink).toBe(null); expect(links[0].tooltip).toBe('Please access the cracked hashes via the row\'s context menu "show subtasks"'); done(); @@ -146,7 +146,7 @@ describe('BaseTableComponent', () => { } as JTaskWrapper; component.getCrackedLinkFromWrapper(mockWrapper).subscribe((links) => { expect(links.length).toBe(1); - expect(links[0].label).toBe('100/100'); + expect(links[0].label).toBe('100'); expect(links[0].routerLink).toEqual(['/hashlists', 'hashes', 'tasks', 1]); expect(links[0].tooltip).toBe(undefined); done();