Skip to content
Merged
70 changes: 70 additions & 0 deletions ci/files/update-hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import requests
import subprocess
import json
import sys
import os


class HashType:
def __init__(self, hashType, description, salted, slowHash):
self.hashType = hashType
self.description = description
self.salted = salted
self.slowHash = slowHash


url = "https://raw.githubusercontent.com/hashcat/hashcat/refs/tags/v7.0.0/docs/hashcat-example_hashes.md"
binary = sys.argv[1] # The hashcat binary is the first argument
if not os.path.isfile(binary):
print("usage: python3 update-hashes.py <hashcat binary>")
args = [binary, "-m", "PLACEHOLDER", "--exam", "--machine-readable", "--quiet"]
new_hashtypes = []

response = requests.get(url)
response.raise_for_status()

lines = response.text.splitlines()

auth_uri = 'http://localhost:8080/api/v2/auth/token'
auth = ("admin", "hashtopolis") # default credentials
r = requests.post(auth_uri, auth=auth)
token = r.json()["token"]

headers = {
'Authorization': 'Bearer ' + token
}
url = "http://localhost:8080/api/v2/ui/hashtypes/"
print("Retrieving hashes from db please wait...")

for line in lines[4:]: # skip first 4 header lines
splitted = line.split("|")
hashType = splitted[1].strip().strip("`")
description = splitted[2].strip().strip("`")
r = requests.get(url + hashType, headers=headers)
if (r.status_code != 200):
args[2] = hashType
hashcat_output = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
data = json.loads(hashcat_output.stdout)
slow_hash = data[hashType]["slow_hash"]
salted = data[hashType]["is_salted"]
new_hashtypes.append(HashType(hashType, description, salted, slow_hash))
print("Finished retrieving hashes!")

print("Add the following to the update script:")
print('if (!isset($PRESENT["PLACEHOLDER"])){')
print(" $hashTypes = [")
for hashType in new_hashtypes:
print(f' new HashType( {hashType.hashType}, "{hashType.description}", {int(hashType.salted)}, {int(hashType.slowHash)}),')
print(" ]")
print(' foreach ($hashtypes as $hashtype) {')
print(' $check = Factory::getHashTypeFactory()->get($hashtype->getId());')
print(' if ($check === null) {')
print(' Factory::getHashTypeFactory()->save($hashtype);')
print(' }')
print(' }')
print(' $EXECUTED["PLACEHOLDER"] = true;')
print('}')

