模拟登录,发送amf类型数据

时间:2023-03-09 15:12:30
模拟登录,发送amf类型数据
参考 http://blog.csdn.net/amandag/article/details/5666219 以及 稍微修改了一下AMFPost的类 
 一、登录

模拟登录,发送amf类型数据

登录过程中主要用到标红的3个请求,以及响应回来的几个js文件

var Login = new Object();

var page={
DE_FROM: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_de&innerCtn=declarationCtn&innerId=declarationForm&swfHtml=bin/DEForm_application.html&swfHeight=600",
DE_DRAFT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_de&innerCtn=declarationCtn&innerId=declarationDraft&swfHtml=bin/DE_application.html&swfHeight=600",
DE_AMEN: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_de&innerCtn=declarationCtn&innerId=deInquiry&swfHtml=bin/DE_inquiry.html&swfHeight=600",
DE_AMEN_DRAFT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_de&innerCtn=declarationCtn&innerId=deAmendment&swfHtml=bin/DE_Amendment.html&swfHeight=600",
CLA_FORM: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_cla&innerCtn=claCtn&innerId=claForm&swfHtml=bin/CLAForm_application.html&swfHeight=1265",
CLA_DRAFT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_cla&innerCtn=claCtn&innerId=claDraft&swfHtml=bin/credit_limit_application.html&swfHeight=600",
CLM_CHG_PAY_TERM: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_claims&innerCtn=claimsCtn&innerId=change&swfHtml=./formSubmission/claims.jsp?claimsType=C&swfHeight=600",
CLM_EXT_DUE_DATE: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_claims&innerCtn=claimsCtn&innerId=extension&swfHtml=./formSubmission/claims.jsp?claimsType=E&swfHeight=600",
CLM_NP: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_claims&innerCtn=claimsCtn&innerId=extension&swfHtml=./formSubmission/claims.jsp?claimsType=E&swfHeight=600",
QUS_ACCT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=asq&innerCtn=asqCtn&innerId=asqForm&swfHtml=bin/QuestionnaireApp.html&swfHeight=1265",
ACCT_INFO_CHG_CNA: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=changeAccInfo&innerCtn=changeAccInfoCtn&innerId=changeAccInfoForm&swfHtml=bin/ChangeAccInfo_application.html&swfHe",
BKR_PORTFOLIO_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=portfolioAO&swfHtml=bin/BrokerPortfolio.html&swfHeight=600",
BKR_PORTFOLIO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=portfolioBkr&swfHtml=bin/BrokerPortfolioForBkr.html&swfHeight=600",
BROKERAGE_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=brokerageAO&swfHtml=bin/BrokerageEnquiryAO.html&swfHeight=650",
BROKERAGE: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=brokerageBkr&swfHtml=bin/BrokerageEnquiryBkr.html&swfHeight=600",
MAINTAIN_BKR: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=maintainBkr&swfHtml=bin/BrokerMaintain.html&swfHeight=600",
MAINTAIN_BKR_PH: "dashboard.jsp?tag=fromOther&menuId=dashmenu_broker&topId=maintainBkrPh&swfHtml=bin/BrokerMaintainPh.html&swfHeight=600",
PCY_DOC_PCY: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=pw&swfHtml=ccp/CCP.html&swfHeight=9200",
PCY_DOC_S1: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=schedule1&swfHtml=bin/scheduleOne.html&swfHeight=800",
PCY_DOC_S2_P1: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=schedule2&innerCtn=edocScheduleIICtn&innerId=edocScheduleIIPartI&swfHtml=bin/scheduleTwoPartOne.html&swfHeight=1100",
PCY_DOC_S2_P2: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=schedule2&innerCtn=edocScheduleIICtn&innerId=edocScheduleIIPartII&swfHtml=bin/ScheduleTwoPartTwo_application.html&swfHeight=2830",
PCY_DOC_S3_BYR: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=schedule3Byr&swfHtml=bin/schedule3Byr.html&swfHeight=800",
PCY_DOC_ENDR: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=endorsement&swfHtml=bin/endorsement.html&swfHeight=500",
PCY_DOC_VIEW_PSL: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=viewProposal&swfHtml=bin/ViewProposal.html&swfHeight=1150",
PCY_DOC_VIEW_PSL_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_edoc&topId=viewProposalAo&swfHtml=bin/OsProposal.html&swfHeight=700",
ERPT_DE: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=de&swfHtml=bin/ErptDe.html&swfHeight=650",
ERPT_CL: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=cl&swfHtml=bin/ErptCl.html&swfHeight=639",
ERPT_CLA: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=cla&swfHtml=bin/ErptCla.html&swfHeight=639",
ERPT_OS_INV: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=oi&swfHtml=bin/ErptOInvoice.html&swfHeight=639",
ERPT_INV: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=is&swfHtml=bin/ErptAccountsSummary.html&swfHeight=639",
ERPT_STMT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=statement&swfHtml=bin/ErptStatement.html&fromEmail=true&swfHeight=639",
ERPT_CCF: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=ccf&swfHtml=bin/ErptCcf.html&swfHeight=639",
ERPT_LA: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=loa&swfHtml=bin/ErptLaBank.html&swfHeight=639",
ERPT_CLM_RPT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=claims&swfHtml=bin/ErptClaims.html&swfHeight=650",
ERPT_RM_PH: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=rmcPh&swfHtml=bin/claimsearch_application.html&swfHeight=650",
ERPT_RM_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=rmcAo&swfHtml=bin/claimsearchforao_application.html&swfHeight=650",
ERPT_AGING: "dashboard.jsp?tag=fromOther&menuId=dashmenu_ereport&topId=svy&swfHtml=bin/ErptSvy.html&swfHeight=650",
ACCT_USER_MGT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=userAdmin&swfHtml=bin/ECLinkUsr.html&swfHeight=600",
ACCT_USER_MGT_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=aouserAdmin&swfHtml=bin/ECLinkManagement.html&swfHeight=600",
ACCT_PW_RESET: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=resetPwd&swfHtml=bin/ECICAdmin.html&swfHeight=600",
ACCT_PW_RESET_PRN: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=print&swfHtml=bin/ECLinkPrint.html&swfHeight=600",
ACCT_AO_MGT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=AOAdmin&swfHtml=bin/ECLinkAOAdmin.html&swfHeight=600",
ACCT_AUTH_MGT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_admin&topId=authManage&swfHtml=bin/AuthManage.html&swfHeight=600",
EMAIL_COMPOSE: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=composemail&swfHtml=bin/EclEmailWrite.html&swfHeight=650",
EMAIL_INBOX: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=inbox&swfHtml=bin/EclEmailInbox.html&swfHeight=800",
EMAIL_OUTBOX: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=outbox&swfHtml=bin/EclEmailOutbox.html&swfHeight=650",
EMAIL_DRAFT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=drafts&swfHtml=bin/EclEmailDraft.html&swfHeight=650",
EMAIL_TRASH: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=trash&swfHtml=bin/EclEmailTrash.html&swfHeight=650",
EMAIL_FORWARD: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=emailforward&swfHtml=bin/EclEmailForwardPH.html&swfHeight=650",
EMAIL_FORWARD_AO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=emailforwardao&swfHtml=bin/EclEmailForwardAO.html&swfHeight=650",
EMAIL_ECLINK_MSG: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=emailMaintain&swfHtml=bin/EclEmailMaintain.html&swfHeight=750",
EMAIL_SYS_PARAM: "dashboard.jsp?tag=fromOther&menuId=dashmenu_email&topId=sysparam&swfHtml=bin/EcLinkParam.html&swfHeight=650",
MISC_CHG_PW: "dashboard.jsp?tag=fromOther&menuId=dashmenu_mix&topId=changePwd&swfHtml=bin/changePwd.html&swfHeight=650",
MISC_DL_FORM: "dashboard.jsp?tag=fromOther&menuId=dashmenu_mix&topId=downloadForms&swfHtml=download.jsp&swfHeight=650",
MISC_VIEW_DEMO: "dashboard.jsp?tag=fromOther&menuId=dashmenu_mix&topId=viewDemo&swfHtml=viewDemo.jsp&swfHeight=1300",
MISC_FAQ: "dashboard.jsp?tag=fromOther&menuId=dashmenu_mix&topId=faq&swfHtml=faq.jsp&swfHeight=1300",
ANALYTICAL_RPT_DE: "dashboard.jsp?tag=fromOther&menuId=dashmenu_analyticalReport&topId=deRpt&swfHtml=bin/AnalyticalRpt_DE.html&swfHeight=650",
//ITSM#1814-Bill_by_cl ADDED BY angie
CL_ACPT: "dashboard.jsp?tag=fromOther&menuId=dashmenu_formSubmission&topId=form_cla&innerCtn=claCtn&innerId=clAcpt&swfHtml=bin/ClAcptForm.html&swfHeight=600"
} Login.url = "/eclink/LoginCheck";
Login.keyUrl = "/eclink/Key"; Login.clientIp = ""; Login.handleFailure = function(o) {
YAHOO.wait.hide();
alert(LanguageManager.LangData.service_unavailable);
}; Login.handleSuccess = function(o) {
YAHOO.wait.hide(); if (o.responseText != undefined) {
//ITSM1001 added by angie
if (o.responseText.search("notLogin") != -1) {
showFaultDialog(LanguageManager.LangData.nologin_Text);
//ITM040003-1204 [Disable inactive LA bank and broker login] by MIT23 Windy Kwok Start
} else if (o.responseText.search("Inactive") != -1) {
showInactiveDialog();
//ITM040003-1204 [Disable inactive LA bank and broker login] by MIT23 Windy Kwok End
} else if (o.responseText.search("NonePcyType") != -1) {
showNoPcyDialog();
} else if (o.responseText.search("NewExporter") != -1) {
showNewWarningDialog();
} else if (o.responseText.search("MultiplePcyNo") != -1) {
if (o.responseText.search("PH") != -1) {
showPcyTypeDialog(o.responseText.split("-"), "PH");
} else {
showPcyTypeDialog(o.responseText.split("-"), "EXPORTER");
}
showPcyTypeDialog(o.responseText.split("-"));
} else if (o.responseText.search("OnlyOnePcyNo") != -1) {
try{
//Localization Project; by Kelvin Hung; if (o.responseText.search("currentLangType:T") != -1) {
LanguageManager.SetCookie("tw");
LanguageManager.LangData = "tw"
}
else if (o.responseText.search("currentLangType:S") != -1) {
LanguageManager.SetCookie("gb");
LanguageManager.LangData = "gb"
}
else if (o.responseText.search("currentLangType") == -1 || o.responseText.search("currentLangType:E") != -1) {
LanguageManager.SetCookie("en");
LanguageManager.LangData = "en"
}
var redirectTo = page[window.parent.$("redirectTo").value];
if(redirectTo == undefined){
redirectTo = "/eclink/phHome.jsp";
}
}catch(err){
redirectTo = "/eclink/phHome.jsp";
} window.parent.location = redirectTo;
} else if (o.responseText.search("AoBankerBroker") != -1) {
try{
var redirectTo = page[window.parent.$("redirectTo").value];
if(redirectTo == undefined){
redirectTo = "/eclink/othHome.jsp";
}
}catch(err){
redirectTo = "/eclink/othHome.jsp";
} window.parent.location = redirectTo;
} else if (o.responseText.search("unavailableIP") != -1) {
showFaultDialog(LanguageManager.LangData.login_unavailableIp);
} else if (o.responseText.search("GotoCAS")!=-1){
document.forms["LoginDomino"].action = "https://cas.hkecic-eclink.com/ECLink_CAS_Web/doLogin";
document.forms["LoginDomino"].submit();
}else if (o.responseText.search("notMigrated") != -1) {
showNotMigratedDialog();
}else {
showFaultDialog(LanguageManager.LangData.login_warningText);
}
} }; Login.callback = {
success :Login.handleSuccess,
failure :Login.handleFailure
}; Login.keySuccess = function(o) {
if (o.responseText != undefined) {
if (o.responseText.search("separator") != -1) {
var module = o.responseText.split("separator")[0];
var empoent = o.responseText.split("separator")[1]; Login.key = new RSAKey();
Login.key.setPublic(module,empoent); Login.login();
}
}
}; Login.keyCallback = {
success :Login.keySuccess,
failure :Login.handleFailure
}; Login.login = function() {
if ($("username").value.length > 0 && $("password").value.length > 0) { var resUseranme = Login.key.encrypt($("username").value);
var resPassword = Login.key.encrypt($("password").value); var postData = "username=" + resUseranme
+ "&password=" + resPassword
+ "&clientIp=" + Login.clientIp
+ "&param_clNo="+window.parent.$("param_clNo").value; var request = YAHOO.util.Connect.asyncRequest("POST", Login.url,
Login.callback, postData);
} else {
showFaultDialog(LanguageManager.LangData.login_userNameNullError);
}
}; Login.getKey = function() {
if ($("username").value.length > 0 && $("password").value.length > 0) {
var request = YAHOO.util.Connect.asyncRequest("POST", Login.keyUrl,
Login.keyCallback, ""); showWaitPanel();
} else {
showFaultDialog(LanguageManager.LangData.login_userNameNullError);
} }; function pressEnter(e){
var keynum;
if(window.event) { // IE
keynum = e.keyCode;
}
else if(e.which) { // Netscape/Firefox/Opera
keynum = e.which;
}
if(keynum == 13){
document.getElementById('loginBtn').click();
}
} function showFaultDialog(warningText) { // Define various event handlers for Dialog
var handleYes = function() {
this.hide();
$("username").value = "";
$("username").focus();
$("password").value = "";
}; // Instantiate the Dialog
YAHOO.loginFaultDialog = new YAHOO.widget.SimpleDialog("loginFaultDialog",
{
width :"330px",
fixedcenter :true,
visible :false,
draggable :true,
close :true,
modal :true,
text :warningText,
icon :YAHOO.widget.SimpleDialog.ICON_WARN,
constraintoviewport :true,
buttons : [ {
text :LanguageManager.LangData.login_warningBtn,
handler :handleYes,
isDefault :true
} ]
});
YAHOO.loginFaultDialog.setHeader(LanguageManager.LangData.login_warning); // Render the Dialog
YAHOO.loginFaultDialog.render("container"); YAHOO.loginFaultDialog.show(); } function showWaitPanel() {
if (!YAHOO.wait) { // Initialize the temporary Panel to display while waiting for external
// content to load YAHOO.wait = new YAHOO.widget.Panel("wait", {
width :"240px",
fixedcenter :true,
close :false,
draggable :true,
zindex :4,
modal :true,
visible :false
}); YAHOO.wait.setHeader(LanguageManager.LangData.waitPanel_title);
YAHOO.wait
.setBody("<img src=\"images/rel_interstitial_loading.gif\"/>");
YAHOO.wait.render($("dialogCtn")); } YAHOO.wait.show(); // Connect to our data source and load the data
} function showNewWarningDialog() { // Define various event handlers for Dialog
var handleYes = function() {
this.hide();
window.parent.location = "/eclink/phHome.jsp";
}; // Instantiate the Dialog
YAHOO.loginFaultDialog = new YAHOO.widget.SimpleDialog(
"newWarningDialog",
{
width :"450px",
fixedcenter :true,
visible :false,
draggable :true,
close :false,
modal :true,
text :"<div style='text-align: left;'><ul><li>Always remember to log out when you have completed your submission and enquires.</li><li>The system will accept simultaneous or multiple login.</li><li>The system will time-out if there is no screen page change for 30 minutes.</li><li>For assistance, simply call our Service Hotline at <font color='blue'>2732 9933</font>.</li></ul></div>",
constraintoviewport :true,
buttons : [ {
text :LanguageManager.LangData.login_warningBtn,
handler :handleYes,
isDefault :true
} ]
});
YAHOO.loginFaultDialog.setHeader("Points to Note"); // Render the Dialog
YAHOO.loginFaultDialog.render("container"); YAHOO.loginFaultDialog.show(); } function showNoPcyDialog() { // Define various event handlers for Dialog
var handleYes = function() {
this.hide();
$("username").value = "";
$("username").focus();
$("password").value = "";
}; // Instantiate the Dialog
YAHOO.noPcyDialog = new YAHOO.widget.SimpleDialog("noPcyDialog", {
width :"250px",
fixedcenter :true,
visible :false,
draggable :true,
close :true,
modal :true,
text :LanguageManager.LangData.nopcy_Text,
icon :YAHOO.widget.SimpleDialog.ICON_WARN,
constraintoviewport :true,
buttons : [ {
text :LanguageManager.LangData.login_warningBtn,
handler :handleYes,
isDefault :true
} ]
});
YAHOO.noPcyDialog.setHeader(LanguageManager.LangData.login_warning); // Render the Dialog
YAHOO.noPcyDialog.render("container"); YAHOO.noPcyDialog.show(); } function showNotMigratedDialog() { // Define various event handlers for Dialog
var handleYes = function() {
this.hide();
$("username").value = "";
$("username").focus();
$("password").value = "";
}; // Instantiate the Dialog
YAHOO.notMigratedDialog = new YAHOO.widget.SimpleDialog("notMigratedDialog", {
width :"300px",
fixedcenter :true,
visible :false,
draggable :true,
close :true,
modal :true,
text :LanguageManager.LangData.notMigrated_Text,
icon :YAHOO.widget.SimpleDialog.ICON_WARN,
constraintoviewport :true,
buttons : [ {
text :LanguageManager.LangData.login_warningBtn,
handler :handleYes,
isDefault :true
} ]
});
YAHOO.notMigratedDialog.setHeader(LanguageManager.LangData.login_warning); // Render the Dialog
YAHOO.notMigratedDialog.render("container"); YAHOO.notMigratedDialog.show(); } //logout confirm
function showLogoutConfirm() { var handleYes = function() {
window.location.href="/eclink/logout.jsp";
$("username").value = "";
$("password").value = "";
};
var handleNo = function() {
this.hide();
}; // Instantiate the Dialog
YAHOO.logoutConfirm = new YAHOO.widget.SimpleDialog("logoutConfirm",
{
width :"330px",
fixedcenter :true,
visible :false,
draggable :true,
close :true,
modal :true,
text : LanguageManager.LangData.logoutConfirm_warningText,
icon :YAHOO.widget.SimpleDialog.ICON_WARN,
constraintoviewport :true,
buttons : [{
text : LanguageManager.LangData.logoutConfirm_yesBtn,
handler :handleYes,
isDefault :true
},{
text : LanguageManager.LangData.logoutConfirm_noBtn,
handler :handleNo
}]
});
YAHOO.logoutConfirm.setHeader(LanguageManager.LangData.login_warning); // Render the Dialog
YAHOO.logoutConfirm.render("container"); YAHOO.logoutConfirm.show();
} function showInactiveDialog() { // Define various event handlers for Dialog
var handleYes = function() {
this.hide();
$("username").value = "";
$("username").focus();
$("password").value = "";
}; // Instantiate the Dialog
YAHOO.inactiveDialog = new YAHOO.widget.SimpleDialog("i", {
width :"250px",
fixedcenter :true,
visible :false,
draggable :true,
close :true,
modal :true,
text :LanguageManager.LangData.login_inactive,
icon :YAHOO.widget.SimpleDialog.ICON_WARN,
constraintoviewport :true,
buttons : [ {
text :LanguageManager.LangData.login_warningBtn,
handler :handleYes,
isDefault :true
} ]
});
YAHOO.inactiveDialog.setHeader(LanguageManager.LangData.login_warning); // Render the Dialog
YAHOO.inactiveDialog.render("container"); YAHOO.inactiveDialog.show(); }

