Exemplo n.º 1
0
function htaccessUsers()
{
    $options = array('options' => array('default' => 1, 'min_range' => 1, 'max_range' => 100));
    $USER_NUMBER = filter_input(INPUT_POST, 'nb', FILTER_VALIDATE_INT, $options);
    $PATH = filter_input(INPUT_POST, 'path', FILTER_SANITIZE_URL);
    $TEXT = filter_input(INPUT_POST, 'mdp', FILTER_SANITIZE_STRING);
    $_SESSION['nb'] = $USER_NUMBER;
    $_SESSION['sentence'] = $TEXT;
    $_SESSION['path'] = $PATH;
    ?>

	<h1>.htaccess and .htpasswd generator</h1>
	<h2>State 2/3</h2>
	
	<form method="post" action="?etape=2">
	<?php 
    $length = $USER_NUMBER + 1;
    for ($i = 1; $i < $length; $i++) {
        ?>
		User <?php 
        echo $i;
        ?>
<br/>
		<table>
			<tr>
				<td>Nickname</td>
				<td><input type="text" name="pseudo<?php 
        echo $i;
        ?>
"><br/></td>
			</tr>
				<td>Password</td>
				<TD><input type="text" name="mdp<?php 
        echo $i;
        ?>
" value="<?php 
        echo passGen(10);
        ?>
"><br/></td>
			</tr>
		</table>
		<hr/>
	<?php 
    }
    ?>

	<input type="submit" value="Continuer" style="background-color:#e0e0e0;color:black;"/></form>


	<?php 
}
Exemplo n.º 2
0
    $zip = new ZipArchive();
    $filename = "{$zippath}/p12_" . time() . ".zip";
    if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
        die("cant open <{$filename}>\n");
    }
    $zip->addFromString("certinfo.txt", "{$cert_info}\n");
    $zip->addFromString("password.txt", "{$pass}\n");
    $zip->addFromString("cert.pem", "{$cert}\n");
    $zip->addFromString("key.pem", "{$key}\n");
    $zip->addFromString("cert.p12", "{$p12k}\n");
    $zip->close();
    $simple = "cert_p12_" . time() . ".zip";
    header('Content-Disposition: attachment; filename=' . $simple);
    readfile($filename);
    die(0);
}
function passGen()
{
    $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
    $minchars = 15;
    $maxchars = 20;
    $escapecharplus = 0;
    $repeat = mt_rand($minchars, $maxchars);
    while ($escapecharplus < $repeat) {
        $randomword .= $chars[mt_rand(1, strlen($chars) - 1)];
        $escapecharplus += 1;
    }
    return $randomword;
}
$pass = passGen();
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n<title>sslmanager: make p12</title>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"view.css\" media=\"all\">\r\n<script type=\"text/javascript\" src=\"view.js\"></script>\r\n\r\n</head>\r\n<body id=\"main_body\" >\r\n\t\r\n\t<img id=\"top\" src=\"top.png\" alt=\"\">\r\n\t<div id=\"form_container\">\r\n\t\r\n\t\t<h1><a>create p12</a></h1>\r\n\t\t<form id=\"form_574014\" class=\"appnitro\"  method=\"post\" action=\"\">\r\n\t\t\t\t\t<div class=\"form_description\">\r\n\t\t\t<h2>create p12</h2>\r\n\t\t\t<p>please paste certificate and private key</p>\r\n\t\t</div>\t\t\t\t\t\t\r\n\t\t\t<ul >\r\n\t\t\t\r\n\t\t\t\t\t<li id=\"li_1\" >\r\n\t\t<label class=\"description\" for=\"element_1\">CERTIFICATE</label>\r\n\t\t<div>\r\n\t\t\t<textarea id=\"element_1\" name=\"element_1\" class=\"element textarea large\"></textarea> \r\n\t\t</div><p class=\"guidelines\" id=\"guide_1\"><small>certificate begin from line -----BEGIN CERTIFICATE----- till line -----END CERTIFICATE-----\r\n you should paste block with both these lines</small></p> \r\n\t\t</li>\t\t<li id=\"li_2\" >\r\n\t\t<label class=\"description\" for=\"element_2\">RSA PRIVATE KEY </label>\r\n\t\t<div>\r\n\t\t\t<textarea id=\"element_2\" name=\"element_2\" class=\"element textarea large\"></textarea> \r\n\t\t</div><p class=\"guidelines\" id=\"guide_2\"><small>private key begin from line -----BEGIN RSA PRIVATE KEY----- till line -----END RSA PRIVATE KEY-----\r\nyou should paste block with both these lines</small></p> \r\n\t\t</li>\r\n\t\t\t<li id=\"li_3\" >\r\n\t\t<label class=\"description\" for=\"element_3\">password</label>\r\n\t\t<div>\r\n\t\t\t<input id=\"element_3\" name=\"element_3\" class=\"element text large\" type=\"text\" maxlength=\"255\" value=\"{$pass}\"/> \r\n\t\t</div><p class=\"guidelines\" id=\"guide_3\"><small>this is autogenerated password, i will save it in zip file</small></p> \r\n\t\t</li>\r\n\t\t\t\t\t\r\n\t\t\t\t\t<li class=\"buttons\">\r\n\t\t\t    <input type=\"hidden\" name=\"form_id\" value=\"574014\" />\r\n\t\t\t    \r\n\t\t\t\t<input id=\"saveForm\" class=\"button_text\" type=\"submit\" name=\"submit\" value=\"make p12\" />\r\n\t\t</li>\r\n\t\t\t</ul>\r\n\t\t</form>\t\r\n\t\t<div id=\"footer\">\r\n\t\t\tGenerated by <a href=\"http://www.phpform.org\">pForm</a>\r\n\t\t</div>\r\n\t</div>\r\n\t<img id=\"bottom\" src=\"bottom.png\" alt=\"\">\r\n\t</body>\r\n</html>";