print("Add the following to the install script:")
for hashType in new_hashtypes:
print(f" ({hashType.hashType}, '{hashType.description}', {int(hashType.salted)}, {int(hashType.slowHash)}),")
4 changes: 4 additions & 0 deletions src/inc/Util.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ public static function getGitCommit($hashOnly = false) {
*/
public static function checkAgentVersion($type, $version, $silent = false) {
$qF = new QueryFilter(AgentBinary::BINARY_TYPE, $type, "=");
if (Util::databaseColumnExists("AgentBinary", "type")) {
// This check is needed for older updates when agentbinary column still got old 'type' name
$qF = new QueryFilter("type", $type, "=");
}
$binary = Factory::getAgentBinaryFactory()->filter([Factory::FILTER => $qF], true);
if ($binary != null) {
if (Util::versionComparison($binary->getVersion(), $version) == 1) {
Expand Down
20 changes: 12 additions & 8 deletions src/inc/apiv2/common/AbstractModelAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ protected function doFetch(string $pk, AbstractModelFactory $otherFactory = null
if ($object === null) {
throw new ResourceNotFoundError();
}
if ($otherFactory == null && $this->getSingleACL($this->getCurrentUser(), $object) === false) {
$group = Factory::getRightGroupFactory()->get($this->getCurrentUser()->getRightGroupId());
if ($group->getPermissions() !== 'ALL' && $otherFactory == null && $this->getSingleACL($this->getCurrentUser(),
$object) === false) {
throw new HttpForbidden("No access to this object!", 403);
}

Expand Down Expand Up @@ -614,13 +616,15 @@ public static function getManyResources(object $apiClass, Request $request, Resp
/* Generate filters */
$filters = $apiClass->getFilters($request);
$qFs_Filter = $apiClass->makeFilter($filters, $apiClass);

$aFs_ACL = $apiClass->getFilterACL();
if (isset($aFs_ACL[Factory::FILTER])) {
$qFs_Filter = array_merge($aFs_ACL[Factory::FILTER], $qFs_Filter);
}
if (isset($aFs_ACL[Factory::JOIN])) {
$aFs[Factory::JOIN] = $aFs_ACL[Factory::JOIN];
$group = Factory::getRightGroupFactory()->get($apiClass->getCurrentUser()->getRightGroupId());
if ($group->getPermissions() !== 'ALL') { // Only add permission filters when no admin user
$aFs_ACL = $apiClass->getFilterACL();
if (isset($aFs_ACL[Factory::FILTER])) {
$qFs_Filter = array_merge($aFs_ACL[Factory::FILTER], $qFs_Filter);
}
if (isset($aFs_ACL[Factory::JOIN])) {
$aFs[Factory::JOIN] = $aFs_ACL[Factory::JOIN];
}
}

if (count($qFs_Filter) > 0) {
Expand Down
92 changes: 92 additions & 0 deletions src/install/hashtopolis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,26 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(2600, 'md5(md5($pass))', 0, 0),
(2611, 'vBulletin < v3.8.5', 1, 0),
(2612, 'PHPS', 0, 0),
(2630, 'md5(md5($pass.$salt))', 1, 0),
(2711, 'vBulletin >= v3.8.5', 1, 0),
(2811, 'IPB2+, MyBB1.2+', 1, 0),
(3000, 'LM', 0, 0),
(3100, 'Oracle H: Type (Oracle 7+), DES(Oracle)', 1, 0),
(3200, 'bcrypt, Blowfish(OpenBSD)', 0, 0),
(3500, 'md5(md5(md5($pass)))', 0, 0),
(3610, 'md5(md5(md5($pass)).$salt)', 1, 0),
(3710, 'md5($salt.md5($pass))', 1, 0),
(3711, 'Mediawiki B type', 0, 0),
(3730, 'md5($salt1.strtoupper(md5($salt2.$pass)))', 1, 0),
(3800, 'md5($salt.$pass.$salt)', 1, 0),
(3910, 'md5(md5($pass).md5($salt))', 1, 0),
(4010, 'md5($salt.md5($salt.$pass))', 1, 0),
(4110, 'md5($salt.md5($pass.$salt))', 1, 0),
(4300, 'md5(strtoupper(md5($pass)))', 0, 0),
(4400, 'md5(sha1($pass))', 0, 0),
(4410, 'md5(sha1($pass).$salt)', 1, 0),
(4420, 'md5(sha1($pass.$salt))', 1, 0),
(4430, 'md5(sha1($salt.$pass))', 1, 0),
(4500, 'sha1(sha1($pass))', 0, 0),
(4510, 'sha1(sha1($pass).$salt)', 1, 0),
(4520, 'sha1($salt.sha1($pass))', 1, 0),
Expand All @@ -407,6 +412,8 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(5700, 'Cisco-IOS SHA256', 0, 0),
(5800, 'Samsung Android Password/PIN', 1, 0),
(6000, 'RipeMD160', 0, 0),
(6050, 'HMAC-RIPEMD160 (key = $pass)', 1, 0),
(6060, 'HMAC-RIPEMD160 (key = $salt)', 1, 0),
(6100, 'Whirlpool', 0, 0),
(6211, 'TrueCrypt 5.0+ PBKDF2-HMAC-RipeMD160 + AES/Serpent/Twofish', 0, 1),
(6212, 'TrueCrypt 5.0+ PBKDF2-HMAC-RipeMD160 + AES-Twofish/Serpent-AES/Twofish-Serpent', 0, 1),
Expand All @@ -431,6 +438,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(7100, 'OS X v10.8 / v10.9', 0, 1),
(7200, 'GRUB 2', 0, 1),
(7300, 'IPMI2 RAKP HMAC-SHA1', 1, 0),
(7350, 'IPMI2 RAKP HMAC-MD5', 1, 0),
(7400, 'sha256crypt, SHA256(Unix)', 0, 0),
(7401, 'MySQL $A$ (sha256crypt)', 0, 0),
(7500, 'Kerberos 5 AS-REQ Pre-Auth', 0, 0),
Expand Down Expand Up @@ -471,6 +479,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(10410, 'PDF 1.1 - 1.3 (Acrobat 2 - 4), collider #1', 0, 0),
(10420, 'PDF 1.1 - 1.3 (Acrobat 2 - 4), collider #2', 0, 0),
(10500, 'PDF 1.4 - 1.6 (Acrobat 5 - 8)', 0, 0),
(10510, 'PDF 1.3 - 1.6 (Acrobat 4 - 8) w/ RC4-40', 1, 1),
(10600, 'PDF 1.7 Level 3 (Acrobat 9)', 0, 0),
(10700, 'PDF 1.7 Level 8 (Acrobat 10 - 11)', 0, 0),
(10800, 'SHA384', 0, 0),
Expand Down Expand Up @@ -498,6 +507,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(12000, 'PBKDF2-HMAC-SHA1', 0, 1),
(12001, 'Atlassian (PBKDF2-HMAC-SHA1)', 0, 1),
(12100, 'PBKDF2-HMAC-SHA512', 0, 1),
(12150, 'Apache Shiro 1 SHA-512', 1, 1),
(12200, 'eCryptfs', 0, 1),
(12300, 'Oracle T: Type (Oracle 12+)', 0, 1),
(12400, 'BSDiCrypt, Extended DES', 0, 0),
Expand Down Expand Up @@ -541,6 +551,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(13900, 'OpenCart', 1, 0),
(14000, 'DES (PT = $salt, key = $pass)', 1, 0),
(14100, '3DES (PT = $salt, key = $pass)', 1, 0),
(14200, 'RACF KDFAES', 1, 1),
(14400, 'sha1(CX)', 1, 0),
(14500, 'Linux Kernel Crypto API (2.4)', 0, 0),
(14600, 'LUKS 10', 0, 1),
Expand All @@ -564,12 +575,16 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(16300, 'Ethereum Pre-Sale Wallet, PBKDF2-HMAC-SHA256', 0, 1),
(16400, 'CRAM-MD5 Dovecot', 0, 0),
(16500, 'JWT (JSON Web Token)', 0, 0),
(16501, 'Perl Mojolicious session cookie (HMAC-SHA256, >= v9.19)', 1, 0),
(16600, 'Electrum Wallet (Salt-Type 1-3)', 0, 0),
(16700, 'FileVault 2', 0, 1),
(16800, 'WPA-PMKID-PBKDF2', 0, 1),
(16801, 'WPA-PMKID-PMK', 0, 1),
(16900, 'Ansible Vault', 0, 1),
(17010, 'GPG (AES-128/AES-256 (SHA-1($pass)))', 0, 1),
(17020, 'GPG (AES-128/AES-256 (SHA-512($pass)))', 1, 1),
(17030, 'GPG (AES-128/AES-256 (SHA-256($pass)))', 1, 1),
(17040, 'GPG (CAST5 (SHA-1($pass)))', 1, 1),
(17200, 'PKZIP (Compressed)', 0, 0),
(17210, 'PKZIP (Uncompressed)', 0, 0),
(17220, 'PKZIP (Compressed Multi-File)', 0, 0),
Expand All @@ -595,6 +610,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(19000, 'QNX /etc/shadow (MD5)', 0, 1),
(19100, 'QNX /etc/shadow (SHA256)', 0, 1),
(19200, 'QNX /etc/shadow (SHA512)', 0, 1),
(19210, 'QNX 7 /etc/shadow (SHA512)', 1, 1),
(19300, 'sha1($salt1.$pass.$salt2)', 0, 0),
(19500, 'Ruby on Rails Restful-Authentication', 0, 0),
(19600, 'Kerberos 5 TGS-REP etype 17 (AES128-CTS-HMAC-SHA1-96)', 0, 1),
Expand All @@ -612,20 +628,24 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(20600, 'Oracle Transportation Management (SHA256)', 0, 0),
(20710, 'sha256(sha256($pass).$salt)', 1, 0),
(20711, 'AuthMe sha256', 0, 0),
(20712, 'RSA Security Analytics / NetWitness (sha256)', 1, 0),
(20720, 'sha256($salt.sha256($pass))', 1, 0),
(20730, 'sha256(sha256($pass.$salt))', 1, 0),
(20800, 'sha256(md5($pass))', 0, 0),
(20900, 'md5(sha1($pass).md5($pass).sha1($pass))', 0, 0),
(21000, 'BitShares v0.x - sha512(sha512_bin(pass))', 0, 0),
(21100, 'sha1(md5($pass.$salt))', 1, 0),
(21200, 'md5(sha1($salt).md5($pass))', 1, 0),
(21300, 'md5($salt.sha1($salt.$pass))', 1, 0),
(21310, 'md5($salt1.sha1($salt2.$pass))', 1, 0),
(21400, 'sha256(sha256_bin(pass))', 0, 0),
(21420, 'sha256($salt.sha256_bin($pass))', 1, 0),
(21500, 'SolarWinds Orion', 0, 0),
(21501, 'SolarWinds Orion v2', 0, 0),
(21600, 'Web2py pbkdf2-sha512', 0, 0),
(21700, 'Electrum Wallet (Salt-Type 4)', 0, 0),
(21800, 'Electrum Wallet (Salt-Type 5)', 0, 0),
(21900, 'md5(md5(md5($pass.$salt1)).$salt2)', 1, 0),
(22000, 'WPA-PBKDF2-PMKID+EAPOL', 0, 0),
(22001, 'WPA-PMK-PMKID+EAPOL', 0, 0),
(22100, 'BitLocker', 0, 0),
Expand All @@ -636,6 +656,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(22500, 'MultiBit Classic .key (MD5)', 0, 0),
(22600, 'Telegram Desktop App Passcode (PBKDF2-HMAC-SHA1)', 0, 0),
(22700, 'MultiBit HD (scrypt)', 0, 1),
(22800, 'Simpla CMS - md5($salt.$pass.md5($pass))', 1, 0),
(22911, 'RSA/DSA/EC/OPENSSH Private Keys ($0$)', 0, 0),
(22921, 'RSA/DSA/EC/OPENSSH Private Keys ($6$)', 0, 0),
(22931, 'RSA/DSA/EC/OPENSSH Private Keys ($1, $3$)', 0, 0),
Expand All @@ -653,6 +674,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(23700, 'RAR3-p (Uncompressed)', 0, 0),
(23800, 'RAR3-p (Compressed)', 0, 0),
(23900, 'BestCrypt v3 Volume Encryption', 0, 0),
(24000, 'BestCrypt v4 Volume Encryption', 1, 1),
(24100, 'MongoDB ServerKey SCRAM-SHA-1', 0, 0),
(24200, 'MongoDB ServerKey SCRAM-SHA-256', 0, 0),
(24300, 'sha1($salt.sha1($pass.$salt))', 1, 0),
Expand Down Expand Up @@ -682,6 +704,7 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(26403, 'AES-256-ECB NOKDF (PT = $salt, key = $pass)', 0, 0),
(26500, 'iPhone passcode (UID key + System Keybag)', 0, 0),
(26600, 'MetaMask Wallet', 0, 1),
(26610, 'MetaMask Wallet (short hash, plaintext check)', 1, 1),
(26700, 'SNMPv3 HMAC-SHA224-128', 0, 0),
(26800, 'SNMPv3 HMAC-SHA256-192', 0, 0),
(26900, 'SNMPv3 HMAC-SHA384-256', 0, 0),
Expand Down Expand Up @@ -763,8 +786,77 @@ INSERT INTO `HashType` (`hashTypeId`, `description`, `isSalted`, `isSlowHash`) V
(29543, 'LUKS v1 RIPEMD-160 + Twofish', 0, 1),
(29600, 'Terra Station Wallet (AES256-CBC(PBKDF2($pass)))', 0, 1),
(29700, 'KeePass 1 (AES/Twofish) and KeePass 2 (AES) - keyfile only mode', 0, 1),
(29800, 'Bisq .wallet (scrypt)', 1, 1),
(29910, 'ENCsecurity Datavault (PBKDF2/no keychain)', 1, 1),
(29920, 'ENCsecurity Datavault (PBKDF2/keychain)', 1, 1),
(29930, 'ENCsecurity Datavault (MD5/no keychain)', 1, 1),
(29940, 'ENCsecurity Datavault (MD5/keychain)', 1, 1),
(30000, 'Python Werkzeug MD5 (HMAC-MD5 (key = $salt))', 0, 0),
(30120, 'Python Werkzeug SHA256 (HMAC-SHA256 (key = $salt))', 0, 0),
(30420, 'DANE RFC7929/RFC8162 SHA2-256', 0, 0),
(30500, 'md5(md5($salt).md5(md5($pass)))', 1, 0),
(30600, 'bcrypt(sha256($pass)) / bcryptsha256', 1, 1),
(30601, 'bcrypt-sha256 v2 bcrypt(HMAC-SHA256($pass))', 1, 1),
(30700, 'Anope IRC Services (enc_sha256)', 1, 0),
(30901, 'Bitcoin raw private key (P2PKH), compressed', 0, 0),
(30902, 'Bitcoin raw private key (P2PKH), uncompressed', 0, 0),
(30903, 'Bitcoin raw private key (P2WPKH, Bech32), compressed', 0, 0),
(30904, 'Bitcoin raw private key (P2WPKH, Bech32), uncompressed', 0, 0),
(30905, 'Bitcoin raw private key (P2SH(P2WPKH)), compressed', 0, 0),
(30906, 'Bitcoin raw private key (P2SH(P2WPKH)), uncompressed', 0, 0),
(31000, 'BLAKE2s-256', 0, 0),
(31100, 'ShangMi 3 (SM3)', 0, 0),
(31200, 'Veeam VBK', 1, 1),
(31300, 'MS SNTP', 1, 0),
(31400, 'SecureCRT MasterPassphrase v2', 1, 0),
(31500, 'Domain Cached Credentials (DCC), MS Cache (NT)', 1, 1),
(31600, 'Domain Cached Credentials 2 (DCC2), MS Cache 2, (NT)', 1, 1),
(31700, 'md5(md5(md5($pass).$salt1).$salt2)', 1, 0),
(31800, '1Password, mobilekeychain (1Password 8)', 1, 1),
(31900, 'MetaMask Mobile Wallet', 1, 1),
(32000, 'NetIQ SSPR (MD5)', 1, 1),
(32010, 'NetIQ SSPR (SHA1)', 1, 1),
(32020, 'NetIQ SSPR (SHA-1 with Salt)', 1, 1),
(32030, 'NetIQ SSPR (SHA-256 with Salt)', 1, 1),
(32031, 'Adobe AEM (SSPR, SHA-256 with Salt)', 1, 1),
(32040, 'NetIQ SSPR (SHA-512 with Salt)', 1, 1),
(32041, 'Adobe AEM (SSPR, SHA-512 with Salt)', 1, 1),
(32050, 'NetIQ SSPR (PBKDF2WithHmacSHA1)', 1, 1),
(32060, 'NetIQ SSPR (PBKDF2WithHmacSHA256)', 1, 1),
(32070, 'NetIQ SSPR (PBKDF2WithHmacSHA512)', 1, 1),
(32100, 'Kerberos 5, etype 17, AS-REP', 1, 1),
(32200, 'Kerberos 5, etype 18, AS-REP', 1, 1),
(32300, 'Empire CMS (Admin password)', 1, 0),
(32410, 'sha512(sha512($pass).$salt)', 1, 0),
(32420, 'sha512(sha512_bin($pass).$salt)', 1, 0),
(32500, 'Dogechain.info Wallet', 1, 1),
(32600, 'CubeCart (whirlpool($salt.$pass.$salt))', 1, 0),
(32700, 'Kremlin Encrypt 3.0 w/NewDES', 1, 1),
(32800, 'md5(sha1(md5($pass)))', 0, 0),
(32900, 'PBKDF1-SHA1', 1, 1),
(33000, 'md5($salt1.$pass.$salt2)', 1, 0),
(33100, 'md5($salt.md5($pass).$salt)', 1, 0),
(33300, 'HMAC-BLAKE2S (key = $pass)', 1, 0),
(33400, 'mega.nz password-protected link (PBKDF2-HMAC-SHA512)', 1, 1),
(33500, 'RC4 40-bit DropN', 1, 0),
(33501, 'RC4 72-bit DropN', 1, 0),
(33502, 'RC4 104-bit DropN', 1, 0),
(33600, 'RIPEMD-320', 0, 0),
(33650, 'HMAC-RIPEMD320 (key = $pass)', 1, 0),
(33660, 'HMAC-RIPEMD320 (key = $salt)', 1, 0),
(33700, 'Microsoft Online Account (PBKDF2-HMAC-SHA256 + AES256)', 1, 1),
(33800, 'WBB4 (Woltlab Burning Board) Plugin [bcrypt(bcrypt($pass))]', 1, 1),
(33900, 'Citrix NetScaler (PBKDF2-HMAC-SHA256)', 1, 1),
(34000, 'Argon2', 1, 1),
(34100, 'LUKS v2 argon2id + SHA-256 + AES', 1, 1),
(34200, 'MurmurHash64A', 1, 0),
(34201, 'MurmurHash64A (zero seed)', 0, 0),
(34211, 'MurmurHash64A truncated (zero seed)', 0, 0),
(70000, 'argon2id [Bridged: reference implementation + tunings]', 1, 1),
(70100, 'scrypt [Bridged: Scrypt-Jane ROMix]', 1, 1),
(70200, 'scrypt [Bridged: Scrypt-Yescrypt]', 1, 1),
(72000, 'Generic Hash [Bridged: Python Interpreter free-threading]', 1, 1),
(73000, 'Generic Hash [Bridged: Python Interpreter with GIL]', 1, 1),
(99999, 'Plaintext', 0, 0);

CREATE TABLE `LogEntry` (
Expand Down
Loading