login.js

var dbits;

// JavaScript engine analysis
var canary = 0xdeadbeefcafe;
var j_lm = ((canary&0xffffff)==0xefcafe); // (public) Constructor
function BigInteger(a,b,c) {
if(a != null)
if("number" == typeof a) this.fromNumber(a,b,c);
else if(b == null && "string" != typeof a) this.fromString(a,256);
else this.fromString(a,b);
} // return new, unset BigInteger
function nbi() { return new BigInteger(null); } // am: Compute w_j += (x*this_i), propagate carries,
// c is initial carry, returns final carry.
// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
// We need to select the fastest one that works in this environment. // am1: use a single mult and divide to get the high bits,
// max digit bits should be 26 because
// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
function am1(i,x,w,j,c,n) {
while(--n >= 0) {
var v = x*this[i++]+w[j]+c;
c = Math.floor(v/0x4000000);
w[j++] = v&0x3ffffff;
}
return c;
}
// am2 avoids a big mult-and-extract completely.
// Max digit bits should be <= 30 because we do bitwise ops
// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
function am2(i,x,w,j,c,n) {
var xl = x&0x7fff, xh = x>>15;
while(--n >= 0) {
var l = this[i]&0x7fff;
var h = this[i++]>>15;
var m = xh*l+h*xl;
l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
w[j++] = l&0x3fffffff;
}
return c;
}
// Alternately, set max digit bits to 28 since some
// browsers slow down when dealing with 32-bit numbers.
function am3(i,x,w,j,c,n) {
var xl = x&0x3fff, xh = x>>14;
while(--n >= 0) {
var l = this[i]&0x3fff;
var h = this[i++]>>14;
var m = xh*l+h*xl;
l = xl*l+((m&0x3fff)<<14)+w[j]+c;
c = (l>>28)+(m>>14)+xh*h;
w[j++] = l&0xfffffff;
}
return c;
}
if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
BigInteger.prototype.am = am2;
dbits = 30;
}
else if(j_lm && (navigator.appName != "Netscape")) {
BigInteger.prototype.am = am1;
dbits = 26;
}
else { // Mozilla/Netscape seems to prefer am3
BigInteger.prototype.am = am3;
dbits = 28;
} 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; // Digit conversions
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
var BI_RC = new Array();
var 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(n) { return BI_RM.charAt(n); }
function intAt(s,i) {
var c = BI_RC[s.charCodeAt(i)];
return (c==null)?-1:c;
} // (protected) copy this to r
function bnpCopyTo(r) {
for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
r.t = this.t;
r.s = this.s;
} // (protected) set from integer value x, -DV <= x < DV
function bnpFromInt(x) {
this.t = 1;
this.s = (x<0)?-1:0;
if(x > 0) this[0] = x;
else if(x < -1) this[0] = x+DV;
else this.t = 0;
} // return bigint initialized to value
function nbv(i) { var r = nbi(); r.fromInt(i); return r; } // (protected) set from string and radix
function bnpFromString(s,b) {
var k;
if(b == 16) k = 4;
else if(b == 8) k = 3;
else if(b == 256) k = 8; // byte array
else if(b == 2) k = 1;
else if(b == 32) k = 5;
else if(b == 4) k = 2;
else { this.fromRadix(s,b); return; }
this.t = 0;
this.s = 0;
var i = s.length, mi = false, sh = 0;
while(--i >= 0) {
var x = (k==8)?s[i]&0xff:intAt(s,i);
if(x < 0) {
if(s.charAt(i) == "-") mi = true;
continue;
}
mi = false;
if(sh == 0)
this[this.t++] = x;
else if(sh+k > this.DB) {
this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
this[this.t++] = (x>>(this.DB-sh));
}
else
this[this.t-1] |= x<<sh;
sh += k;
if(sh >= this.DB) sh -= this.DB;
}
if(k == 8 && (s[0]&0x80) != 0) {
this.s = -1;
if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
}
this.clamp();
if(mi) BigInteger.ZERO.subTo(this,this);
} // (protected) clamp off excess high words
function bnpClamp() {
var c = this.s&this.DM;
while(this.t > 0 && this[this.t-1] == c) --this.t;
} // (public) return string representation in given radix
function bnToString(b) {
if(this.s < 0) return "-"+this.negate().toString(b);
var k;
if(b == 16) k = 4;
else if(b == 8) k = 3;
else if(b == 2) k = 1;
else if(b == 32) k = 5;
else if(b == 4) k = 2;
else return this.toRadix(b);
var km = (1<<k)-1, d, m = false, r = "", i = this.t;
var p = this.DB-(i*this.DB)%k;
if(i-- > 0) {
if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
while(i >= 0) {
if(p < k) {
d = (this[i]&((1<<p)-1))<<(k-p);
d |= this[--i]>>(p+=this.DB-k);
}
else {
d = (this[i]>>(p-=k))&km;
if(p <= 0) { p += this.DB; --i; }
}
if(d > 0) m = true;
if(m) r += int2char(d);
}
}
return m?r:"0";
} // (public) -this
function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } // (public) |this|
function bnAbs() { return (this.s<0)?this.negate():this; } // (public) return + if this > a, - if this < a, 0 if equal
function bnCompareTo(a) {
var r = this.s-a.s;
if(r != 0) return r;
var i = this.t;
r = i-a.t;
if(r != 0) return r;
while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
return 0;
} // returns bit length of the integer x
function nbits(x) {
var r = 1, t;
if((t=x>>>16) != 0) { x = t; r += 16; }
if((t=x>>8) != 0) { x = t; r += 8; }
if((t=x>>4) != 0) { x = t; r += 4; }
if((t=x>>2) != 0) { x = t; r += 2; }
if((t=x>>1) != 0) { x = t; r += 1; }
return r;
} // (public) return the number of bits in "this"
function bnBitLength() {
if(this.t <= 0) return 0;
return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
} // (protected) r = this << n*DB
function bnpDLShiftTo(n,r) {
var i;
for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
for(i = n-1; i >= 0; --i) r[i] = 0;
r.t = this.t+n;
r.s = this.s;
} // (protected) r = this >> n*DB
function bnpDRShiftTo(n,r) {
for(var i = n; i < this.t; ++i) r[i-n] = this[i];
r.t = Math.max(this.t-n,0);
r.s = this.s;
} // (protected) r = this << n
function bnpLShiftTo(n,r) {
var bs = n%this.DB;
var cbs = this.DB-bs;
var bm = (1<<cbs)-1;
var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
for(i = this.t-1; i >= 0; --i) {
r[i+ds+1] = (this[i]>>cbs)|c;
c = (this[i]&bm)<<bs;
}
for(i = ds-1; i >= 0; --i) r[i] = 0;
r[ds] = c;
r.t = this.t+ds+1;
r.s = this.s;
r.clamp();
} // (protected) r = this >> n
function bnpRShiftTo(n,r) {
r.s = this.s;
var ds = Math.floor(n/this.DB);
if(ds >= this.t) { r.t = 0; return; }
var bs = n%this.DB;
var cbs = this.DB-bs;
var bm = (1<<bs)-1;
r[0] = this[ds]>>bs;
for(var i = ds+1; i < this.t; ++i) {
r[i-ds-1] |= (this[i]&bm)<<cbs;
r[i-ds] = this[i]>>bs;
}
if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
r.t = this.t-ds;
r.clamp();
} // (protected) r = this - a
function bnpSubTo(a,r) {
var i = 0, c = 0, m = Math.min(a.t,this.t);
while(i < m) {
c += this[i]-a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
if(a.t < this.t) {
c -= a.s;
while(i < this.t) {
c += this[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c += this.s;
}
else {
c += this.s;
while(i < a.t) {
c -= a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c -= a.s;
}
r.s = (c<0)?-1:0;
if(c < -1) r[i++] = this.DV+c;
else if(c > 0) r[i++] = c;
r.t = i;
r.clamp();
} // (protected) r = this * a, r != this,a (HAC 14.12)
// "this" should be the larger one if appropriate.
function bnpMultiplyTo(a,r) {
var x = this.abs(), y = a.abs();
var i = x.t;
r.t = i+y.t;
while(--i >= 0) r[i] = 0;
for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
r.s = 0;
r.clamp();
if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
} // (protected) r = this^2, r != this (HAC 14.16)
function bnpSquareTo(r) {
var x = this.abs();
var i = r.t = 2*x.t;
while(--i >= 0) r[i] = 0;
for(i = 0; i < x.t-1; ++i) {
var c = x.am(i,x[i],r,2*i,0,1);
if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
r[i+x.t] -= x.DV;
r[i+x.t+1] = 1;
}
}
if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
r.s = 0;
r.clamp();
} // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
// r != q, this != m. q or r may be null.
function bnpDivRemTo(m,q,r) {
var pm = m.abs();
if(pm.t <= 0) return;
var pt = this.abs();
if(pt.t < pm.t) {
if(q != null) q.fromInt(0);
if(r != null) this.copyTo(r);
return;
}
if(r == null) r = nbi();
var y = nbi(), ts = this.s, ms = m.s;
var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
else { pm.copyTo(y); pt.copyTo(r); }
var ys = y.t;
var y0 = y[ys-1];
if(y0 == 0) return;
var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
var i = r.t, j = i-ys, t = (q==null)?nbi():q;
y.dlShiftTo(j,t);
if(r.compareTo(t) >= 0) {
r[r.t++] = 1;
r.subTo(t,r);
}
BigInteger.ONE.dlShiftTo(ys,t);
t.subTo(y,y); // "negative" y so we can replace sub with am later
while(y.t < ys) y[y.t++] = 0;
while(--j >= 0) {
// Estimate quotient digit
var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
y.dlShiftTo(j,t);
r.subTo(t,r);
while(r[i] < --qd) r.subTo(t,r);
}
}
if(q != null) {
r.drShiftTo(ys,q);
if(ts != ms) BigInteger.ZERO.subTo(q,q);
}
r.t = ys;
r.clamp();
if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
if(ts < 0) BigInteger.ZERO.subTo(r,r);
} // (public) this mod a
function bnMod(a) {
var r = nbi();
this.abs().divRemTo(a,null,r);
if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
return r;
} // Modular reduction using "classic" algorithm
function Classic(m) { this.m = m; }
function cConvert(x) {
if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
else return x;
}
function cRevert(x) { return x; }
function cReduce(x) { x.divRemTo(this.m,null,x); }
function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } Classic.prototype.convert = cConvert;
Classic.prototype.revert = cRevert;
Classic.prototype.reduce = cReduce;
Classic.prototype.mulTo = cMulTo;
Classic.prototype.sqrTo = cSqrTo; // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
// justification:
// xy == 1 (mod m)
// xy = 1+km
// xy(2-xy) = (1+km)(1-km)
// x[y(2-xy)] = 1-k^2m^2
// x[y(2-xy)] == 1 (mod m^2)
// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
// JS multiply "overflows" differently from C/C++, so care is needed here.
function bnpInvDigit() {
if(this.t < 1) return 0;
var x = this[0];
if((x&1) == 0) return 0;
var y = x&3; // y == 1/x mod 2^2
y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
// last step - calculate inverse mod DV directly;
// assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
// we really want the negative inverse, and -DV < y < DV
return (y>0)?this.DV-y:-y;
} // Montgomery reduction
function Montgomery(m) {
this.m = m;
this.mp = m.invDigit();
this.mpl = this.mp&0x7fff;
this.mph = this.mp>>15;
this.um = (1<<(m.DB-15))-1;
this.mt2 = 2*m.t;
} // xR mod m
function montConvert(x) {
var r = nbi();
x.abs().dlShiftTo(this.m.t,r);
r.divRemTo(this.m,null,r);
if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
return r;
} // x/R mod m
function montRevert(x) {
var r = nbi();
x.copyTo(r);
this.reduce(r);
return r;
} // x = x/R mod m (HAC 14.32)
function montReduce(x) {
while(x.t <= this.mt2) // pad x so am has enough room later
x[x.t++] = 0;
for(var i = 0; i < this.m.t; ++i) {
// faster way of calculating u0 = x[i]*mp mod DV
var j = x[i]&0x7fff;
var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
// use am to combine the multiply-shift-add into one call
j = i+this.m.t;
x[j] += this.m.am(0,u0,x,i,0,this.m.t);
// propagate carry
while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
}
x.clamp();
x.drShiftTo(this.m.t,x);
if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
} // r = "x^2/R mod m"; x != r
function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } // r = "xy/R mod m"; x,y != r
function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } Montgomery.prototype.convert = montConvert;
Montgomery.prototype.revert = montRevert;
Montgomery.prototype.reduce = montReduce;
Montgomery.prototype.mulTo = montMulTo;
Montgomery.prototype.sqrTo = montSqrTo; // (protected) true iff this is even
function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
function bnpExp(e,z) {
if(e > 0xffffffff || e < 1) return BigInteger.ONE;
var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
g.copyTo(r);
while(--i >= 0) {
z.sqrTo(r,r2);
if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
else { var t = r; r = r2; r2 = t; }
}
return z.revert(r);
} // (public) this^e % m, 0 <= e < 2^32
function bnModPowInt(e,m) {
var z;
if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
return this.exp(e,z);
} // protected
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; // public
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; // "constants"
BigInteger.ZERO = nbv(0);
BigInteger.ONE = nbv(1);

jsbn.js

function Arcfour() {
this.i = 0;
this.j = 0;
this.S = new Array();
} // Initialize arcfour context from key, an array of ints, each from [0..255]
function ARC4init(key) {
var i, j, t;
for(i = 0; i < 256; ++i)
this.S[i] = i;
j = 0;
for(i = 0; i < 256; ++i) {
j = (j + this.S[i] + key[i % key.length]) & 255;
t = this.S[i];
this.S[i] = this.S[j];
this.S[j] = t;
}
this.i = 0;
this.j = 0;
} function ARC4next() {
var t;
this.i = (this.i + 1) & 255;
this.j = (this.j + this.S[this.i]) & 255;
t = this.S[this.i];
this.S[this.i] = this.S[this.j];
this.S[this.j] = t;
return this.S[(t + this.S[this.i]) & 255];
} Arcfour.prototype.init = ARC4init;
Arcfour.prototype.next = ARC4next; // Plug in your RNG constructor here
function prng_newstate() {
return new Arcfour();
} // Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
var rng_psize = 256;

prng4.js

onKeyPress='rng_seed_time();'>
// in your main HTML document. var rng_state;
var rng_pool;
var rng_pptr; // Mix in a 32-bit integer into the pool
function rng_seed_int(x) {
rng_pool[rng_pptr++] ^= x & 255;
rng_pool[rng_pptr++] ^= (x >> 8) & 255;
rng_pool[rng_pptr++] ^= (x >> 16) & 255;
rng_pool[rng_pptr++] ^= (x >> 24) & 255;
if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
} // Mix in the current time (w/milliseconds) into the pool
function rng_seed_time() {
rng_seed_int(new Date().getTime());
} // Initialize the pool with junk if needed.
if(rng_pool == null) {
rng_pool = new Array();
rng_pptr = 0;
var t;
if(navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
// Extract entropy (256 bits) from NS4 RNG if available
var z = window.crypto.random(32);
for(t = 0; t < z.length; ++t)
rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
}
while(rng_pptr < rng_psize) { // extract some randomness from Math.random()
t = Math.floor(65536 * Math.random());
rng_pool[rng_pptr++] = t >>> 8;
rng_pool[rng_pptr++] = t & 255;
}
rng_pptr = 0;
rng_seed_time();
//rng_seed_int(window.screenX);
//rng_seed_int(window.screenY);
} 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;
//rng_pool = null;
}
// TODO: allow reseeding after first request
return rng_state.next();
} function rng_get_bytes(ba) {
var i;
for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
} function SecureRandom() {} SecureRandom.prototype.nextBytes = rng_get_bytes;

rng.js

function parseBigInt(str,r) {
return new BigInteger(str,r);
} function linebrk(s,n) {
var ret = "";
var i = 0;
while(i + n < s.length) {
ret += s.substring(i,i+n) + "\n";
i += n;
}
return ret + s.substring(i,s.length);
} function byte2Hex(b) {
if(b < 0x10)
return "0" + b.toString(16);
else
return b.toString(16);
} // PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
function pkcs1pad2(s,n) {
if(n < s.length + 11) {
alert("Message too long for RSA");
return null;
}
var ba = new Array();
var i = s.length - 1;
while(i >= 0 && n > 0) ba[--n] = s.charCodeAt(i--);
ba[--n] = 0;
var rng = new SecureRandom();
var x = new Array();
while(n > 2) { // random non-zero pad
x[0] = 0;
while(x[0] == 0) rng.nextBytes(x);
ba[--n] = x[0];
}
ba[--n] = 2;
ba[--n] = 0;
return new BigInteger(ba);
} // "empty" RSA key constructor
function RSAKey() {
this.n = null;
this.e = 0;
this.d = null;
this.p = null;
this.q = null;
this.dmp1 = null;
this.dmq1 = null;
this.coeff = null;
} // Set the public key fields N and e from hex strings
function RSASetPublic(N,E) {
if(N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N,16);
this.e = parseInt(E,16);
}
else
alert("Invalid RSA public key");
} // Perform raw public operation on "x": return x^e (mod n)
function RSADoPublic(x) {
return x.modPowInt(this.e, this.n);
} // Return the PKCS#1 RSA encryption of "text" as an even-length hex string
function RSAEncrypt(text) {
var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3);
if(m == null) return null;
var c = this.doPublic(m);
if(c == null) return null;
var h = c.toString(16);
if((h.length & 1) == 0) return h; else return "0" + h;
} // Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
//function RSAEncryptB64(text) {
// var h = this.encrypt(text);
// if(h) return hex2b64(h); else return null;
//} // protected
RSAKey.prototype.doPublic = RSADoPublic; // public
RSAKey.prototype.setPublic = RSASetPublic;
RSAKey.prototype.encrypt = RSAEncrypt;
//RSAKey.prototype.encrypt_b64 = RSAEncryptB64;

rsa.js

模拟登录,发送amf类型数据

从login.js中去执行该方法

请求 https://main.hkecic-eclink.com/eclink/Key

响应回来下列一串文本

9773ff3b88ef7e520f995c9472977fc84b9587b367965cfcd7062fb81cca00b68b79f23d6ce9b167c94627b21f579bfe2a2fd74fcf60c5184e022402db662b6d550b81b6cb02fc7b3916fcbb133dd1c5af06fd1e3b36f84676418056e500e13c9df6f9670e116a757e9257acead9340c50bb370372f759bb4f0bc2ed6025b84bseparator10001 js中有对该串文本进行处理

成功之后调用js Login.keySuccess ,执行 login方法,获得加密的 resUseranme ,resPassword

携带加密的resUseranme ,resPassword  去请求 https://main.hkecic-eclink.com/eclink/LoginCheck

返回  GotoCAS

再去请求   https://cas.hkecic-eclink.com/ECLink_CAS_Web/doLogin

返回302自动跳转

获取订单列表 请求https://cas.hkecic-eclink.com/ECLink_CAS_Web/messagebroker/amf/

传递的参数如下截图

模拟登录,发送amf类型数据

响应回来的列表:

模拟登录,发送amf类型数据

模拟登录,发送amf类型数据

C#代码如下:

  public class EcicOrderInfo
{
public ulong? AcqCode { get; set; } public DateTime? FirstRequestDate { get; set; } public DateTime? LastRequestDate { get; set; } public string CaseNo { get; set; } public string CompanyName { get; set; } public string CaseStatus { get; set; } public string ReportType { get; set; } public string AgencyReference { get; set; } public string Address1 { get; set; } public string Address2 { get; set; } public string Address3 { get; set; } public string Address4 { get; set; } public string TelephoneNo { get; set; } public string FaxNo { get; set; } public string Amount { get; set; } public string Currency { get; set; } public string RegistrationNo { get; set; } public DateTime? ReportSentDate { get; set; } public string Remark { get; set; } public bool IsExist { get; set; } /// <summary>
/// 提交报告文件的参数
/// </summary>
public string AcqOfr { get; set; }
}

订单实体类 EcicOrderInfo

 public class AMFPostData
{
public List<byte> Message; /// <summary>
/// 初始化Message
/// </summary>
/// <param name="amfType"></param>
/// <param name="headers"></param>
/// <param name="bodies"></param>
public AMFPostData(AMFType amfType, int headers, int bodies)
{
//AMF版本
if (amfType == AMFType.AMF0)
Message = new List<byte>(new byte[] { 0x00, 0x00 });
else if (amfType == AMFType.AMF3)
Message = new List<byte>(new byte[] { 0x00, 0x03 });
//headers数量
Message.Add(BitConverter.GetBytes(headers)[]);
Message.Add(BitConverter.GetBytes(headers)[]);
//body数量
Message.Add(BitConverter.GetBytes(bodies)[]);
Message.Add(BitConverter.GetBytes(bodies)[]);
} /// <summary>
/// 添加Target
/// </summary>
/// <param name="target"></param>
/// <param name="response"></param>
public void AddTargetAndResponse(string target, string response)
{
//添加Target长度
if (!string.IsNullOrEmpty(target))
{
Message.Add(BitConverter.GetBytes(target.Length)[]);
Message.Add(BitConverter.GetBytes(target.Length)[]);
//添加Target内容
Message.AddRange(Encoding.UTF8.GetBytes(target));
}
//添加Response长度
Message.Add(BitConverter.GetBytes(response.Length)[]);
Message.Add(BitConverter.GetBytes(response.Length)[]);
//添加Response内容
Message.AddRange(Encoding.UTF8.GetBytes(response));
} /// <summary>
/// 添加Body
/// </summary>
public void AddBody(AMFPostDataBody amfPostDataBody)
{
Message.AddRange(amfPostDataBody.GetLength());
Message.AddRange(amfPostDataBody.Content.ToArray());
}
}
public class AMFPostDataBody
{
private byte[] length = new byte[];
public List<byte> Content = new List<byte>(); /// <summary>
/// 初始化body
/// </summary>
/// <param name="dataType"></param>
/// <param name="arrayLength"></param>
public AMFPostDataBody(DataType dataType, int arrayLength)
{ //添加类型标识
Content.Add((byte)dataType);
//数组的话添加长度
if (dataType == DataType.Array)
{
Content.Add(BitConverter.GetBytes(arrayLength)[]);
Content.Add(BitConverter.GetBytes(arrayLength)[]);
Content.Add(BitConverter.GetBytes(arrayLength)[]);
Content.Add(BitConverter.GetBytes(arrayLength)[]);
} } public void AddData(DataType dataType, object value)
{
//添加类型标识
Content.Add((byte)dataType);
switch (dataType)
{
case DataType.Number:
AddData(Convert.ToDouble(value));
break;
case DataType.String:
AddData(value);
break;
case DataType.Boolean:
AddData(Convert.ToBoolean(value));
break;
case DataType.AMFdata:
AddData(value);
break;
default:
AddData(value);
break;
} } #region 各种类型处理方法
private void AddData(bool flag)
{
if (flag)
Content.Add(0x01);
else
Content.Add(0x00);
} private void AddData(string value)
{
//添加长度
Content.Add(BitConverter.GetBytes(Encoding.UTF8.GetBytes(value).Length)[]);
Content.Add(BitConverter.GetBytes(Encoding.UTF8.GetBytes(value).Length)[]);
//添加内容
Content.AddRange(Encoding.UTF8.GetBytes(value));
} private void AddData(double number)
{
byte[] b = new byte[];
b = BitConverter.GetBytes(number);
for (int i = ; i > -; i--)
{
Content.Add(b[i]);
}
} private void AddData(object obj)
{
//if (obj != null && (obj is ContentObject))
//{
// ContentObject contentObj = (ContentObject)obj;
// RemotingMessage message = new RemotingMessage(); // //FluorineFx.RemotingServiceAttribute
// message.source = contentObj.source;
// message.operation = contentObj.operation;
// message.body = contentObj.body; // message.timeToLive = contentObj.timeToLive;
// message.timestamp = contentObj.timestamp;
// message.clientId = contentObj.clientId; // message.headers = contentObj.headers;
// message.messageId = contentObj.messageId;
// message.destination = contentObj.destination; // Byte[] bytes = AMF_Serializer(message); // Content.AddRange(bytes);//添加内容
//}
Byte[] bytes = AMF_Serializer(obj); Content.AddRange(bytes);//添加内容
} #endregion public byte[] GetLength()
{
length[] = BitConverter.GetBytes(Content.Count)[];
length[] = BitConverter.GetBytes(Content.Count)[];
length[] = BitConverter.GetBytes(Content.Count)[];
length[] = BitConverter.GetBytes(Content.Count)[];
return length;
} public static T AMF_Deserializer<T>(byte[] buffer, int length)
{
MemoryStream stream = new MemoryStream(buffer, , length);
ByteArray byteArray = new ByteArray(stream);
object obj = byteArray.ReadObject(); if (obj == null)
{
return default(T);
}
return (T)obj;
}
// 将对象转换为AMF格式的字节流
public static byte[] AMF_Serializer(object obj)
{
FluorineFx.AMF3.ByteArray byteArray = new FluorineFx.AMF3.ByteArray(); byteArray.WriteObject(obj); byte[] buffer = new byte[byteArray.Length];
byteArray.Position = ;
byteArray.ReadBytes(buffer, , byteArray.Length); return buffer;
}
public static byte[] AMF_Serializer(RemotingMessage obj)
{
FluorineFx.AMF3.ByteArray byteArray = new FluorineFx.AMF3.ByteArray(); byteArray.WriteObject(obj); byte[] buffer = new byte[byteArray.Length];
byteArray.Position = ;
byteArray.ReadBytes(buffer, , byteArray.Length); return buffer;
} /// <summary>
/// 将对象序列化为byte[]
/// 使用IFormatter的Serialize序列化
/// </summary>
/// <param name="obj">需要序列化的对象</param>
/// <returns>序列化获取的二进制流</returns>
public static byte[] FormatterObjectBytes(object obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
byte[] buff;
try
{
using (var ms = new MemoryStream())
{
IFormatter iFormatter = new BinaryFormatter();
iFormatter.Serialize(ms, obj);
buff = ms.GetBuffer();
}
}
catch (Exception er)
{
throw new Exception(er.Message);
}
return buff;
} } public enum AMFType
{
AMF0,
AMF3
} public enum DataType
{
Number = ,
Boolean = ,
String = ,
UnTypedObject = ,
MovieClip = ,
Null = ,
Undefined = ,
ReferencedObject = ,
MixedArray = ,
End = ,
Array = ,//0x0A
Date = ,//0x0B
LongStrin = ,//0x0C
TypeAsObject = ,//0x0D
Recordset = ,//0x0E
Xml = ,//0x0F
TypedObject = ,//0x10
AMFdata = //0x11
}

AMFPost类及其他

class Program
{
static void Main(string[] args)
{
string content = null;
CookieCollection cookies = null;
content = GetEcicLogin(ref cookies);//模拟登录
if (!Regex.IsMatch(content, "Logout"))//说明登录成功
{
Console.WriteLine("登录失败");
return;
}
string resultMsg = null;
WebHeaderCollection headers = new WebHeaderCollection(); headers.Add("Accept-Encoding", "gzip, deflate");
headers.Add("Accept-Language", "zh-Hans-CN, zh-Hans; q=0.5"); string strUrl = null;
string referer = null;
string contentType = null;
strUrl = "https://cas.hkecic-eclink.com/ECLink_CAS_Web/messagebroker/amf/";
referer = "https://cas.hkecic-eclink.com/ECLink_CAS_Web/cas_development.swf";
contentType = "application/x-amf"; //封装数据 start
AMFPostData amfpostdata = new AMFPostData(AMFType.AMF3, 0, 1);
amfpostdata.AddTargetAndResponse("null", "/2"); RemotingMessage message = new RemotingMessage();
message.source = null;
message.operation = "selectOutstandingCase";
ArrayList body = new ArrayList();
body.Add("/SINOINFO");
ArrayList bodyArr = new ArrayList(); int currPage = 1;//当前第一页
int pageRowCount = 200;//改一下每页大小的参数 改为200条
bodyArr.Add((currPage - 1) * pageRowCount);//起始下标,第一页为0,第二页为15 第三页为30...不分页,直接传200 远大于总量 直接展示所有 bodyArr.Add(pageRowCount); body.Add(bodyArr);
message.body = body; message.timeToLive = 0;
message.timestamp = 0;
message.clientId = null;
Dictionary<string, object> objHeaders = new Dictionary<string, object>(); objHeaders.Add("DSEndpoint", null);
objHeaders.Add("DSId", Guid.NewGuid().ToString().ToUpper());
message.headers = objHeaders;
message.messageId = Guid.NewGuid().ToString().ToUpper();
message.destination = "CommonDataRO";
//end AMFPostDataBody amfpostdatabody = new AMFPostDataBody(DataType.Array, 1);
amfpostdatabody.AddData(DataType.AMFdata, message); amfpostdata.AddBody(amfpostdatabody); byte[] data = amfpostdata.Message.ToArray(); int totalCount = 0;
int[] today = new int[4] { 0, 0, 0, 0 };
int[] yesterday = new int[4] { 0, 0, 0, 0 };
IList<EcicOrderInfo> ecicOrderList = GetEcicOrderInfoList(data, strUrl, ref cookies, headers, contentType, referer, Encoding.UTF8, Encoding.UTF8, ref resultMsg, out totalCount, today, yesterday);
}
 public static string Traditional2Simplified(string str)
{
if (string.IsNullOrEmpty(str) || str.Trim() == "") return null;
return (Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, )); }

繁体转简体字

        public static IList<EcicOrderInfo> GetEcicOrderInfoList(byte[] bs, string postUrl, ref CookieCollection cookies, WebHeaderCollection headers, string contentType, string referer, Encoding requestEncode, Encoding responseEncode, ref string statusMsg, out int totalCount, int[] today, int[] yesterday)
{
IList<EcicOrderInfo> ecicOrderList = null; FluorineFx.IO.AMFMessage message = GetAMFMessageByPost(bs, postUrl, ref cookies, headers, contentType, referer, requestEncode, responseEncode, ref statusMsg);
ecicOrderList = new List<EcicOrderInfo>();
totalCount = ;
if (message != null)
{
foreach (FluorineFx.IO.AMFBody body in message.Bodies)
{
try
{
Dictionary<string, object> dict = new Dictionary<string, object>(((FluorineFx.ASObject)(((FluorineFx.Messaging.Messages.MessageBase)(body.Content)).body)));
EcicOrderInfo ecicOrder = null;
if (dict.Count > )
{
System.Collections.IList resultList = ((FluorineFx.AMF3.ArrayCollection)dict["resultList"]).List;
totalCount = (int)dict["totalCount"];//总数量
foreach (object obj in resultList)
{
ecicOrder = new EcicOrderInfo();
FluorineFx.ASObject fxObj = ((FluorineFx.ASObject)obj);
if (fxObj["acqCode"] != null)
ecicOrder.AcqCode = Convert.ToUInt64(fxObj["acqCode"]);
if (fxObj["casCaseNo"] != null)
ecicOrder.CaseNo = fxObj["casCaseNo"].ToString();
if (fxObj["casSts"] != null)
ecicOrder.CaseStatus = fxObj["casSts"].ToString();
if (fxObj["rptType"] != null)
ecicOrder.ReportType = fxObj["rptType"].ToString();
if (fxObj["sendDate"] != null)
ecicOrder.FirstRequestDate = Convert.ToDateTime(fxObj["sendDate"].ToString()).AddHours();
if (fxObj["lastReplyDate"] != null)
ecicOrder.LastRequestDate = Convert.ToDateTime(fxObj["lastReplyDate"].ToString()).AddHours();
if (fxObj["byrName"] != null)
ecicOrder.CompanyName = Traditional2Simplified(fxObj["byrName"].ToString());//繁体字转简体字
ecicOrderList.Add(ecicOrder);
}
}
}
catch
{
continue;
}
}
}
return ecicOrderList;
}

获取列表

GetAMFMessageByPost
private static string GetEcicLogin(ref CookieCollection cookies)
{
string content = null; WebHeaderCollection headers = new WebHeaderCollection();
string referer = null;
string resultMsg = null;
string contentType = null;
string strUrl = "https://main.hkecic-eclink.com/eclink/eclink_new.jsp";
content = GetData(strUrl, ref cookies, headers, referer, Encoding.UTF8, ref resultMsg); headers.Add("Accept-Encoding", "gzip, deflate");
headers.Add("Accept-Language", "zh-Hans-CN, zh-Hans; q=0.5");
referer = "https://main.hkecic-eclink.com/eclink/ecLink_e.html";
string postData = "";
strUrl = "https://main.hkecic-eclink.com/eclink/Key";
contentType = "application/x-www-form-urlencoded; charset=UTF-8";
content = PostData(postData, strUrl, ref cookies, headers, contentType, referer, Encoding.UTF8, Encoding.UTF8, ref resultMsg);
string module = content.Split(new string[] { "separator" }, StringSplitOptions.RemoveEmptyEntries)[];
string empoent = content.Split(new string[] { "separator" }, StringSplitOptions.RemoveEmptyEntries)[];
string userName = "******";
string password = "******";
string upStr = RSAEncrypt(userName, password, module, empoent);
if (!string.IsNullOrEmpty(upStr))
{
string[] upArr = upStr.Split('?');
string EncryptUserName = upArr[];
string Encryptpassword = upArr[];
postData = "username=" + EncryptUserName + "&password=" + Encryptpassword + "&clientIp=\"\"&param_clNo=\"\"";
}
strUrl = "https://main.hkecic-eclink.com/eclink/LoginCheck";
content = PostData(postData, strUrl, ref cookies, headers, contentType, referer, Encoding.UTF8, Encoding.UTF8, ref resultMsg); if (content != "GotoCAS")
return "登录失败"; cookies = null;//如果不把cookies 置为null,则下面一步请求会报错,cookies path不对
strUrl = "https://cas.hkecic-eclink.com/ECLink_CAS_Web/doLogin";
postData = "username=" + userName + "&password=" + password;
content = PostData(postData, strUrl, ref cookies, headers, contentType, referer, Encoding.UTF8, Encoding.UTF8, ref resultMsg);
//下面一个请求可以取消 ,doLogin会自动跳转至cas_main这个请求
//strUrl = "https://cas.hkecic-eclink.com/ECLink_CAS_Web/cas_main";
//content = basic.GetData(strUrl, ref cookies, headers, referer, Encoding.UTF8, ref resultMsg);
return content;
}

GetEcicLogin 模拟登录方法

public static string GetData(string getUrl, ref CookieCollection cookies, WebHeaderCollection headers, string referer, Encoding responseEncode, ref string statusMsg)
{
string content = null;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
CookieContainer cookieContainer = new CookieContainer();
try
{
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(getUrl);
httpWebRequest.Method = "GET";
httpWebRequest.Timeout = ;
if (headers != null && headers.Count > ) httpWebRequest.Headers = headers;
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"; httpWebRequest.Referer = referer;
httpWebRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*"; //httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
if (cookies != null && cookies.Count > ) cookieContainer.Add(httpWebRequest.RequestUri, cookies);
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.AllowAutoRedirect = true;
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (httpWebResponse.StatusCode == HttpStatusCode.OK)
{
Stream stream = httpWebResponse.GetResponseStream();
if (httpWebResponse.ContentEncoding.ToLower().Contains("gzip"))
stream = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress);
StreamReader reader = new StreamReader(stream, responseEncode);
string tmpStr = "";
while ((tmpStr = reader.ReadLine()) != null) content += tmpStr;
reader.Close();
stream.Close();
content = GetMatchResult(content);
cookies = AdditionalCookies(httpWebRequest.CookieContainer.GetCookies(httpWebRequest.RequestUri), httpWebResponse.Cookies);
}
httpWebResponse.Close();
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse res = (HttpWebResponse)e.Response;
statusMsg = "错误代码:" + res.StatusCode + ",错误信息:" + res.StatusDescription;
StreamReader reader = new StreamReader(res.GetResponseStream(), responseEncode);
content = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception e)
{
statusMsg = e.ToString();
}
return content;
}

GetData 发送请求获取数据

public static string PostData(string postData, string postUrl, ref CookieCollection cookies, WebHeaderCollection headers, string contentType, string referer, Encoding requestEncode, Encoding responseEncode, ref string statusMsg)
{
string content = null;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
CookieContainer cookieContainer = new CookieContainer();
try
{
byte[] bs = requestEncode.GetBytes(postData);
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(postUrl);
httpWebRequest.Method = "POST";
httpWebRequest.Timeout = ;
if (headers != null && headers.Count > ) httpWebRequest.Headers = headers;
httpWebRequest.ContentType = contentType;
//httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0";
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36";
//httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
httpWebRequest.Referer = referer;
httpWebRequest.Accept = "*/*";
if (cookies != null && cookies.Count > )
cookieContainer.Add(httpWebRequest.RequestUri, cookies);
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.ContentLength = bs.Length; Stream reqStream = httpWebRequest.GetRequestStream();
reqStream.Write(bs, , bs.Length);
reqStream.Close(); HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode == HttpStatusCode.OK)
{
Stream stream = httpWebResponse.GetResponseStream();
if (httpWebResponse.ContentEncoding.ToLower().Contains("gzip"))
stream = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress);
StreamReader reader = new StreamReader(stream, responseEncode); string tmpStr = "";
while ((tmpStr = reader.ReadLine()) != null) content += tmpStr;
reader.Close();
stream.Close();
content = GetMatchResult(content);
cookies = AdditionalCookies(httpWebRequest.CookieContainer.GetCookies(httpWebRequest.RequestUri), httpWebResponse.Cookies);
}
httpWebResponse.Close();
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse res = (HttpWebResponse)e.Response;
statusMsg = "错误代码:" + res.StatusCode + ",错误信息:" + res.StatusDescription;
StreamReader reader = new StreamReader(res.GetResponseStream(), responseEncode);
content = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception e)
{
statusMsg = e.ToString();
}
return content;
}

PostData post请求发送数据

 /// <summary>
