csdn類比登陸

來源:互聯網
上載者:User

著作權聲明:原創作品,允許轉載,轉載時請務必以超連結形式標明文章原始出版、作者資訊和本聲明。否則將追究法律責任。http://blog.csdn.net/mayongzhan - 馬永占,myz,mayongzhan

首先聲明本類比不穩定,有時會出現登陸不進去.
類比的原理請參考blog.csdn.net/mayongzhan的文章,相關的知識也請參考blog.csdn.net/mayongzhan.
原來是因為csdn的metaweblog不能發布類別,所以採用類比登陸然後發布.當然也發現了不少csdn秘密,比如隱藏的用於發送垃圾郵件
的field,還有很多csdn只隱藏沒刪掉的功能.有興趣大家可以嘗試一下,看看是否被封掉.
迴歸xmlrpc了.這個東西發布出來給大家欣賞一下 by MyZ.

一些其他的hidden fields

發布到網頁
&ctl00%24cphContent%24EntryEditor1%24ckbPublished=on

允許在Blog首頁顯示
&ctl00%24cphContent%24EntryEditor1%24chkIsAggregated=on

將本文內容複寫到剪下板(只在IE下有效)
&ctl00%24cphContent%24EntryEditor1%24chkCopytoClipboard=on

顯示在我的首頁
&ctl00%24cphContent%24EntryEditor1%24chkDisplayHomePage=on

加站外好友郵件AddFriend.aspx

發郵件給站外好友
ctl00$cphContent$EntryEditor1$ckbMailTo
發短訊息給站內好友
ctl00$cphContent$EntryEditor1$ckbMessageTo
推薦個編輯
ctl00$cphContent$EntryEditor1$ckbRecommendTo

看到了吧.還有發郵件的功能,就是前一段時間出現的la圾郵件.本身如果是要推廣的話...可以試試.

本文.上代碼

--------------------------------------------------------------------------------------------

test.php

<?php
/**
 * @name test.php
 * @date Sun Jul 20 12:31:20 CST 2008
 * @copyright 馬永占(MyZ)
 * @author 馬永占(MyZ)
 * @link http://blog.csdn.net/mayongzhan/
 */

//header("Content-type: text/html;charset=utf-8");
header("Content-type: image/jpeg");
session_start();

$url = 'http://hi.csdn.net/IndexLogIn.aspx';
$url2 = 'http://hi.csdn.net/IndexLoginImage.aspx';

$post = 1;
$returntransfer = 1;
$port = 80;
$header = 0;
$nobody = 0;
$followlocation = 1;

$cookie_jar = tempnam('./tmp','cookie.txt');
$_SESSION['cookie_jar'] = $cookie_jar;

$ch = curl_init();
$options = array(CURLOPT_URL => $url,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEJAR => $cookie_jar
                 );
curl_setopt_array($ch, $options);
$temp = curl_exec($ch);
curl_close($ch);

//echo $temp;

preg_match_all('/id=/"__VIEWSTATE/" value=/"(//[0-9a-z]+)" //>/i',$temp,$tempArr);
preg_match_all('/id=/"__EVENTVALIDATION/" value=/"(//[0-9a-z+]+)" //>/i',$temp,$tempArr2);

$_SESSION['__VIEWSTATE'] = $tempArr[1][0];
$_SESSION['__EVENTVALIDATION'] = $tempArr2[1][0];

$ch2 = curl_init();
$options2 = array(CURLOPT_URL => $url2,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEFILE => $cookie_jar,
     CURLOPT_REFERER => $url
                 );
curl_setopt_array($ch2, $options2);
$temp = curl_exec($ch2);
curl_close($ch2);

echo $temp;

//$tem = file_get_contents($cookie_jar);print_r($tem);

//CURLOPT_URL是要得到內容的地址
//CURLOPT_HEADER是要得到的頭 
//CURLOPT_NOBODY是要得到的內容 
//CURLOPT_PORT是連接埠
//CURLOPT_RETURNTRANSFER是要把輸出的內容放到buffer中,可以被echo或者賦予某變數
//CURLOPT_POST是標準的提交
//CURLOPT_POSTFIELDS是提交的內容
//CURLOPT_COOKIEJAR是要儲存的cookie
//CURLOPT_COOKIEFILE是從檔案讀取cookie並提交
//CURLOPT_FOLLOWLOCATION啟用時會將伺服器伺服器返回的“Location:”放在header中遞迴的返回給伺服器
//CURLOPT_MAXREDIRS限定遞迴返回的數量
//CURLOPT_HTTPHEADER設定一個header中傳輸內容的數組
//CURLOPT_REFERER設定header中"Referer:"部分的值
//CURLOPT_USERAGENT在HTTP請求中包含一個”user-agent”頭的字串。
//CURLOPT_ENCODING設定header中“Accept-Encoding: ”部分的內容,支援的編碼格式為:"identity","deflate","gzip"。如果設定為空白字串,則表示支援所有的編碼格式
//CURLOPT_COOKIE設定HTTP請求中Set-Cookie:部分的內容
?>

--------------------------------------------------------------------------------------------

test2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="author" content="馬永占(MyZ)" />
<meta name="Copyright" content="馬永占(MyZ)" />
<meta http-equiv="Content-Language" content="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<iframe src="test.php" scrolling="No" frameborder="0" width="400px" height="100px"></iframe>
<form action="test3.php" method="POST">
VerifyCode:<input type="text" name="VerifyCode" /><br />
<input type="submit" value="登陸" />
</body>
</html>

--------------------------------------------------------------------------------------------

test3.php

<?php
/**
 * @name test3.php
 * @date Sun Jul 20 12:31:30 CST 2008
 * @copyright 馬永占(MyZ)
 * @author 馬永占(MyZ)
 * @link http://blog.csdn.net/mayongzhan/
 */

header("Content-type: text/html;charset=utf-8");
session_start();

$url = 'http://hi.csdn.net/IndexLogIn.aspx';

$post = 1;
$returntransfer = 1;
$port = 80;
$header = 0;
$nobody = 0;
$followlocation = 1;

$request = '__VIEWSTATE='.urlencode($_SESSION['__VIEWSTATE']).'&__EVENTVALIDATION='.urlencode($_SESSION['__EVENTVALIDATION']).'&UserName=testman110&UserPwd=testman111111&VerifyCode='.$_POST['VerifyCode'].'&buttonLogin='.urlencode(' 登 錄 ');

$cookie_jar = $_SESSION['cookie_jar'];

$ch = curl_init();

$options = array(CURLOPT_URL => $url,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_POST => $post,
     CURLOPT_POSTFIELDS => $request,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEJAR => $cookie_jar,
     CURLOPT_COOKIEFILE => $cookie_jar,
     CURLOPT_REFERER => $url
                 );
curl_setopt_array($ch, $options);
$temp = curl_exec($ch);
curl_close($ch);

echo $temp;
?>

--------------------------------------------------------------------------------------------

the end

php不比任何的東西差.包括已經寫出來csdn登陸的python c#.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.