Skip to content
Permalink
Browse files

changed file structure

added handler to agent
updated functions to handle agent actions
  • Loading branch information...
s3inlc committed Nov 10, 2016
1 parent f90bba8 commit fff772a9f9237bf57016a930b6073b16020ba90f
Showing with 322 additions and 234 deletions.
  1. 0 LICENSE.txt
  2. 0 README.md
  3. 0 doc/.gitignore
  4. BIN doc/protocol.pdf
  5. 0 doc/protocol.tex
  6. 0 src/about.php
  7. 0 src/account.php
  8. +6 −176 src/agents.php
  9. 0 src/chunks.php
  10. 0 src/config.php
  11. 0 src/files.php
  12. 0 src/fix.php
  13. 0 src/forgot.php
  14. 0 src/get.php
  15. 0 src/hashcat.php
  16. 0 src/hashes.php
  17. 0 src/hashlists.php
  18. 0 src/hashtypes.php
  19. 0 src/inc/.gitignore
  20. +16 −15 src/inc/API.class.php
  21. +19 −0 src/inc/UI.class.php
  22. 0 src/inc/crypt.class.php
  23. 0 src/inc/dataset.class.php
  24. 0 src/inc/factory.class.php
  25. +252 −0 src/inc/handlers/AgentHandler.class.php
  26. 0 src/inc/lang.class.php
  27. +8 −0 src/inc/load.php
  28. 0 src/inc/login.class.php
  29. 0 src/inc/menu.class.php
  30. 0 src/inc/template.class.php
  31. +1 −23 src/inc/util.class.php
  32. 0 src/index.php
  33. 0 src/install/hashtopussy.sql
  34. 0 src/install/index.php
  35. 0 src/install/migrate.sql
  36. BIN src/jscolor/arrow.gif
  37. BIN src/jscolor/cross.gif
  38. BIN src/jscolor/hs.png
  39. BIN src/jscolor/hv.png
  40. 0 src/jscolor/jscolor.js
  41. 0 src/lang/DE-de.php
  42. 0 src/lang/EN-en.php
  43. 0 src/login.php
  44. 0 src/logout.php
  45. +2 −2 src/models/AbstractModelFactory.class.php
  46. 0 src/models/Agent.class.php
  47. 0 src/models/AgentError.class.php
  48. 0 src/models/AgentErrorFactory.class.php
  49. 0 src/models/AgentFactory.class.php
  50. 0 src/models/Assignment.class.php
  51. 0 src/models/AssignmentFactory.class.php
  52. 0 src/models/Chunk.class.php
  53. 0 src/models/ChunkFactory.class.php
  54. 0 src/models/Config.class.php
  55. 0 src/models/ConfigFactory.class.php
  56. 0 src/models/File.class.php
  57. 0 src/models/FileFactory.class.php
  58. 0 src/models/Hash.class.php
  59. 0 src/models/HashBinary.class.php
  60. 0 src/models/HashBinaryFactory.class.php
  61. 0 src/models/HashFactory.class.php
  62. 0 src/models/HashType.class.php
  63. 0 src/models/HashTypeFactory.class.php
  64. 0 src/models/HashcatRelease.class.php
  65. 0 src/models/HashcatReleaseFactory.class.php
  66. 0 src/models/Hashlist.class.php
  67. 0 src/models/HashlistAgent.class.php
  68. 0 src/models/HashlistAgentFactory.class.php
  69. 0 src/models/HashlistFactory.class.php
  70. 0 src/models/RegVoucher.class.php
  71. 0 src/models/RegVoucherFactory.class.php
  72. 0 src/models/RightGroup.class.php
  73. 0 src/models/RightGroupFactory.class.php
  74. 0 src/models/Session.class.php
  75. 0 src/models/SessionFactory.class.php
  76. 0 src/models/SuperHashlistHashlist.class.php
  77. 0 src/models/SuperHashlistHashlistFactory.class.php
  78. 0 src/models/Supertask.class.php
  79. 0 src/models/SupertaskFactory.class.php
  80. 0 src/models/SupertaskTask.class.php
  81. 0 src/models/SupertaskTaskFactory.class.php
  82. 0 src/models/Task.class.php
  83. 0 src/models/TaskFactory.class.php
  84. 0 src/models/TaskFile.class.php
  85. 0 src/models/TaskFileFactory.class.php
  86. 0 src/models/User.class.php
  87. 0 src/models/UserFactory.class.php
  88. 0 src/models/generator.php
  89. 0 src/models/model.svg
  90. 0 src/newagent.php
  91. 0 src/newhashcat.php
  92. 0 src/newhashlist.php
  93. 0 src/newsuperhashlist.php
  94. 0 src/newsupertask.php
  95. 0 src/newtask.php
  96. 0 src/newuser.php
  97. 0 src/pretasks.php
  98. +1 −1 src/server.php
  99. BIN src/static/7zr
  100. BIN src/static/7zr.exe
  101. BIN src/static/active.gif
  102. 0 src/static/admin.css
  103. 0 src/static/bootstrap.min.css
  104. 0 src/static/bootstrap.min.js
  105. BIN src/static/check.png
  106. BIN src/static/favicon.ico
  107. BIN src/static/hashcat-3.00.7z
  108. BIN src/static/hashtopus.exe
  109. 0 src/static/jquery.min.js
  110. BIN src/static/lock.gif
  111. BIN src/static/logo.png
  112. 0 src/static/navbar.css
  113. BIN src/static/pause.gif
  114. BIN src/static/stats.gif
  115. BIN src/static/unix.png
  116. BIN src/static/win.png
  117. 0 src/stats.php
  118. 0 src/superhashlists.php
  119. 0 src/supertasks.php
  120. 0 src/taskimg.php
  121. 0 src/tasks.php
  122. 0 src/templates/about.template.html
  123. 0 src/templates/account.template.html
  124. 0 src/templates/{agents.detail.idle.template.html → agents/detail/idle.template.html}
  125. 0 src/templates/{agents.detail.template.html → agents/detail/index.template.html}
  126. 0 src/templates/{agents.detail.name.template.html → agents/detail/name.template.html}
  127. 0 src/templates/{agents.detail.owner.template.html → agents/detail/owner.template.html}
  128. 0 src/templates/{agents.detail.platform.template.html → agents/detail/platform.template.html}
  129. 0 src/templates/{agents.detail.secret1.template.html → agents/detail/secret1.template.html}
  130. 0 src/templates/{agents.detail.secret2.template.html → agents/detail/secret2.template.html}
  131. +16 −16 src/templates/{agents.template.html → agents/index.template.html}
  132. 0 src/templates/{agents.new.template.html → agents/new.template.html}
  133. 0 src/templates/chunks.template.html
  134. 0 src/templates/config.template.html
  135. 0 src/templates/email.creation.template.html
  136. 0 src/templates/email.forgot.template.html
  137. 0 src/templates/error.template.html
  138. 0 src/templates/files.secret1.template.html
  139. 0 src/templates/files.secret2.template.html
  140. 0 src/templates/files.template.html
  141. +1 −1 src/templates/foot.template.html
  142. 0 src/templates/forgot.template.html
  143. 0 src/templates/hashcat.template.html
  144. 0 src/templates/hashes.selection.inner.template.html
  145. 0 src/templates/hashes.selection.template.html
  146. 0 src/templates/hashes.template.html
  147. 0 src/templates/hashlists.detail.notfound.template.html
  148. 0 src/templates/hashlists.detail.pretasks.template.html
  149. 0 src/templates/hashlists.detail.secret1.template.html
  150. 0 src/templates/hashlists.detail.secret2.template.html
  151. 0 src/templates/hashlists.detail.superhashlist.template.html
  152. 0 src/templates/hashlists.detail.tasks.template.html
  153. 0 src/templates/hashlists.detail.template.html
  154. 0 src/templates/hashlists.template.html
  155. 0 src/templates/hashlists.zap.template.html
  156. 0 src/templates/hashtypes.template.html
  157. 0 src/templates/head.template.html
  158. 0 src/templates/help.template.html
  159. 0 src/templates/index.template.html
  160. 0 src/templates/install0.template.html
  161. 0 src/templates/install1.template.html
  162. 0 src/templates/install100.template.html
  163. 0 src/templates/install101.template.html
  164. 0 src/templates/install102.template.html
  165. 0 src/templates/install2.template.html
  166. 0 src/templates/install50.template.html
  167. 0 src/templates/install51.template.html
  168. 0 src/templates/install52.template.html
  169. 0 src/templates/install_foot.template.html
  170. 0 src/templates/install_head.template.html
  171. 0 src/templates/menu.template.html
  172. 0 src/templates/newhashcat.template.html
  173. 0 src/templates/newhashlist.template.html
  174. 0 src/templates/newsuperhashlist.template.html
  175. 0 src/templates/newsupertask.template.html
  176. 0 src/templates/newtask.template.html
  177. 0 src/templates/newuser.template.html
  178. 0 src/templates/pretasks.template.html
  179. 0 src/templates/restricted.template.html
  180. 0 src/templates/superhashlists.template.html
  181. 0 src/templates/supertaskcreate.template.html
  182. 0 src/templates/supertasks.detail.template.html
  183. 0 src/templates/supertasks.template.html
  184. 0 src/templates/tasks.autorefresh.template.html
  185. 0 src/templates/tasks.detail.allassigned.template.html
  186. 0 src/templates/tasks.detail.assign.template.html
  187. 0 src/templates/tasks.detail.assigned.template.html
  188. 0 src/templates/tasks.detail.attached.template.html
  189. 0 src/templates/tasks.detail.dispatched.template.html
  190. 0 src/templates/tasks.detail.part1.list1.template.html
  191. 0 src/templates/tasks.detail.part1.list2.template.html
  192. 0 src/templates/tasks.detail.part1.template.html
  193. 0 src/templates/tasks.detail.static.template.html
  194. 0 src/templates/tasks.detail.template.html
  195. 0 src/templates/tasks.template.html
  196. 0 src/templates/users.detail.rights.template.html
  197. 0 src/templates/users.detail.template.html
  198. 0 src/templates/users.template.html
  199. 0 src/users.php
