Files
CTF/HTB/encoding/target/api.v2.tools.string.index.php
Simon 82b0759f1e init htb
old htb folders
2023-08-29 21:53:22 +02:00

55 lines
1.2 KiB
PHP

<?php
include_once '../../header.php';
include_once '../../../utils.php';
include_once 'utils.php';
start();
if (isset($_FILES['data_file'])) {
$action = $_POST['action'];
$data = file_get_contents($_FILES['data_file']['tmp_name']);
} else {
$jsondata = json_decode(file_get_contents('php://input'), true);
$action = $jsondata['action'];
$data = $jsondata['data'];
if ( empty($jsondata) || !array_key_exists('action', $jsondata))
{
echo jsonify(['message' => 'Insufficient parameters!']);
}
}
if ($action === 'str2hex') {
echo jsonify(['data'=> str2hex($data)]);
} else if ($action === 'hex2str') {
echo jsonify(['data' => hex2str($data) ]);
} else if ($action === 'md5') {
echo jsonify(['data'=> md5($data)]);
} else if ($action === 'sha1') {
echo jsonify(['data'=> sha1($data)]);
} else if ($action === 'urlencode') {
echo jsonify(['data'=> urlencode($data)]);
} else if ($action === 'urldecode') {
echo jsonify(['data'=> urldecode($data)]);
} else if ($action === 'b64encode') {
echo jsonify(['data'=> base64_encode($data)]);
} else if ($action === 'b64decode') {
echo jsonify(['data'=> base64_decode($data)]);
} else {
echo jsonify(['message'=> 'Invalid action'], 404);
}
?>