Skip to content

Instantly share code, notes, and snippets.

@andibastian
Last active December 6, 2018 17:28
Show Gist options
  • Save andibastian/2ba6b15ca1c4c27c38c6021ff35b73c6 to your computer and use it in GitHub Desktop.
Save andibastian/2ba6b15ca1c4c27c38c6021ff35b73c6 to your computer and use it in GitHub Desktop.
<?php
/*
thejagat.net - Auto Capture Proxy for Proxychains
--------------------------------------------------------
PREPARE :
1. Install Proxychains & tor (sudo apt install proxychains && sudo apt install tor)
2. Modifkasi config untuk memudahkan, jalankan perintah berikut untuk memberi batasan karakter pada file config :
sudo sed -i "\$a#start \n#end" /etc/proxychains.conf
Hasilnya akan menempatkan string #start dan #end sebagai wrapper bagi list ip address.
--------------------------------------------------------
Digunakan untuk melakukan auto update IP proxychains
thanks to pubproxy.com untuk free proxynya. Asumsi file config berada di /etc/proxychains.conf
Jalankan sebagai root : sudo php getproxy.php
Setelah selesai, jalankan perintah seperti :
proxychains firefox https://namaweb.com atau proxychains curl https://namaweb.com
*/
echo "Get Proxies ...";
$url="http://pubproxy.com/api/proxy?limit=20";
$header=@get_headers($url);
$fileoutput="output.txt";
$file_config="/etc/proxychains.conf";
if(file_exists($fileoutput)){
unlink($fileoutput);
}
if($header[0]=="HTTP/1.1 200 OK"){
$getdata=file_get_contents($url);
if(stripos($getdata,"We have to temporarily stop you.")!==false){
echo "Anda terblok, silakan coba lagi nanti, jangan terlalu sering, idealnya boleh per-5menit.\n";
exit;
}
$getdata=json_decode($getdata,true);
$listproxy=$getdata['data'];
foreach ($listproxy as $key => $value) {
//print_r($value);
$ip=$value['ip'];
$port=$value['port'];
$country=$value['country'];
file_put_contents($fileoutput,"$ip $port\n", FILE_APPEND);
}
echo "OK\n";
}
else {
echo "\nError, koneksi internet down atau URL invalid\n";
exit;
}
echo "Pengosongan IP Proxy ...";
exec("sed -i '/#start/,/#end/{//!d}' $file_config");
echo "OK\n";
echo "Edit File Config...";
//jika pake baris
//$baris=exec("cat /etc/proxychains.conf | grep -n '#start'");
//$baris=intval($baris);
//exec("sed -i '$baris a $fileoutput' /etc/proxychains.conf");
//penulisan setelah string dan bersumber dari file, /r = read file
exec("sed -i '/#start/r $fileoutput' $file_config");
unlink($fileoutput);
echo "OK\n";
echo "SELESAI\n\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment