From ff984633feb7475fb12146da64a818e475fdddb9 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Fri, 16 Oct 2020 22:34:58 +0200 Subject: [PATCH] Add function to set common curl options --- common_config.php | 10 ++++++++++ cron/phishing_tests.php | 6 +----- cron/tests.php | 26 ++++---------------------- cron/update.php | 7 +------ helpers/fill_unknown_phishing.php | 8 +------- helpers/tmp.php | 5 +---- helpers/tmp2.php | 7 +------ helpers/tmp3.php | 5 +---- helpers/tmp4.php | 7 +------ helpers/tmp5.php | 7 +------ helpers/tmp6.php | 7 +------ helpers/tmp7.php | 7 +------ www/test.php | 6 +----- 13 files changed, 25 insertions(+), 83 deletions(-) diff --git a/common_config.php b/common_config.php index 7075339..3ff538e 100644 --- a/common_config.php +++ b/common_config.php @@ -150,3 +150,13 @@ function is_definitely_ssl() : bool { } return false; } + +function set_curl_options(CurlHandle $ch){ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); + curl_setopt($ch, CURLOPT_PROXY, PROXY); + curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); + curl_setopt($ch, CURLOPT_TIMEOUT, 60); +} diff --git a/cron/phishing_tests.php b/cron/phishing_tests.php index 29bd01d..288d271 100644 --- a/cron/phishing_tests.php +++ b/cron/phishing_tests.php @@ -8,11 +8,7 @@ try{ die($I['nodb']); } $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_PROXY, PROXY); -curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25); -curl_setopt($ch, CURLOPT_TIMEOUT, 40); +set_curl_options($ch); //check('http://tt3j2x4k5ycaa5zt.onion/onions.php?cat=15&pg=0', 'http://tt3j277rncfaqmj7.onion/onions.php?cat=15&pg=0'); //check('http://skunksworkedp2cg.onion/sites.html', 'http://skunkrdunsylcfqd.onion/sites.html'); diff --git a/cron/tests.php b/cron/tests.php index 698dadf..12dd532 100644 --- a/cron/tests.php +++ b/cron/tests.php @@ -16,13 +16,7 @@ $curl_handles = []; //do tests foreach($onions as $onion){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); - curl_setopt($ch, CURLOPT_PROXY, PROXY); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); - curl_setopt($ch, CURLOPT_TIMEOUT, 50); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); @@ -81,11 +75,7 @@ foreach($curl_handles as $handle){ } if(preg_match('~window\.location\.replace\("http://'.$onion['address'].'.onion/(.*?)"\)~', $content, $matches)){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); - curl_setopt($ch, CURLOPT_TIMEOUT, 50); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); @@ -96,11 +86,7 @@ foreach($curl_handles as $handle){ } if(preg_match('~^refresh:.*url=(https?://[^;\s]+).*?$~m', $header, $matches)){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); - curl_setopt($ch, CURLOPT_TIMEOUT, 50); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); @@ -119,11 +105,7 @@ foreach($curl_handles as $handle){ } } $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); - curl_setopt($ch, CURLOPT_TIMEOUT, 50); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); diff --git a/cron/update.php b/cron/update.php index fde1a69..cbe0e35 100644 --- a/cron/update.php +++ b/cron/update.php @@ -7,12 +7,7 @@ try{ die($I['nodb']); } $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); -curl_setopt($ch, CURLOPT_PROXY, PROXY); -curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25); -curl_setopt($ch, CURLOPT_TIMEOUT, 30); +set_curl_options($ch); curl_setopt($ch, CURLOPT_ENCODING, ''); $onions=[]; $scanned_onions=[]; diff --git a/helpers/fill_unknown_phishing.php b/helpers/fill_unknown_phishing.php index d9a5b8a..f91bf5a 100644 --- a/helpers/fill_unknown_phishing.php +++ b/helpers/fill_unknown_phishing.php @@ -6,13 +6,7 @@ try{ die('No Connection to MySQL database!'); } $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); -curl_setopt($ch, CURLOPT_PROXY, PROXY); -curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); -curl_setopt($ch, CURLOPT_TIMEOUT, 30); +set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); $online=$offline=$desc_online=$error=[]; diff --git a/helpers/tmp.php b/helpers/tmp.php index 9f40e69..89e1a10 100644 --- a/helpers/tmp.php +++ b/helpers/tmp.php @@ -8,10 +8,7 @@ try{ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phishing.onion_id=onions.id) WHERE onions.address!='' AND onions.category!=15 AND onions.category!=18 AND isnull(phishing.onion_id) LIMIT 2100,10000;"); $move=$db->prepare("UPDATE onions SET category=18, locked=1 WHERE address=?;"); $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); -curl_setopt($ch, CURLOPT_TIMEOUT, 60); +set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp2.php b/helpers/tmp2.php index 6910744..c2c5b47 100644 --- a/helpers/tmp2.php +++ b/helpers/tmp2.php @@ -9,12 +9,7 @@ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phish $move=$db->prepare("UPDATE onions SET category=15, locked=1, description='WARNING - This site will crash your browser with infinite iframes.' WHERE address=?;"); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050'); -curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); -curl_setopt($ch, CURLOPT_TIMEOUT, 30); +set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp3.php b/helpers/tmp3.php index cacffb5..afcbef5 100644 --- a/helpers/tmp3.php +++ b/helpers/tmp3.php @@ -8,10 +8,7 @@ try{ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phishing.onion_id=onions.id) WHERE onions.address!='' AND isnull(phishing.onion_id) AND onions.id>22439;"); $move=$db->prepare("UPDATE onions SET category=18, locked=1, description='Add injecting phishing clone of an existing site - SCAM' WHERE address=?;"); $ch=curl_init(); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); -curl_setopt($ch, CURLOPT_TIMEOUT, 60); +set_curl_options($ch); //curl_setopt($ch, CURLOPT_HEADER, true); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp4.php b/helpers/tmp4.php index 2eeeac0..58cd25a 100644 --- a/helpers/tmp4.php +++ b/helpers/tmp4.php @@ -9,12 +9,7 @@ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phish $move=$db->prepare("UPDATE onions SET category=18, locked=1, description='CP - SCAM' WHERE address=?;"); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050'); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp5.php b/helpers/tmp5.php index 381fe3a..b4b58ae 100644 --- a/helpers/tmp5.php +++ b/helpers/tmp5.php @@ -9,12 +9,7 @@ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phish $move=$db->prepare("UPDATE onions SET category=18, locked=1, description='Part of scam network - SCAM' WHERE address=?;"); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050'); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp6.php b/helpers/tmp6.php index 95e6e34..fee10ac 100644 --- a/helpers/tmp6.php +++ b/helpers/tmp6.php @@ -9,12 +9,7 @@ $stmt=$db->query("SELECT onions.address FROM onions LEFT JOIN phishing ON (phish $move=$db->prepare("UPDATE onions SET category=18, locked=1, description='Part of scam network - SCAM' WHERE address=?;"); while($tmp=$stmt->fetch(PDO::FETCH_NUM)){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050'); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_URL, "http://".gethostbyname("$tmp[0].onion")); diff --git a/helpers/tmp7.php b/helpers/tmp7.php index bc46f3b..8a3341f 100644 --- a/helpers/tmp7.php +++ b/helpers/tmp7.php @@ -10,12 +10,7 @@ $move=$db->prepare("UPDATE onions SET category=18, locked=1, description=CONCAT( $insert=$db->prepare('INSERT INTO onions (address, md5sum, timeadded, locked, description, category) VALUES (?, ?, ?, 1, "Part of scam network - SCAM", 18);'); for($i = 1; $i < 213; ++$i){ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050'); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_URL, "http://kenimar6g7h2z75m.onion/go.php?id=$i"); diff --git a/www/test.php b/www/test.php index 26327da..a137099 100644 --- a/www/test.php +++ b/www/test.php @@ -35,11 +35,7 @@ if(!empty($_REQUEST['addr'])){ echo "

$I[invalonion]

"; }else{ $ch=curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT); - curl_setopt($ch, CURLOPT_PROXY, PROXY); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); + set_curl_options($ch); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($ch, CURLOPT_ENCODING, '');