domingo, 15 de junio de 2008

Cheat para Word Challenge en Facebook

Aqui les dejo un bot generado en php para el famoso juego de facebook "Word Challenge". El programa genera un script en Windows Scripting Tool (vbs) que juega por ti.

"miscript.vbs"; // archivo de salida
$retardoinicial = 1800; // tiempo inicial de espera (en milisegundos) para hacer foco en la ventana del juego
$retardotecla = 0; //milisegundos
$diccionario = "xxxxxxxxxx"; // aqui va la pagina donde se obtienen las palabras
// esta pagina del diccionario deberan solicitármela por correo

function OutputFile($file) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; '
.'filename="'.$file.'"');
echo
file_get_contents($file);
}

function
SaveContent($content, $file)
{
if (
file_exists($file)) @unlink($file);
if (!
$handle = fopen($file, 'w')) die("Error in $file");
fwrite($handle,$content);
fclose($handle);
}

function ParseContent($string){
preg_match_all("(word=[a-zA-Z]{3}[a-zA-Z]*)", $string, $matches);
$rightwords = array();
foreach(
$matches[0] as $valor) $rightwords[] = substr($valor,5);
$rightwords = array_reverse(array_unique($rightwords));
return $rightwords;
}

if (
$_POST) {
srand((float)microtime() * 1000000);
$url = "http://$diccionario?letters=".substr($_POST['letras'],0,6).
"&dict=sowpods&Cheat=Cheat"
;
$input = @file_get_contents($url) or die('Cant access $url');
$rightwords = ParseContent($input);
$content = 'Dim Wsh'."\r\n";
$content.= 'Set Wsh = Wscript.CreateObject("Wscript.Shell")'."\r\n";
$content.= 'Wsh.AppActivate "Exploring"'."\r\n";
$content.= 'Wscript.sleep('.$retardoinicial.')'."\r\n";
foreach(
$rightwords as $word) {
$scriptline = '';
for(
$i=0; $i<strlen($word); $i++)
{
$letter = substr($word,$i,1);
$scriptline.='Wsh.SendKeys "{'.$letter.'}"'."\r\n";
}
$scriptline.='Wsh.SendKeys "{ENTER}"'."\r\n";
$content.=$scriptline;
}
SaveContent($content,"./".$scriptname);
OutputFile($scriptname);
exit();
}

?>
<html>
<body>
<h3>Generador de palabras para Word Challenge</h3>
<form name="miforma" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<label>letras</label>
<input type="text" name="letras" />
<input type="submit" name="submit" value="submit">
<br>
</form>
</body>
</html>