Advertisement
Guest User

LinkSpeedUp PHP Auto-Bot

a guest
Sep 20th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.53 KB | None | 0 0
  1. <?php
  2. require_once 'vendor/autoload.php';
  3.  
  4. # 一些網址的資訊, 沒事別亂改他不然會壞掉
  5. define('BASE_URL', 'http://linkspeedup.com');
  6. define('AJAX_URL', sprintf('%s%s', BASE_URL, '/free_points/ajax'));
  7.  
  8. /**
  9.  * 這邊是初始化 Guzzle Client 的一些預設設定值
  10.  */
  11. $client = new GuzzleHttp\Client([
  12.     'defaults' => [
  13.         'cookies' => true,
  14.         'connect_timeout' => 3,
  15.         'debug' => false,
  16.         'exceptions' => true,
  17.         #'proxy' => 'socks://127.0.0.1:9050',
  18.        'timeout' => 30,
  19.         'verify' => false
  20.     ]
  21. ]);
  22.  
  23. /**
  24.  * 每個請求皆共有的 header 資訊
  25.  */
  26. $headers = [
  27.     'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  28.     'Accept-Encoding' => 'gzip,deflate,sdch',
  29.     'Accept-Language' => 'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4',
  30.     'Cache-Control' => 'no-cache',
  31.     'Connection' => 'keep-alive',
  32.     'Pragma' => 'no-cache',
  33.     'User-Agent' => random_uagent()
  34. ];
  35.  
  36. /**
  37.  * 目前網站上可用的積分點擊類別
  38.  */
  39. $methods = [
  40.     # Facebook
  41.    '1' => 'Facebook Likes',
  42.     '2' => 'Facebook Share',
  43.     '3' => 'Facebook Subscribes',
  44.     '4' => 'Facebook Post Like',
  45.     # Youtube
  46.    '6' => 'Youtube Views',
  47.     '7' => 'Youtube Subscribes',
  48.     '8' => 'Youtube Likes',
  49.     '9' => 'Youtube Favorites',
  50.     # Twitter
  51.    '10' => 'Twitter Followers',
  52.     '11' => 'Twitter Tweets',
  53.     '12' => 'Twitter Retweets',
  54.     '13' => 'Twitter Favorites',
  55.     # Google
  56.    '14' => 'Google Circles',
  57.     # Others
  58.    #'15' => 'Website Hits'
  59. ];
  60.  
  61. /**
  62.  * 註冊的固定資訊
  63.  */
  64. $register = [
  65.     'name' => 'John Doe',
  66.     'password' => 'fuck_linkspeedup',
  67.     'month' => 9,
  68.     'day' => 13,
  69.     'year' => 2014,
  70.     'gender' => 'male',
  71.     'ref' => '804UlueSPt'
  72. ];
  73.  
  74. # ok, 開砲拉 !
  75. try {
  76.     # 模擬使用者於瀏覽器鍵入網址並瀏覽
  77.    getIndexPage();
  78.  
  79.     # 可以隨意更換成想要洗點數的帳號密碼
  80.    if ($argc == 2) {
  81.         define('USERNAME', $argv[1]);
  82.         define('PASSWORD', $argv[2]);
  83.     } else {
  84.         define('USERNAME', sprintf('%d@mailnesia.com', time()));
  85.         define('PASSWORD', $register['password']);
  86.  
  87.         registerNewAccount(USERNAME, $register['ref']);
  88.  
  89.         # 註冊完就做點簡單的紀錄, 以後方便查詢嘛 !
  90.        $fp = fopen('/tmp/linkspeedup.txt', 'a');
  91.         fwrite($fp, USERNAME . "\n");
  92.         fclose($fp);
  93.     }
  94.  
  95.     # 模擬使用者鍵入帳號以及密碼
  96.    enterLoginInfo(3);
  97.  
  98.     # 模擬使用者的登入行為
  99.    clickLoginButton(USERNAME, PASSWORD);
  100.  
  101.     # 模擬使用者點擊取得每日紅利點數
  102.    # clickBonusButton();
  103.  
  104.     # 無限自動點擊循環開始 !
  105.    while (true) {
  106.         # 怕被盯上或封鎖, 當然是隨機挑選一個來洗點數唄
  107.        $rand = array_rand($methods);
  108.  
  109.         # 這裡模擬使用者於左方點擊 Facebook Likes, Youtube Favorites 或 Twitter Followers 等連結時所傳送的查詢
  110.        $getLinksList = clickPointURL($rand);
  111.  
  112.         # 從後端回傳一段 javascript, 以正則表達式擷取我們所需要的參數資訊
  113.        # confirmSingleFB('53304', "https://www.facebook.com/studentsforabetterfuture", 1, '',9, "245682198938224", "ci_csrf_token", "");
  114.        preg_match('/confirmSingleFB[^(]*\(([^)]*)\)/', $getLinksList, $confirmSingleFB);
  115.  
  116.         # 這邊簡單地採用字串的長度比對, 檢查是否出現以下的錯誤訊息
  117.        # No more new pages in this item, please try again later!
  118.        if ((count($confirmSingleFB) != 2) or (strlen($getLinksList) == 55)) {
  119.             continue;
  120.         } else {
  121.             # 第二組所匹配的正則結果就是我們要的 id, url, network 等資訊啦嘿嘿
  122.            # '53304', "https://www.facebook.com/studentsforabetterfuture", 1, '',9, "245682198938224", "ci_csrf_token", ""
  123.            $confirmSingleFB = explode(',', $confirmSingleFB[1]);
  124.  
  125.             # 這邊就是我們所需要傳送的參數資訊了, 處理下單引號空白等字元
  126.            $id = trim(str_replace('\'', '', $confirmSingleFB[0]));
  127.             $url = trim(str_replace('"', '', $confirmSingleFB[1]));
  128.             $network = trim($confirmSingleFB[2]);
  129.             $cpc = trim($confirmSingleFB[4]);
  130.             $title = trim(str_replace('"', '', $confirmSingleFB[5]));
  131.  
  132.             # 這裡模擬當點擊開始的按鈕時所傳送的查詢
  133.            $getFBLikesDataBefore = clickStartButton($rand, $id, $url, $network);
  134.  
  135.             # 這裡模擬當將點擊視窗關閉時所傳送的查詢
  136.            $checkFollowed = closePopupWindow($rand, $id, $url, $network);
  137.  
  138.             # 哇哈哈 ! 這邊就是可以新增積分的函數啦 !!
  139.            $updateAction = sendFakeFollowed($rand, $id, $url, $network);
  140.  
  141.             # 取得該次詳細的積分點擊說明
  142.            preg_match(
  143.                 '/<br \/\>(.*?)<br\/\>/',
  144.                 getPointinfo($rand, $cpc, $network, $title, $checkFollowed),
  145.                 $likeNote
  146.             );
  147.  
  148.             $prompt = sprintf(
  149.                 '現在時間: %s, 點擊方法: %s, 目前點數: %s, 折現金額: %s, 詳細資訊: %s',
  150.                 date("Y-m-d H:i:s", time()),
  151.                 $methods[$rand],
  152.                 $updateAction['point'],
  153.                 $updateAction['money'],
  154.                 $likeNote[1]
  155.             );
  156.             print $prompt . PHP_EOL;
  157.         }
  158.  
  159.     }
  160. } catch (Exception $e) {
  161.     # 不做其他的例外處理, 只印出錯誤訊息就好
  162.    print '已出現以下錯誤: ' . $e->getMessage() . PHP_EOL;
  163. }
  164.  
  165. /**
  166.  * 模擬使用者於瀏覽器鍵入網址 http://linkspeedup.com 並瀏覽網頁
  167.  *
  168.  * @return \GuzzleHttp\Stream\StreamInterface|null
  169.  *
  170.  * @see https://gist.github.com/skiddie/0bec2f609ad33d19d0e0
  171.  */
  172. function getIndexPage()
  173. {
  174.     global $client, $headers;
  175.  
  176.     return $client->get(BASE_URL, ['headers' => $headers])->getBody();
  177. }
  178.  
  179. /**
  180.  * 模擬使用者註冊帳號
  181.  *
  182.  * @param string $email
  183.  * @param string $ref
  184.  *
  185.  * @return \GuzzleHttp\Stream\StreamInterface|null
  186.  *
  187.  * @see https://gist.github.com/skiddie/e9a7491171f4fedc4efe
  188.  */
  189. function registerNewAccount($email, $ref = '804UlueSPt')
  190. {
  191.     global $client, $headers, $register;
  192.  
  193.     # http://linkspeedup.com/user/register/804UlueSPt
  194.    $address = sprintf('%s%s%s', BASE_URL, '/user/register/', $ref);
  195.  
  196.     $getCaptchaText = function ($address) {
  197.         global $client, $headers;
  198.  
  199.         preg_match(
  200.             '/<input type="hidden" name="capchatext" value="(.*?)"/',
  201.             $client->get(
  202.                 $address,
  203.                 [
  204.                     'headers' => array_merge(
  205.                         $headers,
  206.                         [
  207.                             'Accept-Encoding' => 'gzip,deflate',
  208.                             'Origin' => BASE_URL,
  209.                             'Referer' => $address
  210.                         ]
  211.                     )
  212.                 ]
  213.             )->getBody(),
  214.             $matches
  215.         );
  216.  
  217.         return $matches[1];
  218.     };
  219.     $captcha = $getCaptchaText($address);
  220.  
  221.     return $client->post(
  222.         $address,
  223.         [
  224.             'body' => [
  225.                 'user_name' => $register['name'],
  226.                 'user_email' => $email,
  227.                 'user_password' => $register['password'],
  228.                 'birthday_month' => $register['month'],
  229.                 'birthday_day' => $register['day'],
  230.                 'birthday_year' => $register['year'],
  231.                 'user_gender' => $register['gender'],
  232.                 'captcha' => $captcha,
  233.                 'urlref' => $register['ref'],
  234.                 'capchatext' => $captcha
  235.             ],
  236.             'headers' => array_merge(
  237.                 $headers,
  238.                 [
  239.                     'Accept-Encoding' => 'gzip,deflate',
  240.                     'Origin' => BASE_URL,
  241.                     'Referer' => $address
  242.                 ]
  243.             )
  244.         ]
  245.     )->getBody();
  246. }
  247.  
  248. /**
  249.  * 模擬使用者鍵入帳號以及密碼
  250.  * 這邊需要假裝用了點時間, 所以瀏覽器會至少觸發一次 /welcome/live_exchange ajax 請求
  251.  * 預設等待五秒後才會繼續下一個動作
  252.  *
  253.  * @param int $seconds
  254.  *
  255.  * @return \GuzzleHttp\Stream\StreamInterface|null
  256.  *
  257.  * @see https://gist.github.com/skiddie/6b512b0e1936d14187fb
  258.  */
  259. function enterLoginInfo($seconds = 5)
  260. {
  261.     global $client, $headers;
  262.  
  263.     sleep($seconds);
  264.  
  265.     return $client->get(
  266.         sprintf('%s%s', BASE_URL, '/welcome/live_exchange'),
  267.         [
  268.             'headers' => array_merge(
  269.                 $headers,
  270.                 [
  271.                     'Accept' => '*/*',
  272.                     'Referer' => sprintf('%s/', BASE_URL),
  273.                     'X-Requested-With' => 'XMLHttpRequest'
  274.                 ]
  275.             )
  276.         ]
  277.     )->getBody();
  278. }
  279.  
  280. /**
  281.  * 模擬使用者的登入行為
  282.  *
  283.  * @param string $email
  284.  * @param string $password
  285.  * @param int $remember
  286.  * @param string $redirect
  287.  *
  288.  * @return \GuzzleHttp\Stream\StreamInterface|null
  289.  *
  290.  * @see https://gist.github.com/skiddie/482c60f371b6d686c71a
  291.  */
  292. function clickLoginButton($email, $password, $remember = 1, $redirect = '')
  293. {
  294.     global $client, $headers;
  295.  
  296.     return $client->post(
  297.         sprintf('%s%s', BASE_URL, '/user/login'),
  298.         [
  299.             'body' => [
  300.                 'email' => $email,
  301.                 'password' => $password,
  302.                 'rememberme' => $remember,
  303.                 'redirect' => $redirect
  304.             ],
  305.             'headers' => array_merge(
  306.                 $headers,
  307.                 [
  308.                     'Accept-Encoding' => 'gzip,deflate',
  309.                     'Origin' => BASE_URL,
  310.                     'Referer' => sprintf('%s/', BASE_URL)
  311.                 ]
  312.             )
  313.         ]
  314.     )->getBody();
  315. }
  316.  
  317. /**
  318.  * todo: 還沒寫完 ! 官方那邊有問題就是了
  319.  */
  320. function clickBonusButton()
  321. {
  322.     global $client, $headers;
  323.  
  324.     $response = $client->post(
  325.         sprintf('%s%s', BASE_URL, '/user/bonus_points'),
  326.         [
  327.             'body' => [
  328.                 'checkbonus' => 'check'
  329.             ],
  330.             'headers' => array_merge(
  331.                 $headers,
  332.                 [
  333.                     'Referer' => sprintf('%s%s', BASE_URL, '/user/bonus_points')
  334.                 ]
  335.             )
  336.         ]
  337.     );
  338.  
  339.     checkAccountBaned($response);
  340. }
  341.  
  342. /**
  343.  * 模擬使用者於左方點擊 Facebook Likes, Youtube Favorites 或 Twitter Followers 等連結時所傳送的查詢
  344.  *
  345.  * @param int $rand
  346.  *
  347.  * @return mixed
  348.  *
  349.  * @see https://gist.github.com/skiddie/e85b3427a81266e78f5e
  350.  */
  351. function clickPointURL($rand)
  352. {
  353.     global $client, $headers, $methods;
  354.  
  355.     # http://linkspeedup.com/free_points/facebook_subscribes
  356.    $address = sprintf('%s/free_points/%s', BASE_URL, strtolower(str_replace(' ', '_', $methods[$rand])));
  357.  
  358.     $sendAjaxRequest = function ($rand, $address) {
  359.         global $client, $headers;
  360.  
  361.         return $client->get(
  362.             AJAX_URL,
  363.             [
  364.                 'query' => [
  365.                     'act' => 'getLinksList',
  366.                     'params' => sprintf('{"network":"%s", "page":"1"}', $rand),
  367.                     # 這裡把 _ 參數的值加入了隨機的秒數, 以避免可能被偵測為使用自動化工具
  368.                    '_' => round((microtime(true) * 1000) + ($rand * rand(1 * 1000, 30 * 1000)))
  369.                 ],
  370.                 'headers' => array_merge(
  371.                     $headers,
  372.                     [
  373.                         'Accept' => '*/*',
  374.                         'Referer' => $address,
  375.                         'X-Requested-With' => 'XMLHttpRequest'
  376.                     ]
  377.                 )
  378.             ]
  379.         );
  380.     };
  381.  
  382.     $client->get(
  383.         $address,
  384.         [
  385.             'headers' => array_merge(
  386.                 $headers,
  387.                 [
  388.                     'Referer' => sprintf('%s%s', BASE_URL, '/free_points')
  389.                 ]
  390.             )
  391.         ]
  392.     );
  393.  
  394.     return checkAccountBaned($sendAjaxRequest($rand, $address));
  395. }
  396.  
  397. /**
  398.  * 模擬當點擊 Like, Share, Follow 等開始的按鈕時所傳送的查詢
  399.  *
  400.  * @param int $rand
  401.  * @param int $id
  402.  * @param string $url
  403.  * @param int $network
  404.  * @param int $user_id
  405.  *
  406.  * @return mixed
  407.  *
  408.  * @see https://gist.github.com/skiddie/aa4c4ba44d925010f877
  409.  */
  410. function clickStartButton($rand, $id, $url, $network, $user_id = 0)
  411. {
  412.     global $client, $headers, $methods;
  413.  
  414.     # http://linkspeedup.com/free_points/facebook_subscribes
  415.    $address = sprintf('%s/free_points/%s', BASE_URL, strtolower(str_replace(' ', '_', $methods[$rand])));
  416.  
  417.     $response = $client->post(
  418.         AJAX_URL,
  419.         [
  420.             'body' => [
  421.                 'act' => 'getFBLikesDataBefore',
  422.                 'params' => sprintf(
  423.                     '{"id":"%s", "url":"%s", "network":"%s", "user_id":"%s"}',
  424.                     $id,
  425.                     $url,
  426.                     $network,
  427.                     $user_id
  428.                 ),
  429.                 'ci_csrf_token' => ''
  430.             ],
  431.             'headers' => array_merge(
  432.                 $headers,
  433.                 [
  434.                     'Accept' => '*/*',
  435.                     'Accept-Encoding' => 'gzip,deflate',
  436.                     'Origin' => BASE_URL,
  437.                     'Referer' => $address,
  438.                     'X-Requested-With' => 'XMLHttpRequest'
  439.                 ]
  440.             )
  441.         ]
  442.     );
  443.  
  444.     return checkAccountBaned($response);
  445. }
  446.  
  447. /**
  448.  * 模擬當將點擊視窗關閉時所傳送的查詢
  449.  *
  450.  * @param int $rand
  451.  * @param int $id
  452.  * @param string $url
  453.  * @param int $network
  454.  *
  455.  * @return mixed
  456.  *
  457.  * @see https://gist.github.com/skiddie/d5945950575fb9789c03
  458.  */
  459. function closePopupWindow($rand, $id, $url, $network)
  460. {
  461.     global $client, $headers, $methods;
  462.  
  463.     # http://linkspeedup.com/free_points/facebook_subscribes
  464.    $address = sprintf('%s/free_points/%s', BASE_URL, strtolower(str_replace(' ', '_', $methods[$rand])));
  465.  
  466.     $response = $client->post(
  467.         AJAX_URL,
  468.         [
  469.             'body' => [
  470.                 'act' => 'checkFollowed',
  471.                 'params' => sprintf('{"id":"%s", "url":"%s", "network":"%s"}', $id, $url, $network),
  472.                 'ci_csrf_token' => ''
  473.             ],
  474.             'headers' => array_merge(
  475.                 $headers,
  476.                 [
  477.                     'Accept' => '*/*',
  478.                     'Accept-Encoding' => 'gzip,deflate',
  479.                     'Origin' => BASE_URL,
  480.                     'Referer' => $address,
  481.                     'X-Requested-With' => 'XMLHttpRequest'
  482.                 ]
  483.             )
  484.         ]
  485.     );
  486.  
  487.     return checkAccountBaned($response);
  488. }
  489.  
  490. /**
  491.  * 哇哈哈 ! 這邊就是可以新增積分的函數啦 !!
  492.  *
  493.  * @param int $rand
  494.  * @param int $id
  495.  * @param string $url
  496.  * @param int $network
  497.  *
  498.  * @return mixed
  499.  *
  500.  * @see https://gist.github.com/skiddie/1c590b7fcecaac603805
  501.  */
  502. function sendFakeFollowed($rand, $id, $url, $network)
  503. {
  504.     global $client, $headers, $methods;
  505.  
  506.     # http://linkspeedup.com/free_points/facebook_subscribes
  507.    $address = sprintf('%s/free_points/%s', BASE_URL, strtolower(str_replace(' ', '_', $methods[$rand])));
  508.  
  509.     return $client->post(
  510.         AJAX_URL,
  511.         [
  512.             'body' => [
  513.                 'act' => 'updateAction',
  514.                 'params' => sprintf('{"link_id":"%s", "url":"%s", "network":"%s"}', $id, $url, $network),
  515.                 'ci_csrf_token' => ''
  516.             ],
  517.             'headers' => array_merge(
  518.                 $headers,
  519.                 [
  520.                     # 得先把 Aceept 欄位修改一下不然等下資料可能送不出去或傳不回來
  521.                    'Accept' => 'application/json, text/javascript, */*; q=0.01',
  522.                     'Accept-Encoding' => 'gzip,deflate',
  523.                     'Origin' => BASE_URL,
  524.                     'Referer' => $address,
  525.                     'X-Requested-With' => 'XMLHttpRequest'
  526.                 ]
  527.             )
  528.         ]
  529.     )->json();
  530. }
  531.  
  532. /**
  533.  * 取得該次詳細的積分點擊說明
  534.  *
  535.  * @param int $rand
  536.  * @param int $cpc
  537.  * @param int $network
  538.  * @param string $title
  539.  * @param int $m
  540.  *
  541.  * @return mixed
  542.  *
  543.  * @see https://gist.github.com/skiddie/aa339bd6164c3b2ca36c
  544.  */
  545. function getPointinfo($rand, $cpc, $network, $title, $m = 1)
  546. {
  547.     global $client, $headers, $methods;
  548.  
  549.     # http://linkspeedup.com/free_points/facebook_subscribes
  550.    $address = sprintf('%s/free_points/%s', BASE_URL, strtolower(str_replace(' ', '_', $methods[$rand])));
  551.  
  552.     $response = $client->post(
  553.         AJAX_URL,
  554.         [
  555.             'body' => [
  556.                 'act' => 'getLikeNote',
  557.                 'params' => sprintf('{"m":"%s", "cpc":"%s", "network":"%s", "title":"%s"}', $m, $cpc, $network, $title),
  558.                 'ci_csrf_token' => ''
  559.             ],
  560.             'headers' => array_merge(
  561.                 $headers,
  562.                 [
  563.                     'Accept' => '*/*',
  564.                     'Accept-Encoding' => 'gzip,deflate',
  565.                     'Origin' => BASE_URL,
  566.                     'Referer' => $address,
  567.                     'X-Requested-With' => 'XMLHttpRequest'
  568.                 ]
  569.             )
  570.         ]
  571.     );
  572.  
  573.     return checkAccountBaned($response);
  574. }
  575.  
  576. function checkAccountBaned($response)
  577. {
  578.     $html = $response->getBody();
  579.  
  580.     if (strlen(strval($html)) == 99) {
  581.         # <script type="text/javascript">window.location.href = "http://linkspeedup.com/user/login";</script>
  582.        die(sprintf('%s 可能被封鎖了 !', USERNAME) . PHP_EOL);
  583.     } else {
  584.         return $html;
  585.     }
  586. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement