Last active
November 10, 2017 03:19
-
-
Save Djenova/30a171c5855633a54348ca75161ef6d5 to your computer and use it in GitHub Desktop.
Auto change proxy with tor on linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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