Skip to content

Instantly share code, notes, and snippets.

@Djenova
Last active November 10, 2017 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Djenova/30a171c5855633a54348ca75161ef6d5 to your computer and use it in GitHub Desktop.
Save Djenova/30a171c5855633a54348ca75161ef6d5 to your computer and use it in GitHub Desktop.
Auto change proxy with tor on linux
#!/usr/bin/php
<?php
// HOW TO USE :
// 0. You must run this script as sudoers / root
// 1. chmod +x tor.php
// 2. ./tor.php and follow the instructions
// 3. use proxychains or set your (browser) proxy to 127.0.0.1 9050
// 4. Happy Anonym
// 5. CTRL + C for stop
declare(ticks = 1);
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
function signal_handler($signal) {
switch($signal) {
case SIGTERM:
shell_exec('sudo ervice tor stop');
print "\nTOR STOPED \n";
exit;
case SIGKILL:
shell_exec('sudo service tor stop');
print "\nTOR STOPED\n";
exit;
case SIGINT:
shell_exec('sudo service tor stop');
print "\n TOR STOPED \n";
exit;
}
}
$ct = shell_exec('which tor');
if ($ct == null) {
echo "Please install tor first! \n";
} else {
echo "TOR Found! \n";
$fp = fSockOpen('google.com',80,$errno,$errstr,1);
if($fp) { $status=0; fclose($fp); } else { $status=1; }
if ($status == 1) {
echo "Please connect internet first!\n";
} else {
echo "Internet Found! \n";
echo "Input auto change interval (Second) = ";
$handle = fopen ("php://stdin","r");
$interval = fgets($handle);
if ($interval <= 10) {
echo "Minimum interval 10 second \n";
} else {
if (!is_numeric(trim($interval)) == TRUE) {
echo "Please input only numeric \n";
exit();
} else {
echo "Ok, You are so awesome..! \n";
while(1){
echo "Make some magic, please wait....\n";
shell_exec('sudo service tor restart');
sleep("5");
$IP = exec('curl -s -x socks://127.0.0.1:9050 ipinfo.io/ip');
echo "Your new IP = ".$IP ."\n";
for ($i=0; $i < $interval ; $i++) {
echo "Counting down = ".$i."\r";
sleep(1);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment