kc-interface/initTorAndHS.php
2023-01-13 17:18:05 +00:00

30 lines
929 B
PHP

<?php
$rootPW = $_POST["rootPW"];
$hsname = $_POST["hsname"];
$newTorState = "hs"
$configureHiddenService1 = "echo $rootPW | sudo -S sed -i 's/#HiddenServiceDir\ \/var\/lib\/tor\/hidden_service/HiddenServiceDir\ \/var\/lib\/tor\/$hsname/' /etc/tor/torrc";
$configureHiddenService2 = "echo $rootPW | sudo -S sed '0,/#HiddenServiceP/{s/#HiddenServicePort\ 80 127.0.0.1:80/HiddenServicePort 80 127.0.0.1:80\nHiddenServicePort 22 127.0.0.1:22/}' /etc/tor/torrc";
$restartTor = "echo $rootPW | sudo -S systemctl restart tor";
$replaceTorState = "echo $newTorState > torstate.csv"
$writeTheNewGeneratedAddress = "echo $rootPW | sudo -S cat /var/lib/tor/$hsname/hostname > hshostname.txt"
$output = exec($configureHiddenService1);
$output1 = exec($configureHiddenService2);
$output2 = exec($restartTor);
$output3 = exec($replaceTorState);
$output4 = exec($writeTheNewGeneratedAddress);
echo $output3;
echo " oi oi oi ";
?>