C # It is easy to pay automatically when connecting to China Telecom,

Source: Internet
Author: User

C # It is easy to pay automatically when connecting to China Telecom,

He has such a JS PassGuardCtrl. js Code 1 defaults: {2 obj: null, 3 random: null, // number of random factors 4 hidPwdName: 'Password', // hide the name of the password box, used to save the encrypted password value 5 outInputClass: '', // The position 6 params: {// additional attribute to be written in the password input box, optional 7 pgePath :". /ocx/", // control file directory 8 pgeId:" _ ocx_password ", // Control ID 9 pgeEdittype: 0, // control type, 0 asterisks, 1 plaintext 10 pgeEreg1: "[\ s \ S] *", // The character type Limit During the input process is 11. pgereg2: "[\ s \ S] {6, 50 }", // when the input is complete, the character type judgment condition 12 pgmaxlength: 50, // The maximum allowed input length is 13 pgeTabindex: 2, // Tab key Order 14 pgeClass: "ocx_style", // control css style 15 pginstallclass: "ocx_style", // for installation or upgrade of 16 pgonkeydown: "FormSubmit ()", // return key response function 17 tabCallback: "_ ocx_password2" 18} This js Code initializes the password control. in the background, I will change it to C #'s _ setRandom: function () {if (null = this. settings. random) {alert ("error: random is empty"); return false;} this. object. pwdSetSk (this. settings. random); return true ;}} pwdSetSk: function (s) {if (this. checkInsta Ll () {try {var control = document. getElementById (this. settings. pgid); if (this. osBrowser = 1 | this. osBrowser = 3 | this. osBrowser = 6 | this. osBrowser = 8) {control. input1 = s;} else if (this. osBrowser = 2 | this. osBrowser = 4 | this. osBrowser = 5) {control. input (1, s) ;}} catch (err) {}} this js file sets the random factor of the security control to operate on the input1 pwdResult: function () of the security control () {var code = ''; if (! This. checkInstall () {code = '';} else {try {var control = document. getElementById (this. settings. pgid); if (this. osBrowser = 1 | this. osBrowser = 3) {code = control. output1;} else if (this. osBrowser = 2 | this. osBrowser = 4 | this. osBrowser = 5) {code = control. output (7);} else if (this. osBrowser = 6 | this. osBrowser = 8) {code = control. get_output1 () ;}} catch (err) {code = '';}}// alert (Code); return code;}, this file is our main character, that is, when we enter the content in the security control, our password is automatically encrypted. however, the added password is not the submitted ciphertext, and a BASE64 encryption function setPwdVal (clazz) {var _ $ = jQuery; _ $ ("input. "+ clazz ). each (function (I, n) {var _ objId = _ $ (n ). attr ("objId"); var _ code = null; var control = _ $ ("#" + _ objId) [0]; _ code = window ["PassGuardCtrl" + control. id. split ("-") [0]. toLocaleLowerCase ()]. pwdResult (); // _ code = Base64.encoder (_ code); _ code = BASE64.enc Oder (_ code); _ $ (n ). val (_ code) ;}) ;}in this method, we can see that a BASE64 encryption is used, after the above steps. we can encrypt our passwords as we did when submitting them. We may have used the security controls in, basically, right-click the toolbar and choose "select item"> "COM component"> "select the corresponding component." OK ". However, unfortunately, when you drag the control to the interface, your VS collapsed. I used vs2005 and vs2008 vs2010 and vs2013, but I couldn't find a good solution. I could only create it manually. This is an estimate of the key points. I guess this is the security of the control that caused VS to crash. In the past, the support payment assistant was the same as that of the control. I found that the control is actually the same, but it only has different names, (it should be that the telecom and mobile projects are outsourced to the same company, huh, huh) Now paste the key code segment of the password and encryption method, public static String GetPayPass (AxPassGuardCtrlLi B. axPassGuard paypwd, String random) {paypwd. input1 = random; paypwd. edittype = 0; paypwd. maxlength = 50; paypwd. input2 = "[\ s \ S] *"; // The character type is limited to paypwd. input13 = "[\ s \ S] {6, 50}"; String strPwd = paypwd. output1; paypwd. clearSeCtrl (); return EncodeBase64 (strPwd);} the random factor is large. You can find it on the page you log on to. This is not the same, every time you refresh the page, it seems to be different. When you refresh the page, all of us need to log on to the homepage and request the following random factor. Below are some of my login methods. internal void Login () {String Result = ""; net. Url = "https:// B .bestpay.com.cn/bppf/login.do? Method = login "; net. method = NetHelper. requestMethod. GET; net. isStream = false; Result = net. sendRequest (); if (Result. startsWith ("-1") {LastError = "unable to connect to the server"; return;} String random = Utils. getValue (Result, "pwdSetSk \ (\" "," \ ""); Utils. setPassword (PassGuard, LoginPass); net. url = "https:// B .bestpay.com.cn/bppf/vimage.do? 0. "+ Utils. GetUnixTime (); net. Referer =" https:// B .bestpay.com.cn/bppf/login.do? Method = login "; net. isStream = true; net. method = NetHelper. requestMethod. GET; net. sendRequest (); if (net. IOStream = null) {LastError = "failed to obtain the verification code"; return;} Bitmap bmp = new Bitmap (net. IOStream); String chkCode = Captcha. getCheckString (bmp); // check the verification code. net. url = "https:// B .bestpay.com.cn/bppf/verifyCode"; net. postData = "verifyCode =" + chkCode; net. isStream = false; net. method = NetHelper. requestMeth Od. POST; Result = net. SendRequest (); if (Result. StartsWith ("-1") | Result! = "True") {LastError = "unable to connect to the server"; return;} String LoginPwd = Utils. getPayPass (PassGuard, random); net. url = "https:// B .bestpay.com.cn/bppf/login.do"; net. postData = "signature = & certSN = & toURL = & TOURL_MENUID = & sysLoginType = BPPF & username =" + MerchantId + "& password =" + LoginPwd + "& method = login & verifyCode = "+ chkCode; net. method = NetHelper. requestMethod. POST; net. encode = "gbk"; net. isStream = false; Result = net. sendRequest (); LastError = Result; if (Result. contains ("Merchant ID:" + MerchantId) {IsLogin = true; dAmt0 = Convert. toDecimal (Utils. getValue (Result, "account balance: <span class = \" property-amount \ ">", "</span>"); dAmt1 = Convert. toDecimal (Utils. getValue (Result, "available balance: <span class = \" property-amount \ ">", "</span>"); dAmt2 = Convert. toDecimal (Utils. getValue (Result, "balance: <span class = \" property-amount \ ">", "</Span>"); dAmt3 = Convert. toDecimal (Utils. getValue (Result, "frozen amount: <span class = \" property-amount \ ">", "</span> "));}} mobile phone recharge Order Method internal Boolean MobilePay (order Order, ref String msg) {Boolean isSuccess = false; for (int I = 0; I <3; I ++) {String Result = ""; net. url = "https:// B .bestpay.com.cn/bppf/ipos/mobilerecharge.do? Method = process "; net. method = NetHelper. requestMethod. POST; net. postData = "mobile =" + order. account + "& otherMoney =" + order. price + "& moneyText ="; net. isStream = false; Result = net. sendRequest (); if (Result. startsWith ("-1") {continue;} if (! Result. contains ("Please check the carrier information, recharge number, and amount to avoid filling errors") {continue;} String random = Utils. getValue (Result, "pwdSetSk \ (\" "," \ ""); String token = Utils. getValue (Result, "\" org. apache \\. struts \\. taglib \\. html \\. TOKEN \ "", "type"); token = Utils. getValue (Result, "value = \"","\""). trim (); String phone = Utils. getValue (Result, "name = \" phone \ "value = \"","\""). trim (); String money = Utils. getValue (Result, "name = \" Money \ "value = \"","\""). trim (); String txnAmount = Utils. getValue (Result, "name = \" txnAmount \ "value = \"","\""). trim (); String poundage = Utils. getValue (Result, "name = \" poundage \ "value = \"","\""). trim (); Utils. setPassword (PassGuard, PayPass); if (order. account! = Phone) {msg = "recharge account token tampering"; return false;} if (order. Price! = Money) {msg = "Recharge Amount tampering"; return false;} String PayPwd = Utils. GetPayPass (PassGuard, random); net. Url = "https:// B .bestpay.com.cn/bppf/ipos/mobilerecharge.do? Method = checkPayPwd & payPwd = "+ PayPwd; net. method = NetHelper. requestMethod. POST; net. postData = ""; net. isStream = false; Result = net. sendRequest (); Log. write (Result, "debut.txt"); net. url = "https:// B .bestpay.com.cn/bppf/ipos/mobilerecharge.do? Method = confirm "; net. method = NetHelper. requestMethod. POST; net. postData = String. format ("org.apache.struts.taglib.html. TOKEN = {0} & phone = {1} & money = {2} & txnAmount = {3} & poundage = {4} & receivePhone = {5} & payPwd = {6 }", token, phone, money, txnAmount, poundage, phone, PayPwd); Log. write (net. postData, "debug.txt"); net. isStream = false; Result = net. sendRequest (); if (Result. contains ("recharge successful") {msg = "payment order successful"; return true;} msg = Utils. getValue (Result, "cause of recharge failure: </span> <span class = \" title \ "style = \" color: red; \ "> ", "</span>"); Log. write (Result, "debut.txt");} return isSuccess ;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.