1 |
1512
|
darkviper
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2 |
1506
|
DarkViper
|
<?php
|
3 |
|
|
/**
|
4 |
|
|
* @category Core
|
5 |
|
|
* @package Core_security
|
6 |
|
|
* @author Werner v.d.Decken
|
7 |
|
|
* @copyright ISTeasy-project(http://isteasy.de/)
|
8 |
|
|
* @license Creative Commons BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/
|
9 |
|
|
* @version $Id$
|
10 |
|
|
* @filesource $HeadURL:$
|
11 |
|
|
* @since Datei vorhanden seit Release 2.8.2
|
12 |
|
|
* @lastmodified $Date:$
|
13 |
|
|
*
|
14 |
1512
|
darkviper
|
* This generator is based on the class PasswordHash (c)2011 ISTeasy
|
15 |
|
|
* It generates very strong Passwords and calculates several hashes also.
|
16 |
1506
|
DarkViper
|
*
|
17 |
|
|
*/
|
18 |
1512
|
darkviper
|
|
19 |
|
|
$minLoops = 8;
|
20 |
|
|
$maxLoops = 16;
|
21 |
|
|
$path2class = './framework/PasswordHash.php';
|
22 |
|
|
include $path2class;
|
23 |
1506
|
DarkViper
|
$newpass = '';
|
24 |
|
|
$pass = '';
|
25 |
|
|
$hash = '';
|
26 |
1512
|
darkviper
|
// ** sanitize arguments
|
27 |
|
|
// length of password
|
28 |
|
|
if(!isset($_POST['length']) ) { $_POST['length'] = PasswordHash::SECURITY_NORMAL; }
|
29 |
|
|
$length = intval($_POST['length']);
|
30 |
|
|
// crypt type of hash
|
31 |
|
|
if(!isset($_POST['crypt']) ) { $_POST['crypt'] = 2; }
|
32 |
|
|
$crypt = intval($_POST['crypt']);
|
33 |
|
|
if($crypt < 0 || $crypt > 2) { $crypt = 2; }
|
34 |
|
|
// number of encryption loops
|
35 |
|
|
if(!isset($_POST['loops']) ) { $_POST['loops'] = 0; }
|
36 |
|
|
$loops = intval($_POST['loops']);
|
37 |
|
|
if($loops < $minLoops || $loops > $maxLoops) { $loops = $minLoops + floor(($maxLoops - $minLoops) / 2); }
|
38 |
|
|
// requested action
|
39 |
1506
|
DarkViper
|
if(!isset($_POST['action']) ) { $_POST['action'] = 'pass'; }
|
40 |
1512
|
darkviper
|
// select actions
|
41 |
1506
|
DarkViper
|
if($_POST['action'] == 'hash') {
|
42 |
|
|
if(isset($_POST['pass']) && trim($_POST['pass']) != '') {
|
43 |
|
|
$pass = trim($_POST['pass']);
|
44 |
|
|
$newpass = $pass;
|
45 |
1512
|
darkviper
|
$ph = new PasswordHash($loops, ($crypt == 1));
|
46 |
|
|
$hash = $ph->HashPassword($pass, ($crypt == 0) );
|
47 |
1506
|
DarkViper
|
}
|
48 |
|
|
}else {
|
49 |
|
|
$newpass = PasswordHash::NewPassword($length);
|
50 |
|
|
$pass = $newpass;
|
51 |
|
|
}
|
52 |
1512
|
darkviper
|
// preselect length of password
|
53 |
|
|
$checkQuality0 = $length == PasswordHash::SECURITY_WEAK ? ' checked="checked"' : '';
|
54 |
|
|
$checkQuality1 = $length == PasswordHash::SECURITY_MEDIUM ? ' checked="checked"' : '';
|
55 |
|
|
$checkQuality2 = $length == PasswordHash::SECURITY_NORMAL ? ' checked="checked"' : '';
|
56 |
|
|
$checkQuality3 = $length == PasswordHash::SECURITY_STRONG ? ' checked="checked"' : '';
|
57 |
|
|
$checkQuality4 = $length == PasswordHash::SECURITY_STRONGER ? ' checked="checked"' : '';
|
58 |
|
|
if($checkQuality0.$checkQuality1.$checkQuality2.$checkQuality3.$checkQuality4 == '') {
|
59 |
|
|
$checkQuality2 = ' checked="checked"';
|
60 |
|
|
}
|
61 |
|
|
// preselect hash type
|
62 |
|
|
$checkCrypt0 = $crypt == 0 ? ' checked="checked"' : '';
|
63 |
|
|
$checkCrypt1 = $crypt == 1 ? ' checked="checked"' : '';
|
64 |
|
|
$checkCrypt2 = $crypt == 2 ? ' checked="checked"' : '';
|
65 |
|
|
$bcryptActive = ( (method_exists('PasswordHash', '_GenSaltSha512') && CRYPT_SHA512 == 1) ||
|
66 |
|
|
(method_exists('PasswordHash', '_GenSaltBlowfish') && CRYPT_BLOWFISH == 1) ||
|
67 |
|
|
(method_exists('PasswordHash', '_GenSaltExtended') && CRYPT_EXT_DES == 1) );
|
68 |
|
|
$bcryptActive = $bcryptActive ? '' : ' style="display: none;"';
|
69 |
|
|
// create encryption loops option-list
|
70 |
|
|
$loopsOptions = '';
|
71 |
|
|
for($x = $minLoops; $x <= $maxLoops; $x++) {
|
72 |
|
|
$curr = ($x == $loops ? ' selected="selected"' : '');
|
73 |
|
|
$loopsOptions .= '<option value="'.$x.'"'.$curr.'>2^'.$x.' ('.number_format(pow(2, $x), 0, ',', '.').') </option>'."\n";
|
74 |
|
|
}
|
75 |
1506
|
DarkViper
|
|
76 |
1512
|
darkviper
|
// autodetect language
|
77 |
|
|
$lang = 'en';
|
78 |
|
|
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE'])>2) {
|
79 |
|
|
$lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
|
80 |
|
|
}
|
81 |
|
|
// define language translation tables
|
82 |
|
|
$TXT = array(
|
83 |
|
|
'en' => array(
|
84 |
|
|
'pw_title' => 'Password-Generator',
|
85 |
|
|
'pw_quality' => 'Quality of password',
|
86 |
|
|
'pw_quality_0' => 'bad',
|
87 |
|
|
'pw_quality_1' => 'weak',
|
88 |
|
|
'pw_quality_2' => 'good',
|
89 |
|
|
'pw_quality_3' => 'strong',
|
90 |
|
|
'pw_quality_4' => 'excellent',
|
91 |
|
|
'pw_suggestion' => 'Our password suggestion',
|
92 |
|
|
'pw_action' => 'suggest password',
|
93 |
|
|
'hg_title' => 'Hash-Generator',
|
94 |
|
|
'hg_text' => 'Enter Text to hash',
|
95 |
|
|
'hg_type' => 'Kind of crypt',
|
96 |
|
|
'hg_type_0' => 'simple MD5 (very insecure)',
|
97 |
|
|
'hg_type_1' => 'MD5 + salt + rounds (relatively safe)',
|
98 |
|
|
'hg_type_2' => 'Ext-DES/Blowfish/SHA512 + rounds (high security)',
|
99 |
|
|
'hg_loops' => 'Number of rounds',
|
100 |
|
|
'hg_copy' => 'Hash to copy',
|
101 |
|
|
'hg_action' => 'calculate'
|
102 |
|
|
),
|
103 |
|
|
'de' => array(
|
104 |
|
|
'pw_title' => 'Passwort-Generator',
|
105 |
|
|
'pw_quality' => 'Qualität des Passwortes',
|
106 |
|
|
'pw_quality_0' => 'schlecht',
|
107 |
|
|
'pw_quality_1' => 'schwach',
|
108 |
|
|
'pw_quality_2' => 'gut',
|
109 |
|
|
'pw_quality_3' => 'stark',
|
110 |
|
|
'pw_quality_4' => 'exzellent',
|
111 |
|
|
'pw_suggestion' => 'Unser Passwortvorschlag',
|
112 |
|
|
'pw_action' => 'Passwort vorschlagen',
|
113 |
|
|
'hg_title' => 'Hash-Generator',
|
114 |
|
|
'hg_text' => 'zu hashenden Text eingeben',
|
115 |
|
|
'hg_type' => 'Verschlüsselungsart',
|
116 |
|
|
'hg_type_0' => 'einfaches MD5 (sehr unsicher)',
|
117 |
|
|
'hg_type_1' => 'MD5 + Salz + mehrere Runden (relativ sicher)',
|
118 |
|
|
'hg_type_2' => 'Ext-DES/Blowfish/SHA512 + mehrere Runden (sehr sicher)',
|
119 |
|
|
'hg_loops' => 'Anzahl der Runden',
|
120 |
|
|
'hg_copy' => 'erzeugten Hash kopieren',
|
121 |
|
|
'hg_action' => 'berechnen'
|
122 |
|
|
)
|
123 |
|
|
);
|
124 |
|
|
// start screen output
|
125 |
|
|
?>
|
126 |
1506
|
DarkViper
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
|
127 |
|
|
<head>
|
128 |
|
|
<title>PWH-Generator v.0.1</title>
|
129 |
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
130 |
|
|
<meta name="author" content="Werner von der Decken" />
|
131 |
|
|
<meta name="copyright" content="ISTeasy, W.v.d.Decken" />
|
132 |
|
|
<meta name="generator" content="ISTeasy - PWH-Generator v.0.1" />
|
133 |
|
|
<style type="text/css">
|
134 |
|
|
html { /* Schrifteinstellung für das ganze Dokument */
|
135 |
|
|
font-family: "Trebuchet MS",Verdana, Arial, Helvetica, sans-serif;
|
136 |
|
|
font-size: 78%;
|
137 |
|
|
font-weight: normal;
|
138 |
|
|
color: #303030;
|
139 |
|
|
min-height: 100.2%;
|
140 |
|
|
}
|
141 |
|
|
body {
|
142 |
|
|
text-align: center;
|
143 |
1512
|
darkviper
|
padding-top: 2em;
|
144 |
1506
|
DarkViper
|
}
|
145 |
|
|
.body {
|
146 |
|
|
width: 40em;
|
147 |
|
|
margin: auto;
|
148 |
|
|
}
|
149 |
|
|
fieldset {
|
150 |
1512
|
darkviper
|
padding: 1em;
|
151 |
|
|
text-align: left;
|
152 |
1506
|
DarkViper
|
}
|
153 |
|
|
legend {
|
154 |
|
|
font-size: 1.3em;
|
155 |
|
|
}
|
156 |
|
|
input {
|
157 |
|
|
margin: 0.5em 0;
|
158 |
|
|
padding: 3px;
|
159 |
|
|
font-size: 1.2em;
|
160 |
1512
|
darkviper
|
width: 97%;
|
161 |
|
|
background-color: transparent;
|
162 |
1506
|
DarkViper
|
}
|
163 |
1512
|
darkviper
|
input[type = "radio"] {
|
164 |
|
|
display: inline;
|
165 |
|
|
}
|
166 |
1506
|
DarkViper
|
#hash { font-size: 1em; }
|
167 |
|
|
</style>
|
168 |
|
|
</head>
|
169 |
|
|
<body>
|
170 |
|
|
<div class="body">
|
171 |
|
|
<h1>PWH-Generator v.0.1</h1>
|
172 |
|
|
<fieldset>
|
173 |
1512
|
darkviper
|
<legend> <?php echo $TXT[$lang]['pw_title']; ?> </legend>
|
174 |
1506
|
DarkViper
|
<form method="post" name="genpass" action="">
|
175 |
|
|
<input type="hidden" name="action" value="pass" />
|
176 |
1512
|
darkviper
|
<input type="hidden" name="crypt" value="<?php echo $crypt; ?>" />
|
177 |
|
|
<input type="hidden" name="loops" value="<?php echo $loops; ?>" />
|
178 |
|
|
<label for="length"><strong><?php echo $TXT[$lang]['pw_quality']; ?></strong></label><br />
|
179 |
|
|
<input type="radio" id="length0" name="length" value="<?php echo PasswordHash::SECURITY_WEAK.'"'.$checkQuality0; ?>>
|
180 |
|
|
<label for="length0"><?php echo $TXT[$lang]['pw_quality_0']; ?></label></input>
|
181 |
|
|
<input type="radio" id="length1" name="length" value="<?php echo PasswordHash::SECURITY_MEDIUM.'"'.$checkQuality1; ?>>
|
182 |
|
|
<label for="length1"><?php echo $TXT[$lang]['pw_quality_1']; ?></label></input>
|
183 |
|
|
<input type="radio" id="length2" name="length" value="<?php echo PasswordHash::SECURITY_NORMAL.'"'.$checkQuality2; ?>>
|
184 |
|
|
<label for="length2"><?php echo $TXT[$lang]['pw_quality_2']; ?></label></input>
|
185 |
|
|
<input type="radio" id="length3" name="length" value="<?php echo PasswordHash::SECURITY_STRONG.'"'.$checkQuality3; ?>>
|
186 |
|
|
<label for="length3"><?php echo $TXT[$lang]['pw_quality_3']; ?></label></input>
|
187 |
|
|
<input type="radio" id="length4" name="length" value="<?php echo PasswordHash::SECURITY_STRONGER.'"'.$checkQuality4; ?>>
|
188 |
|
|
<label for="length4"><?php echo $TXT[$lang]['pw_quality_4']; ?></label></input> <br /><br />
|
189 |
|
|
<label for="pass"><strong><?php echo $TXT[$lang]['pw_suggestion']; ?></strong></label><br />
|
190 |
1506
|
DarkViper
|
<input type="text" id="pass" name="pass" value="<?php echo $newpass; ?>" readonly="readonly" /><br /><br />
|
191 |
1512
|
darkviper
|
<input name="submit" id="submit1" type="submit" value="<?php echo $TXT[$lang]['pw_action']; ?>" />
|
192 |
1506
|
DarkViper
|
</form>
|
193 |
|
|
</fieldset><br /><br />
|
194 |
1512
|
darkviper
|
<fieldset id="setHash" style="position: relative; background: url('warten.gif') -1000px no-repeat;">
|
195 |
|
|
<legend> <?php echo $TXT[$lang]['hg_title']; ?> </legend>
|
196 |
1506
|
DarkViper
|
<form method="post" name="genhash" action="">
|
197 |
|
|
<input type="hidden" name="action" value="hash" />
|
198 |
1512
|
darkviper
|
<input type="hidden" name="length" value="<?php echo $length; ?>" />
|
199 |
|
|
<label for="pass"><strong><?php echo $TXT[$lang]['hg_text']; ?></strong></label><br />
|
200 |
|
|
<input type="text" id="hgpass" name="pass" value="<?php echo $pass; ?>" /><br />
|
201 |
|
|
<strong><?php echo $TXT[$lang]['hg_type']; ?></strong><br />
|
202 |
|
|
<input type="radio" id="crypt0" name="crypt" value="0"<?php echo $checkCrypt0; ?>>
|
203 |
|
|
<label for="crypt0"><?php echo $TXT[$lang]['hg_type_0']; ?></label></input><br />
|
204 |
|
|
<input type="radio" id="crypt1" name="crypt" value="1"<?php echo $checkCrypt1; ?>>
|
205 |
|
|
<label for="crypt1"><?php echo $TXT[$lang]['hg_type_1']; ?></label></input><br />
|
206 |
|
|
<span<?php echo $bcryptActive; ?>>
|
207 |
|
|
<input type="radio" id="crypt2" name="crypt" value="2"<?php echo $checkCrypt2; ?>>
|
208 |
|
|
<label for="crypt2"><?php echo $TXT[$lang]['hg_type_2']; ?></label></input>
|
209 |
|
|
</span>
|
210 |
|
|
<br />
|
211 |
|
|
<div id="loopsbox">
|
212 |
|
|
<select name="loops">
|
213 |
|
|
<?php echo $loopsOptions; ?>
|
214 |
|
|
</select> <?php echo $TXT[$lang]['hg_loops']?><br /><br />
|
215 |
|
|
</div>
|
216 |
|
|
<br />
|
217 |
|
|
<label for="hash"><strong><?php echo $TXT[$lang]['hg_copy']; ?></strong></label>
|
218 |
|
|
<div>
|
219 |
|
|
<input type="text" id="hash" name="hash" value="<?php echo $hash; ?>" readonly="readonly" />
|
220 |
|
|
</div>
|
221 |
|
|
<br />
|
222 |
|
|
<input name="submit" id="submit0" type="submit" value="<?php echo $TXT[$lang]['hg_action']; ?>" />
|
223 |
1506
|
DarkViper
|
</form>
|
224 |
|
|
</fieldset>
|
225 |
1512
|
darkviper
|
<span style="font-size: 0.7em">
|
226 |
|
|
©2011 <a href="http://isteasy.de/" title="ISTeasy-project"><span style="font-style: italic; fontweight: bold;">
|
227 |
|
|
<span style="color: #aa0000;">IST</span>easy</span>-project</a>
|
228 |
|
|
<a href="http://creativecommons.org/licenses/by-sa/3.0/" title="Creative Commons BY-SA 3.0">
|
229 |
|
|
Creative Commons BY-SA 3.0</a>
|
230 |
|
|
</span>
|
231 |
1506
|
DarkViper
|
</div>
|
232 |
1512
|
darkviper
|
|
233 |
|
|
<script type="text/javascript">
|
234 |
|
|
/* <![CDATA[ */
|
235 |
|
|
function showWait() {
|
236 |
|
|
document.getElementById('setHash').style.backgroundPosition = 'center';
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
function clearHash() {
|
240 |
|
|
document.getElementById('hash').value = "";
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
function showLoops() {
|
244 |
|
|
if (document.getElementById("crypt0").checked == true) {
|
245 |
|
|
document.getElementById("loopsbox").style.display = 'none';
|
246 |
|
|
}else {
|
247 |
|
|
document.getElementById("loopsbox").style.display = 'block';
|
248 |
|
|
}
|
249 |
|
|
}
|
250 |
|
|
showLoops();
|
251 |
|
|
document.getElementById('crypt0').addEventListener("click", showLoops, false);
|
252 |
|
|
document.getElementById('crypt1').addEventListener("click", showLoops, false);
|
253 |
|
|
document.getElementById('crypt2').addEventListener("click", showLoops, false);
|
254 |
|
|
document.getElementById('hgpass').addEventListener("keypress", clearHash, false);
|
255 |
|
|
document.getElementById('submit0').addEventListener("click", showWait, false);
|
256 |
|
|
/* ]]> */
|
257 |
|
|
</script>
|
258 |
|
|
|
259 |
1506
|
DarkViper
|
</body>
|
260 |
|
|
</html>
|