dongqiyou0303 2015-01-04 15:41
浏览 158

通过tor发送cURL请求?

I have some code that sends curl requests to a website but it only has the one website in it at the moment and I don't want them wrongly banning my server IP. Is there anyway I can send those cURL requests through the tor network?

What software would I need to do it?

Running CentOS 6.5

public function checkLogin2($email, $password, $cookiefile){
        $cookiefile = 'cookies/'.$cookiefile;
        $handle = fopen($cookiefile, 'w+');
                #$proxy = 'proxy-nl.privateinternetaccess.com:1080';
                #$us = 'x9597458:Th3hXjVyuD';
        $this->_curl->setCookieFile($cookiefile);
        #$this->_curl->addOption(CURLOPT_PROXY, $proxy);
        #$this->_curl->addOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
                #$this->_curl->addOption(CURLOPT_PROXYUSERPWD, $us);
        $this->_curl->setUserAgent('FreshAndroidApp-1.3.1');
        $this->_curl->addHeader('Content-Type', 'application/x-www-form-urlencoded');
        $this->_curl->addHeader('Cookie', 'JSESSIONID=' . strtoupper(md5(time())));
        $this->_curl->addHeader('Cookie2', '$Version=1');

        try {
        $HTML = $this->_curl->post("URL HERE",
                            array('password' => $password, 
                                  'emailAddress' => $email
                            ));         

        if(!self::isJson($HTML)){
            return '{"status":"uncheck", "msg":"<font color="red"><b>Uncheck</b></font> => ' .$email.'|'.$password.'"}';

        }       
        $resp = json_decode($HTML);


        if($resp->{'status'} == "success"){
            $details = $this->_curl->get('URL HERE');
            return $details;
        } else if ($resp->{'status'} == "failure"){
            return '{"status":"failure"}';
        }
        fclose($handle);    
        } catch (CurlWrapperException $e){
            return '{"status":"socksfailure", "msg":"'.$proxy. ' => Die or timeout"}';
        }   
        fclose($handle);
    }
  • 写回答

1条回答 默认 最新

  • douju2012 2015-01-29 23:41
    关注

    You would need to install and run TOR, as explained in this link: https://www.torproject.org/docs/rpms.html.en

    Then, if your code is right (I don't know much of PHP), just do:

        $this->_curl->addOption(CURLOPT_PROXY, 127.0.0.1:9050);
        $this->_curl->addOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    

    Because TOR proxy runs by default on port 9050. You can also put another IP instead of 127.0.0.1, if you are running TOR in another machine.

    I think this should work

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题