Bot kaskus for Education Only

[code]<?php
error_reporting(0);
/*-----------------------------------------------------------------------
Kaskus BOT v.1.0 Beta
Just for Educational Only
do it with your own risk
Author : wenkhairu [at] devilzc0de [dot] org

+---------------------------------------------------+
|   thanks for who have been made this bot before   |
+---------------------------------------------------+

this bot using cURL PHP extension
with command line Usage
eg:
wenkhairu@devilz-inside # php kaskusbot.php [username] [password]

-----------------------------------------------------------------------*/

/----------------------------------------------------------------------
Class cURL
this function used for curl extension for PHP
if you have another idea let me know :slight_smile:
fell free to share it dude :slight_smile:
------------------------------------------------------------------------
/
class cURL
{
var $user_agent = “Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)”;
var $proxy_ip = “”;
var $proxy_port = 0;
var $proxy_url = “”;
var $proxy_type = “”;
var $status = 0;
var $error = “”;
var $timeout = 30;
var $cookies = “”;
var $last_url = “”;
var $fix_cookies = false;

function __construct($cookies) 
{
	if (!$cookies) $cookies = tempnam("./", "CURLCOOKIE");
	$this->cookies = $cookies;
}

function open($url,$post="") {
	$ch = curl_init();
	if ($this->proxy_url != "") $url = str_replace("%s", str_replace("http://","",$url), $this->proxy_url);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	if ($post != "") {
		curl_setopt($ch, CURLOPT_POST,1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	}

	curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
	curl_setopt($ch,CURLOPT_TIMEOUT, $this->timeout); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch,CURLOPT_REFERER, $this->last_url);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookies); 
	curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookies);

	if ($this->proxy_ip != "") {
		curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_port);
		curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
		curl_setopt($ch, CURLOPT_PROXY, $this->proxy_ip);
		if ($this->proxy_type == "socks") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
	}
	$data = curl_exec($ch);
		$this->status = curl_getinfo($ch,CURLINFO_HTTP_CODE);
		$this->error = curl_error($ch);
	$this->last_url = $url;
	curl_close($ch);
	return $data;
}

}

/----------------------------------------------------------------------
This Class used for retrive data from http://sockslist.net/
to find working proxy and check it
group by type and proxy port
so we have fresh proxy all the time :slight_smile:
------------------------------------------------------------------------
/
class findsock
{
function findsock()
{
$proxy = array();
for ($i=1;$i<2;$i++)
{
$html = file_get_contents(“http://sockslist.net/proxy/server-socks-hide-ip-address/$i”);
$matches = explode(“t_ip”, $html);
$n = 0;

		foreach ($matches as $mt) 
		{
			$ip = $this->stringBetween('">', "</td>", $mt);
			if ($n > 0 && $ip != "") 
			{
				$pt = explode(",", $this->stringBetween('t_port">', "</td>", $mt));
				$port = "";
				$kd = $this->stringBetween('fromCharCode(', '+parseInt', $html);
				foreach ($pt as $p) 
				{
					$a = intval($p) + intval($kd);
					$port .= chr($a);
				}
				if ($n > 0 && $ip != "") array_push($proxy, array("type" => "socks", "ip" => $ip, "port" => $port, "url" => ""));
			}
			$n++;
		}
	}
	return $proxy;
}

function stringBetween($start, $end, $var) 
{
	return preg_match('{' . preg_quote($start) . '(.*?)' . preg_quote($end) . '}s', $var, $m)
	? $m[1]
	: '';
}

}

/*
This class for bypass some captha or image perivication
may be this need more time but i tough it will work good
or you could to bypass them with your own way :slight_smile:
*/

class imgper
{
function read($data)
{
$orig = imagecreatefromstring($data);
$letter_num = 2;

	$pos = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
	$code = '';
	$lbl = "";
	$hasil = array();
	foreach ($pos as $p1) 
	{
		foreach ($pos as $p2) 
		{
			$lbl = $p1.$p2;
			$gbr = $this->gambar($lbl);
			$skor = $this->beda($orig, $gbr);
			$hasil[$lbl] = $skor;
		}
	}
	asort($hasil);
	foreach ($hasil as $k=>$v) { $kode = $k; break; }
	return $kode;
}

function ketengah($image, $image_width, $string, $font_size, $y, $color) 
{ 
	$text_width = imagefontwidth($font_size)*strlen($string); 
	$center = ceil($image_width / 2); 
	$x = $center - (ceil($text_width/2)); 
	ImageString($image, $font_size, $x, $y, $string, $color); 
} 

function gambar($teks) 
{
	$width = 30;
	$height = 20;

	$image = ImageCreate($width, $height);
	$black = ImageColorAllocate($image, 0, 0, 0);
	$white = ImageColorAllocate($image, 255, 255, 255);
	$grey = ImageColorAllocate($image, 200, 200, 200);
	ImageFill($image, 0, 0, $white);
	$this->ketengah($image, $width, $teks, 3, 3, $black);
	ImageRectangle($image,0,0,$width-1,$height-1,$grey);
	return $image;
}

function gambar_canvas($teks) 
{
	$img = $this->gambar($teks);
	header("Content-Type: image/jpeg");
	ImageJpeg($img);
	ImageDestroy($img);
}

function beda($i1, $i2) 
{
	$sx1 = imagesx($i1);
	$sy1 = imagesy($i1);

	if ($sx1 !== imagesx($i2) || $sy1 !== imagesy($i2)) 
	{
	return 100;
	}

	$diffi = imagecreatetruecolor($sx1, $sy1);
	$green = imagecolorallocate($diffi, 0, 255, 0);
	imagefill($diffi, 0, 0, imagecolorallocate($diffi, 0, 0, 0));

	$different_pixels = 0;

	for ($x = 0; $x < $sx1; $x++) 
	{
		for ($y = 0; $y < $sy1; $y++) 
		{
			$rgb1 = imagecolorat($i1, $x, $y);
			$pix1 = imagecolorsforindex($i1, $rgb1);

			$rgb2 = imagecolorat($i2, $x, $y);
			$pix2 = imagecolorsforindex($i2, $rgb2);

			if ($pix1 !== $pix2) 
			{
				$different_pixels++;
				imagesetpixel($diffi, $x, $y, $green);
			}
		}
	}
	if (!$different_pixels)
	{
		return 0;
	}
	else{
		$total = $sx1 * $sy1;
		return number_format(100 * $different_pixels / $total, 2);
	}
}

}

/*
Main function for kaskusbot
this function will make autopost on kaskus
find random good thread, and replay comment with
random replay, also replace some word that made this bot more
look like real person
*/

$username = $argv[1];
$password = $argv[2];

if (!$username || !$password)
{
print “[+] Please input Your Username & Password!\n”;
exit;
}
$x =“±---------------------------------+\n”;
$x.="| Kaskus BOT |\n";
$x.=“±---------------------------------+\n”;
$x.="| Loged as $username |\n";
$x.=“±---------------------------------+\n”;

print $x;
/* use instance class for cURL extension */
$cURL = new cURL("./$username");

/* use instance class for finding good proxy */
$unyu_unyu = new findsock();
$config = array();
$config[“proxy”] = $unyu_unyu->findsock();

/* use instance class for image perivication ss*/
$img_prev = new imgper();

/* Use good USer Agent, you could to change it if you guest this one is not usefull enough */
$cURL->user_agent = “Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54”;

/* Login on the fly */
login();

/* if we have loged before then made it from json encode */
$sebelumnya = (array) json_decode(file_get_contents(“posted_”.$username.".json"));

/* Count aur Post before */
print "+ Posted Thread Counts : ". count($sebelumnya). “\n”;

/* do auto post while the script is running */
while (1==1)
{
$config[“proxy”] = $unyu_unyu->findsock();

/* get random proxy */
acak_proxy();

/* Crawl the pages and find random thread */
print "+ Crawling pages \n";
$trit = crawl("21", 10);
foreach ($trit as $k=>$v) 
{
	if (!isset($sebelumnya[$k])) 
	{
		acak_proxy();
		print "[+] http://m.kaskus.us/thread/$k \n";
		$komen = random_komen($k);
		if ($komen) 
		{
			print "[+] Komentar :\n $komen \n\n";
			print "[+] Replay Komentar :\n" . ganti($komen) . "\n\n";

			if (post($k, ganti($komen))) 
			{
				print "[+]Replay Komentar Berhasil\n\n";
				$sebelumnya[$k] = 1;
				simpan("posted_".$username.".json", json_encode($sebelumnya));
				print "+ Sleeping for 2 seconds ...\n";
				sleep(2);
			} 
			else print "[+] Replay Komentar Gagal\n\n";
		} 
	}
}

}

exit;

function ganti($teks)
{
/* Replace some word for real action instead */
$dia = array(“gan”, “bos”, “om”, “coy”, “bray”, “cuy”);
$gw = array(“gw”, “ane”, “ogut”, “aye”, “gua”);
$sering = array(“dengan” => “dgn”, “dgn” => “dengan”);
$ketawa = array(“wkwkwk”, “hahaha”);

$teks = str_replace("...", "..", $teks);

$tk = explode(" ", $teks);
$tmp  = ""; $break = false;
foreach ($tk as $tks) 
{
	$break = false;
	$tt = strtolower($tks);

	/* Replace For $dia */
	foreach ($dia as $d) 
	{
		if ($tt == $d) 
		{
			$ack = array_rand($dia, 1);
			$ac = $dia[$ack];
			$tmp .= " ".$ac;
			$break = true;
			break;
		}
		if ($break) break;
	}

	if (!$break) 
	{
		/* Replace for $gw */
		foreach ($gw as $c) 
		{
			if ($tt == $c) 
			{
				$ack = array_rand($gw, 1);
				$ac = $gw[$ack];
				$tmp .= " ".$ac;
				$break = true;
				break;
			}
			if ($break) break;
		}
		if (!$break) 
		{
			$tmp .= " ". $tt;
		}
	}
}
return $tmp;

}

/* function to save json data */
function simpan($file, $data)
{
$fp = fopen($file, “w”);
fwrite($fp, $data);
fclose($fp);
}

/* function to make some random proxy ss*/
function acak_proxy()
{
global $config, $cURL, $cur_proxy;
$x = array_rand($config[“proxy”],1);

while ($x == $cur_proxy) 
{
	$x = array_rand($config["proxy"],1);
}

$cur_proxy = $x;
$proxy = $config["proxy"][$cur_proxy];
$cURL->proxy_type = $proxy["type"];
$cURL->proxy_url = $proxy["url"];
$cURL->proxy_ip = $proxy["ip"];
$cURL->proxy_port = $proxy["port"];

print "[+] Used Proxy : " . $proxy["ip"].":".$proxy["port"]."\n";

}

/* what ever you said, it just for comment */
function komentar($title)
{
$komen = array(“iya yah? hmm :beer:”,“ijin menyimak dulu”,“serasa dejavu”,“hmm…”,“wekkkkkkks”);
$km = array_rand($komen,1);
return $komen[$km];
}

/* function for loged in */
function login()
{
global $cURL,$trit, $username, $password;
$cURL->open($trit);
$post = render_form(array(“username” => $username, “password” => $password, “rememberme” => null, “login” => “Login”));
$isi = $cURL->open(“http://m.kaskus.us/user/login”, $post);
}

function post($trit_id=“7369840”, $komentar=“jiahahaha”)
{
global $cURL, $img_prev;

$trit = "http://m.kaskus.us/reply/$trit_id";
$balas = $cURL->open($trit);
$captcha = stringBetween("Code Verification: <img src=\"","\"/>", $balas);
$c = $cURL->open($captcha);
if (!$c) return FALSE;

$kode = $img_prev->read($c);
$hash = stringBetween('hash" type="hidden"  value="',"\"", $balas);
print "[+] Captcha = $captcha\n";

$form = array();
$form["captcha"] = $kode;
$form["title"] = "";
$form["message"] = $komentar;
$form["reply"] = "Submit Reply";
$form["threadid"] = $trit_id;
$form["hash"] = $hash;
$kirim = $cURL->open($trit, $form);
$cek = strpos($kirim, "redirect");
if ($cek > -1) return true;
else return false;

}

function crawl($forum_id,$max=50)
{
global $cURL;
$trits = array();
for ($i = 1; $i <= $max; $i++)
{
$c = ($i - 1) * 20;
$trit = “http://m.kaskus.us/forum/$forum_id/$c”;
print “[+] Crawl $trit\n”;
$isi = $cURL->open($trit);
$tret = html2trits($isi);
print “\t-> Total " . count($tret).”\n";

	foreach ($tret as $t) 
	{
		if (substr($t["title"],0,7) != "Sticky:") $trits[$t["id"]] = $t["title"];
	}
	
	if (count($tret) == 0) 
	{
		acak_proxy();
		$i--;
	}
}
return $trits;

}

function random_komen($id)
{
global $cURL;
$total_hal = trit_page($id);
if ($total_hal > 15)
{
$acak_hal = rand(1,$total_hal - 1);
$komen = trit_posts($id, $acak_hal);

	$total_post = count($komen["posts"]);

	$acak_post = array_rand($komen["posts"], 1);
	$post = $komen["posts"][$acak_post];

	$cek = strpos($post[2], "http://");
	
	while ($cek > -1 && $acak_post > ($total_post - 5)) 
	{
		$acak_post = array_rand($komen["posts"], 1);
		$post = $komen["posts"][$acak_post];
		$cek = strpos($post[2], "http://");
	}
	return $post[2];
}

}

function acak_p($komen)
{
$total_post = count($komen[“posts”]);
$acak_post = array_rand($komen[“posts”], 1);
$post = $komen[“posts”][$acak_post];
return $post;
}

function trit_posts($id, $page=1)
{
global $cURL;
$c = ($page - 1) * 10;
$trit = “http://m.kaskus.us/thread/$id/$c”;
$a = $cURL->open($trit);
$b = explode("<div class=“post”, $a);
$kom = array(); $n = 0;

foreach ($b as $c) 
{
	$komen = stringBetween("<hr size=\"0.2\" style=\"color: rgb(209, 209, 225); background-color: rgb(209, 209, 225);\"/>","<div class=\"right\">",$c);
	$komen = trim(strip_tags($komen));
	$usr_id = stringBetween("<a href=\"http://m.kaskus.us/user/profile/", "\"", $c);
	$usr_name = stringBetween("<a href=\"http://m.kaskus.us/user/profile/$usr_id\">","</a>",$c);
	if ($n == 2) { $ts_id = $usr_id; $ts_name = $usr_name; }
	if ($komen && $ts_id && $usr_id != $ts_id) array_push($kom, array($usr_id, $usr_name, $komen));
	$n++;
}
$hsl = array("ts_id" => $ts_id, "ts_name" => $ts_name, "posts" => $kom);
return $hsl;

}

function html2trits($html)
{
$a = stringBetween("<div id=“forum”>","<div class=“kaskusad”>",$html);
$b = explode("<li", $a);
$d = array();
foreach ($b as $c)
{
$id = stringBetween(“href=“http://m.kaskus.us/thread/","/”,$c);
$title = trim(stringBetween(”">", “( 1”,$c));
if ($title)
{
array_push($d, array(“id” => $id, “title” => $title));
}
}
return $d;
}

function trit_page($id)
{
global $cURL;
$trit = “http://m.kaskus.us/thread/$id/”;
$isi = $cURL->open($trit);
$a = stringBetween("<div class=“paging”>","|",$isi);
$b = stringBetween(" of “,” ",$a);
return $b;
}

function render_form($data)
{
$t = “”;
foreach ($data as $k=>$v) { $t .= “&$k=$v”;}
return str_replace("###&","","###".$t);
}

function stringBetween($start, $end, $var)
{
return preg_match(’{’ . preg_quote($start) . ‘(.*?)’ . preg_quote($end) . ‘}s’, $var, $m)
? $m[1]
: ‘’;
}
?>[/code]

[quote]
thread ini membahas tentang pembuatan bot pada cms vbuletin, penulis tidak bertanggung jawab atas kerusakan yang terjadi pada tindakan - tindakan yang dilakukan oleh script ini, karena script ini dibahas hanya untuk pembelajaran semata…

thx[/quote]

NB :
Warning … Nyampah jualan bot . [color=#FF0000]BANNED[/color]

bkalan bikin heboh nag kaskus lagi nih… :ngakak: :ngakak: :ngakak:
[spoiler] sayang gax suka ngakus… :bangga: [/spoiler]

:ngakak: :ngakak: Heboh lagi nich di kaskus… :wawa:

apakah gerangan itu om :bangga::

cara pakenya gimana om? :belajar:

di ane kok cmn diem aje ye om :o ini kan autopost.php nya kan :o
edit : jalan deh sampe posted thread count :o

pake php cli jalaninnya bukan dari browser, sekripnya diedit2 lagi . biar runing. soalnya udah lama ga di update

ternyata ane salah aksi nama om :stuck_out_tongue: gk di rename ke kaskusbot.php :stuck_out_tongue: matiin proxy biar ngebut ah :smiley:
mattin proxy nya //$config[“proxy”] = $unyu_unyu->findsock(); gini bkn om?? :stuck_out_tongue:

monggo modipannya juga dishare dimari. buat member laen belajar :belajar:

Pengen bikin bot mybb ah… :ngakak:.

Ane sie ga suka maen kaskus.
Ijin pelajarin script nya om :piss:
Thanks om wenk , thanks om chaer…$unyu-unyu

nuggu nuggu para suhu suhu dateng
moggo POC nya :smiley:

Pie Om Carane wkwk

pkep roxy gagal terus posting nye :o di tunggu suhu2 :stuck_out_tongue:

Waduh… PP nya Aasli Kan Omzz…???
:ngakak: :ngakak:
[spoiler][size=large][font=Arial]kebiasaan !!![/font][/size][/spoiler]

kalo mau pake juga om haha

Om Wenk memang selalu luar biasa… :smangat::smangat:

izin modifikasi ya om… :belajar::belajar:

:ngakak::ngakak::ngakak::ngakak: ane liat avatar om yang satu ini… apa bener2 pecandu ya?? buat om chaer thanks om…

[quote]:ngakak::ngakak::ngakak::ngakak: ane liat avatar om yang satu ini… apa bener2 pecandu ya?? buat om chaer thanks om…
[/quote]

Dikit sih :ngakak::ngakak:

[spoiler][size=large][font=Arial]Kalo sesama suka gini ga usah dibilang om :hmm: [/font][/size][/spoiler]

om mau tanya nih…
cara edit2 script bot…
supaya setiap posting bisa di tambahin karakter ini gimna om?
( * )
caranya?
cuma bintang nya aja

wogh mantap nich DC gan… ini yg paling saya suka dari DC,banyak ilmu yg saya bisa dapat disini…
btw boleh ga saya minta tutorial nya master2… saya newbie banged n gaptek banged masa script… bisa tau langkah2nya hrs gmn dan harus download apa dulu ya??terimakasih… maaf newbie tp sudah merepotkan…