全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
楼主: _____________Cc
打印 上一主题 下一主题

这样的JS脚本 肿么在linux下运行

[复制链接]
11#
 楼主| 发表于 2012-9-7 23:53:30 | 只看该作者
zheng1995 发表于 2012-9-7 23:52
session你以为就这么简单验证么?

只需post即可
12#
发表于 2012-9-7 23:53:55 来自手机 | 只看该作者
smyz 发表于 2012-9-7 23:17
无限循环list数据,post到/pt.3g.qq.com。

那list数组数据****去哪里搞得先?

腾讯的验证的不仅是验证表单
13#
发表于 2012-9-8 00:09:12 | 只看该作者
OVZ跑WIN,就可以运行ACTIVEX了
14#
发表于 2012-9-8 00:15:22 | 只看该作者
看上去挺简单的
15#
发表于 2012-9-8 04:21:41 | 只看该作者
本帖最后由 newphp 于 2012-9-8 04:55 编辑

如果你的php开启了pcntl模块的话,可以考虑用下面的代码:
  1. #!/usr/bin/env php
  2. <?php
  3. error_reporting(E_ALL);
  4. set_time_limit(0);
  5. ob_implicit_flush();

  6. $daemon = new daemon();
  7. switch ($_SERVER['argv'][1]) {
  8.         case '-n':
  9.                 $daemon->start(FALSE);
  10.         break;
  11.         case 'start':
  12.                 $daemon->start();
  13.         break;
  14.         case 'stop':
  15.                 $daemon->stop();
  16.         break;
  17.         case 'forcestop':
  18.                 $daemon->stop(SIGKILL);
  19.         break;
  20.         default:
  21.                 $daemon->tips();
  22.         break;
  23. }

  24. function main_action ()
  25. {
  26.         $phpqq = new phpqq();
  27.         $phpqq->load_config(dirname(__FILE__) . '/sids_data.php');
  28.         $phpqq->loop();
  29. }

  30. class phpqq
  31. {
  32.         private $http_status; // 记录请求返回状态
  33.         private $freq_http = 500; // 向腾迅请求的最高频率,单位毫秒
  34.         private $last_request_time = 0; // 记录上次向腾迅请求的时间
  35.         private $last_login_time = 0; //记录上次统一登陆的时间
  36.         private $freq_login; //登陆频率
  37.        

  38.         private $sids_file = './sids_data.php'; // 配置文件位置
  39.         private $sids_file_mtime = 0; // 配置文件最后修改时间
  40.         private $sid_array = array(); // sid数组
  41.         private $addon_sids = array(); // 新添加的sid
  42.        

  43.         public function __construct ($freq_login = 1800)
  44.         {
  45.                 $this->freq_login = $freq_login;
  46.         }
  47.        
  48.         public function load_config ($sids_file = '')
  49.         {
  50.                 if ($sids_file != '') {
  51.                         $this->sids_file = $sids_file;
  52.                 }
  53.                 if (file_exists($this->sids_file)) {
  54.                         require $this->sids_file;
  55.                 }
  56.                 if ($this->sids_file_mtime > 0) {
  57.                         foreach ($sid_array as $sid) {
  58.                                 if (! in_array($sid, $this->sid_array)) {
  59.                                         $this->addon_sids[] = $sid;
  60.                                 }
  61.                         }
  62.                 }
  63.                 $this->sid_array = $sid_array;
  64.                 if (! is_array($this->sid_array)) {
  65.                         $this->sid_array = array();
  66.                         $this->write_config();
  67.                 }
  68.                 clearstatcache();
  69.                 $this->sids_file_mtime = filemtime($this->sids_file);
  70.         }
  71.        
  72.         public function loop ()
  73.         {
  74.                 while (true) {
  75.                         // 当配置文件被修改时,重新载入
  76.                         clearstatcache();
  77.                         if (filemtime($this->sids_file) > $this->sids_file_mtime) {
  78.                                 $this->load_config($this->sids_file);
  79.                         }
  80.                        
  81.                         // 定时登陆
  82.                         $curr_time = time();
  83.                         if ($curr_time - $this->last_login_time > $this->freq_login) {
  84.                                 foreach ($this->sid_array as $k => $sid) {
  85.                                         $return = $this->doLogin($sid);
  86.                                         if ($return === FALSE) {
  87.                                                 $this->sid_array[$k] = '';
  88.                                                 $this->sid_array = array_filter($this->sid_array);
  89.                                                 $this->write_config();
  90.                                                 $this->log("sid: " . $sid . " 失效\n");
  91.                                         }
  92.                                         else {
  93.                                                 list ($qqnum, $qqnickname) = $return;
  94.                                                 $this->log("sid: " . $sid . " 登陆成功。 QQ: " . $qqnum . " 昵称:" . $qqnickname . "\n\n");
  95.                                         }
  96.                                 }
  97.                                 $this->last_login_time = $curr_time;
  98.                         }
  99.                        
  100.                         // 当新添加sid时,马上就登陆一次
  101.                         foreach ($this->addon_sids as $sid1) {
  102.                                 $return = $this->doLogin($sid1);
  103.                                 if ($return === FALSE) {
  104.                                         foreach ($this->sid_array as $k => $sid2) {
  105.                                                 if ($sid1 == $sid2) {
  106.                                                         $this->sid_array[$k] = '';
  107.                                                         $this->sid_array = array_filter($this->sid_array);
  108.                                                         $this->write_config();
  109.                                                         $this->log("sid: " . $sid1 . " 失效\n");
  110.                                                 }
  111.                                                 else {
  112.                                                         list ($qqnum, $qqnickname) = $return;
  113.                                                         $this->log("sid: " . $sid1 . " 登陆成功。 QQ: " . $qqnum . " 昵称:" . $qqnickname . "\n\n");
  114.                                                 }
  115.                                         }
  116.                                 }
  117.                         }
  118.                         // 清空新添加的sid
  119.                         $this->addon_sids = array();
  120.                        
  121.                         sleep(1);
  122.                 }
  123.         }
  124.        
  125.         private function write_config ()
  126.         {
  127.                 $fp = fopen($this->sids_file, "w+");
  128.                 fwrite($fp, "<?php\n\$sid_array = " . var_export($this->sid_array, TRUE) . ";");
  129.                 fclose($fp);
  130.         }
  131.        
  132.         private function doLogin ($sid, $sleep_utime = 1000)
  133.         {
  134.                 $login_url = "http://pt.3g.qq.com/s?aid=nLogin3gqqbysid&r=" . $this->randomFloat();
  135.                 $postdata = array();
  136.                 $postdata['auto'] = "1";
  137.                 $postdata['loginType'] = "1";
  138.                 $postdata['3gqqsid'] = $sid;
  139.                 $return_html = $this->curl_request($login_url, $postdata);
  140.                 if ($this->http_status != 200) {
  141.                         return FALSE;
  142.                 }
  143.                 if (preg_match("/3G_UIN=(\d+)/", $return_html, $matchs1)) {
  144.                         preg_match("/&nbsp;(.*?)&nbsp;/", $return_html, $matchs2);
  145.                         $return_array = array_merge($matchs1, $matchs2);
  146.                         unset($return_html);
  147.                         return array($matchs1[1], $matchs2[1]);
  148.                 }
  149.                 else {
  150.                         return FALSE;
  151.                 }
  152.         }
  153.         private function curl_request ($source_url, $postdata = array())
  154.         {
  155.                 if ((microtime(TRUE) - $this->last_request_time) < ($this->freq_http / 1000)) {
  156.                         usleep($this->freq_http);
  157.                 }
  158.                
  159.                 $ch = curl_init();
  160.                 curl_setopt($ch, CURLOPT_URL, $source_url);
  161.                 curl_setopt($ch, CURLOPT_HEADER, FALSE);
  162.                 curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  163.                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
  164.                 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  165.                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  166.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  167.                 curl_setopt($ch, CURLOPT_USERAGENT,
  168.                 "BlackBerry8820/4.5.0.182 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102"); //我手机的User-Agent
  169.                 if (! empty($postdata)) {
  170.                         $postdata = http_build_query($postdata);
  171.                         curl_setopt($ch, CURLOPT_POST, TRUE);
  172.                         curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  173.                 }
  174.                 $return_html = curl_exec($ch);
  175.                 $curl_info = curl_getinfo($ch);
  176.                 curl_close($ch);
  177.                 $this->http_status = $curl_info['http_code'];
  178.                 unset($source_url, $ch, $curl_info);
  179.                
  180.                 $this->last_request_time = microtime(TRUE);
  181.                
  182.                 return $return_html;
  183.         }
  184.        
  185.         private function randomFloat ($min = 0, $max = 1)
  186.         {
  187.                 return $min + mt_rand() / mt_getrandmax() * ($max - $min);
  188.         }
  189.        
  190.         private function log ($text)
  191.         {}
  192. }

  193. class daemon
  194. {
  195.        
  196.         private $pidfile;
  197.        
  198.         function __construct ()
  199.         {
  200.                 $this->pidfile = '/tmp/' . str_replace(".", "_", basename(__FILE__)) . '.pid';
  201.         }
  202.        
  203.         function tips ()
  204.         {
  205.                 echo "\nUsage: " . $_SERVER['_'] . " " . __FILE__ . " [start|stop]\n\n";
  206.                 exit(2);
  207.         }
  208.        
  209.         function stop ($sig = SIGTERM)
  210.         {
  211.                 // 判断进程pid文件是否存在
  212.                 if (! file_exists($this->pidfile)) {
  213.                         echo "PHP daemon is not running.\n";
  214.                         exit(0);
  215.                 }
  216.                 else {
  217.                         $pid = intval(file_get_contents($this->pidfile));
  218.                         // 判断进程是否存在
  219.                         if (! file_exists('/proc/' . $pid)) {
  220.                                 echo "PHP daemon is not running.\n";
  221.                                 @unlink($this->pidfile);
  222.                                 exit(0);
  223.                         }
  224.                         // 中止进程
  225.                         $kill_result = posix_kill($pid, $sig);
  226.                         usleep(500);
  227.                         if ($kill_result) { // 中止进程成功
  228.                                 if (file_exists('/proc/' . $pid)) { //检查进程是否还存在
  229.                                         echo "PHP daemon stop failed.\n";
  230.                                         exit(0);
  231.                                 }
  232.                                 else {
  233.                                         echo "PHP daemon stopped.\n";
  234.                                         @unlink($this->pidfile);
  235.                                         exit(0);
  236.                                 }
  237.                         }
  238.                         else { // 中止进程失败
  239.                                 echo "PHP daemon stop failed.\n";
  240.                                 exit(1);
  241.                         }
  242.                 }
  243.         }
  244.        
  245.         function start ($daemon = TRUE)
  246.         {
  247.                 $pid = pcntl_fork();
  248.                 if ($pid == - 1) {
  249.                         die('could not fork');
  250.                 }
  251.                 else {
  252.                         if ($pid) {
  253.                                 // we are the parent
  254.                                 if ($daemon === FALSE) {
  255.                                         pcntl_wait($status);
  256.                                 }
  257.                         }
  258.                         else {
  259.                                 $fork_pid = posix_getpid();
  260.                                 $length = @file_put_contents($this->pidfile, $fork_pid);
  261.                                 if ($length !== FALSE) {
  262.                                         echo "PHP daemon start successfull.\n";
  263.                                         posix_setgid(getmygid());
  264.                                         posix_setuid(getmyuid());
  265.                                         main_action();
  266.                                 }
  267.                                 echo "PHP daemon start failed.\n";
  268.                                 @unlink($this->pidfile);
  269.                         }
  270.                 }
  271.         }
  272. }
复制代码
如果有pcntl,代码加上可执行权chmod +x name.php
然后直接可以用/path/to/name.php start执行,或者放到/etc/rc.local里开始自动执行

判断有没有pcntl,执行
  1. php -i | grep pcntl
复制代码
如果没有输出那就代表不支持

如果没有pcntl的话,把daemon类去掉,并且把
  1. $daemon = new daemon();
  2. switch ($_SERVER['argv'][1]) {
  3.         case '-n':
  4.                 $daemon->start(FALSE);
  5.         break;
  6.         case 'start':
  7.                 $daemon->start();
  8.         break;
  9.         case 'stop':
  10.                 $daemon->stop();
  11.         break;
  12.         case 'forcestop':
  13.                 $daemon->stop(SIGKILL);
  14.         break;
  15.         default:
  16.                 $daemon->tips();
  17.         break;
  18. }
复制代码
换成
  1. main_action();
复制代码
然后用nohup来执行
  1. nohup /path/to/name.php > /dev/null 2>&1 &
复制代码
void log ($text)方法自己写成你自己想要的。

评分

参与人数 2威望 +25 收起 理由
_____________Cc + 20 很给力!
胖子 + 5 技术帝。膜拜、

查看全部评分

16#
发表于 2012-9-8 04:23:21 | 只看该作者
@圈圈
17#
发表于 2012-9-8 09:50:52 | 只看该作者
_____________Cc 发表于 2012-9-7 23:13
上千QQ表示压力巨大啊

看到这个数字就吓尿了。

评分

参与人数 1威望 +20 收起 理由
Kokgog + 20 淡定

查看全部评分

18#
发表于 2012-9-8 09:57:55 | 只看该作者
這個是nodejs腳本 安裝好nodejs後運行 node /path/to/your/script即可
19#
发表于 2012-9-8 10:42:08 | 只看该作者
shadownee 发表于 2012-9-8 09:57
這個是nodejs腳本 安裝好nodejs後運行 node /path/to/your/script即可

楼主那个是win下的jscript.....node没ActiveXObject的.....

评分

参与人数 2威望 +40 收起 理由
慕容咩咩 + 20 有JS的地方,就有圈圈。。。
smyz + 20 圈圈

查看全部评分

20#
发表于 2012-9-8 11:08:19 | 只看该作者
看到了ActiveXObject
用wine上ie吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-10-30 08:13 , Processed in 0.070263 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表