/// 执行js
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="module"></param>
/// <param name="empoent"></param>
/// <returns></returns>
public static string RSAEncrypt(string userName, string password, string module, string empoent)
{
string result = null;
string expression = null;
//prng4.js
expression = "function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(key){var i,j,t;for(i=0;i<256;++i)this.S[i]=i;j=0;for(i=0;i<256;++i){j=(j+this.S[i]+key[i%key.length])&255;t=this.S[i];this.S[i]=this.S[j];this.S[j]=t}this.i=0;this.j=0}function ARC4next(){var t;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;t=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=t;return this.S[(t+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256;";
//jsbn.js
expression += "var dbits;var canary=0xdeadbeefcafe;var j_lm=((canary&0xffffff)==0xefcafe);function BigInteger(a,b,c){if(a!=null)if(\"number\"==typeof a)this.fromNumber(a,b,c);else if(b==null&&\"string\"!=typeof a)this.fromString(a,256);else this.fromString(a,b)}function nbi(){return new BigInteger(null)}function am1(i,x,w,j,c,n){while(--n>=0){var v=x*this[i++]+w[j]+c;c=Math.floor(v/0x4000000);w[j++]=v&0x3ffffff}return c}function am2(i,x,w,j,c,n){var xl=x&0x7fff,xh=x>>15;while(--n>=0){var l=this[i]&0x7fff;var h=this[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w[j++]=l&0x3fffffff}return c}function am3(i,x,w,j,c,n){var xl=x&0x3fff,xh=x>>14;while(--n>=0){var l=this[i]&0x3fff;var h=this[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&0x3fff)<<14)+w[j]+c;c=(l>>28)+(m>>14)+xh*h;w[j++]=l&0xfffffff}return c} BigInteger.prototype.am=am3;dbits=28;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\";var BI_RC=new Array();var 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(n){return BI_RM.charAt(n)}function intAt(s,i){var c=BI_RC[s.charCodeAt(i)];return (c==null)?-1:c}function bnpCopyTo(r){for(var i=this.t-1;i>=0;--i)r[i]=this[i];r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=(x<0)?-1:0;if(x>0)this[0]=x;else if(x<-1)this[0]=x+DV;else this.t=0}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16)k=4;else if(b==8)k=3;else if(b==256)k=8;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else{this.fromRadix(s,b);return}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=(k==8)?s[i]&0xff:intAt(s,i);if(x<0){if(s.charAt(i)==\"-\")mi=true;continue}mi=false;if(sh==0)this[this.t++]=x;else if(sh+k>this.DB){this[this.t-1]|=(x&((1<<(this.DB-sh))-1))<<sh;this[this.t++]=(x>>(this.DB-sh))}else this[this.t-1]|=x<<sh;sh+=k;if(sh>=this.DB)sh-=this.DB}if(k==8&&(s[0]&0x80)!=0){this.s=-1;if(sh>0)this[this.t-1]|=((1<<(this.DB-sh))-1)<<sh}this.clamp();if(mi)BigInteger.ZERO.subTo(this,this)}function bnpClamp(){var c=this.s&this.DM;while(this.t>0&&this[this.t-1]==c)--this.t}function bnToString(b){if(this.s<0)return \"-\"+this.negate().toString(b);var k;if(b==16)k=4;else if(b==8)k=3;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else return this.toRadix(b);var km=(1<<k)-1,d,m=false,r=\"\",i=this.t;var p=this.DB-(i*this.DB)%k;if(i-->0){if(p<this.DB&&(d=this[i]>>p)>0){m=true;r=int2char(d)}while(i>=0){if(p<k){d=(this[i]&((1<<p)-1))<<(k-p);d|=this[--i]>>(p+=this.DB-k)}else{d=(this[i]>>(p-=k))&km;if(p<=0){p+=this.DB;--i}}if(d>0)m=true;if(m)r+=int2char(d)}}return m?r:\"0\"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return (this.s<0)?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0) return r;var i=this.t;r=i-a.t;if(r!=0)return r;while(--i>=0)if((r=this[i]-a[i])!=0) return r;return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t=x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0) return 0;return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i<this.t;++i)r[i-n]=this[i];r.t=Math.max(this.t-n,0);r.s=this.s}function bnpLShiftTo(n,r){var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<<cbs)-1;var ds=Math.floor(n/this.DB),c=(this.s<<bs)&this.DM,i;for(i=this.t-1;i>=0;--i){r[i+ds+1]=(this[i]>>cbs)|c;c=(this[i]&bm)<<bs}for(i=ds-1;i>=0;--i)r[i]=0;r[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<<bs)-1;r[0]=this[ds]>>bs;for(var i=ds+1;i<this.t;++i){r[i-ds-1]|=(this[i]&bm)<<cbs;r[i-ds]=this[i]>>bs}if(bs>0)r[this.t-ds-1]|=(this.s&bm)<<cbs;r.t=this.t-ds;r.clamp()}function bnpSubTo(a,r){var i=0,c=0,m=Math.min(a.t,this.t);while(i<m){c+=this[i]-a[i];r[i++]=c&this.DM;c>>=this.DB}if(a.t<this.t){c-=a.s;while(i<this.t){c+=this[i];r[i++]=c&this.DM;c>>=this.DB}c+=this.s}else{c+=this.s;while(i<a.t){c-=a[i];r[i++]=c&this.DM;c>>=this.DB}c-=a.s}r.s=(c<0)?-1:0;if(c<-1)r[i++]=this.DV+c;else if(c>0)r[i++]=c;r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0)r[i]=0;for(i=0;i<y.t;++i)r[i+x.t]=x.am(0,y[i],r,i,0,x.t);r.s=0;r.clamp();if(this.s!=a.s)BigInteger.ZERO.subTo(r,r)}function bnpSquareTo(r){var x=this.abs();var i=r.t=2*x.t;while(--i>=0)r[i]=0;for(i=0;i<x.t-1;++i){var c=x.am(i,x[i],r,2*i,0,1);if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1))>=x.DV){r[i+x.t]-=x.DV;r[i+x.t+1]=1}}if(r.t>0)r[r.t-1]+=x.am(i,x[i],r,2*i,0,1);r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0) return;var pt=this.abs();if(pt.t<pm.t){if(q!=null)q.fromInt(0);if(r!=null)this.copyTo(r);return}if(r==null)r=nbi();var y=nbi(),ts=this.s,ms=m.s;var nsh=this.DB-nbits(pm[pm.t-1]);if(nsh>0){pm.lShiftTo(nsh,y);pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y[ys-1];if(y0==0) return;var yt=y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<<this.F1)/yt,e=1<<this.F2;var i=r.t,j=i-ys,t=(q==null)?nbi():q;y.dlShiftTo(j,t);if(r.compareTo(t)>=0){r[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t<ys)y[y.t++]=0;while(--j>=0){var qd=(r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))<qd){y.dlShiftTo(j,t);r.subTo(t,r);while(r[i]<--qd)r.subTo(t,r)}}if(q!=null){r.drShiftTo(ys,q);if(ts!=ms)BigInteger.ZERO.subTo(q,q)}r.t=ys;r.clamp();if(nsh>0)r.rShiftTo(nsh,r);if(ts<0)BigInteger.ZERO.subTo(r,r)}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0)a.subTo(r,r);return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0) return x.mod(this.m);else return x}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}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 x=this[0];if((x&1)==0) return 0;var y=x&3;y=(y*(2-(x&0xf)*y))&0xf;y=(y*(2-(x&0xff)*y))&0xff;y=(y*(2-(((x&0xffff)*y)&0xffff)))&0xffff;y=(y*(2-x*y%this.DV))%this.DV;return (y>0)?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp=m.invDigit();this.mpl=this.mp&0x7fff;this.mph=this.mp>>15;this.um=(1<<(m.DB-15))-1;this.mt2=2*m.t}function montConvert(x){var r=nbi();x.abs().dlShiftTo(this.m.t,r);r.divRemTo(this.m,null,r);if(x.s<0&&r.compareTo(BigInteger.ZERO)>0)this.m.subTo(r,r);return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2)x[x.t++]=0;for(var i=0;i<this.m.t;++i){var j=x[i]&0x7fff;var u0=(j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;j=i+this.m.t;x[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x[j]>=x.DV){x[j]-=x.DV;x[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}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(e,z){if(e>0xffffffff||e<1) return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&(1<<i))>0)z.mulTo(r2,g,r);else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven())z=new Classic(m);else z=new Montgomery(m);return this.exp(e,z)}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);";
//rng.js
expression += "var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(x){rng_pool[rng_pptr++]^=x&255;rng_pool[rng_pptr++]^=(x>>8)&255;rng_pool[rng_pptr++]^=(x>>16)&255;rng_pool[rng_pptr++]^=(x>>24)&255;if(rng_pptr>=rng_psize)rng_pptr-=rng_psize}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;while(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(ba){var i;for(i=0;i<ba.length;++i)ba[i]=rng_get_byte()}function SecureRandom(){}SecureRandom.prototype.nextBytes=rng_get_bytes;";
//rsa.js
expression += "function parseBigInt(str,r){return new BigInteger(str,r)}function linebrk(s,n){var ret=\"\";var i=0;while(i+n<s.length){ret+=s.substring(i,i+n)+\"\\n\";i+=n}return ret+s.substring(i,s.length)}function byte2Hex(b){if(b<0x10)return \"0\"+b.toString(16);else return b.toString(16)}function pkcs1pad2(s,n){if(n<s.length+11){alert(\"Message too long for RSA\");return null}var ba=new Array();var i=s.length-1;while(i>=0&&n>0)ba[--n]=s.charCodeAt(i--);ba[--n]=0;var rng=new SecureRandom();var x=new Array();while(n>2){x[0]=0;while(x[0]==0)rng.nextBytes(x);ba[--n]=x[0]}ba[--n]=2;ba[--n]=0;return new BigInteger(ba)}function RSAKey(){this.n=null;this.e=0;this.d=null;this.p=null;this.q=null;this.dmp1=null;this.dmq1=null;this.coeff=null}function RSASetPublic(N,E){if(N!=null&&E!=null&&N.length>0&&E.length>0){this.n=parseBigInt(N,16);this.e=parseInt(E,16)}else alert(\"Invalid RSA public key\")}function RSADoPublic(x){return x.modPowInt(this.e,this.n)}function RSAEncrypt(text){var m=pkcs1pad2(text,(this.n.bitLength()+7)>>3);if(m==null)return null;var c=this.doPublic(m);if(c==null)return null;var h=c.toString(16);if((h.length&1)==0) return h;else return \"0\"+h}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;";
//回返值用?作为用户名和密码的分割符
expression += "var Login = new Object(); function CmdEncrypt() { var module = '" + module + "';var empoent = '" + empoent + "'; Login.key = new RSAKey();Login.key.setPublic(module,empoent);var resUseranme = Login.key.encrypt('" + userName + "');var resPassword = Login.key.encrypt('" + password + "');return resUseranme+\"?\"+resPassword;} CmdEncrypt();";
MSScriptControl.ScriptControlClass sc = new MSScriptControl.ScriptControlClass();
sc.Language = "javascript";
sc.AllowUI = true;
sc.UseSafeSubset = false;
result = (string)sc.Eval(expression);//NET4.0以下为js.Run("Eval",ref _params).ToString();
return result;
}
/// <summary>
/// 解密js NET4.0以下版本
/// </summary>
/// <param name="stringjs"></param>
/// <returns></returns>
public string DecodeEval(string stringjs)
{
string MyJs = "function Eval(code){code2=code.replace(/^eval/,'');return eval(code2);}";
object[] _params = new object[];
_params[] = stringjs;
MSScriptControl.ScriptControlClass sc = new MSScriptControl.ScriptControlClass();
sc.Language = "javascript";
sc.AddCode(MyJs);
string result = sc.Run("Eval", _params).ToString();//NET4.0以下为js.Run("Eval",ref _params).ToString();
return result;
}
/// <summary>
/// 解密js
/// </summary>
/// <param name="stringJs"></param>
/// <returns></returns>
public static string Decode(string stringJs)
{
string myJs =
"function de_code(code) {if (/^eval/gi.test(code)) {try {eval(code.replace(/^eval/gi, 'var a=').replace('/(', '('));} catch (e) { alert(e); }if (!/^eval/gi.test(a)) { var b = a;} return de_code(a);} else { return code;}}";
object[] parms = new object[]; parms[] = stringJs;
MSScriptControl.ScriptControl js = new MSScriptControl.ScriptControl();
js.Language = "javascript";
js.AddCode(myJs);
string result = (string)js.Run("de_code", parms);//NET4.0以下为js.Run("Eval",ref _params).ToString();
return result;
}

C#后台执行js

public static string GetMatchResult(string content)
{
if (!string.IsNullOrEmpty(content))
{
content = content.Trim().Replace("\n", "").Replace("\r", "").Replace("\t", "");
//content = Regex.Replace(content, "\\s+", " ");
content = Regex.Replace(content, " ", " ");
//content = Regex.Replace(content, "<br\\s*/*>", System.Environment.NewLine);
return content;
}
return null;
} public static CookieCollection AdditionalCookies(CookieCollection cookies, CookieCollection addCookies)
{
if ((addCookies == null || addCookies.Count == )) return cookies;
if ((cookies == null || cookies.Count == )) return addCookies;
CookieCollection newCookies = new CookieCollection();
newCookies.Add(addCookies);
foreach (Cookie cookie in cookies)
{
bool find = false;
foreach (Cookie addCookie in addCookies)
{
if (addCookie.Name == cookie.Name) find = true;
}
if (!find) newCookies.Add(cookie);
}
return newCookies;
}
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}

其他方法

 }