dsgsdg206050 2011-03-10 17:33
浏览 65

使用curl登录vbullentin。 需要一些javascript工作

EDIT: solved. I missed a '&'. Trying to log into http://www.techenclave.com/forums/ using curl. This is the form:

 <form  action="http://www.techenclave.com/login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
  <input type="text" class="form-field" name="vb_login_username" accesskey="u" tabindex="101" value="User Name" onfocus="if(this.value == 'User Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'User Name';}" /> 
<More inpUT FIELDS HEre>
.
.
.
<input type="hidden" name="vb_login_md5password_utf" /> </form>

I got this so far:

$ref = "http://www.techenclave.com" ;

       define("WEBBOT_NAME", "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
        define("CURL_TIMEOUT", 25);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://www.techenclave.com/login.php?do=login") ;       // Target site
        curl_setopt ($ch, CURLOPT_COOKIEFILE, "C:/cookie-techenclave.txt");         

        curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/cookie-techenclave.txt");
        curl_setopt($ch, CURLOPT_REFERER, $ref);  
        curl_setopt($ch, CURLOPT_TIMEOUT, CURL_TIMEOUT);    // Timeout
        curl_setopt($ch, CURLOPT_USERAGENT, WEBBOT_NAME); 
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, "vb_login_username=cute.bandar&vb_login_password=".md5("mypass)"
                      ."securitytoken=guest&cookieuser=1&do=login&vb_login_md5password=&vb_login_md5password_utf=");

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);     // Follow redirects
        curl_setopt($ch, CURLOPT_MAXREDIRS, 4);             // Limit redirections to four
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);     // Return in string  

        $webpage['FILE'] = curl_exec($ch);
        curl_close($ch);
        echo $webpage['FILE'] ;

This doesn't work. Wrong username/password error. MY password is fine, me thinks the problem iscaused by this piece of javascript:

 onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)

Definition of md5hash from the javascript file:

function md5hash(B,A,E,C){
if(navigator.userAgent.indexOf("Mozilla/")==0&&parseInt(navigator.appVersion)>=4){
var D=hex_md5(str_to_ent(trim(B.value)));
A.value=D;if(E){D=hex_md5(trim(B.value));
E.value=D
} if(!C){B.value=""}}return true};

So basically the function md5hash is setting 3/4 vars before they are posted. Do I have to emulate this function is php ? Or is there some other thing that I am over looking ?

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算