geschrieben von /-_-
Demo:
Please Login HERE or Register HERE to see this link!
<?php
$SafeMail = new SafeMailGenerator();
if(isset($_POST['submit'])) {
echo $SafeMail->Register();
} else {
echo $SafeMail->ReadCaptcha();
}
/*
* Safe-Mail.net Generator - Secunet.cc
* @example
Please Login HERE or Register HERE to see this link!
* @author /-_-
* @version 0.1
*/
class SafeMailGenerator {
private $Curl;
private $Url;
private $Error;
private $Captcha;
private $FormID;
private $ActionID;
/*
* URL setzen
*/
public function __construct() {
$this->Url = '
Please Login HERE or Register HERE to see this link!
}
/*
* Captcha anzeigen
*/
public function ReadCaptcha() {
if(!in_array ('curl', get_loaded_extensions())) {
return 'CURL is not enabled..';
}
$this->Curl = curl_init($this->Url);
$this->setOPTs();
$src = curl_exec($this->Curl);
if($this->getCaptcha($src)) {
if($this->getFormID($src)) {
return $this->Captcha.$this->createSubmitForm($this->FormID, $this->Captcha);
} else {
return 'Error: '.$this->Error;
}
} else {
return 'Error: '.$this->Error;
}
}
/*
* Registrieren
*/
public function Register() {
if(!empty($_POST['captcha']) && !empty($_POST['action_id']) && !empty($_POST['form_id'])) {
$username = $this->getRandomString(10);
$password = $this->getRandomString(10);
$this->Curl = curl_init($this->Url.$_POST['form_id'].'?Regist&');
$this->setOPTs();
curl_setopt($this->Curl, CURLOPT_POST, TRUE);
curl_setopt($this->Curl, CURLOPT_POSTFIELDS, 'Design=clean&UserName='.$username.'&Password='.$password.'&PasswordVerify='.$password.'&UInfo.Name.Publish=Yes&UInfo.FirstName='.$username.'&UInfo.LastName='.$password.'&ThemeLanguage=eng&Language=multi&OTA.FormId='.$_POST['action_id'].'&OTA.Answer='.$_POST['captcha'].'&Continue.x=222&Continue.y=41');
$src = curl_exec($this->Curl);
if(strpos($src, 'Congratulations') !== false) {
return '<p><strong>Successfully registered!</strong></p>Username: '.$username.'<br />Password: '.$password;
} else {
return 'Error: Captcha wrong..';
}
} else {
return 'Empty field(s) found..';
}
}
/*
* Captcha und ActionID auslesen und in Variable speichern
* Captcha = ActionID ohne .jpg
*/
private function getCaptcha($value) {
preg_match('/<img src="(.*?)" border=2 bordercolor="#000000">/', $value, $treffer);
if(strpos($treffer[1], '.jpg')) {
if($this->saveCaptcha($this->Url.$treffer[1])) {
$this->Captcha = '<img src="captcha.jpg" />';
$this->ActionID = str_replace('.jpg', '', $treffer[1]);
return true;
} else {
$this->Error = 'Captcha could not be saved..';
return false;
}
} else {
$this->Error = 'Captcha not found..';
return false;
}
}
/*
* FormID auslesen
* Diese wird beim erstellen des Accounts übergeben als POST
*/
private function getFormID($value) {
preg_match('/AUTOCOMPLETE="OFF" action="/cgi-bin/Safe-mail.net/regist/(.*?)?Regist&/', $value, $treffer);
if(!empty($treffer[1])) {
$this->FormID = $treffer[1];
return true;
} else {
$this->Error = 'Form ID not found..';
return false;
}
}
/*
* CURL Optionen setzen
*/
private function setOPTs() {
curl_setopt($this->Curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0');
curl_setopt($this->Curl, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($this->Curl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($this->Curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($this->Curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->Curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($this->Curl, CURLOPT_SSL_VERIFYPEER, FALSE);
}
/*
* Kleine Form erstellen zur Eingabe vom Captcha
*/
private function createSubmitForm($FormID) {
return '<form method="post"><input type="text" name="captcha" value="" /><input type="hidden" name="action_id" value="'.$this->ActionID.'" /><input type="hidden" name="form_id" value="'.$FormID.'" /><input type="submit" name="submit" /></form>';
}
/*
* Captcha speichern
*/
private function saveCaptcha($url) {
$this->Curl = curl_init($url);
$this->setOPTs();
$fp = fopen('captcha.jpg', 'w');
if(fwrite($fp, curl_exec($this->Curl)) === false) {
return false;
} else {
fclose($fp);
return true;
}
}
/*
* Random String generieren (A-Z, a-z und 0-9)
*/
private function getRandomString($len) {
$char = array_merge(range('A','Z'),range('a','z'),range('0','9'));
$str = '';
for($i=0; $i<$len; $i++){
$str .= $char[mt_rand(0,count($char)-1)];
}
return $str;
}
}