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

New Task: Added Hashcat Command Validation #672

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ src/files/*
*.phpproj
*.sln
*.phpproj.user
.DS_Store
5 changes: 5 additions & 0 deletions src/inc/Util.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,11 @@ public static function sectotime($seconds) {
$days = floor($seconds / 86400);
$return = $days . "d ";
$seconds = $seconds % 86400;
if($days > 365.25) { // taken leap year into consideration
$years = floor($days / 365.25);
$days = $days % 365.25;
$return = number_format($years) . "y " . $days . "d ";
Copy link
Contributor

@0xVavaldi 0xVavaldi Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not yield the same results?

if ($seconds >= 86400*365.25) {
    return .= gmdate("Y", $seconds)."y ";
}
if ($seconds >= 86400) {
    return .= gmdate("d", $seconds)."d ";
}
return $return.gmdate("H:i:s", $seconds);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are typos. In both lines within the if clause, the return should be $return instead. No offence, but your suggested code works exactly the same as my code, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot less math is involved and it's in line with other code, using the same functions

}
}
$return .= gmdate("H:i:s", $seconds);
return $return;
Expand Down
12 changes: 6 additions & 6 deletions src/templates/tasks/detail.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ <h2>Task details{{IF [[task.getUsePreprocessor()]]}} (Preprocessor task){{ENDIF}
<td>Keyspace size:</td>
<td>
{{IF [[task.getKeyspace()]] > 0}}
[[task.getKeyspace()]]
[[number_format([[task.getKeyspace()]])]]
{{ELSE}}
N/A
{{ENDIF}}
Expand All @@ -238,7 +238,7 @@ <h2>Task details{{IF [[task.getUsePreprocessor()]]}} (Preprocessor task){{ENDIF}
<tr>
<td>Keyspace dispatched:</td>
<td>
[[task.getKeyspaceProgress()]]{{IF [[task.getKeyspace()]] > 0}} ([[Util::showperc([[task.getKeyspaceProgress()]], [[task.getKeyspace()]])]]%){{ENDIF}}
[[number_format([[task.getKeyspaceProgress()]])]]{{IF [[task.getKeyspace()]] > 0}} ([[Util::showperc([[task.getKeyspaceProgress()]], [[task.getKeyspace()]], 3)]]%){{ENDIF}}
{{IF [[isActive]] == 0 && [[accessControl.hasPermission([[$DAccessControl::MANAGE_TASK_ACCESS]])]]}}
<form class='form-inline' action="tasks.php?id=[[task.getId()]]" method="POST" onSubmit="if (!confirm('Really completely purge task [[task.getId()]]?')) return false;">
<input type="hidden" name="action" value="[[$DTaskAction::PURGE_TASK]]">
Expand All @@ -253,7 +253,7 @@ <h2>Task details{{IF [[task.getUsePreprocessor()]]}} (Preprocessor task){{ENDIF}
<td>Keyspace searched:</td>
<td>
{{IF [[task.getKeyspace()]] > 0 || ([[task.getUsePreprocessor()]] && [[cProgress]] > 0)}}
[[cProgress]]{{IF [[task.getKeyspace()]] > 0}} ([[Util::showperc([[cProgress]], [[task.getKeyspace()]])]]%){{ENDIF}}
[[number_format([[cProgress]])]]{{IF [[task.getKeyspace()]] > 0}} ([[Util::showperc([[cProgress]], [[task.getKeyspace()]], 3)]]%){{ENDIF}}
{{ELSE}}
N/A
{{ENDIF}}
Expand Down Expand Up @@ -282,9 +282,9 @@ <h2>Task details{{IF [[task.getUsePreprocessor()]]}} (Preprocessor task){{ENDIF}
<tr>
<td>
{{IF [[hashlist.getFormat()]] == 3}}
Superhashlist
Superhashlist:
{{ELSE}}
Hashlist
Hashlist:
{{ENDIF}}
</td>
<td>
Expand All @@ -304,7 +304,7 @@ <h2>Task details{{IF [[task.getUsePreprocessor()]]}} (Preprocessor task){{ENDIF}
{{IF [[accessControl.hasPermission([[$DAccessControl::CRACKER_BINARY_ACCESS]])]]}}
<tr>
<td>
Cracker binary
Cracker binary:
</td>
<td>
<a href ="crackers.php?id=[[TaskUtils::getCrackerInfo([[task]],'id')]]">[[TaskUtils::getCrackerInfo([[task]])]]</a>
Expand Down
42 changes: 38 additions & 4 deletions src/templates/tasks/new.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{%TEMPLATE->struct/menu%}
<h2>New task</h2>
{%TEMPLATE->struct/messages%}
<form class='form-inline' action="tasks.php{{IF [[orig]] > 0 && [[origType]] == 2}}?new=true&copyPre=[[orig]]{{ENDIF}}" method="POST" enctype="multipart/form-data">
<form class='form-inline' action="tasks.php{{IF [[orig]] > 0 && [[origType]] == 2}}?new=true&copyPre=[[orig]]{{ENDIF}}" method="POST" enctype="multipart/form-data" id="frm_task">
<div class="row" style="width: 110%">
<div class='col-md-8'>
<input type='hidden' name='action' value='[[$DTaskAction::CREATE_TASK]]'>
Expand All @@ -19,7 +19,7 @@ <h2>New task</h2>
<tr>
<td>Name:</td>
<td>
<input type="text" class='form-control full-width' name="name" value="[[copy.getTaskName()]]">
<input type="text" class='form-control full-width' name="name" value="[[copy.getTaskName()]]" required>
</td>
</tr>
<tr>
Expand All @@ -36,8 +36,9 @@ <h2>New task</h2>
<td>Command line:</td>
<td>
<textarea name="cmdline" class='form-control my-1 full-width' id="cmdLine" title="Cmd Line" {{IF ![[accessControl.hasPermission([[$DAccessControl::CREATE_TASK_ACCESS]])]]}} readonly{{ENDIF}}>[[copy.getAttackCmd()]]</textarea>
Use <b>[[config.getVal('hashlistAlias')]]</b> for hash list and assume all files in current directory.<br>
If you have Linux agents, please mind the filename case sensitivity!
<div class="invalid-feedback" id="cmdLineError">Invalid command</div>
<p>Use <b>[[config.getVal('hashlistAlias')]]</b> for hash list and assume all files in current directory.<br>
If you have Linux agents, please mind the filename case sensitivity!</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -382,4 +383,37 @@ <h2>New task</h2>
</div>
</div>
</form>
<script src="https://cdn.jsdelivr.net/gh/shivanraptor/[email protected]/lib/optparse.js"></script>
<script src="https://cdn.jsdelivr.net/gh/shivanraptor/[email protected]/lib/optparse.hashtopolis.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external library might need to be made internal?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the author said so too. I'm going to update the pull request.

Copy link
Author

@shivanraptor shivanraptor Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the changes at commit 5e4b955

<script>
$('#cmdLine').on('change', function(event) {
$('#cmdLine').removeClass('is-invalid is-valid');
$('#cmdLineError').html('');
});
$('#frm_task').submit(function(event) {
event.preventDefault();
// resetting options
$('#cmdLine').removeClass('is-invalid is-valid');
$('#cmdLineError').html('');

var cmd = $('#cmdLine').val();
if(cmd.length > 200) { // Check Command Length (DB is VARCHAR(256))
$('#cmdLine').addClass('is-invalid');
$('#cmdLineError').html('The command is too long');
return false;
} else {
var response = startParse($('#cmdLine').val(), true);
if(response.result === false) {
$('#cmdLine').addClass('is-invalid');
$('#cmdLineError').html(response.reason);
return false;
} else {
$('#cmdLine').addClass('is-valid');
$('#cmdLineError').html('');
$('#frm_task').unbind('submit').submit();
return true;
}
}
});
</script>
{%TEMPLATE->struct/foot%}