Snow_Flake

"mass" fake email generator

Sep 21st, 2014
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.42 KB | None | 0 0
  1. <?php
  2. class massFakeEmailGenerator
  3. {
  4.  
  5.     private $timeout = 0.5; // timeout in seconds
  6.     private $emailName = "";
  7.     private $domainName = "";
  8.     private $fetchSwitch = true;
  9.     private $mailServices = array(
  10.       "fakemailgenerator" => array(
  11.       "armyspy.com",
  12.       "cuvox.de",
  13.       "dayrep.com",
  14.       "einrot.com",
  15.       "fleckens.hu",
  16.       "gustr.com",
  17.       "jourrapide.com",
  18.       "rhyta.com",
  19.       "superrito.com",
  20.       "teleworm.us"
  21.       ),
  22.       "guerrillamail" => array(
  23.       "guerrillamail.com",
  24.       "guerrillamailblock.com",
  25.       "sharklasers.com",
  26.       "guerrillamail.net",
  27.       "guerrillamail.org",
  28.       "guerrillamail.biz",
  29.       "spam4.me",
  30.       "grr.la",
  31.       "guerrillamail.de"
  32.       )
  33.     );
  34.  
  35.     public $httpUserAgent = array(
  36.       "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36",
  37.       "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0",
  38.       "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
  39.     );
  40.     public $currentEmail = null;
  41.     public $currentEmailInfo = array(
  42.       "to"=>null,
  43.       "from"=>null,
  44.       "subject"=>null,
  45.       "received"=>null,
  46.       "expires"=>null
  47.     );
  48.     public $currentEmailContent = null;
  49.     public $savedHeaders = [];
  50.  
  51.     public function fetch($email)
  52.     {
  53.       $this->currentEmail = $email;
  54.       $email_parts = explode("@", $email);
  55.       $this->emailName = $email_parts[0];
  56.       $this->domainName = $email_parts[1];
  57.       $function_name = "";
  58.       foreach ($this->mailServices as $key => $value) {
  59.       if (in_array($this->domainName, $value)) {
  60.             return $this->$key();
  61.             break;  
  62.       }
  63.       }
  64.       return 'no such domains found in our class';
  65.     }
  66.  
  67.     public function getUrl($url,$headers='')
  68.     {
  69.       $ctx = stream_context_create(
  70.       array('http'=>
  71.             array(
  72.             'timeout' => $this->timeout,
  73.             'user_agent' => $this->httpUserAgent[array_rand($this->httpUserAgent)],
  74.             'header' => $headers."\r\n"
  75.             )
  76.       )
  77.       );
  78.       $result = file_get_contents($url, false, $ctx);
  79.       if(empty($headers)) {
  80.       $this->savedHeaders[] = $http_response_header;
  81.       }
  82.       return $result;
  83.     }
  84.  
  85.     public function postUrl($url,$data,$headers='')
  86.     {
  87.       $postdata = http_build_query($data);
  88.       $ctx = stream_context_create(
  89.       array('http' =>
  90.             array(
  91.             'method'  => 'POST',
  92.             'header'  => 'Content-type: application/x-www-form-urlencoded'."\r\n".$headers,
  93.             'content' => $postdata
  94.             )
  95.       )
  96.       );
  97.       $result = file_get_contents($url, false, $ctx);
  98.       if(empty($headers)) {
  99.       $this->savedHeaders[] = $http_response_header;
  100.       }
  101.       return $result;
  102.     }
  103.  
  104.     public function arrayContains($array=array(),$count=0) {
  105.  
  106.     }
  107.  
  108.     public function fakemailgenerator()
  109.     {
  110.       if ($this->fetchSwitch) {
  111.       $result = $this->getUrl('http://www.fakemailgenerator.com/?u='.$this->emailName.'&d='.$this->domainName);
  112.       $this->fetchSwitch = false;
  113.       $this->fakemailgenerator();
  114.       } else {
  115.       $result = $this->getUrl('http://www.fakemailgenerator.com/inbox/'.$this->domainName.'/'.$this->emailName.'/');
  116.       header('Content-Type: text/plain');
  117.       //email info
  118.       preg_match("'<dl class=\"info-list\">(.*?)</dl>'si", $result, $match);
  119.       if ($match) {
  120.             $dom = new DOMDocument;
  121.             $dom->loadHTML($match[0]);
  122.             foreach ($dom->getElementsByTagName('dd') as $node) {
  123.             $tmpEmailarray[] = strip_tags($dom->saveHTML($node));
  124.             }
  125.             $this->currentEmailInfo = array(
  126.             "to"=>$tmpEmailarray[0],
  127.             "from"=>$tmpEmailarray[1],
  128.             "subject"=>$tmpEmailarray[2],
  129.             "received"=>$tmpEmailarray[3],
  130.             "expires"=>$tmpEmailarray[4],
  131.             "message"=>null
  132.             );
  133.       }
  134.       //email body
  135.       $pattern = preg_quote('id="emailFrame"', '/');
  136.       $pattern = "/^.*$pattern.*\$/m";
  137.       if (preg_match_all($pattern, $result, $matches)) {
  138.             preg_match('/src="([^"]+)"/', implode("\n", $matches[0]), $match);
  139.             header('Content-Type: text/html');
  140.             $this->currentEmailContent = $this->getUrl($match[1]);
  141.       } else {
  142.             $this->currentEmailContent = false;
  143.       }
  144.       header('Content-Type: text/html');
  145.       }
  146.     }
  147.  
  148.     public function guerrillamail()
  149.     {
  150.       if ($this->fetchSwitch) {
  151.       $result = $this->postUrl('https://www.guerrillamail.com/ajax.php?f=set_email_user', array(
  152.             'email_user' => $this->emailName,
  153.             'lang' => 'en',
  154.             'domain' => 'guerrillamail.com'
  155.       ),$resultheaders);
  156.  
  157.       $this->fetchSwitch = false;
  158.       $this->guerrillamail();
  159.       } else {
  160.       $resultheaders = $this->searchArrayForAndReturnValue($this->savedHeaders[0],"PHPSESSID");
  161.       $result = $this->getUrl('https://www.guerrillamail.com/ajax.php?f=check_email&seq=1&domain=guerrillamail.com',str_replace("Set-Cookie", "Cookie", $resultheaders));
  162.       $result = $this->getUrl('https://www.guerrillamail.com/ajax.php?f=fetch_email&email_id=mr_'.json_decode($result)->list[0]->mail_id.'&domain=guerrillamail.com',str_replace("Set-Cookie", "Cookie", $resultheaders));
  163.  
  164.       $this->currentEmailInfo = array(
  165.             "to"=>$this->currentEmail,
  166.             "from"=>json_decode($result)->mail_from,
  167.             "subject"=>json_decode($result)->mail_subject,
  168.             "received"=>null,
  169.             "expires"=>null,
  170.             "message"=>null
  171.       );
  172.       $this->currentEmailContent = json_decode($result)->mail_body;
  173.       }
  174.     }
  175.  
  176.     public function searchArrayForAndReturnValue($array,$string) {
  177.       $tmpValue = "";
  178.       if(is_array($array)) {
  179.       foreach($array as $value) {
  180.             if (strpos($value,$string) !== false) {
  181.             $tmpValue .= $value."\r\n";
  182.             }
  183.       }
  184.       }
  185.       return $tmpValue;
  186.     }
  187.  
  188.     public function emailMessage() {
  189.       return $this->currentEmailContent;
  190.     }
  191.  
  192. }
  193. $email = new massFakeEmailGenerator();
  194. $email->fetch('[email protected]');
  195. echo "Email: ".$email->currentEmail."\r\n";
  196.  
  197. if ($email->emailMessage()) {
  198.     foreach($email->currentEmailInfo as $key => $value) {
  199.       echo $key.": ".$value."\r\n";
  200.     }
  201.     echo $email->emailMessage();
  202. }
  203. ?>
Advertisement
Add Comment
Please, Sign In to add comment