Advertisement
causevd

Facebook autolike PHP script

Nov 1st, 2012
1,652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.81 KB | None | 0 0
  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
  13. 13.
  14. 14.
  15. 15.
  16. 16.
  17. 17.
  18. 18.
  19. 19.
  20. 20.
  21. 21.
  22. 22.
  23. 23.
  24. 24.
  25. 25.
  26. 26.
  27. 27.
  28. 28.
  29. 29.
  30. 30.
  31. 31.
  32. 32.
  33. 33.
  34. 34.
  35. 35.
  36. 36.
  37. 37.
  38. 38.
  39. 39.
  40. 40.
  41. 41.
  42. 42.
  43. 43.
  44. 44.
  45. 45.
  46. 46.
  47. 47.
  48. 48.
  49. 49.
  50. 50.
  51. 51.
  52. 52.
  53. 53.
  54. 54.
  55. 55.
  56. 56.
  57. 57.
  58. 58.
  59. 59.
  60. 60.
  61. 61.
  62. 62.
  63. 63.
  64. 64.
  65. 65.
  66. 66.
  67. 67.
  68. 68.
  69. 69.
  70. 70.
  71. 71.
  72. 72.
  73. 73.
  74. 74.
  75. 75.
  76. 76.
  77. 77.
  78. 78.
  79. 79.
  80. 80.
  81. 81.
  82. 82.
  83. 83.
  84. 84.
  85. 85.
  86. 86.
  87. 87.
  88. 88.
  89. 89.
  90. 90.
  91. 91.
  92. 92.
  93. 93.
  94. 94.
  95. 95.
  96. 96.
  97. 97.
  98. 98.
  99. 99.
  100. 100.
  101. 101.
  102. 102.
  103. 103.
  104. 104.
  105. 105.
  106. 106.
  107. 107.
  108. 108.
  109. 109.
  110. 110.
  111. 111.
  112. 112.
  113. 113.
  114. 114.
  115. 115.
  116. 116.
  117. 117.
  118. 118.
  119. 119.
  120. 120.
  121. 121.
  122. 122.
  123. 123.
  124. 124.
  125. 125.
  126. 126.
  127. 127.
  128. 128.
  129. 129.
  130. 130.
  131. 131.
  132. 132.
  133. 133.
  134. 134.
  135. 135.
  136. 136.
  137. 137.
  138. 138.
  139. 139.
  140. 140.
  141. 141.
  142. 142.
  143. 143.
  144. 144.
  145. 145.
  146. 146.
  147. 147.
  148. 148.
  149. 149.
  150. 150.
  151. 151.
  152. 152.
  153. 153.
  154. 154.
  155. 155.
  156. 156.
  157. 157.
  158. 158.
  159. 159.
  160. 160.
  161. 161.
  162. 162.
  163. 163.
  164. 164.
  165. 165.
  166. 166.
  167. 167.
  168. 168.
  169. 169.
  170. 170.
  171. 171.
  172. 172.
  173. 173.
  174. 174.
  175. 175.
  176. 176.
  177. 177.
  178. 178.
  179. 179.
  180. 180.
  181. 181.
  182. 182.
  183. 183.
  184. 184.
  185. 185.
  186. 186.
  187. 187.
  188. 188.
  189. 189.
  190. 190.
  191. 191.
  192. 192.
  193. 193.
  194. 194.
  195. 195.
  196. 196.
  197. 197.
  198. 198.
  199. 199.
  200. 200.
  201. 201.
  202. 202.
  203. 203.
  204. 204.
  205. 205.
  206. 206.
  207. 207.
  208. 208.
  209. 209.
  210. 210.
  211. 211.
  212. 212.
  213. 213.
  214. 214.
  215. 215.
  216. 216.
  217. 217.
  218. 218.
  219. 219.
  220. 220.
  221.  
  222.  
  223. <?php
  224.  
  225. /*
  226. * NAME
  227. * Facebook autolike PHP script
  228. *
  229. * SYNOPSIS
  230. * php ./fbautolike.php
  231. *
  232. * DESCRIPTION
  233. * Facebook autolike PHP script allows automatically liking friend\'s posts with some level of randomness.
  234. *
  235. * The script runs in background and iterates a user\'s facebook page every 10 seconds to see if there are new posts added, if so there is a coin-flip with a user-defined probability value to see if those posts will be liked.
  236. *
  237. * OPTIONS
  238. * $login_email has the username/email of the user to be logged-in.
  239. *
  240. * $login_pass has the password of the $login_email to access to.
  241. *
  242. * $users has the values of each user and the probability in a given moment of a certain post being liked. Example: 0.5 means there is a 50% chance of a post being set liked.
  243. *
  244. * http://r00tsecurity.org
  245. */
  246.  
  247. /* ----------- USER CONFIGURATIONS ------------ */
  248. $login_email = \"YOUR_LOGIN_EMAIL\";
  249. $login_pass = \"YOUR_PASSWORD\";
  250. $users = Array(
  251. \"CHANGE THIS TO A FRIEND\'S NAME\" => 0.5,
  252. \"CHANGE THIS TO A FRIEND\'S NAME\" => 0.9,
  253. \"CHANGE THIS TO A FRIEND\'S NAME\" => 0.5,
  254. \"CHANGE THIS TO A FRIEND\'S NAME\" => 0.9,
  255. );
  256. /* ------- END OF USER CONFIGURATIONS -------- */
  257.  
  258. if (isset($argv[1]) && $argv[1] == \"web\")
  259. $web = 1;
  260. else
  261. $web = 0;
  262.  
  263. # stories seen
  264. $ss = Array();
  265. $page = \'\';
  266.  
  267. function extractLikeUrls($from)
  268. {
  269. /*
  270. * $matches structure
  271. * 0: whole matching string from \"<div\" to \"(Un)like\"
  272. * 1: /profile.php?id=...
  273. * 2: user name
  274. * OLD 3: story id
  275. * 3: like url
  276. * 4: Like or Unlike
  277. */
  278. # preg_match_all(\"/<div id=\\\"anchor_fbid_[^\\\"]+\\\"><a href=\\\"(\\/profile\\.php\\?id=(\\d+).+?refid=\\d+)\\\">([^<]+)<\\/a>.+?- <a href=\\\"(\\/a\\/like\\.php\\?a=\\\\2&amp;s=(\\d+)[^\\\"]+)\\\">(?:Unl|L)ike/\", $from, $matches);
  279. #echo $from;
  280. #echo $from;
  281. # <div class=\"abb acw apl\"><a href=\"/profile.php?id=1060861583&amp;fbb=rdacccddd&amp;refid=7\"><strong>André Cotter</strong></a> Carrega beira-mar!!!<div class=\"actions mfss fcg\"><abbr title=\"Sunday, November 7, 2010 at 7:27pm\"
  282. data-date=\"Sun, 07 Nov 2010 11:27:37 -0800\" class=\"timestamp\">15 minutes ago</abbr> · <a class=\"sec\" href=\"/profile.php?id=1060861583&amp;v=wall&amp;story_fbid=174587085890919&amp;fbb=rdacccddd&amp;refid=7\">Comment</a> · <a
  283. class=\"sec\" href=\"/a/like.php?a=1060861583&amp;s=174587085890919&amp;src=1&amp;gfid=68e2265e45&amp;fbb=rdacccddd&amp;refid=7#anchor_fbid_174587085890919\">Like</a> · <a class=\"sec\"
  284. href=\"/profile.php?id=1060861583&amp;v=wall&amp;story_fbid=174587085890919&amp;fbb=rdacccddd&amp;refid=7\"><img class=\"img likethumbicon\" src=\"http://static.ak.fbc...LoyWtxbXTT.png\" width=\"10\" height=\"9\"
  285. alt=\"Photo\" />1</a></div></div>
  286. # preg_match_all(\"/<div id=\\\"anchor_fbid_[^>]+><a href=\\\"(\\/.+?refid=\\d+)\\\">([^<]+)<\\/a>.+? <a href=\\\"(\\/a\\/like\\.php\\?a=\\d+&amp;s=(\\d+)[^\\\"]+)\\\">((?:Unl|L)ike)/\", $from, $matches);
  287. #preg_match_all(\"/<a href=\\\"(\\/profile.php.+?)\\\"><strong>(.+?)<\\/strong>.+?href=\\\"(\\/a\\/like\\.php\\?a=\\d+&amp;s=(\\d+)[^\\\"]+)\\\">((?:Unl|L)ike)/\", $from, $matches);
  288. # preg_match_all(\"/<a href=\\\"(\\/profile.php.+?)\\\"><strong>(.+?)<\\/strong>.+?<span.+?id=\\\"like_(\\d+)\\\">/\", $from, $matches);
  289.  
  290. # start from news feed.
  291. $from = strstr($from,\"News Feed\");
  292. #preg_match_all(\"/<a href=\\\"(\\/profile.php.+?)\\\"><strong>(.+?)<\\/strong>.+?<span.+?id=\\\"like_(\\d+)\\\"><a.+?href=\\\"(\\/a\\/like\\.php\\?[^\\\"]+)\\\">((?:Unl|L)ike)/\", $from, $matches);
  293. preg_match_all(\"/<a href=\\\"(\\/profile.php.+?)\\\"><strong>(.+?)<\\/strong>.+?<a.+?href=\\\"(\\/a\\/like\\.php\\?[^\\\"]+)\\\">((?:Unl|L)ike)/\", $from, $matches);
  294.  
  295. # echo $from;exit;
  296. # print_r($matches);exit;
  297. return $matches;
  298. }
  299.  
  300. function do_web($content)
  301. {
  302. $h = fopen(\"fbautolike.html\", \'a+\');
  303. if (!$h)
  304. die (\"could not open fbautolike.html\");
  305. rewind($h);
  306. fwrite($h,$content);
  307. fwrite($h,\"<div style=\\\"clear:both\\\"></div>\");
  308. fclose($h);
  309. }
  310.  
  311. if ($web) {
  312. do_web(\'
  313. <style>
  314. html { font: 11px/18px \"Lucida Grande\",\"Lucida Sans Unicode\",Arial,Verdana,sans-serif; }
  315. #date { float: left; margin-right: 20px; }
  316. #event { float: left; border-left: 1px solid black;padding-left: 20px; }
  317. #fblogo { float: left; margin-bottom: 10px; height: 31px; width: 103px; background: url(\\\'http://static.ak.fbcdn.net/rsrc.php/z7VU4/hash/66ad7upf.png\\\') no-repeat scroll -21px 0 #3B5998 }
  318. </style>
  319. <div>
  320. <div id=\"fblogo\"></div><div style=\"float: left; font-size: 18px; margin: 5px 0 0 14px;\">auto like script</div>
  321. <div style=\"clear: both\"></div>\');
  322. }
  323.  
  324. $ch = curl_init();
  325. #curl_setopt($ch, CURLOPT_URL, \'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php\');
  326. #curl_setopt($ch, CURLOPT_URL, \'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php\');
  327. curl_setopt($ch, CURLOPT_URL, \'http://m.facebook.com\');
  328. curl_setopt($ch, CURLOPT_POST, 0);
  329. curl_setopt($ch, CURLOPT_HEADER, 0);
  330. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  331. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  332. curl_setopt($ch, CURLOPT_COOKIEJAR, \"my_cookies.txt\");
  333. curl_setopt($ch, CURLOPT_COOKIEFILE, \"my_cookies.txt\");
  334. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  335. curl_setopt($ch, CURLOPT_USERAGENT, \"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4\");
  336. $page = curl_exec($ch);
  337. #echo $page.\"\\n\\n\\n\\n\\n\";exit;
  338. if (preg_match(\"/<form.+?action=\\\"(https:\\/\\/login.facebook.com\\/login.php?[^\\\"]+)\\\">/\", $page, $_login)) {
  339. preg_match(\"/(http%3A%2F%2F.+?$)/\", $_login[1], $_loginentrance);
  340. preg_match(\"/<input type=\\\"hidden\\\" name=\\\"charset_test\\\" value=\\\"([^\\\"]+)\\\"/\", $page, $_charset_test);
  341. #echo $_charset_test[1].\"\\n\\n\";
  342. #echo $_login[1].\"\\n\\n\";
  343. $loginentrance = html_entity_decode(rawurldecode($_loginentrance[1]));
  344. $loginentrance = preg_replace(\"/http:\\/\\/m.facebook.com\\/&/\", \"http://m.facebook.com/?\", $loginentrance);
  345. #echo $loginentrance.\"\\n\\n\";
  346. curl_setopt($ch, CURLOPT_URL, $_login[1]);
  347. curl_setopt($ch, CURLOPT_POSTFIELDS, \'charset_test=\'.urlencode($_charset_test[1]).\'&email=\' . urlencode($login_email) . \'&pass=\' . urlencode($login_pass) . \'&login=\' . urlencode(\"Log In\"));
  348. curl_setopt($ch, CURLOPT_POST, 1);
  349. curl_exec($ch); # Login
  350. curl_setopt($ch, CURLOPT_POST, 0);
  351. curl_setopt($ch, CURLOPT_URL, $loginentrance);
  352. $page = curl_exec($ch);
  353. }
  354. #echo $page;exit;
  355.  
  356. # Click the \"See More Stories\"
  357. # <a href=\"/stories.php?max=1289139643&amp;fbb=rf9b84b5a&amp;refid=7\">See More Stories</a>
  358. #preg_match(\"/href=\\\"(\\/stories\\.php\\?max=.+?)\\\"/\", $page, $_stories);
  359. #print_r($_stories);exit;
  360. while (1)
  361. {
  362. if ($web)
  363. do_web( \"<div id=\\\"date\\\">\".date(\"Y/m/d - H:i:s\") . \"</div> <div id=\\\"event\\\">Fetching facebook pages...</div>\\n\");
  364. else
  365. echo \"[\".date(\"Y/m/d - H:i:s\") . \"] Fetching facebook pages...\\n\";
  366.  
  367.  
  368. for ($a=0; $a < 4; $a++)
  369. {
  370. $likeUrls = extractLikeUrls($page);
  371.  
  372. for ($i=0, $c=count($likeUrls); $i < $c; $i++)
  373. {
  374. # already seen or already Liked
  375. if (!isset($likeUrls[3][$i]) || !isset($likeUrls[4][$i]) || in_array($likeUrls[3][$i], $ss) || $likeUrls[4][$i] != \"Like\")
  376. {
  377. continue;
  378. }
  379.  
  380. if (array_key_exists($likeUrls[2][$i], $users))
  381. {
  382. $p = $users[$likeUrls[2][$i]];
  383. $r = rand(0,100);
  384. if ($r < $p*100)
  385. {
  386. if ($web)
  387. {
  388. #do_web( \"<div id=\\\"date\\\">\".date(\"Y/m/d - H:i:s\") . \"</div> <div id=\\\"event\\\">Liked <a href=\\\"http://facebook.com\"...ecode($likeUrls[1][$i]).\"\\\">\".$likeUrls[2][$i].\"</a>
  389. <a href=\\\"http://facebook.com\".html_entity_decode($likeUrls[1][$i]).\"&story_fbid=\".$likeUrls[3][$i].\"\\\">link</a></div>\\n\");
  390. echo \"Liked \".$likeUrls[2][$i].\" link\\n\";
  391. }
  392. else
  393. {
  394. #echo \"Liked \".$likeUrls[2][$i].\" link: \".\"http://facebook.com\"...ecode($likeUrls[1][$i]).\"&story_fbid=\".$likeUrls[3][$i].\"\\n\";
  395. echo \"Liked \".$likeUrls[2][$i].\" link\\n\";
  396. }
  397. curl_setopt($ch, CURLOPT_POST, 0);
  398. curl_setopt($ch, CURLOPT_URL, \'http://m.facebook.com\'.html_entity_decode($likeUrls[4][$i]));
  399. curl_exec($ch);
  400. }
  401. else
  402. {
  403. if ($web)
  404. {
  405. # do_web( \"<div id=\\\"date\\\">\".date(\"Y/m/d - H:i:s\") . \"</div> <div id=\\\"event\\\">Skipped liking <a
  406. href=\\\"http://facebook.com\".html_entity_decode($likeUrls[1][$i]).\"\\\">\".$likeUrls[2][$i].\"</a> <a href=\\\"http://facebook.com\".html_entity_decode($likeUrls[1][$i]).\"&story_fbid=\".$likeUrls[3][$i].\"\\\">link</a></div>\\n\");
  407. echo \"Skipped liking \".$likeUrls[2][$i].\" link\\n\";
  408. }
  409. else
  410. {
  411. echo \"Skipped liking \".$likeUrls[2][$i].\" link\\n\";
  412. }
  413. }
  414. }
  415.  
  416. # echo $likeUrls[2][$i] . \" \" .$likeUrls[3][$i] . \"\\n\";
  417. array_push($ss, $likeUrls[3][$i]);
  418. }
  419.  
  420. preg_match_all(\"/href=\\\"(\\/stories\\.php\\?max=.+?)\\\"/\", $page, $stories); # get the other pages in $stories
  421. curl_setopt($ch, CURLOPT_POST, 0);
  422. curl_setopt($ch, CURLOPT_URL, \'http://m.facebook.com\'.$stories[1][0]);
  423. $page = curl_exec($ch); # $page is now the first page of stories.
  424. # echo $page;
  425. # print_r($stories);exit;
  426. # echo $page;exit;
  427. }
  428.  
  429. /*
  430. * Randomly wait/sleep from 10 seconds to 3 hours (30% chance) or 1 hour (70% chance)
  431. */
  432. $_sleep = rand(10, (rand(0,100) < 30 ? 10800 : 3600));
  433. if ($web)
  434. do_web( \"<div id=\\\"date\\\">\".date(\"Y/m/d - H:i:s\") . \"</div> <div id=\\\"event\\\">Sleeping for \".$_sleep.\" seconds</div>\\n\");
  435. else
  436. echo \"Sleeping for \".$_sleep.\" seconds\\n\".($web?\"<br>\":\"\");
  437. sleep ($_sleep);
  438. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement