Last active
December 10, 2015 02:39
-
-
Save shobotch/4369288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
スクリプトキディが使うのはよろしくないと思いますので、ところどころを擬似コード(にもなっていない)に書き換えてあります。 | |
あと、あんまり高速でアカウントを探す敵は増やしたくないので、私の初期のcommitを公開しておきます。 | |
table.phpのアカウントリストの作成メソッドの中身を消したので、自分で書かないと動かないです。 | |
foreachを入れ子にすれば簡単に書けると思いますので、簡単なアルゴリズムの勉強をすればすぐに書けるかと思います。 | |
このスクリプトを使用して、いかなる問題が発生しても私は一切の責任を負いません。あらかじめ了承願います。 | |
使い方は、php.exeのパス run.php | |
とでもバッチファイルに書いておけばいいと思います。 | |
------ | |
このテキストも読まないでさっそく実行しようとする愚か者のために、table.phpのアカウント作成メソッドにいたずらしてあるので、47行目は消して処理を書いたほうがいいと思います。 | |
ライセンスは特に設けません。ですが、このスクリプトの類は過去の規制回避のように一般に知れ渡ると使えなくなる可能性があるので、再配布はしないようにお願い致します。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AccountSearch{ | |
public $account_list = array(); | |
public function checkAccount($name = array(), $single = false){ | |
$url = array(); | |
$falg = array(); | |
foreach ($name as $value) { | |
$url[] = "http://twitter.com/users/username_available?username=" . urlencode($value); | |
} | |
if (!$single){ | |
$res = $this->multi_request($url); | |
}else{ | |
$res = $this->array_single_request($url); | |
} | |
foreach ($res as $key => $value) { | |
if($this->check($value)){ | |
$falg[] = $key; | |
} | |
} | |
if(count($falg) != 0){ | |
$re = array(); | |
foreach ($falg as $value){ | |
$re[] = $name[$value]; | |
} | |
return $re; | |
} | |
return false; | |
} | |
private function array_single_request($url = array()){ | |
$ret = array(); | |
foreach ($url as $value) { | |
$ret[] = $this->single_request($value); | |
} | |
return $ret; | |
} | |
public function single_request($url, $post = null){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
if($post !== null) | |
curl_setopt($ch,CURLOPT_POSTFIELDS,"json=".$post); | |
curl_setopt($ch,CURLOPT_TIMEOUT,0); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
// URL を取得し、ブラウザに渡します | |
$res = curl_exec($ch); | |
// cURL リソースを閉じ、システムリソースを解放します | |
curl_close($ch); | |
return $res; | |
} | |
public function multi_request($url = array(),$post = array(), $timeout = 0){ | |
$mh = curl_multi_init(); | |
$conf = array(); | |
foreach ($url as $i => $uri){ | |
$conf[$i] = curl_init($uri); | |
curl_setopt($conf[$i],CURLOPT_TIMEOUT,$timeout); | |
if(isset($post[$i])) | |
curl_setopt ($conf[$i],CURLOPT_POSTFIELDS,"json=".$post[$i]); | |
curl_setopt($conf[$i], CURLOPT_HEADER, 0); | |
curl_setopt ($conf[$i], CURLOPT_RETURNTRANSFER, 1); | |
curl_multi_add_handle($mh, $conf[$i]); | |
} | |
$active = null; | |
do { | |
curl_multi_exec($mh, $active); | |
} while ($active > 0); | |
$res = array(); | |
foreach ($conf as $key => $i){ | |
$res[$key] = curl_multi_getcontent($i); | |
curl_multi_remove_handle($mh, $i); | |
curl_close($i); | |
} | |
curl_multi_close($mh); | |
return $res; | |
} | |
public function check($res){ | |
$json = $this->parse($res); | |
if(isset($json["valid"])){ | |
$this->write_log($res.PHP_EOL, "log2.txt"); | |
return $json["valid"]; | |
}else{ | |
$this->write_log("回収失敗: ". $res . PHP_EOL); | |
return false; | |
} | |
} | |
public function parse($json){ | |
return json_decode($json, true); | |
} | |
public function encode($array){ | |
return json_encode($array); | |
} | |
public function write_log($log, $filename = "log.txt",$logtime = true){ | |
$fp = fopen($filename, "a"); | |
$date = new DateTime(); | |
$logt = ($logtime)?"[".$date->format("m-d-H:i:s")."] ":""; | |
fwrite($fp,$logt.$log); | |
fclose($fp); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// タイムアウトを0にする | |
set_time_limit(0); | |
// メモリ制限を解除する(暴走するとOS落ちるかも) | |
ini_set('memory_limit' ,-1); | |
require_once 'table.php'; | |
require_once 'AccountSearch.php'; | |
$account = new AccountSearch(); | |
$bult = new table(); | |
$start = microtime(true); | |
echo "初期化開始" . PHP_EOL . PHP_EOL; | |
if(!empty($_GET["brute"])){ | |
$bl = $_GET["brute"]; | |
}else{ | |
// 何文字のアカウントを探すか | |
$bl = 4; | |
} | |
if(!empty($_GET["start"])){ | |
$count = $_GET["start"]; | |
}else{ | |
// セクションごとに処理を分けていて、途中で落ちてしまったときに途中から再開することができます。 | |
$count = 1; | |
} | |
$result = $bult->bruteAccount($bl); | |
echo $bl."個の探索を開始します。".PHP_EOL; | |
$bults = array_chunk($result, 170); | |
//$pre = array_chunk($bults, 20); | |
$counts = 1; | |
foreach ($bults as $value) { | |
if($count > $counts){ | |
$counts++; | |
continue; | |
} | |
$startf = microtime(true); | |
echo "第". $counts ."処理開始" . PHP_EOL; | |
$rr = $res[] = $account->checkAccount($value); | |
if(is_array($rr)){ | |
foreach ($rr as $value) { | |
if($value !== false){ | |
//require_once 'create.php'; | |
//$c = new Create(); | |
//$c->CreateAccount($value, "mailaddress+".$value."@gmail.com", "password", $value." for 133cs"); | |
$account->write_log($value. PHP_EOL, "ll.txt",false); | |
} | |
} | |
} | |
$endf = microtime(true); | |
$deff=$endf-$startf; | |
echo "第". $counts ."処理完了(" . $deff . "秒)" . PHP_EOL; | |
$account->write_log("第". $counts ."処理完了(" . $deff . "秒)" . PHP_EOL, "e.txt"); | |
$counts++; | |
} | |
$get = array(); | |
foreach ($res as $value) { | |
if(!empty($value) && $value != "not found" && $value != ""){ | |
// 見つけた時の動作 | |
$get[] = $value; | |
$mail->send("以下のアカウントを取得しました。/r/n@".$value); | |
} | |
} | |
if(count($get) > 0){ | |
echo "アカウントハヶ━m9( ゚д゚)っ━ン!!" . PHP_EOL; | |
ob_start(); | |
foreach ($get as $value) { | |
echo $value; | |
} | |
$raw = ob_get_clean(); | |
echo $raw; | |
}else{ | |
echo "アカウント見つからなかった(´・ω・`)" . PHP_EOL; | |
} | |
echo PHP_EOL; | |
$end = microtime(true); | |
$def=$end-$start; | |
echo "累計処理時間: " . $def . "秒" . PHP_EOL; | |
$account->write_log("累計処理時間: " . $def . "秒" . PHP_EOL,"end.txt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class table{ | |
public $table = array( | |
"a", | |
"b", | |
"c", | |
"d", | |
"e", | |
"f", | |
"g", | |
"h", | |
"i", | |
"j", | |
"k", | |
"l", | |
"m", | |
"n", | |
"o", | |
"p", | |
"q", | |
"r", | |
"s", | |
"t", | |
"u", | |
"v", | |
"w", | |
"x", | |
"y", | |
"z", | |
"0", | |
"1", | |
"2", | |
"3", | |
"4", | |
"5", | |
"6", | |
"7", | |
"8", | |
"9", | |
"_", | |
); | |
public function bruteAccount($max_length = 3){ | |
/** | |
* $resultに良い感じでa b c … aa ab ac … aaa aab aac …… | |
* なーんて連想配列が完成するように処理を書いてね☆(ゝω・)vキャピ | |
*/ | |
$result[] = "baka"; | |
return $result; | |
} | |
/** | |
* 指定した個数に配列を分解します。 | |
* @param array $array 分割される配列 | |
* @param int $chunk この数だけ配列を分解します。この時、余りがあると、その分合計の配列の数が一つ多くなります。 | |
*/ | |
public function result_chunk($array, $chunk){ | |
$chunk_c = (int)(count($array) / $chunk); | |
if($chunk_c > 0){ | |
return array_chunk($array, $chunk_c); | |
}else{ | |
return $array; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment