Skip to content

Commit 9923b98

Browse files
committed
Revert "Merge pull request hashtopolis#750 from hashtopolis/supertask-runtime-estimate"
This reverts commit 4db87dd, reversing changes made to a907491.
1 parent d38eb01 commit 9923b98

21 files changed

+49
-1379
lines changed

doc/changelog.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
- Cracked hashes for all hashlists can be shown together (caution: only use when having smaller hashlists).
77
- Allow abort all chunks of a specific access group from the User API.
88
- Tasks can be set to top priority (to be first in the list) by the User API.
9-
- Supertask runtime can be estimated on the supertask detail page by entering expected attack speeds for hashcat wordlist and bruteforce attacks
109

1110
## Bugfixes
1211

src/dba/models/File.class.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ class File extends AbstractModel {
99
private $isSecret;
1010
private $fileType;
1111
private $accessGroupId;
12-
private $lineCount;
1312

14-
function __construct($fileId, $filename, $size, $isSecret, $fileType, $accessGroupId, $lineCount) {
13+
function __construct($fileId, $filename, $size, $isSecret, $fileType, $accessGroupId) {
1514
$this->fileId = $fileId;
1615
$this->filename = $filename;
1716
$this->size = $size;
1817
$this->isSecret = $isSecret;
1918
$this->fileType = $fileType;
2019
$this->accessGroupId = $accessGroupId;
21-
$this->lineCount = $lineCount;
2220
}
2321

2422
function getKeyValueDict() {
@@ -29,7 +27,6 @@ function getKeyValueDict() {
2927
$dict['isSecret'] = $this->isSecret;
3028
$dict['fileType'] = $this->fileType;
3129
$dict['accessGroupId'] = $this->accessGroupId;
32-
$dict['lineCount'] = $this->lineCount;
3330

3431
return $dict;
3532
}
@@ -97,21 +94,11 @@ function getAccessGroupId() {
9794
function setAccessGroupId($accessGroupId) {
9895
$this->accessGroupId = $accessGroupId;
9996
}
100-
101-
function getLineCount() {
102-
return $this->lineCount;
103-
}
104-
105-
function setLineCount($lineCount) {
106-
$this->lineCount = $lineCount;
107-
}
108-
10997

11098
const FILE_ID = "fileId";
11199
const FILENAME = "filename";
112100
const SIZE = "size";
113101
const IS_SECRET = "isSecret";
114102
const FILE_TYPE = "fileType";
115103
const ACCESS_GROUP_ID = "accessGroupId";
116-
const LINE_COUNT = "lineCount";
117104
}

src/dba/models/FileFactory.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function getCacheValidTime() {
2323
* @return File
2424
*/
2525
function getNullObject() {
26-
$o = new File(-1, null, null, null, null, null, null);
26+
$o = new File(-1, null, null, null, null, null);
2727
return $o;
2828
}
2929

@@ -33,7 +33,7 @@ function getNullObject() {
3333
* @return File
3434
*/
3535
function createObjectFromDict($pk, $dict) {
36-
$o = new File($dict['fileId'], $dict['filename'], $dict['size'], $dict['isSecret'], $dict['fileType'], $dict['accessGroupId'], $dict['lineCount']);
36+
$o = new File($dict['fileId'], $dict['filename'], $dict['size'], $dict['isSecret'], $dict['fileType'], $dict['accessGroupId']);
3737
return $o;
3838
}
3939

src/dba/models/generator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@
102102
'size',
103103
'isSecret',
104104
'fileType',
105-
'accessGroupId',
106-
'lineCount'
105+
'accessGroupId'
107106
];
108107
$CONF['Hash'] = [
109108
'hashId',

src/inc/Util.class.php

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,8 @@ public static function insertFile($path, $name, $type, $accessGroupId) {
359359
// check if there is an old deletion request for the same filename
360360
$qF = new QueryFilter(FileDelete::FILENAME, $name, "=");
361361
Factory::getFileDeleteFactory()->massDeletion([Factory::FILTER => $qF]);
362-
if ($fileType == DFileType::RULE) {
363-
$file = new File(null, $name, Util::filesize($path), 1, $fileType, $accessGroupId, Util::rulefileLineCount($path));
364-
}
365-
else {
366-
$file = new File(null, $name, Util::filesize($path), 1, $fileType, $accessGroupId, Util::fileLineCount($path));
367-
}
362+
363+
$file = new File(null, $name, Util::filesize($path), 1, $fileType, $accessGroupId);
368364
$file = Factory::getFileFactory()->save($file);
369365
if ($file == null) {
370366
return false;
@@ -651,48 +647,7 @@ public static function filesize($file) {
651647

652648
return $pos;
653649
}
654-
655-
/**
656-
* This counts the number of lines in a given file
657-
* @param $file string Filepath you want to get the size from
658-
* @return int -1 if the file doesn't exist, else filesize
659-
*/
660-
public static function fileLineCount($file) {
661-
if (!file_exists($file)) {
662-
return -1;
663-
}
664-
// find out what a prettier solution for this would be, as opposed to setting the max execution time to an arbitrary two hours
665-
ini_set('max_execution_time', '7200');
666-
$file = new \SplFileObject($file, 'r');
667-
$file->seek(PHP_INT_MAX);
668-
669-
return $file->key();
670-
}
671650

672-
/**
673-
* This counts the number of lines in a rule file, excluding lines starting with # and empty lines
674-
* @param $file string Filepath you want to get the size from
675-
* @return int -1 if the file doesn't exist, else filesize
676-
*/
677-
public static function rulefileLineCount($file) {
678-
if (!file_exists($file)) {
679-
return -1;
680-
}
681-
// find out what a prettier solution for this would be, as opposed to setting the max execution time to an arbitrary two hours
682-
ini_set('max_execution_time', '7200');
683-
$lineCount = 0;
684-
$handle = fopen($file, "r");
685-
while(!feof($handle)){
686-
$line = fgets($handle);
687-
if (!(Util::startsWith($line, '#') or trim($line) == "")) {
688-
$lineCount = $lineCount + 1;
689-
}
690-
}
691-
692-
fclose($handle);
693-
return $lineCount;
694-
}
695-
696651
/**
697652
* Refreshes the page with the current url, also includes the query string.
698653
*/
@@ -1393,9 +1348,7 @@ public static function arrayOfIds($array) {
13931348
}
13941349
return $arr;
13951350
}
1396-
1397-
// new function added: fileLineCount(). This function is independent of OS.
1398-
// check whether we can remove one of these functions
1351+
13991352
public static function countLines($tmpfile) {
14001353
if (stripos(PHP_OS, "WIN") === 0) {
14011354
// windows line count

src/inc/defines/files.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,4 @@ class DFileAction {
1919

2020
const EDIT_FILE = "editFile";
2121
const EDIT_FILE_PERM = DAccessControl::MANAGE_FILE_ACCESS;
22-
23-
const COUNT_FILE_LINES = "countFileLines";
24-
const COUNT_FILE_LINES_PERM = DAccessControl::MANAGE_FILE_ACCESS;
2522
}

src/inc/defines/tasks.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ class DSupertaskAction {
5555

5656
const BULK_SUPERTASK = "bulkSupertaskCreation";
5757
const BULK_SUPERTASK_PERM = DAccessControl::CREATE_SUPERTASK_ACCESS;
58-
59-
const REMOVE_PRETASK_FROM_SUPERTASK = "removePretaskFromSupertask";
60-
const REMOVE_PRETASK_FROM_SUPERTASK_PERM = DAccessControl::CREATE_SUPERTASK_ACCESS;
61-
62-
const ADD_PRETASK_TO_SUPERTASK = "addPretaskToSupertask";
63-
const ADD_PRETASK_TO_SUPERTASK_PERM = DAccessControl::CREATE_SUPERTASK_ACCESS;
6458
}
6559

6660
class DTaskAction {

src/inc/handlers/FileHandler.class.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public function handle($action) {
2727
FileUtils::saveChanges($_POST['fileId'], $_POST['filename'], $_POST['accessGroupId'], AccessControl::getInstance()->getUser());
2828
FileUtils::setFileType($_POST['fileId'], $_POST['filetype'], AccessControl::getInstance()->getUser());
2929
break;
30-
case DFileAction::COUNT_FILE_LINES:
31-
AccessControl::getInstance()->checkPermission(DFileAction::COUNT_FILE_LINES_PERM);
32-
FileUtils::fileCountLines($_POST['file']);
33-
UI::addMessage(UI::SUCCESS, "Line count has been successfully calculated!");
34-
break;
3530
default:
3631
UI::addMessage(UI::ERROR, "Invalid action!");
3732
break;

src/inc/handlers/SupertaskHandler.class.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ public function handle($action) {
2929
AccessControl::getInstance()->checkPermission(DSupertaskAction::BULK_SUPERTASK_PERM);
3030
SupertaskUtils::bulkSupertask($_POST['name'], $_POST['command'], $_POST['isCpu'], $_POST['isSmall'], $_POST['crackerBinaryTypeId'], $_POST['benchtype'], @$_POST['basefile'], @$_POST['iterfile'], Login::getInstance()->getUser());
3131
break;
32-
case DSupertaskAction::REMOVE_PRETASK_FROM_SUPERTASK:
33-
AccessControl::getInstance()->checkPermission(DSupertaskAction::REMOVE_PRETASK_FROM_SUPERTASK_PERM);
34-
SupertaskUtils::removePretaskFromSupertask($_POST['supertaskId'], $_POST['pretaskId']);
35-
break;
36-
case DSupertaskAction::ADD_PRETASK_TO_SUPERTASK:
37-
AccessControl::getInstance()->checkPermission(DSupertaskAction::ADD_PRETASK_TO_SUPERTASK_PERM);
38-
SupertaskUtils::addPretaskToSupertask($_POST['supertaskId'], $_POST['pretaskId']);
39-
break;
4032
default:
4133
UI::addMessage(UI::ERROR, "Invalid action!");
4234
break;

src/inc/utils/FileUtils.class.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -338,30 +338,4 @@ public static function getFile($fileId, $user) {
338338
}
339339
return $file;
340340
}
341-
342-
/**
343-
* @param $fileId
344-
* @throws HTException
345-
*/
346-
public static function fileCountLines($fileId) {
347-
$file = Factory::getFileFactory()->get($fileId);
348-
$fileName = $file->getFilename();
349-
$filePath = dirname(__FILE__) . "/../../files/" . $fileName;
350-
if (!file_exists($filePath)) {
351-
throw new HTException("File not found!");
352-
}
353-
if ($file->getFileType() == DFileType::RULE) {
354-
$count = Util::rulefileLineCount($filePath);
355-
}
356-
else {
357-
$count = Util::fileLineCount($filePath);
358-
}
359-
360-
if ($count == -1) {
361-
throw new HTException("Could not determine line count.");
362-
}
363-
else {
364-
Factory::getFileFactory()->set($file, File::LINE_COUNT, $count);
365-
}
366-
}
367341
}

0 commit comments

Comments
 (0)