Skip to content

Commit

Permalink
Merge pull request #124 from s3inlc/dev/v0.2.0
Browse files Browse the repository at this point in the history
dev/v0.2.0
  • Loading branch information
s3inlc authored Mar 8, 2017
2 parents 2ea372b + 19385f9 commit 64c466d
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 93 deletions.
30 changes: 29 additions & 1 deletion src/inc/Util.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,34 @@ public static function getStaticArray($val, $id) {
return "";
}

/**
* @param $version1
* @param $version2
* @return int 1 if version2 is newer, 0 if equal and -1 if version1 is newer
*/
public static function versionComparison($version1, $version2){
$version1 = explode(".", $version1);
$version2 = explode(".", $version2);

for($i=0;$i<sizeof($version1)&&$i<sizeof($version2);$i++){
$num1 = (int)$version1[$i];
$num2 = (int)$version2[$i];
if($num1 > $num2){
return -1;
}
else if($num1 < $num2){
return 1;
}
}
if(sizeof($version1) > sizeof($version2)){
return -1;
}
else if(sizeof($version1) < sizeof($version2)){
return 1;
}
return 0;
}

/**
* Shows big numbers with the right suffixes (k, M, G)
* @param $num int integer you want formatted
Expand Down Expand Up @@ -710,7 +738,7 @@ public static function uploadFile($target, $type, $sourcedata) {
* @return string basic server url
*/
public static function buildServerUrl() {
$protocol = (isset($_SERVER['HTTPS']) && (strcasecmp('off', $_SERVER['HTTPS']) !== 0)) ? "https://" : "https://";
$protocol = (isset($_SERVER['HTTPS']) && (strcasecmp('off', $_SERVER['HTTPS']) !== 0)) ? "https://" : "http://";
$hostname = $_SERVER['HTTP_HOST'];
$port = $_SERVER['SERVER_PORT'];
if ($protocol == "https://" && $port == 443 || $protocol == "http://" && $port == 80) {
Expand Down
5 changes: 5 additions & 0 deletions src/inc/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DConfig {
const STATUS_TIMER = "statustimer";
const BLACKLIST_CHARS = "blacklistChars";
const NUMBER_LOGENTRIES = "numLogEntries";
const TIME_FORMAT = "timefmt";

/**
* Gives the format which a config input should have. Default is string if it's not a known config.
Expand Down Expand Up @@ -89,6 +90,8 @@ public static function getConfigType($config){
return DConfigType::STRING_INPUT;
case DConfig::NUMBER_LOGENTRIES:
return DConfigType::NUMBER_INPUT;
case DConfig::TIME_FORMAT:
return DConfigType::STRING_INPUT;
}
return DConfigType::STRING_INPUT;
}
Expand Down Expand Up @@ -119,6 +122,8 @@ public static function getConfigDescription($config){
return "Chars which are not allowed to be used in attack command inputs";
case DConfig::NUMBER_LOGENTRIES:
return "How many log entries should be saved. When this number is exceeded by 120%, the oldest ones will get deleted";
case DConfig::TIME_FORMAT:
return "Set the formatting of time displaying. Use syntax for PHPs date() method.";
}
return $config;
}
Expand Down
4 changes: 2 additions & 2 deletions src/inc/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
$FACTORIES = new Factory();
$LANG = new Lang();

$gitcommit = "not versioned";
$gitcommit = "";
$out = array();
exec("cd '".dirname(__FILE__)."/../' && git rev-parse HEAD", $out);
if (isset($out[0])) {
$gitcommit = substr($out[0], 0, 7);
$gitcommit = "commit ".substr($out[0], 0, 7);
}
$out = array();
exec("cd '".dirname(__FILE__)."/../' && git rev-parse --abbrev-ref HEAD", $out);
Expand Down
2 changes: 1 addition & 1 deletion src/install/hashtopussy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ INSERT INTO `RightGroup` (`rightGroupId`, `groupName`, `level`) VALUES
(5, 'Administrator', 50);

INSERT INTO `AgentBinary` (`agentBinaryId`, `type`, `operatingSystems`, `filename`, `version`)
VALUES (1, 'csharp', 'Windows', 'hashtopussy.exe', '0.38');
VALUES (1, 'csharp', 'Windows', 'hashtopussy.exe', '0.40');

CREATE TABLE `Session` (
`sessionId` INT(11) NOT NULL,
Expand Down
68 changes: 0 additions & 68 deletions src/install/migrate.sql

This file was deleted.

8 changes: 6 additions & 2 deletions src/install/updates/update_v0.2.0-beta_v0.2.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
$FACTORIES::getAgentFactory()->getDB()->query("ALTER TABLE `LogEntry` CHANGE `level` `level` VARCHAR(20) NOT NULL");
echo "OK\n";

echo "Change plaintext error on BinaryHash... ";
$FACTORIES::getAgentFactory()->getDB()->query("ALTER TABLE `HashBinary` CHANGE `plaintext` `plaintext` VARCHAR(200) NULL DEFAULT NULL;");
echo "OK\n";

echo "Check csharp binary... ";
$qF = new QueryFilter(AgentBinary::TYPE, "csharp", "=");
$binary = $FACTORIES::getAgentBinaryFactory()->filter(array($FACTORIES::FILTER => $qF), true);
if($binary != null){
if($binary->getVersion() < "0.38"){
if(Util::versionComparison($binary->getVersion(), "0.40") == 1){
echo "update version... ";
$binary->setVersion("0.38");
$binary->setVersion("0.40");
$FACTORIES::getAgentBinaryFactory()->update($binary);
echo "OK";
}
Expand Down
Binary file modified src/static/hashtopussy.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/templates/account.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2>My Account ([[htmlentities([[user.getUsername()]], false, "UTF-8")]])</h2>
<tr>
<th>Register date</th>
<td>
[[date([[config.getVal('timefmt')]], [[user.getRegisteredSince()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getRegisteredSince()]])]]
</td>
</tr>
<tr>
Expand Down
8 changes: 4 additions & 4 deletions src/templates/agents/detail.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2>Agent details</h2>
<td>Last activity:</td>
<td>
Action: [[agent.getLastAct()]]<br>
Time: [[date([[config.getVal('timefmt')]], [[agent.getLastTime()]])]]<br>
Time: [[date([[config.getVal(DConfig::TIME_FORMAT)]], [[agent.getLastTime()]])]]<br>
IP: [[agent.getLastIp()]]
</td>
</tr>
Expand Down Expand Up @@ -194,7 +194,7 @@ <h3>Error messages:</h3>
</tr>
{{FOREACH error;[[errors]]}}
<tr>
<td>[[date([[config.getVal('timefmt')]], [[error.getTime()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[error.getTime()]])]]</td>
<td>
{{IF [[error.getTaskId()]] == null}}
N/A
Expand Down Expand Up @@ -250,7 +250,7 @@ <h3>Dispatched chunks:</h3>
{{IF [[chunk.getDispatchTime()]] == 0}}
(no activity)
{{ELSE}}
[[date([[config.getVal('timefmt')]], [[chunk.getDispatchTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getDispatchTime()]])]]
{{ENDIF}}
</td>
<td>
Expand All @@ -259,7 +259,7 @@ <h3>Dispatched chunks:</h3>
</td>
<td>
{{ELSE}}
[[date([[config.getVal('timefmt')]], [[chunk.getSolveTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getSolveTime()]])]]
</td>
<td class='num'>
[[Util::sectotime(0)]] <!--TODO: get spent time on chunk-->
Expand Down
2 changes: 1 addition & 1 deletion src/templates/agents/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h2>Agents ([[numAgents]])</h2>
<td>[[set.getVal('agent').getHcVersion()]]</td>
<td>
[[set.getVal('agent').getLastAct()]] at <br>
[[date([[config.getVal('timefmt')]], [[set.getVal('agent').getLastTime()]])]]<br>
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[set.getVal('agent').getLastTime()]])]]<br>
IP: <code>[[set.getVal('agent').getLastIp()]]</code>
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/agents/new.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h3>Vouchers</h3>
{{FOREACH voucher;[[vouchers]]}}
<tr>
<td><code>[[voucher.getVoucher()]]</code></td>
<td>[[date([[config.getVal('timefmt')]], [[voucher.getTime()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[voucher.getTime()]])]]</td>
<td>
<form action="agents.php?new=true" method="POST" onSubmit="if (!confirm('Really delete this voucher?')) return false;">
<input type="hidden" name="action" value="voucherdelete">
Expand Down
4 changes: 2 additions & 2 deletions src/templates/chunks.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ <h2>Chunk activity</h2>
{{ENDIF}}
</td>
<td>
[[date([[config.getVal('timefmt')]], [[chunk.getDispatchTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getDispatchTime()]])]]
</td>
<td>
{{IF [[chunk.getSolveTime()]] == 0}}
(no activity)</td><td>
{{ELSE}}
[[date([[config.getVal('timefmt')]], [[chunk.getSolveTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getSolveTime()]])]]
</td>
<td class="num">
[[Util::sectotime([[spent.getVal([[chunk.getId()]])]])]]
Expand Down
2 changes: 1 addition & 1 deletion src/templates/hashcat/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2>Hashcat releases</h2>
<td>[[release.getVersion()]]</td>
<td>
{{IF [[release.getTime()]] > 0}}
[[date([[config.getVal('timefmt')]], [[release.getTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[release.getTime()]])]]
{{ENDIF}}
</td>
<td>[[release.getUrl()]]</td>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/struct/foot.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class='container'>
<hr>
<footer class="footer">
<b>Hashtopussy: commit [[gitcommit]] [[version]] - <a href='about.php'>About</a></b>
<b>Hashtopussy: [[gitcommit]] [[version]] - <a href='about.php'>About</a></b>
<p>&copy;2016-[[date("Y")]] s3in!c - <a href='https://github.com/s3inlc/hashtopussy/' target='_blank'>Hashtopussy</a></p>
</footer>
<script src="static/jquery.min.js"></script>
Expand Down
8 changes: 4 additions & 4 deletions src/templates/tasks/detail.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ <h3>Assigned agents</h3>
</td>
<td>
{{IF [[agent.getLastAct()]] > 0}}
[[date([[config.getVal('timefmt')]], [[agent.getLastAct()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[agent.getLastAct()]])]]
{{ELSE}}
---
{{ENDIF}}
Expand Down Expand Up @@ -405,7 +405,7 @@ <h3>All assigned Agents (over all task time)</h3>
<td class="num">[[agentsCracked.getVal([[agent.getId()]])]]</td>
<td>
{{IF [[agent.getLastTime()]] > 0}}
[[date([[config.getVal('timefmt')]], [[agent.getLastTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[agent.getLastTime()]])]]
{{ENDIF}}
</td>
</tr>
Expand Down Expand Up @@ -461,7 +461,7 @@ <h3>Dispatched chunks {{IF [[chunkFilter]] != 1}}(showing active only -
{{IF [[chunk.getDispatchTime()]] == 0}}
(no activity)
{{ELSE}}
[[date([[config.getVal('timefmt')]], [[chunk.getDispatchTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getDispatchTime()]])]]
{{ENDIF}}
</td>
<td>
Expand All @@ -470,7 +470,7 @@ <h3>Dispatched chunks {{IF [[chunkFilter]] != 1}}(showing active only -
</td>
<td>
{{ELSE}}
[[date([[config.getVal('timefmt')]], [[chunk.getSolveTime()]])]]
[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[chunk.getSolveTime()]])]]
</td>
<td class='num'>
[[Util::sectotime([[chunk.getSolveTime()]] - [[chunk.getDispatchTime()]])]]
Expand Down
4 changes: 2 additions & 2 deletions src/templates/users/detail.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ <h2>User ([[htmlentities([[user.getUsername()]], false, "UTF-8")]])</h2>
</tr>
<tr>
<th>Creation date</th>
<td>[[date([[config.getVal('timefmt')]], [[user.getRegisteredSince()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getRegisteredSince()]])]]</td>
</tr>
<tr>
<th>Last login</th>
<td>[[date([[config.getVal('timefmt')]], [[user.getLastLoginDate()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getLastLoginDate()]])]]</td>
</tr>
<tr>
<th>Enable/Disable user</th>
Expand Down
4 changes: 2 additions & 2 deletions src/templates/users/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ <h2>All users ([[numUsers]])</h2>
<tr>
<td>[[entry.getVal('user').getId()]]</td>
<td>[[htmlentities([[entry.getVal('user').getUsername()]], false, "UTF-8")]]</td>
<td>[[date([[config.getVal('timefmt')]], [[entry.getVal('user').getRegisteredSince()]])]]</td>
<td>[[date([[config.getVal('timefmt')]], [[entry.getVal('user').getLastLoginDate()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[entry.getVal('user').getRegisteredSince()]])]]</td>
<td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[entry.getVal('user').getLastLoginDate()]])]]</td>
<td>[[entry.getVal('user').getEmail()]]</td>
<td>
{{IF [[entry.getVal('user').getIsValid()]] == 1}}
Expand Down

0 comments on commit 64c466d

Please sign in to comment.