乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      C#/winform 騰訊QQ注冊(cè)

       昵稱(chēng)10504424 2013-02-19
      今日不知為何,總有點(diǎn)感慨人生。做了程序猿已經(jīng)差不多快2年了,除了工作上的軟件之外,貌似從來(lái)沒(méi)為自己做過(guò)什么實(shí)用的軟件,比如一些快捷的工具等等。感覺(jué)著編程技術(shù)在工作上確實(shí)很難學(xué)到。特別是國(guó)內(nèi)的公司,盡管更新的技術(shù),更優(yōu)秀的技術(shù)誕生了,可我們還是依然用著以前的技術(shù),某些簡(jiǎn)單的技術(shù),反反復(fù)復(fù)。很難找到一些挑戰(zhàn)性的元素。于是,就找點(diǎn)有意思的事情來(lái)做做吧。

      騰訊QQ無(wú)疑已經(jīng)是國(guó)內(nèi)即時(shí)通訊軟件的的巨頭了. 相當(dāng)于國(guó)外的MSN。圍繞著騰訊QQ的軟件也非常多非常多,例如自動(dòng)回復(fù)軟件.群發(fā)消息軟件等等。今天,我們就以騰訊QQ的注冊(cè)為案列實(shí)現(xiàn)一個(gè)只需要輸入驗(yàn)證碼就能注冊(cè)的C#版軟件。

      首先我們看看騰訊QQ的注冊(cè)頁(yè)面



      根據(jù)這個(gè)頁(yè)面,我們可以了解到,注冊(cè)一個(gè)QQ的基本元素。 昵稱(chēng),密碼,性別,生日,所在地,驗(yàn)證碼(一般第一次打開(kāi)這個(gè)頁(yè)面時(shí)沒(méi)有驗(yàn)證碼),還有立即注冊(cè)的提交按鈕。

      在這之前,我們需要這邊一個(gè)抓包工具來(lái)抓取POST包 IE HttpAnalyzer V6



      安裝后在IE瀏覽器的工具里可以找到,如上圖所示。具體用法請(qǐng)百度了。這里將不再講述。

      PS:剛剛抓包才發(fā)現(xiàn),我的IE HttpAnalyzer已經(jīng)過(guò)期了。將就用HttpWatch吧。其實(shí)用哪個(gè)都一樣。。

      抓包結(jié)果如圖





      我們主要關(guān)注POST提交這一段就可以了。如圖



      圖片可能小了。看不清楚,附上文字

      下面是提交POST的信息

      POST /cgi-bin/chs/numreg/get_acc?r=0.6192339314225849 HTTP/1.1
      Accept: */*
      Accept-Language: zh-cn
      Referer: http://zc.qq.com/chs/index.html
      Accept-Encoding: gzip, deflate
      User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
      Host: zc.qq.com
      Content-Length: 487
      Connection: Keep-Alive
      Cache-Control: no-cache
      Cookie: pt2gguin=o2863947406; pgv_pvid=7187609245; RK=4/CD46/CsN; ptui_loginuin=617975284; uin=o2863947406; skey=@qeJO2b28Y; ptisp=ctc; pgv_info=ssid=s4156213344; o_cookie=2863947406; verifysession=h00168891a5a6d40916b6ff218c92710d21caffe26443b349cba00a65b3849c8105588840fd02f67123; machineCookie=655f408c42841e99c57598d3968eebf866fa30383ff98073; zc_uid=1350381363_1822484793; sessionCookie=a20b4ac684c8f95844944206dec3534fa154a2929499851a; uoc=0-0-9-0-10-0-0-19; _new_uin=2863947406; wdl=57fe92992131b79c8df28eea424ac528a95c183264a47555; clientkey=b3c7928a115950440deb11c9e59c7f7c1fd8459b8592f2c2; index_ec=0; nick=sdfsdf

      &verifycode=ovur&qzone_flag=1&country=1&province=44&city=3&isnongli=0&year=1995&month=3&day=3&isrunyue=0&password=b0b81bd39cc122dc2389abd9a6753c474ffc5cd44b29c6fae65a82d0dc9926d0ae52cfad3e70d2801f81d9fbbdaed68880d1af187d246af698ecb25c7d38795579be20cf9d553c3a9e9c70b205a8152aebd22449e0d253296d94eecad82e9583380d76dce6d91bf3760acc44e4f71ba55026e32cd9ae3601f017b757ca4bb63d&phone_num=&nick=sdfsdf&email=false&other_email=false&elevel=1&sex=1&qzdate=&jumpfrom=58030&csloginstatus=0&r5d8=w5g8

      下面是提交完成后返回的數(shù)據(jù)

      HTTP/1.1 200 OK
      Server: QZHTTP-2.12
      Date: Thu, 18 Oct 2012 02:43:42 GMT
      UUID: 0
      Content-Length: 61
      Set-Cookie:_new_uin=1791969847; Domain=zc.qq.com; Path=/
      Set-Cookie:sessionCookie=; Domain=zc.qq.com; Path=/
      Set-Cookie:wdl=0341a2fea2414c9b26097c75206bb7339a25631b7f6860c5; Domain=zc.qq.com; Expires=Thu, 18 Oct 2012 03:43:42 GMT; Path=/; HTTPOnly
      Set-Cookie:clientkey=bf972ece0ce54040c485d69242c3d588d7fa22a82773ffc6; Domain=zc.qq.com; Path=/
      Content-Type: text/html
      Connection: keep-alive

      {"ec":0,"safeverifyResult":"1","type":"0","uin":"1791969847"}

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

      分析提交的數(shù)據(jù)

      &verifycode=ovur&qzone_flag=1&country=1&province=44&city=3&isnongli=0&year=1995&month=3&day=3&isrunyue=0&password=b0b81bd39cc122dc2389abd9a6753c474ffc5cd44b29c6fae65a82d0dc9926d0ae52cfad3e70d2801f81d9fbbdaed68880d1af187d246af698ecb25c7d38795579be20cf9d553c3a9e9c70b205a8152aebd22449e0d253296d94eecad82e9583380d76dce6d91bf3760acc44e4f71ba55026e32cd9ae3601f017b757ca4bb63d&phone_num=&nick=sdfsdf&email=false&other_email=false&elevel=1&sex=1&qzdate=&jumpfrom=58030&csloginstatus=0&r5d8=w5g8

      verifycode:驗(yàn)證碼

      qzone_flag:是否開(kāi)通空間,1代表開(kāi)通0不開(kāi)通

      &country=1&province=44&city=3&isnongli=0&year=1995&month=3&day=3:這些你們懂的。。

      isrunyue=0:不知道什么,估計(jì)是一個(gè)固定值

      password::密碼你懂得后面是加密過(guò)密碼的字符串

      &phone_num=&nick=sdfsdf&email=false&other_email=false&elevel=1&sex=1&qzdate=&jumpfrom=58030&csloginstatus=0&r5d8=w5g8:這些就不說(shuō)了。估計(jì)你不知道的參數(shù)保持原樣,我們只替換知道的參數(shù)就行

      分析返回的結(jié)果

      {"ec":0,"safeverifyResult":"1","type":"0","uin":"1791969847"}

      ec:返回的標(biāo)志代碼,初步預(yù)測(cè)如下:

      case 0: 注冊(cè)成功;

      case 1: EMAIL注冊(cè)成功;

      case 2: 驗(yàn)證碼錯(cuò)誤;

      case 4:case 5:case 6: 生日或省份錯(cuò)誤;

      case 8:case 9: EMAIL錯(cuò)誤;

      case 13:case 15:昵稱(chēng)錯(cuò)誤;

      case 20: 需要手機(jī)短信驗(yàn)證;
      原因:可能是COOKIE錯(cuò)誤

      case 21: 惡意注冊(cè),暫時(shí)禁止;
      原因:注冊(cè)的賬號(hào)過(guò)多,或RSA算法錯(cuò)誤

      case 26: 需要手機(jī)激活;
      原因:相同IP注冊(cè)過(guò)多或提交的COOKIE已經(jīng)過(guò)期,或SESSION超時(shí)

      case 30: 瀏覽器不兼容;



      safeverifyResult:驗(yàn)證碼通過(guò)

      type:真心不知

      uin:很明顯,QQ號(hào)碼

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

      接下來(lái)我們就是要模擬數(shù)據(jù)了,在這之前,我們需要獲得一些元素

      第一:URL分析

      地址:【+ 0.161        !    0.019    944    304    GET    200    html    http://zc.qq.com/cgi-bin/chs/numreg/init?r=0.5402871509444349&cookieCode=undefined】

      分析:返回結(jié)果 -》{"city":"娣卞湷","cityid":"3","country":"涓浗","countryid":"1","ec":0,"elevel":"1","localdate":"2012-10-18","province":"騫夸笢","provinceid":"44"}

               utf-8編碼之后,就是正常的了。看字面上的意思,我相信你們理解的。

                參數(shù)r:隨機(jī)數(shù),準(zhǔn)確的來(lái)說(shuō)是  0.(+16個(gè)隨機(jī)數(shù))[不寫(xiě)貌似也可能獲得]

               cookiecode:cookie代碼,直接忽略吧。不管它

      驗(yàn)證碼:  【 0.244        !    0.039    630    2812    GET    200    jpeg    http://captcha.qq.com/getimage?aid=1007901&r=0.7166559025129264】
      分析:aid是當(dāng)前的版本,r是隨機(jī)數(shù)

      Post地址:【+ 0.000        !    0.166    1459    564    POST    200    html    http://zc.qq.com/cgi-bin/chs/numreg/get_acc?r=0.6192339314225849】

      分析:沒(méi)什么好說(shuō)的。

      第二:密碼分析

      根據(jù):password=b0b81bd39cc122dc2389abd9a6753c474ffc5cd44b29c6fae65a82d0dc9926d0ae52cfad3e70d2801f81d9fbbdaed68880d1af187d246af698ecb25c7d38795579be20cf9d553c3a9e9c70b205a8152aebd22449e0d253296d94eecad82e9583380d76dce6d91bf3760acc44e4f71ba55026e32cd9ae3601f017b757ca4bb63d

      很明顯,經(jīng)過(guò)加密的,到底使用什么加密呢?????

      通常,如果是我們寫(xiě)注冊(cè)模塊的話。會(huì)把加密文件寫(xiě)在哪里呢???

      沒(méi)錯(cuò),不用懷疑,就是JS。。。JS。

      根據(jù)我們的預(yù)測(cè),我們來(lái)look,look我們抓包的頁(yè)面的js下載的URL(帶上你們的火眼look,look)



      相信不用一分鐘的實(shí)現(xiàn),你們就發(fā)現(xiàn)了 simple.js,rsa.js,index.js 我了個(gè)去。夠明顯吧。 rsa.js…..

      預(yù)測(cè)90%是rsa加密了。

      index.js  做網(wǎng)站的人大部分都知道…這個(gè)文件的含義是什么…。很明顯,也是90%通過(guò)這個(gè)文件提交表單數(shù)據(jù),然后再這個(gè)文件里面條用rsa.js進(jìn)行加密。

      (PS:剩下10%大家去研究吧..仔細(xì)看看文件里面的內(nèi)容)

      本人也在研究中…………………….

      大約看了10分鐘的樣子,肯定加一定:rsa.js加密

      細(xì)心的你們肯定還會(huì)發(fā)現(xiàn)…他是這樣調(diào)用的。。。

      rsaEncrypt:function(a)

      {

      var b=new RSAKey;b.setPublic("C4D23C2DB0ECC904FE0CD0CBBCDC988C039D79E1BDA8ED4BFD4D43754EC9693460D15271AB43A59AD6D0F0EEE95424F70920F2C4A08DFDF03661300047CA3A6212E48204C1BE71A846E08DD2D9F1CBDDFF40CA00C10C62B1DD42486C70A09C454293BCA9ED4E7D6657E3F62076A14304943252A88EFA416770E0FBA270A141E7","10001");

      return b.encrypt(a)

      }

      ok,ok,到這里。我們及知道了rsa.js加密js文件,也知道了調(diào)用的方法…那就是說(shuō)。。密碼這一關(guān),過(guò)了!!?。?



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

      萬(wàn)事俱備,只欠東風(fēng)?。。。?!

      分析就此完成,現(xiàn)在開(kāi)始編碼…………….

      新建winform程序。。拖點(diǎn)控件啥的就不說(shuō)了…直接切入主題



      第一:準(zhǔn)備js

      拷貝rsa.js的內(nèi)容,在后面加個(gè)方法,如下:

      function parseBigInt(a, b) { return new BigInteger(a, b) } function linebrk(a, b) { for (var c = "", d = 0; d + b < a.length; ) c += a.substring(d, d + b) + "\n", d += b; return c + a.substring(d, a.length) } function byte2Hex(a) { return a < 16 ? "0" + a.toString(16) : a.toString(16) }function pkcs1pad2(a, b) { if (b < a.length + 11) return uv_alert("Message too long for RSA"), null; for (var c = [], d = a.length - 1; d >= 0 && b > 0; ) { var e = a.charCodeAt(d--); e < 128 ? c[--b] = e : e > 127 && e < 2048 ? (c[--b] = e & 63 | 128, c[--b] = e >> 6 | 192) : (c[--b] = e & 63 | 128, c[--b] = e >> 6 & 63 | 128, c[--b] = e >> 12 | 224) } c[--b] = 0; d = new SecureRandom; for (e = []; b > 2; ) { for (e[0] = 0; e[0] == 0; ) d.nextBytes(e); c[--b] = e[0] } c[--b] = 2; c[--b] = 0; return new BigInteger(c) } function RSAKey() { this.n = null; this.e = 0; this.coeff = this.dmq1 = this.dmp1 = this.q = this.p = this.d = null }function RSASetPublic(a, b) { a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16)) : uv_alert("Invalid RSA public key") } function RSADoPublic(a) { return a.modPowInt(this.e, this.n) } function RSAEncrypt(a) { a = pkcs1pad2(a, this.n.bitLength() + 7 >> 3); if (a == null) return null; a = this.doPublic(a); if (a == null) return null; a = a.toString(16); return (a.length & 1) == 0 ? a : "0" + a }RSAKey.prototype.doPublic = RSADoPublic;RSAKey.prototype.setPublic = RSASetPublic;RSAKey.prototype.encrypt = RSAEncrypt;var dbits, canary = 244837814094590, j_lm = (canary & 16777215) == 15715070; function BigInteger(a, b, c) { a != null && ("number" == typeof a ? this.fromNumber(a, b, c) : b == null && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b)) } function nbi() { return new BigInteger(null) } function am1(a, b, c, d, e, f) { for (; --f >= 0; ) { var g = b * this[a++] + c[d] + e, e = Math.floor(g / 67108864); c[d++] = g & 67108863 } return e }function am2(a, b, c, d, e, f) { var g = b & 32767; for (b >>= 15; --f >= 0; ) { var h = this[a] & 32767, i = this[a++] >> 15, k = b * h + i * g, h = g * h + ((k & 32767) << 15) + c[d] + (e & 1073741823), e = (h >>> 30) + (k >>> 15) + b * i + (e >>> 30); c[d++] = h & 1073741823 } return e } function am3(a, b, c, d, e, f) { var g = b & 16383; for (b >>= 14; --f >= 0; ) { var h = this[a] & 16383, i = this[a++] >> 14, k = b * h + i * g, h = g * h + ((k & 16383) << 14) + c[d] + e, e = (h >> 28) + (k >> 14) + b * i; c[d++] = h & 268435455 } return e }j_lm = true; BigInteger.prototype.am = am2; dbits = 30; BigInteger.prototype.DB = dbits; BigInteger.prototype.DM = (1 << dbits) - 1; BigInteger.prototype.DV = 1 << dbits; var BI_FP = 52; BigInteger.prototype.FV = Math.pow(2, BI_FP); BigInteger.prototype.F1 = BI_FP - dbits; BigInteger.prototype.F2 = 2 * dbits - BI_FP; var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz", BI_RC = [], rr, vv;rr = "0".charCodeAt(0); for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv; rr = "a".charCodeAt(0); for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; rr = "A".charCodeAt(0); for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; function int2char(a) { return BI_RM.charAt(a) } function intAt(a, b) { var c = BI_RC[a.charCodeAt(b)]; return c == null ? -1 : c } function bnpCopyTo(a) { for (var b = this.t - 1; b >= 0; --b) a[b] = this[b]; a.t = this.t; a.s = this.s } function bnpFromInt(a) { this.t = 1; this.s = a < 0 ? -1 : 0; a > 0 ? this[0] = a : a < -1 ? this[0] = a + DV : this.t = 0 }function nbv(a) { var b = nbi(); b.fromInt(a); return b }function bnpFromString(a, b) {    var c; if (b == 16) c = 4; else if (b == c = 3; else if (b == 256) c = 8; else if (b == 2) c = 1; else if (b == 32) c = 5; else if (b == 4) c = 2; else { this.fromRadix(a, b); return } this.s = this.t = 0; for (var d = a.length, e = false, f = 0; --d >= 0; ) { var g = c == 8 ? a[d] & 255 : intAt(a, d); g < 0 ? a.charAt(d) == "-" && (e = true) : (e = false, f == 0 ? this[this.t++] = g : f + c > this.DB ? (this[this.t - 1] |= (g & (1 << this.DB - f) - 1) << f, this[this.t++] = g >> this.DB - f) : this[this.t - 1] |= g << f, f += c, f >= this.DB && (f -= this.DB)) } if (c == 8 && (a[0] & 128) != 0) this.s = -1, f > 0 && (this[this.t -1] |= (1 << this.DB - f) - 1 << f); this.clamp(); e && BigInteger.ZERO.subTo(this, this)} function bnpClamp() { for (var a = this.s & this.DM; this.t > 0 && this[this.t - 1] == a; ) --this.t }function bnToString(a) { if (this.s < 0) return "-" + this.negate().toString(a); if (a == 16) a = 4; else if (a == a = 3; else if (a == 2) a = 1; else if (a == 32) a = 5; else if (a == 4) a = 2; else return this.toRadix(a); var b = (1 << a) - 1, c, d = false, e = "", f = this.t, g = this.DB - f * this.DB % a; if (f-- > 0) { if (g < this.DB && (c = this[f] >> g) > 0) d = true, e = int2char(c); for (; f >= 0; ) g < a ? (c = (this[f] & (1 << g) - 1) << a - g, c |= this[--f] >> (g += this.DB - a)) : (c = this[f] >> (g -= a) & b, g <= 0 && (g += this.DB, --f)), c > 0 && (d = true), d && (e += int2char(c)) } return d ? e : "0" }function bnNegate() { var a = nbi(); BigInteger.ZERO.subTo(this, a); return a } function bnAbs() { return this.s < 0 ? this.negate() : this } function bnCompareTo(a) { var b = this.s - a.s; if (b != 0) return b; var c = this.t, b = c - a.t; if (b != 0) return b; for (; --c >= 0; ) if ((b = this[c] - a[c]) != 0) return b; return 0 } function nbits(a) { var b = 1, c; if ((c = a >>> 16) != 0) a = c, b += 16; if ((c = a >> != 0) a = c, b += 8; if ((c = a >> 4) != 0) a = c, b += 4; if ((c = a >> 2) != 0) a = c, b += 2; a >> 1 != 0 && (b += 1); return b }function bnBitLength() { return this.t <= 0 ? 0 : this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM) } function bnpDLShiftTo(a, b) { var c; for (c = this.t - 1; c >= 0; --c) b[c + a] = this[c]; for (c = a - 1; c >= 0; --c) b[c] = 0; b.t = this.t + a; b.s = this.s } function bnpDRShiftTo(a, b) { for (var c = a; c < this.t; ++c) b[c - a] = this[c]; b.t = Math.max(this.t - a, 0); b.s = this.s }function bnpLShiftTo(a, b) { var c = a % this.DB, d = this.DB - c, e = (1 << d) - 1, f = Math.floor(a / this.DB), g = this.s << c & this.DM, h; for (h = this.t - 1; h >= 0; --h) b[h + f + 1] = this[h] >> d | g, g = (this[h] & e) << c; for (h = f - 1; h >= 0; --h) b[h] = 0; b[f] = g; b.t = this.t + f + 1; b.s = this.s; b.clamp() }function bnpRShiftTo(a, b) { b.s = this.s; var c = Math.floor(a / this.DB); if (c >= this.t) b.t = 0; else { var d = a % this.DB, e = this.DB - d, f = (1 << d) - 1; b[0] = this[c] >> d; for (var g = c + 1; g < this.t; ++g) b[g - c - 1] |= (this[g] & f) << e, b[g - c] = this[g] >> d; d > 0 && (b[this.t - c - 1] |= (this.s & f) << e); b.t = this.t - c; b.clamp() } }function bnpSubTo(a, b) { for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e; ) d += this[c] - a[c], b[c++] = d & this.DM, d >>= this.DB; if (a.t < this.t) { for (d -= a.s; c < this.t; ) d += this[c], b[c++] = d & this.DM, d >>= this.DB; d += this.s } else { for (d += this.s; c < a.t; ) d -= a[c], b[c++] = d & this.DM, d >>= this.DB; d -= a.s } b.s = d < 0 ? -1 : 0; d < -1 ? b[c++] = this.DV + d : d > 0 && (b[c++] = d); b.t = c; b.clamp() }function bnpMultiplyTo(a, b) { var c = this.abs(), d = a.abs(), e = c.t; for (b.t = e + d.t; --e >= 0; ) b[e] = 0; for (e = 0; e < d.t; ++e) b[e + c.t] = c.am(0, d[e], b, e, 0, c.t); b.s = 0; b.clamp(); this.s != a.s && BigInteger.ZERO.subTo(b, b) } function bnpSquareTo(a) { for (var b = this.abs(), c = a.t = 2 * b.t; --c >= 0; ) a[c] = 0; for (c = 0; c < b.t - 1; ++c) { var d = b.am(c, b[c], a, 2 * c, 0, 1); if ((a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV) a[c + b.t] -= b.DV, a[c + b.t + 1] = 1 } a.t > 0 && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1)); a.s = 0; a.clamp() }function bnpDivRemTo(a, b, c) {    var d = a.abs(); if (!(d.t <= 0)) {        var e = this.abs(); if (e.t < d.t) b != null && b.fromInt(0), c != null && this.copyTo(c); else {            c == null && (c = nbi()); var f = nbi(), g = this.s, a = a.s, h = this.DB - nbits(d[d.t - 1]); h > 0 ? (d.lShiftTo(h, f), e.lShiftTo(h, c)) : (d.copyTo(f), e.copyTo(c)); d = f.t; e = f[d - 1]; if (e != 0) {                var i = e * (1 << this.F1) + (d > 1 ? f[d - 2] >> this.F2 : 0), k = this.FV / i, i = (1 << this.F1) / i, o = 1 << this.F2, l = c.t, m = l - d, j = b == null ? nbi() : b; f.dlShiftTo(m, j); c.compareTo(j) >= 0 && (c[c.t++] = 1, c.subTo(j, c)); BigInteger.ONE.dlShiftTo(d,j); for (j.subTo(f, f); f.t < d; ) f[f.t++] = 0; for (; --m >= 0; ) { var n = c[--l] == e ? this.DM : Math.floor(c[l] * k + (c[l - 1] + o) * i); if ((c[l] += f.am(0, n, c, m, 0, d)) < n) { f.dlShiftTo(m, j); for (c.subTo(j, c); c[l] < --n; ) c.subTo(j, c) } } b != null && (c.drShiftTo(d, b), g != a && BigInteger.ZERO.subTo(b, b)); c.t = d; c.clamp(); h > 0 && c.rShiftTo(h, c); g < 0 && BigInteger.ZERO.subTo(c, c)            }         }     } } function bnMod(a) { var b = nbi(); this.abs().divRemTo(a, null, b); this.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && a.subTo(b, b); return b } function Classic(a) { this.m = a }function cConvert(a) { return a.s < 0 || a.compareTo(this.m) >= 0 ? a.mod(this.m) : a } function cRevert(a) { return a } function cReduce(a) { a.divRemTo(this.m, null, a) } function cMulTo(a, b, c) { a.multiplyTo(b, c); this.reduce(c) } function cSqrTo(a, b) { a.squareTo(b); this.reduce(b) } Classic.prototype.convert = cConvert; Classic.prototype.revert = cRevert; Classic.prototype.reduce = cReduce; Classic.prototype.mulTo = cMulTo; Classic.prototype.sqrTo = cSqrTo;function bnpInvDigit() { if (this.t < 1) return 0; var a = this[0]; if ((a & 1) == 0) return 0; var b = a & 3, b = b * (2 - (a & 15) * b) & 15, b = b * (2 - (a & 255) * b) & 255, b = b * (2 - ((a & 65535) * b & 65535)) & 65535, b = b * (2 - a * b % this.DV) % this.DV; return b > 0 ? this.DV - b : -b } function Montgomery(a) { this.m = a; this.mp = a.invDigit(); this.mpl = this.mp & 32767; this.mph = this.mp >> 15; this.um = (1 << a.DB - 15) - 1; this.mt2 = 2 * a.t }function montConvert(a) { var b = nbi(); a.abs().dlShiftTo(this.m.t, b); b.divRemTo(this.m, null, b); a.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && this.m.subTo(b, b); return b } function montRevert(a) { var b = nbi(); a.copyTo(b); this.reduce(b); return b }function montReduce(a) { for (; a.t <= this.mt2; ) a[a.t++] = 0; for (var b = 0; b < this.m.t; ++b) { var c = a[b] & 32767, d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM, c = b + this.m.t; for (a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >= a.DV; ) a[c] -= a.DV, a[++c]++ } a.clamp(); a.drShiftTo(this.m.t, a); a.compareTo(this.m) >= 0 && a.subTo(this.m, a) } function montSqrTo(a, b) { a.squareTo(b); this.reduce(b) } function montMulTo(a, b, c) { a.multiplyTo(b, c); this.reduce(c) } Montgomery.prototype.convert = montConvert;Montgomery.prototype.revert = montRevert; Montgomery.prototype.reduce = montReduce; Montgomery.prototype.mulTo = montMulTo; Montgomery.prototype.sqrTo = montSqrTo; function bnpIsEven() { return (this.t > 0 ? this[0] & 1 : this.s) == 0 } function bnpExp(a, b) { if (a > 4294967295 || a < 1) return BigInteger.ONE; var c = nbi(), d = nbi(), e = b.convert(this), f = nbits(a) - 1; for (e.copyTo(c); --f >= 0; ) if (b.sqrTo(c, d), (a & 1 << f) > 0) b.mulTo(d, e, c); else var g = c, c = d, d = g; return b.revert(c) }function bnModPowInt(a, b) { var c; c = a < 256 || b.isEven() ? new Classic(b) : new Montgomery(b); return this.exp(a, c) } BigInteger.prototype.copyTo = bnpCopyTo; BigInteger.prototype.fromInt = bnpFromInt; BigInteger.prototype.fromString = bnpFromString; BigInteger.prototype.clamp = bnpClamp; BigInteger.prototype.dlShiftTo = bnpDLShiftTo; BigInteger.prototype.drShiftTo = bnpDRShiftTo; BigInteger.prototype.lShiftTo = bnpLShiftTo; BigInteger.prototype.rShiftTo = bnpRShiftTo; BigInteger.prototype.subTo = bnpSubTo;BigInteger.prototype.multiplyTo = bnpMultiplyTo; BigInteger.prototype.squareTo = bnpSquareTo; BigInteger.prototype.divRemTo = bnpDivRemTo; BigInteger.prototype.invDigit = bnpInvDigit; BigInteger.prototype.isEven = bnpIsEven; BigInteger.prototype.exp = bnpExp; BigInteger.prototype.toString = bnToString; BigInteger.prototype.negate = bnNegate; BigInteger.prototype.abs = bnAbs; BigInteger.prototype.compareTo = bnCompareTo; BigInteger.prototype.bitLength = bnBitLength; BigInteger.prototype.mod = bnMod; BigInteger.prototype.modPowInt = bnModPowInt;BigInteger.ZERO = nbv(0); BigInteger.ONE = nbv(1); var rng_state, rng_pool, rng_pptr; function rng_seed_int(a) { rng_pool[rng_pptr++] ^= a & 255; rng_pool[rng_pptr++] ^= a >> 8 & 255; rng_pool[rng_pptr++] ^= a >> 16 & 255; rng_pool[rng_pptr++] ^= a >> 24 & 255; rng_pptr >= rng_psize && (rng_pptr -= rng_psize) } function rng_seed_time() { rng_seed_int((new Date).getTime()) } if (rng_pool == null) { rng_pool = []; rng_pptr = 0; var t; for (; rng_pptr < rng_psize; ) t = Math.floor(65536 * Math.random()), rng_pool[rng_pptr++] = t >>> 8, rng_pool[rng_pptr++] = t & 255; rng_pptr = 0; rng_seed_time() }function rng_get_byte() { if (rng_state == null) { rng_seed_time(); rng_state = prng_newstate(); rng_state.init(rng_pool); for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0; rng_pptr = 0 } return rng_state.next() } function rng_get_bytes(a) { var b; for (b = 0; b < a.length; ++b) a[b] = rng_get_byte() } function SecureRandom() { } SecureRandom.prototype.nextBytes = rng_get_bytes; function Arcfour() { this.j = this.i = 0; this.S = [] }function ARC4init(a) { var b, c, d; for (b = 0; b < 256; ++b) this.S[b] = b; for (b = c = 0; b < 256; ++b) c = c + this.S[b] + a[b % a.length] & 255, d = this.S[b], this.S[b] = this.S[c], this.S[c] = d; this.j = this.i = 0 } function ARC4next() { var a; this.i = this.i + 1 & 255; this.j = this.j + this.S[this.i] & 255; a = this.S[this.i]; this.S[this.i] = this.S[this.j]; this.S[this.j] = a; return this.S[a + this.S[this.i] & 255] } Arcfour.prototype.init = ARC4init; Arcfour.prototype.next = ARC4next; function prng_newstate() { return new Arcfour } var rng_psize = 256;   function rs(a) { var b = new RSAKey; b.setPublic("C4D23C2DB0ECC904FE0CD0CBBCDC988C039D79E1BDA8ED4BFD4D43754EC9693460D15271AB43A59AD6D0F0EEE95424F70920F2C4A08DFDF03661300047CA3A6212E48204C1BE71A846E08DD2D9F1CBDDFF40CA00C10C62B1DD42486C70A09C454293BCA9ED4E7D6657E3F62076A14304943252A88EFA416770E0FBA270A141E7", "10001"); return b.encrypt(a) }
      要想在winform中調(diào)用js….需要安裝控件

      【Microsoft Script Control 】/Winform 調(diào)用js

      沒(méi)有的,猛擊這里

      不懂怎么操作的,猛擊這里

      提示一下:

      引用的文件要把嵌入互操作類(lèi)型設(shè)為false

      第二:準(zhǔn)備HttpHelper類(lèi)

      沒(méi)有的,猛擊這里

      核心代碼頁(yè)貼出來(lái)吧,如下。。。(別人寫(xiě)的)

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.Net;
      using System.IO;
      using System.Drawing;
      using System.Text.RegularExpressions;

      namespace WindowsFormsRs
      {
          public class HttpHelper
          {
              private CookieContainer cc;

              public CookieContainer CC
              {
                  get
                  {
                      return cc;
                  }
                  set
                  {
                      this.cc = value;
                  }
              }

              public HttpHelper()
              {
                  this.cc = new CookieContainer();
              }

              public HttpHelper(CookieContainer cc)
              {
                  this.cc = cc;
              }

              ///<summary>
              /// 使用post方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回stream二進(jìn)制流
              ///</summary>
              public Stream PostAndGetStream(string targetURL, string formData, string contentType, string referer, bool allowAutoRedirect)
              {
                  //數(shù)據(jù)編碼
                  ASCIIEncoding encoding = new ASCIIEncoding();
                  //UTF8Encoding encoding = new UTF8Encoding();
                  byte[] data = encoding.GetBytes(formData);

                  //請(qǐng)求目標(biāo)網(wǎng)頁(yè)
                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetURL);
                  request.CookieContainer = cc;
                  request.Method = "POST";    //使用post方式發(fā)送數(shù)據(jù)
                  request.ContentType = "application/x-www-form-urlencoded";
                  request.Referer = referer;
                  request.AllowAutoRedirect = allowAutoRedirect;
                  request.ContentLength = data.Length;
                  request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.1124)";
                  //request.UnsafeAuthenticatedConnectionSharing = false;
                  //模擬一個(gè)UserAgent
                  Stream newStream = request.GetRequestStream();
                  newStream.Write(data, 0, data.Length);
                  newStream.Close();

                  //獲取網(wǎng)頁(yè)響應(yīng)結(jié)果
                  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                  cc.Add(response.Cookies);
                  Stream stream = response.GetResponseStream();
                  return stream;
              }

              ///<summary>
              /// 使用post方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回字節(jié)數(shù)組
              ///</summary>
              public byte[] PostAndGetByte(string targetURL, string formData, string contentType, string referer, bool allowAutoRedirect)
              {
                  Stream stream = PostAndGetStream(targetURL, formData, contentType, referer, allowAutoRedirect);
                  byte[] bytes = new byte[stream.Length];
                  stream.Read(bytes, 0, bytes.Length);
                  stream.Seek(0, SeekOrigin.Begin);
                  return bytes;
              }

              ///<summary>
              /// 使用post方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回圖片
              ///</summary>
              public Image PostAndGetBitmap(string targetURL, string formData, string contentType, string referer, bool allowAutoRedirect)
              {
                  Stream stream = PostAndGetStream(targetURL, formData, contentType, referer, allowAutoRedirect);
                  Image image = Image.FromStream(stream);
                  return image;
              }

              ///<summary>
              /// 使用post方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回文件
              ///</summary>
              public void PostAndGetBitmap(string targetURL, string formData, string contentType, string referer, bool allowAutoRedirect,string fileName)
              {
                  byte[] bytes = PostAndGetByte(targetURL, formData, contentType, referer, allowAutoRedirect);
                  FileStream fs = new FileStream(fileName, FileMode.Create);
                  BinaryWriter bw = new BinaryWriter(fs);
                  bw.Write(bytes);
                  bw.Close();
                  fs.Close();
              }

              ///<summary>
              /// 使用post方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回html頁(yè)面
              ///</summary>
              public string PostAndGetHtml(string targetURL, string formData, string contentType, string referer, bool allowAutoRedirect, Encoding encoding)
              {
                  Stream stream = PostAndGetStream(targetURL, formData, contentType, referer, allowAutoRedirect);
                  string html = new StreamReader(stream, encoding).ReadToEnd();
                  return html;
              }
             

              ///<summary>
              /// 使用get方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回stream二進(jìn)制流
              ///</summary>
              public Stream GetAndGetStream(string targetURL, string contentType, string referer, bool allowAutoRedirect)
              {
                  //請(qǐng)求目標(biāo)網(wǎng)頁(yè)
                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetURL);
                  request.CookieContainer = cc;
                  CC = cc;
                  request.Method = "GET";    //使用get方式發(fā)送數(shù)據(jù)
                  request.ContentType = contentType;
                  request.Referer = referer;
                  request.AllowAutoRedirect = allowAutoRedirect;
                  request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.1124)";


                  //獲取網(wǎng)頁(yè)響應(yīng)結(jié)果
                  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                  cc.Add(response.Cookies);
                  Stream stream = response.GetResponseStream();
                  return stream;
              }

              ///<summary>
              /// 使用get方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回字節(jié)數(shù)組
              ///</summary>
              public byte[] GetAndGetByte(string targetURL, string contentType, string referer, bool allowAutoRedirect)
              {
                  Stream stream = GetAndGetStream(targetURL, contentType, referer, allowAutoRedirect);
                  byte[] bytes = new byte[stream.Length];
                  stream.Read(bytes, 0, bytes.Length);
                  stream.Seek(0, SeekOrigin.Begin);
                  return bytes;
              }

              ///<summary>
              /// 使用get方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回圖片
              ///</summary>
              public Image GetAndGetBitmap(string targetURL, string contentType, string referer, bool allowAutoRedirect)
              {
                  Stream stream = GetAndGetStream(targetURL, contentType, referer, true);
                  Image image = Image.FromStream(stream);
                  return image;
              }

              ///<summary>
              /// 使用get方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回文件
              ///</summary>
              public void GetAndGetFile(string targetURL, string contentType, string referer, bool allowAutoRedirect, string fileName)
              {
                  byte[] bytes = GetAndGetByte(targetURL, contentType, referer, allowAutoRedirect);
                  FileStream fs = new FileStream(fileName, FileMode.Create);
                  BinaryWriter bw = new BinaryWriter(fs);
                  bw.Write(bytes);
                  bw.Close();
                  fs.Close();
              }

              ///<summary>
              /// 使用get方式訪問(wèn)目標(biāo)網(wǎng)頁(yè),返回html頁(yè)面
              ///</summary>
              public string GetAndGetHtml(string targetURL, string contentType, string referer, bool allowAutoRedirect, Encoding encoding)
              {
                  Stream stream = GetAndGetStream(targetURL, contentType, referer, allowAutoRedirect);
                  string html = new StreamReader(stream, encoding).ReadToEnd();
                  return html;
              }
          }
      }
      第三:編寫(xiě)代碼開(kāi)始

      private static HttpHelper httpHelper = new HttpHelper();
            /// <summary>
            /// 得到第一次加密后的密碼
            /// </summary>
            /// <param name="jsFilePath">js文件</param>
            /// <param name="funcName">加密的方法名</param>
            /// <param name="paramers">加密方法需要傳進(jìn)的參數(shù)(一個(gè)是密碼,另一個(gè)是頁(yè)面上可獲取的一個(gè)標(biāo)志碼)</param>
            /// <returns>加密過(guò)后的密碼</returns>
            public static object GetRSAPassword(string jsFilePath, string funcName, params object[] paramers)
            {
                StreamReader reader = new StreamReader(jsFilePath);
                string sScript = reader.ReadToEnd();
                ScriptEngine se = new ScriptEngine(ScriptLanguage.JavaScript);
                object obj = se.Run(funcName, paramers, sScript);
                return obj;
            }

            //"nick=" + name+ "&isnongli=0&isrunyue=0&appid=9&year=" + year + "&month=" + month + "&day=" + day + "&sex=" + sex+"&elevel=1&password=" + GetRSAPassword(password) + "&verifycode=" + code;
            public static string RegisterQQNum(string name, string rsapassword, string sex, string year, string month, string day, string code)
            {
                UTF8Encoding utf8 = new UTF8Encoding();
                Byte[] encodedBytes = utf8.GetBytes(name);//編碼
                name = System.Text.Encoding.UTF8.GetString(encodedBytes, 0, (int)encodedBytes.Length);
                string registerURL = "http://zc.qq.com/cgi-bin/iframe/numreg/get_acc_9";
                string postData = string.Format("nick={0}&isnongli=0&isrunyue=0&appid=9&year={1}&month={2}&day={3}&sex={4}&elevel=1&password={5}&verifycode={6}", "aaaaabbbb", year, month, day, sex, rsapassword, code);
               

               

                Debug.WriteLine(postData);
               // httpHelper.CC = new System.Net.CookieContainer();
                string html = httpHelper.PostAndGetHtml(registerURL, postData, null, null, false, Encoding.UTF8);

                //string html= htlp.GetHtml(registerURL, postData, Encoding.UTF8);
                return html;

            }


            public static string GetRandrom()
            {
                Random rand = new Random();
                string strNum = "";
                int i = 0;
                while (i<16)
                {
                    i++;
                    int randomNum = rand.Next(0,10);
                    strNum += randomNum.ToString();
                }
                strNum = "0." + strNum;
                return strNum;
            }


            public static Image GetCode()
            {
                string path = "http://captcha.qq.com/getimage?aid=1007901&"+GetRandrom();
                Image image= httpHelper.GetAndGetBitmap(path, null, null, false);
                return image;
                
            }


            public static string GetAddress()
            {
                string path = "http://zc.qq.com/cgi-bin/iframe/numreg/init_9?id="+ GetRandrom();
                string html= httpHelper.GetAndGetHtml(path, null, null, true, Encoding.UTF8);
                return html;
            }

      以上是我編寫(xiě)的代碼 .  調(diào)用而已…沒(méi)啥啥技術(shù)含量滴。。

      注冊(cè)的參數(shù)刪掉了很多,可以吧不必要的刪掉。但是需要謹(jǐn)慎操作啊…!!!



      Winform界面代碼:(上圖,總有動(dòng)手寫(xiě)幾行代碼哦,親…)



      界面效果如下:











      --------------------------------------------運(yùn)行中,下圖返回---------------------------------------





      ok,注冊(cè)成功

      大功告成 ?。?!



      HttpHelper要小小修改一下,騰訊QQ在POST提交的時(shí)候要把獲取驗(yàn)證碼的cookie一并提交上去

      但是這個(gè)HttpHelper沒(méi)有把獲取圖片的Cookie賦值到POST Cookie.

      所以要把CC=cc的代碼寫(xiě)入.





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

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多