-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.php
154 lines (109 loc) · 4.95 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
require_once 'style.php';
require_once 'regmap.php';
require_once 'inc.php';
?>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<?php
$message = '';
$dest_path='';
if (isset($_POST['uploadBtn'])) {
if (isset($_FILES['uploadedFile']) && $_FILES['uploadedFile']['error'] === UPLOAD_ERR_OK) {
// get details of the uploaded file
$fileTmpPath = $_FILES['uploadedFile']['tmp_name'];
$fileName = $_FILES['uploadedFile']['name'];
$fileSize = $_FILES['uploadedFile']['size'];
$fileType = $_FILES['uploadedFile']['type'];
$fileNameCmps = explode(".", $fileName);
$fileExtension = strtolower(end($fileNameCmps));
$newFileName=hash_file('sha256', $fileTmpPath);
$jid=$newFileName;
// directory in which the uploaded file will be moved
$dest_path = $uploadFileDir . $newFileName;
$line="UNKNOWN-UPLOAD-FAILED";
if(move_uploaded_file($fileTmpPath, $dest_path)) {
$message ='File is successfully uploaded.';
print "$message\n<br><br>";
}
}
}
if (isset($_GET['jid'])) {
$jid=$_GET['jid'];
if (!preg_match('/^[a-f0-9]+$/', $jid)) {
echo "bad job ID";
die;
} else {
$dest_path = $uploadFileDir . $jid;
}
}
// add job to list of jobs...
if ($jid !== '') {
$cookie_name = 'hashcrack_jobs';
if(!isset($_COOKIE[$cookie_name])) {
$cookie_value = $jid;
} else {
$ocv=$_COOKIE[$cookie_name];
$cookie_value=$ocv;
if (strpos($jid,$ocv) === false) {
$cookie_value=$ocv.",".$jid;
}
}
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day
}
$line=fgets(fopen($dest_path,'r'));
$type=regmap($line);
echo "First line of file is <font face=courier><div style=\"white-space: pre-wrap; font-family:\"Courier New\", Courier; line-height:1\">".htmlspecialchars($line)."</div></font>";
if (strstr(htmlspecialchars($line), ':::')){
echo "<b>If this is a shadow file, you need just the first two fields; do a cut -f 1,2 -d':'. Hashcat will parse pwdump data but NOT full shadow files.</b><p>";
}
echo "This looks like hash type ".$type;
echo"<br>";
$exec="cd ".$hashcrackDir." && python3 hashcrack.py -Z -i $dest_path | grep RUN: | sed 's/RUN://' ";
if (empty($_GET['jid'])) {
echo "<br>We'll do this:<br><font face=courier><div style=\"white-space: pre-wrap; font-family:\"Courier New\", Courier; line-height:1\">";
$hccmd=rtrim(shell_exec($exec));
echo "$hccmd </div></font>";
file_put_contents($dest_path.".status","waiting to run....\n");
foreach(preg_split("/\n/", $hccmd) as $line){
$dothis .= $line." --outfile ".$dest_path.".out --status-timer=1 --status >> $dest_path.status 2>&1\n";
}
$runme="#!/bin/bash\ncd ".$hashcatRun."\n".$dothis;
$runfile=$hashcatWebDir.$jid.".run";
file_put_contents($runfile, $runme);
$res=`chmod u+x $runfile`;
} else {
if (!preg_match('/^[a-f0-9]+$/', $jid)) {
echo "bad job ID"; die;
} else {
echo "<br>We're doing this:<br><font face=courier><div style=\"white-space: pre-wrap; font-family:\"Courier New\", Courier; line-height:1\">";
$runfile=$hashcatWebDir.$jid.".run";
echo file_get_contents($runfile);
echo "</div></font>";
}
}
//print "$runme";
print "</pre>";
if (empty($_GET['jid'])) {
print "<p>Queuing job now...<br>";
$atq = `tsp $runfile`;
print "<p><h1>You are number ".`tsp -l | grep queued | wc -l`." in the queue</h1>";
} else {
if (!preg_match('/^[a-f0-9]+$/', $jid)) {
echo "bad job ID"; die;
} else {
print "<p>Not queuing because of GET request - use status > restart if needed. <br>";
}
}
echo "<p><b>Please bookmark this link <br> <a href=\"upload.php?jid=$jid\">upload.php?jid=$jid</a></b> if you want to check on the job later on.<p>";
echo "<br> <a href=\"upload.php?jid=$jid\">refresh this page</a> without queuing the job again | <a href=\"job.php?jid=$jid\">Status</a> in single window (also, terminate, restart) | <a href=\"final.php?jid=$jid\">Show cracked</a> in single window | <a href=\"graph-it.php?jid=$jid\">Graph frequency</a> | <a href=\"graph.php?jid=$jid\">Graph quality</a> | <a href=\"joblist.php\">View submitted jobs</a> (from cookie)";
echo "<hr><h2>CRACKED<h2><iframe frameBorder=0 src=\"final.php?jid=$jid\" width=100% height=200></iframe>";
echo "<hr><h2>STATUS<h2><iframe frameBorder=0 src=\"job.php?jid=$jid\" width=100% height=500></iframe>";
// echo $message;
// log in DB
// redir to monitor page
?>
</div></div>
</body>
</html>