cryptoform/index.php

85 lines
3.1 KiB
PHP
Raw Permalink Normal View History

2025-03-09 08:50:22 +01:00
<?php
// https://www.w3docs.com/tools/editor/6252
include "includes/inc-top.php";
if (!isset($_REQUEST["step"])){
?>
<form action=<?php echo $_SERVER['PHP_SELF']; ?> method='post'>
<h1><? echo $title; ?></h1>
<div class=formcontainer>
<hr/>
<div class=container>
<label for=string><strong>String</strong></label>
<input type=text value="<?php echo $_REQUEST['webstring'] ?? null; ?>" placeholder='Enter String' name=string required>
<label for=psw><strong>Password</strong></label>
<input type=password value="<?php echo $_REQUEST['webpwd'] ?? null; ?>" placeholder='Enter Password' name=psw required>
</div>
<div align=center>
<button type=reset style='width: 32%; background-color: #008CBA'>Reset</button>
<button type=submit name=action value=decode style='width: 32%; background-color: #4CAF50'>Decode</button>
<button type=submit name=action value=encode style='width: 32%; background-color: #FF0000'>Encode</button>
</div>
<input type=hidden name=step value=1>
</form>
<?php
} else {
if ($_POST['action'] == 'decode') {
$param="-d";
} else {
$param="-e";
}
$output = shell_exec("echo " .$_REQUEST['string']."| openssl enc ".$param." -base64 -aes-128-ctr -nosalt -pbkdf2 -k ".$_REQUEST['psw']);
// root@webphp:/usr/home/web/default/decrypt# echo 12345678901 | openssl enc -e -base64 -aes-128-ctr -nosalt -pbkdf2 -k pippo
// root@webphp:/usr/home/web/default/decrypt# echo HU+9XYiA+jjK1esx | openssl enc -d -base64 -aes-128-ctr -nosalt -pbkdf2 -k pippo
?>
<form action=<?php echo $_SERVER['PHP_SELF']; ?> method='post'>
<h1><? echo $title; ?></h1>
<div class=formcontainer>
<hr/>
<div class=container>
<label for=string><strong>String</strong></label>
<input type=text id="string" value="<?php echo $output; ?>" readonly>
<label for=psw><strong>Password</strong></label>
<input type=text id="pwd" value=<?php echo $_REQUEST['psw']; ?> readonly>
</div>
<div align=center>
<button type=submit style='width: 32%; background-color: #008CBA'>Restart</button>
<button type=button onclick="Copy('string')" style='width: 32%; background-color: #4CAF50'>Copy String</button>
<button type=button onclick="Copy('pwd')" style='width: 32%; background-color: #FF0000'>Copy Password</button>
</div>
</form>
<?php
if ($param == "-e") {
echo "&nbsp;<p>".
"<strong>Summary:</strong>".
"<p>".
"<table border=0 align=left width=100%>".
"<tr><td width=25%>Original string</td><td>".$_REQUEST['string']."</td></tr>".
"<tr><td width=25%>Encoded string</td><td>".$output."</td></tr>".
"<tr><td width=25%>Password</td><td>".$_REQUEST['psw']."</td></tr>".
"</table>".
"<p>&nbsp;<p>".
"<strong>Generated Links:</strong>".
"<p>".
"<a href=".$_SERVER['HTTP_REFERER']."?webstring=$output>".$_SERVER['HTTP_REFERER']."?webstring=$output</a>".
"<br>".
"<a href=".$_SERVER['HTTP_REFERER']."?webpwd=$_REQUEST[psw]>".$_SERVER['HTTP_REFERER']."?webpwd=$_REQUEST[psw]</a>";
}
}
include "includes/inc-bottom.php";