Skip to content

Instantly share code, notes, and snippets.

@carbolymer
Last active December 15, 2015 07:09
Show Gist options
  • Save carbolymer/5221484 to your computer and use it in GitHub Desktop.
Save carbolymer/5221484 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
/**
* Possible processors on Linux
*/
$linux_proc = array(
'i686',
'x86_64'
);
/**
* Mac processors (i also added U;)
*/
$mac_proc = array(
'Intel',
'PPC',
'U; Intel',
'U; PPC'
);
/**
* Add as many languages as you like.
*/
$lang = array(
'en-GB',
'pl-PL'
);
function firefox() {
global $linux_proc, $mac_proc, $lang;
$ver = array(
'Gecko/' . date('Ymd', rand(strtotime('2011-1-1'), time())) . ' Firefox/' . rand(5, 7) . '.0',
'Gecko/' . date('Ymd', rand(strtotime('2011-1-1'), time())) . ' Firefox/' . rand(5, 7) . '.0.1',
'Gecko/' . date('Ymd', rand(strtotime('2010-1-1'), time())) . ' Firefox/3.6.' . rand(1, 20),
'Gecko/' . date('Ymd', rand(strtotime('2010-1-1'), time())) . ' Firefox/3.8'
);
$platforms = array(
'(Windows NT ' . rand(5, 6) . '.' . rand(0, 1) . '; ' . $lang[array_rand($lang, 1)] . '; rv:1.9.' . rand(0, 2) . '.20) ' . $ver[array_rand($ver, 1)],
'(X11; Linux ' . $linux_proc[array_rand($linux_proc, 1)] . '; rv:' . rand(5, 7) . '.0) ' . $ver[array_rand($ver, 1)],
'(Macintosh; ' . $mac_proc[array_rand($mac_proc, 1)] . ' Mac OS X 10_' . rand(5, 7) . '_' . rand(0, 9) . ' rv:' . rand(2, 6) . '.0) ' . $ver[array_rand($ver, 1)]
);
return $platforms[array_rand($platforms, 1)];
}
function safari() {
global $linux_proc, $mac_proc, $lang;
$saf = rand(531, 535) . '.' . rand(1, 50) . '.' . rand(1, 7);
if (rand(0, 1) == 0) {
$ver = rand(4, 5) . '.' . rand(0, 1);
} else {
$ver = rand(4, 5) . '.0.' . rand(1, 5);
}
$platforms = array(
'(Windows; U; Windows NT ' . rand(5, 6) . '.' . rand(0, 1) . ") AppleWebKit/$saf (KHTML, like Gecko) Version/$ver Safari/$saf",
'(Macintosh; U; ' . $mac_proc[array_rand($mac_proc, 1)] . ' Mac OS X 10_' . rand(5, 7) . '_' . rand(0, 9) . ' rv:' . rand(2, 6) . '.0; ' . $lang[array_rand($lang, 1)] . ") AppleWebKit/$saf (KHTML, like Gecko) Version/$ver Safari/$saf",
'(iPod; U; CPU iPhone OS ' . rand(3, 4) . '_' . rand(0, 3) . ' like Mac OS X; ' . $lang[array_rand($lang, 1)] . ") AppleWebKit/$saf (KHTML, like Gecko) Version/" . rand(3, 4) . ".0.5 Mobile/8B" . rand(111, 119) . " Safari/6$saf",
);
return $platforms[array_rand($platforms, 1)];
}
function iexplorer() {
$ie_extra = array(
'',
'; .NET CLR 1.1.' . rand(4320, 4325) . '',
'; WOW64'
);
$platforms = array(
'(compatible; MSIE ' . rand(5, 9) . '.0; Windows NT ' . rand(5, 6) . '.' . rand(0, 1) . '; Trident/' . rand(3, 5) . '.' . rand(0, 1) . ')'
);
return $platforms[array_rand($platforms, 1)];
}
function opera() {
global $linux_proc, $lang;
$op_extra = array(
'',
'; .NET CLR 1.1.' . rand(4320, 4325) . '',
'; WOW64'
);
$platforms = array(
'(X11; Linux ' . $linux_proc[array_rand($linux_proc, 1)] . '; U; ' . $lang[array_rand($lang, 1)] . ') Presto/2.9.' . rand(160, 190) . ' Version/' . rand(10, 12) . '.00',
'(Windows NT ' . rand(5, 6) . '.' . rand(0, 1) . '; U; ' . $lang[array_rand($lang, 1)] . ') Presto/2.9.' . rand(160, 190) . ' Version/' . rand(10, 12) . '.00'
);
return $platforms[array_rand($platforms, 1)];
}
function chrome() {
global $linux_proc, $mac_proc;
$saf = rand(531, 536) . rand(0, 2);
$platforms = array(
'(X11; Linux ' . $linux_proc[array_rand($linux_proc, 1)] . ") AppleWebKit/$saf (KHTML, like Gecko) Chrome/" . rand(13, 15) . '.0.' . rand(800, 899) . ".0 Safari/$saf",
'(Windows NT ' . rand(5, 6) . '.' . rand(0, 1) . ") AppleWebKit/$saf (KHTML, like Gecko) Chrome/" . rand(13, 15) . '.0.' . rand(800, 899) . ".0 Safari/$saf",
'(Macintosh; U; ' . $mac_proc[array_rand($mac_proc, 1)] . ' Mac OS X 10_' . rand(5, 7) . '_' . rand(0, 9) . ") AppleWebKit/$saf (KHTML, like Gecko) Chrome/" . rand(13, 15) . '.0.' . rand(800, 899) . ".0 Safari/$saf"
);
return $platforms[array_rand($platforms, 1)];
}
/**
* Main function which will choose random browser
* @return string user agent
*/
function random_uagent() {
$x = rand(1, 5);
switch ($x) {
case 1:
return "Mozilla/5.0 " . firefox();
break;
case 2:
return "Mozilla/5.0 " . safari();
break;
case 3:
return "Mozilla/" . rand(4, 5) . ".0 " . iexplorer();
break;
case 4:
return "Opera/" . rand(8, 11) . '.' . rand(10, 99) . ' ' . opera();
break;
case 5:
return 'Mozilla/5.0'. chrome();
break;
}
}
$aMatches = null;
$sName = null;
$iPesel = null;
$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_URL, "http://pl.fakenamegenerator.com/gen-random-pl-pl.php");
curl_setopt($curlHandler, CURLOPT_HEADER, 1);
curl_setopt($curlHandler, CURLOPT_USERAGENT, random_uagent());
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_FOLLOWLOCATION, true);
$sPageContents = curl_exec($curlHandler);
// echo $sPageContents;
preg_match("#<div class=\"address\">(.*?)<h3>(.*?)</h3>#si",$sPageContents, $aMatches);
$sName = $aMatches[2];
preg_match("#PESEL:</li><li>(\d+) <#si",$sPageContents, $aMatches);
$iPesel = $aMatches[1];
preg_match("#<div class=\"adr\">(.*?)</div>#si",$sPageContents, $aMatches);
$sAddress = str_replace("<br />"," ",trim($aMatches[1]));
file_put_contents("names.txt", $sName." ".$iPesel." ".$sAddress."\n\r", FILE_APPEND);
curl_close($curlHandler);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment