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

Added column "Created by" to hashlist overview #778

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Tasks can be set to top priority (to be first in the list) by the User API.
- Supertask runtime can be estimated on the supertask detail page by entering expected attack speeds for hashcat wordlist and bruteforce attacks
- Number of agents per task can be limited (pull request #764).
- The creator of a hashlist will now be stored and shown, to make supporting users in a larger environment easier.

## Bugfixes

Expand Down
16 changes: 14 additions & 2 deletions src/dba/models/Hashlist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class Hashlist extends AbstractModel {
private $notes;
private $brainId;
private $brainFeatures;
private $creatorId;

function __construct($hashlistId, $hashlistName, $format, $hashTypeId, $hashCount, $saltSeparator, $cracked, $isSecret, $hexSalt, $isSalted, $accessGroupId, $notes, $brainId, $brainFeatures) {
function __construct($hashlistId, $hashlistName, $format, $hashTypeId, $hashCount, $saltSeparator, $cracked, $isSecret, $hexSalt, $isSalted, $accessGroupId, $notes, $brainId, $brainFeatures, $creatorId) {
$this->hashlistId = $hashlistId;
$this->hashlistName = $hashlistName;
$this->format = $format;
Expand All @@ -33,6 +34,7 @@ function __construct($hashlistId, $hashlistName, $format, $hashTypeId, $hashCoun
$this->notes = $notes;
$this->brainId = $brainId;
$this->brainFeatures = $brainFeatures;
$this->creatorId = $creatorId;
}

function getKeyValueDict() {
Expand All @@ -51,7 +53,8 @@ function getKeyValueDict() {
$dict['notes'] = $this->notes;
$dict['brainId'] = $this->brainId;
$dict['brainFeatures'] = $this->brainFeatures;

$dict['creatorId'] = $this->creatorId;

return $dict;
}

Expand Down Expand Up @@ -122,6 +125,14 @@ function setSaltSeparator($saltSeparator) {
function getCracked() {
return $this->cracked;
}

function getCreatorId() {
return $this->creator;
dr0pd34d marked this conversation as resolved.
Show resolved Hide resolved
}

function setCreatorId($creatorId) {
$this->creatorId = $creatorId;
}

function setCracked($cracked) {
$this->cracked = $cracked;
Expand Down Expand Up @@ -197,4 +208,5 @@ function setBrainFeatures($brainFeatures) {
const NOTES = "notes";
const BRAIN_ID = "brainId";
const BRAIN_FEATURES = "brainFeatures";
const CREATOR = "creatorId";
dr0pd34d marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 2 additions & 2 deletions src/dba/models/HashlistFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getCacheValidTime() {
* @return Hashlist
*/
function getNullObject() {
$o = new Hashlist(-1, null, null, null, null, null, null, null, null, null, null, null, null, null);
$o = new Hashlist(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
return $o;
}

Expand All @@ -33,7 +33,7 @@ function getNullObject() {
* @return Hashlist
*/
function createObjectFromDict($pk, $dict) {
$o = new Hashlist($dict['hashlistId'], $dict['hashlistName'], $dict['format'], $dict['hashTypeId'], $dict['hashCount'], $dict['saltSeparator'], $dict['cracked'], $dict['isSecret'], $dict['hexSalt'], $dict['isSalted'], $dict['accessGroupId'], $dict['notes'], $dict['brainId'], $dict['brainFeatures']);
$o = new Hashlist($dict['hashlistId'], $dict['hashlistName'], $dict['format'], $dict['hashTypeId'], $dict['hashCount'], $dict['saltSeparator'], $dict['cracked'], $dict['isSecret'], $dict['hexSalt'], $dict['isSalted'], $dict['accessGroupId'], $dict['notes'], $dict['brainId'], $dict['brainFeatures'], $dict['creatorId']);
return $o;
}

Expand Down
20 changes: 18 additions & 2 deletions src/hashlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@
} else if (!AccessUtils::userCanAccessHashlists($hashlists, Login::getInstance()->getUser())) {
UI::printError("ERROR", "No access to this hashlist!");
}
$list = new DataSet(array('hashlist' => $hashlists[0], 'hashtype' => $joined[Factory::getHashTypeFactory()->getModelName()][0]));

// Get User Factory
$UserFactory = Factory::getUserFactory();
// Get creator ID of the hashlist
$creatorId = $hashlists[0]->getCreatorId();
// Get the username of the creator
$creatorUsername = $UserFactory->get($creatorId)->getUsername();

$list = new DataSet(array('hashlist' => $hashlists[0], 'hashtype' => $joined[Factory::getHashTypeFactory()->getModelName()][0], 'creator' => $creatorUsername));
UI::add('list', $list);
UI::add('accessGroup', Factory::getAccessGroupFactory()->get($list->getVal('hashlist')->getAccessGroupId()));
UI::add('accessGroups', AccessUtils::getAccessGroupsOfUser(Login::getInstance()->getUser()));
Expand Down Expand Up @@ -136,8 +144,16 @@
/** @var $joinedHashlists Hashlist[] */
$joinedHashlists = $joined[Factory::getHashlistFactory()->getModelName()];
$hashlists = array();

// Get User Factory
$UserFactory = Factory::getUserFactory();

for ($x = 0; $x < sizeof($joinedHashlists); $x++) {
$hashlists[] = new DataSet(['hashlist' => $joinedHashlists[$x], 'hashtype' => $joined[Factory::getHashTypeFactory()->getModelName()][$x]]);
// Add the creator details to the dataset in order to render a username, not just the ID of the user
$creatorId = $joinedHashlists[$x]->getCreatorId();
$creatorUsername = $UserFactory->get($creatorId)->getUsername();

$hashlists[] = new DataSet(['hashlist' => $joinedHashlists[$x], 'hashtype' => $joined[Factory::getHashTypeFactory()->getModelName()][$x], 'creator' => $creatorUsername]);
}
UI::add('hashlists', $hashlists);
UI::add('numHashlists', sizeof($hashlists));
Expand Down
2 changes: 1 addition & 1 deletion src/inc/utils/HashlistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
}

Factory::getAgentFactory()->getDB()->beginTransaction();
$hashlist = new Hashlist(null, $name, $format, $hashtype, 0, $separator, 0, $secret, $hexsalted, $salted, $accessGroup->getId(), '', $brainId, $brainFeatures);
$hashlist = new Hashlist(null, $name, $format, $hashtype, 0, $separator, 0, $secret, $hexsalted, $salted, $accessGroup->getId(), '', $brainId, $brainFeatures, $user->getId());
$hashlist = Factory::getHashlistFactory()->save($hashlist);

$dataSource = "";
Expand Down
3 changes: 2 additions & 1 deletion src/install/hashtopolis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ CREATE TABLE `Hashlist` (
`accessGroupId` INT(11) NOT NULL,
`notes` TEXT NOT NULL,
`brainId` INT(11) NOT NULL,
`brainFeatures` TINYINT(4) NOT NULL
`brainFeatures` TINYINT(4) NOT NULL,
`creatorId` INT(11) NOT NULL
) ENGINE = InnoDB;

CREATE TABLE `HashlistHashlist` (
Expand Down
6 changes: 6 additions & 0 deletions src/install/updates/update_v0.12.x_v0.x.x.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@
}
$EXECUTED["v0.12.x_maxAgents_pretask_task"] = true;
}
if (!isset($PRESENT["v0.12.x_creatorColumn"])) {
zyronix marked this conversation as resolved.
Show resolved Hide resolved
if (!Util::databaseColumnExists("Hashlist", "creatorId")) {
Factory::getFileFactory()->getDB()->query("ALTER TABLE `Hashlist` ADD `creatorId` INT(11) NULL;");
}
$EXECUTED["v0.12.x_creatorColumn"] = true;
}
4 changes: 4 additions & 0 deletions src/templates/hashlists/detail.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ <h2>Hashlist details</h2>
<td>Member of Access Group:</td>
<td>[[accessGroup.getGroupName()]]</td>
</tr>
<tr>
<td>Creator:</td>
dr0pd34d marked this conversation as resolved.
Show resolved Hide resolved
<td>[[list.getVal('creator')]]</td>
</tr>
<tr>
<td>Name:</td>
<td>
Expand Down
10 changes: 8 additions & 2 deletions src/templates/hashlists/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2>Hashlists ([[numHashlists]])</h2>
<th>Hash type</th>
<th>Format</th>
<th>Cracked</th>
<th>Created By</th>
<th>Pre-cracked</th>
<th>Action</th>
</tr>
Expand Down Expand Up @@ -50,6 +51,11 @@ <h2>Hashlists ([[numHashlists]])</h2>
[[entry.getVal('hashlist').getHashCount()]])
{{ENDIF}}
</td>
<td>
{{IF [[accessControl.hasPermission([[$DAccessControl::VIEW_HASHES_ACCESS]])]]}}
[[entry.getVal('creator')]]
{{ENDIF}}
</td>
<td>
{{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_HASHLIST_ACCESS]])]] && [[accessControl.hasPermission([[$DAccessControl::ADD_FILE_ACCESS]])]]}}
<form class="float-right mx-1" action="hashlists.php" method="POST">
Expand Down Expand Up @@ -88,8 +94,8 @@ <h2>Hashlists ([[numHashlists]])</h2>
pageLength: 50,
"order": [ [0, 'asc'] ],
"columnDefs": [
{ "orderable": false, "targets": [5, 6] },
{ "orderable": true, "targets": [0, 1, 2, 3, 4] }
{ "orderable": false, "targets": [6, 7] },
{ "orderable": true, "targets": [0, 1, 2, 3, 4, 5] }
]
});
});
Expand Down