0 LICENSE.txt 100644 → 100755
No changes.
0 README.md 100644 → 100755
No changes.
0 doc/.gitignore 100644 → 100755
No changes.
BIN -270 Bytes (100%) doc/protocol.pdf 100644 → 100755
Binary file not shown.
0 doc/protocol.tex 100644 → 100755
No changes.
0 src/about.php 100644 → 100755
No changes.
0 src/account.php 100644 → 100755
No changes.
182 src/agents.php 100644 → 100755
@@ -11,186 +11,16 @@
die($TEMPLATE->render($OBJECTS));
}
$TEMPLATE = new Template("agents");
$TEMPLATE = new Template("agents/index");
$MENU->setActive("agents_list");
$message = "";
//catch agents actions here...
if(isset($_POST['action'])){
switch($_POST['action']){
case 'clearerrors':
if($LOGIN->getLevel() < 30){
break;
}
$agent = intval($_POST['agent']);
$qF = new QueryFilter("agentId", $agent, "=");
$FACTORIES::getAgentErrorFactory()->massDeletion(array('filter' => array($qF)));
Util::refresh();
case 'agentrename':
if($LOGIN->getLevel() < 30){
break;
}
$name = htmlentities($_POST['name'], false, "UTF-8");
$agent = $FACTORIES::getAgentFactory()->get($_POST['agent']);
if($agent && strlen($name) > 0){
$agent->setAgentName($name);
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
}
break;
case 'agentowner':
if($LOGIN->getLevel() < 30){
break;
}
// change agent owner
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST['agent']));
if(!$agent){
$message = "<div class='alert alert-danger'>Invalid agent!</div>";
break;
}
else if($_POST['owner'] == 0){
$agent->setUserId(0);
$FACTORIES::getAgentFactory()->update($agent);
header("Location: ".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
die();
}
$owner = $FACTORIES::getUserFactory()->get(intval($_POST["owner"]));
if(!$owner){
$message = "<div class='alert alert-danger'>Invalid user!</div>";
break;
}
$agent->setUserId($owner->getId());
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'agenttrusted':
// switch agent trusted state
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
$trusted = intval($_POST["trusted"]);
if(!$agent){
$message = "<div class='alert alert-danger'>Could not change agent trust!</div>";
break;
}
$agent->setIsTrusted($trusted);
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'agentignore':
// switch error ignoring for agent
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
$ignore = intval($_POST["ignore"]);
if(!$agent){
$message = "<div class='alert alert-danger'>Could not change error ignoring!</div>";
break;
}
$agent->setIgnoreErrors($ignore);
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'setparam':
// change agent extra cmd line parameters for hashcat
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
$pars = htmlentities($_POST["cmdpars"], false, "UTF-8");
if(!$agent){
$message = "<div class='alert alert-danger'>Could not change agent-specific parameters!</div>";
break;
}
$agent->setCmdPars($pars);
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'agentwait':
// change agent waiting time for idle
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
$wait = intval($_POST["wait"]);
if(!$agent){
$message = "<div class='alert alert-danger'>Could not change agent idle wait period!</div>";
break;
}
$agent->setWait($wait);
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'agentactive':
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
if(!$agent){
$message = "<div class='alert alert-danger'>Could not change agent activity!</div>";
break;
}
else if($agent->getIsActive() == 1){
$agent->setIsActive(0);
}
else{
$agent->setIsActive(1);
}
$FACTORIES::getAgentFactory()->update($agent);
Util::refresh();
case 'agentdelete':
if($LOGIN->getLevel() < 30){
break;
}
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST['agent']));
$FACTORIES::getAgentFactory()->getDB()->query("START TRANSACTION");
if (Util::deleteAgent($agent)) {
$FACTORIES::getAgentFactory()->getDB()->query("COMMIT");
}
else {
$FACTORIES::getAgentFactory()->getDB()->query("ROLLBACK");
$message = "<div class='alert alert-danger'>Could not delete agent!</div>";
break;
}
Util::refresh();
case 'agentassign':
$agent = $FACTORIES::getAgentFactory()->get(intval($_POST["agent"]));
if(!$agent){
$message = "<div class='alert alert-danger'>Invalid agent!</div>";
break;
}
else if(intval($_POST['task']) == 0){
//unassign
$qF = new QueryFilter("agentId", $agent->getId(), "=");
$FACTORIES::getAssignmentFactory()->massDeletion(array('filter' => array($qF)));
Util::refresh();
}
$task = $FACTORIES::getTaskFactory()->get(intval($_POST['task']));
if(!$task){
$message = "<div class='alert alert-danger'>Invalid task!</div>";
break;
}
$qF = new QueryFilter("agentId", $agent->getId(), "=");
$assignments = $FACTORIES::getAssignmentFactory()->filter(array('filter' => array($qF)));
//determine benchmark number
$benchmark = 0;
$qF1 = new ComparisonFilter("solveTime", "dispatchTime", ">");
$qF2 = new ComparisonFilter("progress", "length", "=");
$qF3 = new ContainFilter("state", array("4, 5"));
$qF4 = new QueryFilter("agentId", $agent->getId(), "=");
$qF5 = new QueryFilter("taskId", $task->getId(), "=");
$oF = new OrderFilter("solveTime", "DESC");
$entries = $FACTORIES::getChunkFactory()->filter(array('filter' => array($qF1, $qF2, $qF3, $qF4, $qF5), 'order' => array($oF)));
if(sizeof($entries) > 0){
$benchmark = $entries[0]->getLength();
}
unset($entries);
if(sizeof($assignments) > 0){
for($i=1;$i<sizeof($assignments);$i++){ // clean up if required
$FACTORIES::getAssignmentFactory()->delete($assignments[$i]);
}
$assignment = $assignments[0];
$assignment->setTaskId($task->getId());
$assignment->setBenchmark($benchmark);
$assignment->setautoAdjust($task->getAutoAdjust());
$assignment->setSpeed(0);
$FACTORIES::getAssignmentFactory()->update($assignment);
}
else{
$assignment = new Assignment(0, $task->getId(), $agent->getId(), $benchmark, $task->getAutoAdjust(), 0);
$FACTORIES::getAssignmentFactory()->save($assignment);
}
if(isset($_GET['task'])){
header("Location: tasks.php?id=".intval($_GET['task']));
die();
}
Util::refresh();
}
$agentHandler = new AgentHandler($_POST['agentId']);
$agentHandler->handle($_POST['action']);
Util::refresh();
}
$allTasks = $FACTORIES::getTaskFactory()->filter(array());
@@ -250,7 +80,7 @@
$allAgents = array();
foreach($agents as $agent){
$set = new DataSet($agent->getKeyValueDict());
$set->addValue('gpus', explode("\x01", $agent->getGpus()));
$set->addValue('gpus', explode("\n", $agent->getGpus()));
$qF = new QueryFilter("agentId", $agent->getId(), "=");
$assignments = $FACTORIES::getAssignmentFactory()->filter(array('filter' => array($qF)));
0 src/chunks.php 100644 → 100755
No changes.
0 src/config.php 100644 → 100755
No changes.
0 src/files.php 100644 → 100755
No changes.
0 src/fix.php 100644 → 100755
No changes.
0 src/forgot.php 100644 → 100755
No changes.
0 src/get.php 100644 → 100755
No changes.
0 src/hashcat.php 100644 → 100755
No changes.
0 src/hashes.php 100644 → 100755
No changes.
0 src/hashlists.php 100644 → 100755
No changes.
0 src/hashtypes.php 100644 → 100755
No changes.
0 src/inc/.gitignore 100644 → 100755
No changes.
31 src/inc/API.class.php 100644 → 100755
@@ -46,10 +46,10 @@ private static function sendResponse($RESPONSE){
}
public static function registerAgent($QUERY){
global $FACTORIES, $CONFIG, $SEPARATOR;
global $FACTORIES, $CONFIG;
//check required values
if(API::checkValues($QUERY, array('voucher', 'gpus', 'uid', 'name', 'os'))){
if(!API::checkValues($QUERY, array('voucher', 'gpus', 'uid', 'name', 'os'))){
API::sendErrorResponse("register", "Invalid registering query!");
}
@@ -59,23 +59,24 @@ public static function registerAgent($QUERY){
API::sendErrorResponse("register", "Provided voucher does not exist.");
}
$gpu = $_POST["gpus"];
$uid = htmlentities($_POST["uid"], false, "UTF-8");
$name = htmlentities($_POST["name"], false, "UTF-8");
$os = intval($_POST["os"]);
$gpu = $QUERY["gpus"];
$uid = htmlentities($QUERY["uid"], false, "UTF-8");
$name = htmlentities($QUERY["name"], false, "UTF-8");
$os = intval($QUERY["os"]);
//determine if the client has cpu only
$cpuOnly = 1;
foreach(explode($SEPARATOR, strtolower($gpu)) as $card){
foreach($gpu as $card){
$card = strtolower($card);
if((strpos($card, "amd") !== false) || (strpos($card, "ati ") !== false) || (strpos($card, "radeon") !== false) || strpos($card, "nvidia") !== false){
$cpuOnly = 0;
}
}
//create access token & save agent details
$token = Util::randomString(10);
$gpu = htmlentities($gpu, false, "UTF-8");
$agent = new Agent(0, $name, $uid, $os, $gpu, "", "", $CONFIG->getVal('agenttimeout'), "", 1, 0, $token, "", 0, Util::getIP(), 0, $cpuOnly);
$gpu = htmlentities(implode("\n", $gpu), false, "UTF-8");
$agent = new Agent(0, $name, $uid, $os, $gpu, "", "", $CONFIG->getVal('agenttimeout'), "", 1, 0, $token, "register", time(), Util::getIP(), 0, $cpuOnly);
$FACTORIES::getRegVoucherFactory()->delete($voucher);
if($FACTORIES::getAgentFactory()->save($agent)){
API::sendResponse(array("action" => "register", "response" => "SUCCESS", "token" => $token));
@@ -88,7 +89,7 @@ public static function registerAgent($QUERY){
public static function loginAgent($QUERY){
global $FACTORIES, $CONFIG;
if(API::checkValues($QUERY, array('token'))){
if(!API::checkValues($QUERY, array('token'))){
API::sendErrorResponse("login", "Invalid login query!");
}
@@ -107,7 +108,7 @@ public static function checkClientUpdate($QUERY){
global $SCRIPTVERSION, $SCRIPTNAME;
// check if provided hash is the same as script and send file contents if not
if(API::checkValues($QUERY, array('version'))){
if(!API::checkValues($QUERY, array('version'))){
API::sendErrorResponse('update', 'Version value missing!');
}
@@ -124,7 +125,7 @@ public static function checkClientUpdate($QUERY){
public static function downloadApp($QUERY){
global $FACTORIES;
if(API::checkValues($QUERY, array('token', 'type'))){
if(!API::checkValues($QUERY, array('token', 'type'))){
API::sendErrorResponse("download", "Invalid download query!");
}
$qF = new QueryFilter("token", $QUERY['token'], "=");
@@ -175,7 +176,7 @@ public static function agentError($QUERY){
global $FACTORIES;
//check required values
if(API::checkValues($QUERY, array('token', 'task', 'message'))){
if(!API::checkValues($QUERY, array('token', 'task', 'message'))){
API::sendErrorResponse("error", "Invalid error query!");
}
@@ -211,7 +212,7 @@ public static function getFile($QUERY){
global $FACTORIES;
//check required values
if(API::checkValues($QUERY, array('token', 'task', 'filename'))){
if(!API::checkValues($QUERY, array('token', 'task', 'filename'))){
API::sendErrorResponse("file", "Invalid file query!");
}
@@ -255,7 +256,7 @@ public static function getHashes($QUERY){
global $FACTORIES;
//check required values
if(API::checkValues($QUERY, array('token', 'hashlist'))){
if(!API::checkValues($QUERY, array('token', 'hashlist'))){
API::sendErrorResponse("hashes", "Invalid hashes query!");
}
@@ -0,0 +1,19 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: sein
* Date: 10.11.16
* Time: 14:46
*/
class UI
{
public static function printError($level, $message){
$OBJECTS = array();
$TEMPLATE = new Template("error");
$OBJECTS['message'] = $message;
$OBJECTS['level'] = $level;
echo $TEMPLATE->render($OBJECTS);
die();
}
}
0 src/inc/crypt.class.php 100644 → 100755
No changes.
0 src/inc/dataset.class.php 100644 → 100755
No changes.
0 src/inc/factory.class.php 100644 → 100755
No changes.
Oops, something went wrong.

0 comments on commit fff772a

Please sign in to comment.
You can’t perform that action at this time.