声明:本文只作学习研究,禁止用于非法用途,否则后果自负,如有侵权,请告知删除,谢谢!
前言
这两周工作比较忙,都没时间发博客了,今天手上的活干的差不多,终于可以发一篇最近的逆向网站
aHR0cDovLzIxOC45NC43OC42MTo4MDgwL25ld1B1Yi93ZWIvaG9tZS5odG0=
一、页面分析
这个网站主要是请求参数和响应参数进行了加密,我们只要破解一个接口的加密方式就可以,然后每个接口的请求参数都不一样,需要自己下断点调试找
二、参数加密位置
1.这里以排污许可证企业下拉(点击+号)数据为例
2.参数没有详细的数据,无法搜索,直接下XHR断点,慢慢调试找
3.最终找到了请求参数加密的位置,里面有两个参数,其中settings.data
参数里的cantonCode是下拉省份的id
settings.data参数如下:(每个接口参数会便话)
{
methodName: "queryOnlineEntCountList",
paramsJson: '{"ticket":"451a9846-058b-4944-86c6-fccafdb7d8d0","parameter":{"cantonCode":"321100","cantonLevel":2,"onlineYear":"9999"}}',
serviceName: "publish"
}
settings.dataPublicKey参数如下:(固定参数)
"技术支持:江苏神彩科技股份有限公司"
4.然后我们就要找fw.fwSafe.FWSafeHelper.encrypt
的加密函数,直接断点进去看看
5.好像加密函数挺好找的,直接吧这个文件扣下来,加几个变量就能用了,去掉一些没用的,代码如下:
window = {
};
(function (window, undefined) {
var _fw = window.fw;
fw = {
fwArrayHelper: {
FWArrayHelper: {
add: function (value, item) {
return value.push(item)
},
indexOf: function (Object) {
for (var i = 0; i < this.length; i++) {
if (this[i] == Object) {
return i
}
}
;
return -1
},
remove: function (obj) {
var index = this.indexOf(obj);
if (index > -1) {
this.splice(index, 1)
}
}
}
},
fwBoolean: {
FWBooleanHelper: {
toBoolean: function (_Boolean) {
return _Boolean
},
toNumber: function (_Boolean) {
return _Boolean ? 1 : 0
}
}
},
fwButton: {
fwButtonHelper: {
}
},
fwConfig: {
FWConfigHelper: {
dataPublicKey: undefined,
dynamicDirectory: undefined
}
},
fwCookie: {
},
fwData: {
FWResultStatus: {
Error: -3,
NoRight: -2,
LoginOut: -1,
Failure: 0,
Success: 1,
Frequently: 2
},
FWFileUploadStatus: {
Analysing: 0,
Uploading: 1,
Pause: 2,
Finished: 3
},
FWDataType: {
String: "String",
Int16: "tinyint",
Int32: "int",
Int64: "bigint",
Single: "Single",
Double: "Double",
Decimal: "decimal",
Boolean: "bit",
DateTime: "datetime"
},
FWFileExtensionType: {
Image: 1,
Word: 2
},
FWSelectType: {
Single: 1,
Multi: "n",
All: "all"
},
FWSortType: {
inherit: -1,
asc: 0,
desc: 1
},
FWMenuType: {
SysManage: "sysManage",
MainMenu: "mainMenu"
},
FWTaskType: {
Dll: 10,
Url: 11,
Sql: 12
},
FWTimingType: {
Year: 10,
Month: 11,
Day: 12,
Hour: 13,
Interval: 20,
Timing: 30,
Week: 40
},
FWOpenType: {
Tab: 10,
UIOpen: 11,
WindowOpen: 19
},
FWDBAction: {
Update: 2,
Delete: 3
},
FWObjType: {
T: "T",
V: "V",
M: "M",
O: "O"
}
},
fwDataTable: {
FWDataTableHelper: {
}
},
fwDateTime: {
FWDateTimeHelper: {
toString: function (_DateTime, format) {
var result = null;
if (!fw.fwObject.FWObjectHelper.hasValue(format)) {
format = "yyyy-MM-dd HH:mm:ss"
}
;
if (format == "UTCDateTime") {
result = "/Date(" + (TL.DateTime.AddHours(_DateTime, -8) - TL.ToDateTime("1970-01-01")) + "+0800)/"
} else {
var o = {
"M+": _DateTime.getMonth() + 1,
"d+": _DateTime.getDate(),
"h+": _DateTime.getHours() % 12 == 0 ? 12 : _DateTime.getHours() % 12,
"H+": _DateTime.getHours(),
"m+": _DateTime.getMinutes(),
"s+": _DateTime.getSeconds(),
"q+": Math.floor((_DateTime.getMonth() + 3) / 3),
"S": _DateTime.getMilliseconds()
};
var week = {
"0": "/u65e5",
"1": "/u4e00",
"2": "/u4e8c",
"3": "/u4e09",
"4": "/u56db",
"5": "/u4e94",
"6": "/u516d"
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (_DateTime.getFullYear() + "").substr(4 - RegExp.$1.length))
}
;
if (/(E+)/.test(format)) {
format = format.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""])
}
;
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
}
}
;result = format
}
;
return result
},
toInTime: function (startTime, endTime) {
var seconds = Math.abs(parseInt((endTime - startTime) / 1000, 10));
return fw.fwNumber.FWNumberHelper.toInTime(seconds)
}
}
},
fwFileUpload: {
fwFileUploadHelper: {
imageExtensions: "gif|bmp|jpg|jpeg|png",
wordExtensions: "txt|doc|docx",
}
},
fwJson: {
FWJsonHelper: {
JsonFormatMode: {
ToString: 0,
ToFormatString: 1,
ToHTML: 2,
ToXML: 3
},
JsonMode: {
View: 0,
Edit: 1
},
_SerializeObject: function (Properties) {
var Settings = {
Value: null,
IsUseCustomFormat: false,
FormatMode: fw.fwJson.FWJsonHelper.JsonFormatMode.ToString,
Level: 0
};
if (!fw.fwObject.FWObjectHelper.hasValue(Properties)) {
Properties = {
}
}
;$.extend(Settings, Properties);
var value = Settings.Value;
var IsUseCustomFormat = fw.fwBoolean.FWBooleanHelper.toBoolean(Settings.IsUseCustomFormat);
var FormatMode = Settings.FormatMode;
var Level = fw.fwObject.FWObjectHelper.toNumber(Settings.Level);
var Space = "";
var Space_Plus1 = "";
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
for (var i = 0; i < Level; i++) {
Space += " "
}
;
for (var i = 0; i < Level + 1; i++) {
Space_Plus1 += " "
}
;
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
for (var i = 0; i < Level; i++) {
Space += " "
}
;
for (var i = 0; i < Level + 1; i++) {
Space_Plus1 += " "
}
;
break
}
;
switch (Object.prototype.toString.apply(value)) {
case "[object String]":
if (IsUseCustomFormat && value.indexOf("/Date(") > -1) {
return "\"" + value.ToDate().ToString("yyyy-MM-dd HH:mm:ss") + "\""
} else if (value.indexOf("/Date(") == 0 && value.lastIndexOf(")/") == (value.length - 2) && value.length == 21) {
return "\"" + value.replace(/\//g, "\\/") + "\""
} else {
return "\"" + value.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g, function () {
var a = arguments[0];
return (a == "\n") ? "\\n" : (a == "\r") ? "\\r" : (a == "\t") ? "\\t" : ""
}) + "\""
}
;
case "[object Number]":
return value;
case "[object Boolean]":
return value;
case "[object Object]":
if (value == undefined || value == null) {
return null
} else {
var valueArray = [];
for (var i in value) {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
valueArray.push("\"" + i + "\":" + fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}));
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
valueArray.push(Space_Plus1 + "\"" + i + "\": " + fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}));
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
valueArray.push("<br /><span>" + Space_Plus1 + "</span><span class=\"TL_Json_Property\">\"" + i + "\"</span><span class=\"TL_Json_Colon\">: </span><span class=\"TL_Json_Value\">" + fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}) + "</span>");
break
}
}
;
if (valueArray.length > 0) {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
return '{' + valueArray.join(',') + '}';
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
return '{\n' + valueArray.join(',\n') + '\n' + Space + '}';
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
return '<span class=\"TL_Json_Braces\">{</span><span class=\"TL_Json_NodeToggle\"></span><span class=\"TL_Json_Nodes\">' + valueArray.join('<span class=\"TL_Json_Comma\">,</span>') + '</span><br /><span>' + Space + '</span><span class=\"TL_Json_Braces\">}</span>';
break
}
} else {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
return '{}';
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
return '{}';
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
return '<span class=\"TL_Json_Braces\">{</span><span class=\"TL_Json_Braces\">}</span>';
break
}
}
}
;
case "[object Array]":
var valueArray = [];
for (var i = 0; i < value.length; i++) {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
valueArray.push(fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}));
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
valueArray.push(Space_Plus1 + fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}));
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
valueArray.push("<br /><span>" + Space_Plus1 + "</span>" + fw.fwJson.FWJsonHelper._SerializeObject({
Value: value[i],
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode,
Level: Level + 1
}));
break
}
}
;
if (valueArray.length > 0) {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
return "[" + valueArray.join(',') + "]";
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
return "[\n" + valueArray.join(',\n') + "\n" + Space + "]";
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
return "<span class=\"TL_Json_Brackets\">[</span><span class=\"TL_Json_NodeToggle\"></span><span class=\"TL_Json_Nodes\">" + valueArray.join('<span class=\"TL_Json_Comma\">,</span>') + "</span><br /><span>" + Space + "</span><span class=\"TL_Json_Brackets\">]</span>";
break
}
} else {
switch (FormatMode) {
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToString:
return "[]";
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToFormatString:
return "[]";
break;
case fw.fwJson.FWJsonHelper.JsonFormatMode.ToHTML:
return "<span class=\"TL_Json_Brackets\">[</span><span class=\"TL_Json_Brackets\">]</span>";
break
}
}
;
case "[object Null]":
return null;
case "[object Undefined]":
return null;
case "[object Function]":
return null;
case "[object DOMWindow]":
return null;
case "[object global]":
return null;
default:
alert(value.toString() + "_SerializeObject发现未知类型!" + Object.prototype.toString.apply(value));
break
}
},
serializeObject: function (value, IsUseCustomFormat, FormatMode) {
if (!fw.fwObject.FWObjectHelper.hasValue(IsUseCustomFormat)) {
IsUseCustomFormat = false
}
;
if (!fw.fwObject.FWObjectHelper.hasValue(FormatMode)) {
FormatMode = fw.fwJson.FWJsonHelper.JsonFormatMode.ToString
}
;
return fw.fwJson.FWJsonHelper._SerializeObject({
Value: value,
IsUseCustomFormat: IsUseCustomFormat,
FormatMode: FormatMode
})
}
}
},
fwNumber: {
intMaxValue: 2147483647,
FWNumberHelper: {
toNumber: function (_Number) {
return _Number
},
toBoolean: function (_Number) {
return _Number == 1
},
toDateTime: function (_Number) {
var DateString = fw.fwString.FWStringHelper.trim(value.toString());
if (DateString.indexOf("/Date(") == 0 && DateString.lastIndexOf(")/") == DateString.length - 2) {
return eval('new ' + DateString.replace(/\//g, ''))
}
;var Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
if (Results && Results.length > 3) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]))
}
;Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
if (Results && Results.length > 6) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]), parseFloat(Results[4]), parseFloat(Results[5]), parseFloat(Results[6]))
}
;Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
if (Results && Results.length > 7) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]), parseFloat(Results[4]), parseFloat(Results[5]), parseFloat(Results[6]), parseFloat(Results[7]))
}
;
return ""
},
toString: function (_Number, format) {
var result = null;
if (!fw.fwObject.FWObjectHelper.hasValue(format)) {
result = _Number.toString()
}
;
if (format == "UTCDateTime") {
result = "/Date(" + (TL.DateTime.AddHours(_DateTime, -8) - TL.ToDateTime("1970-01-01")) + "+0800)/"
} else {
var re = /%/;
if (re.test(format)) {
_Number = _Number * 100
}
;var patterns = format.split(".");
var numbers = (_Number + "").split(".");
var lpatterns = patterns[0].split("");
var lpatternsbak = patterns[0].split("");
var lkeep = "";
var rkeep = "";
if (numbers[1]) {
var rnumbers = numbers[1].split("");
var count = 0;
if (patterns[1]) {
var rpatterns = patterns[1].split("");
for (var i = 0; i < rpatterns.length; i++) {
if (rpatterns[i] == "#" || rpatterns[i] == "0") {
count++
}
}
}
;
if (rnumbers.length > count) {
numbers = (_Number.toFixed(count) + "").split(".")
}
}
;var lnumbers = numbers[0].split("");
var lplaces = [];
for (var i = 0; i < lpatterns.length; i++) {
var parternchar = lpatterns[i];
if (parternchar == "#" || parternchar == "0") {
lplaces.push(i)
}
}
;
if (lnumbers[0] && lnumbers[0].length > 0) {
var numberIndex = lnumbers.length - 1;
var replaced = 0;
for (var i = lplaces.length - 1; i >= 0; i--) {
replaced++;
var place = lplaces[i];
lpatterns[place] = lnumbers[numberIndex];
if (numberIndex == 0) {
break
}
;numberIndex--
}
;var lstartIdx = lplaces[0];
var nlen = lnumbers.length;
var plen = lplaces.length;
if (nlen > plen) {
lpatternsbak.splice(lstartIdx, 0, "#")
}
;
if (lpatternsbak[lstartIdx] == "#") {
if (lnumbers.length > replaced) {
var idx = lnumbers.length - replaced;
for (var i = 0; i < idx; i++) {
lkeep += lnumbers[i]
}
;lpatterns[lstartIdx] = lkeep + lpatterns[lstartIdx]
}
}
}
;
if (patterns[1] && patterns[1].length > 0) {
var rpatterns = patterns[1].split("");
if (numbers[1] && numbers[1].length > 0) {
var rnumbers = numbers[1].split("");
var rplaces = [];
for (var i = 0; i < rpatterns.length; i++) {
var parternchar = rpatterns[i];
if (parternchar == "#" || parternchar == "0") {
rplaces.push(i)
}
}
;var replaced = 0;
for (var i = 0; i < rplaces.length; i++) {
replaced++;
var place = rplaces[i];
rpatterns[place] = rnumbers[i];
if (i == rnumbers.length - 1) {
break
}
}
}
}
;
for (var i = 0; i < lpatterns.length; i++) {
if (lpatterns[i] == "#") {
lpatterns[i] = ""
}
}
;result = lpatterns.join("");
if (patterns[1]) {
for (var i = 0; i < rpatterns.length; i++) {
if (rpatterns[i] == "#") {
rpatterns[i] = ""
}
}
;result += "." + rpatterns.join("")
}
;
if (result.substring(0, 1) == ",") {
result = result.substring(1)
}
;
if (result.substring(result.length - 1) == ",") {
result = result.substring(0, result.length)
}
;
if (result == format) {
result = ""
}
}
;
return result
},
toInTime: function (seconds) {
var inTime = "";
var years = 0
, months = 0
, dates = 0
, hours = 0
, minutes = 0;
if (seconds >= (12 * 30 * 24 * 60 * 60)) {
years = parseInt(seconds / (12 * 30 * 24 * 60 * 60), 10);
seconds -= years * (12 * 30 * 24 * 60 * 60);
inTime += years + "年"
}
;
if (seconds >= (30 * 24 * 60 * 60)) {
months = parseInt(seconds / (30 * 24 * 60 * 60), 10);
seconds -= months * (30 * 24 * 60 * 60);
inTime += months + "月"
}
;
if (seconds >= (24 * 60 * 60)) {
dates = parseInt(seconds / (24 * 60 * 60), 10);
seconds -= dates * (24 * 60 * 60);
inTime += dates + "天"
}
;
if (seconds >= (60 * 60)) {
hours = parseInt(seconds / (60 * 60), 10);
seconds -= hours * (60 * 60);
inTime += hours + "时"
}
;
if (seconds >= (60)) {
minutes = parseInt(seconds / (60), 10);
seconds -= minutes * (60);
inTime += minutes + "分"
}
;
if (seconds >= 0) {
seconds = parseInt(seconds, 10);
inTime += seconds + "秒"
}
;
return inTime
},
add: function (_Number1, _Number2) {
var r1, r2, m;
try {
r1 = _Number1.toString().split(".")[1].length
} catch (e) {
r1 = 0
}
;
try {
r2 = _Number2.toString().split(".")[1].length
} catch (e) {
r2 = 0
}
;m = Math.pow(10, Math.max(r1, r2));
return (_Number1 * m + _Number2 * m) / m
}
}
},
fwObject: {
FWObjectHelper: {
hasValue: function (anyType, isIncludeString) {
var Is = false;
if (anyType != undefined && anyType != null) {
switch (Object.prototype.toString.apply(anyType)) {
case "[object String]":
anyType = fw.fwString.FWStringHelper.trim(anyType.toLocaleLowerCase());
Is = (anyType == "undefined" || anyType == "null" || anyType.length < 1);
break;
case "[object Number]":
break;
case "[object Boolean]":
break;
case "[object Object]":
Is = $.isEmptyObject(anyType);
break;
case "[object Array]":
Is = (anyType.length < 1);
break
}
} else {
Is = true
}
;
return !Is
},
isArray: function (anyType) {
return $.isArray(anyType)
},
toString: function (value, format) {
var result = null;
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
switch (Object.prototype.toString.apply(value)) {
case "[object Date]":
result = fw.fwDateTime.FWDateTimeHelper.toString(value, format);
break;
case "[object Number]":
result = fw.fwNumber.FWNumberHelper.toString(value, format);
break;
case "[object Boolean]":
result = fw.fwBoolean.FWBooleanHelper.toString(value, format);
break;
default:
result = fw.fwJson.FWJsonHelper.serializeObject(value);
break
}
} else {
result = null
}
;
return result
},
toDateTime: function (value) {
var result = null;
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
switch (Object.prototype.toString.apply(value)) {
case "[object String]":
result = fw.fwString.FWStringHelper.toDateTime(value);
break;
case "[object Number]":
result = fw.fwNumber.FWNumberHelper.toDateTime(value);
break;
default:
result = value;
break
}
} else {
result = null
}
;
return result
},
toBoolean: function (value) {
var result = false;
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
switch (Object.prototype.toString.apply(value)) {
case "[object Boolean]":
result = fw.fwBoolean.FWBooleanHelper.toBoolean(value);
break;
case "[object Number]":
result = fw.fwNumber.FWNumberHelper.toBoolean(value);
break;
case "[object String]":
result = fw.fwString.FWStringHelper.toBoolean(value);
break;
default:
result = false;
break
}
} else {
result = false
}
;
return result
},
toNumber: function (value, format) {
var result = null;
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
switch (Object.prototype.toString.apply(value)) {
case "[object Boolean]":
result = fw.fwBoolean.FWBooleanHelper.toNumber(value, format);
break;
case "[object Number]":
result = fw.fwNumber.FWNumberHelper.toNumber(value, format);
break;
case "[object String]":
result = fw.fwString.FWStringHelper.toNumber(value, format);
break
}
}
;
return result
},
toArray: function (value, separator) {
var result = null;
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
switch (Object.prototype.toString.apply(value)) {
case "[object Boolean]":
result = fw.fwBoolean.FWBooleanHelper.toNumber(value, separator);
break;
case "[object Number]":
result = fw.fwNumber.FWNumberHelper.toNumber(value, separator);
break;
case "[object String]":
result = fw.fwString.FWStringHelper.toArray(value, separator);
break;
case "[object Array]":
result = value;
break
}
}
;
return result
},
emptyToNull: function (value, propertyArray) {
if (fw.fwObject.FWObjectHelper.isArray(value)) {
for (var i = 0; i < value.length; i++) {
fw.fwObject.FWObjectHelper.emptyToNull(value[i], propertyArray)
}
} else {
if (!fw.fwObject.FWObjectHelper.hasValue(propertyArray)) {
propertyArray = [];
for (var propertyName in value) {
propertyArray.push(propertyName)
}
}
;var propertyName;
for (var i = 0; i < propertyArray.length; i++) {
propertyName = propertyArray[i];
if (!fw.fwObject.FWObjectHelper.hasValue(value[propertyName])) {
value[propertyName] = null
}
}
}
;
return value
}
}
},
fwSafe: {
FWSafeHelper: {
ENCRYPT_DIVISOR: 10,
ENCRYPT_MUST_INSERT_INDEX: 1,
ENCRYPT_COUNT: 2,
encrypt: function (value, key) {
if (key == undefined || key == null) {
key = fw.fwConfig.FWConfigHelper.dataPublicKey
}
// ;if (fw.fwObject.FWObjectHelper.hasValue(value) && fw.fwObject.FWObjectHelper.hasValue(key)) {
;
if (true) {
switch (Object.prototype.toString.apply(value)) {
case "[object Object]":
for (var i in value) {
var v = value[i];
if (Object.prototype.toString.apply(v) != "[object String]") {
value[i] = fw.fwJson.FWJsonHelper.serializeObject(value[i])
}
}
;var valueResult = {
};
for (var i in value) {
valueResult[fw.fwSafe.FWSafeHelper.encrypt(i, key)] = fw.fwSafe.FWSafeHelper.encrypt(value[i], key)
}
;value = valueResult;
break;
default:
value = value.toString();
var encryptCount = 0;
do {
value = fw.fwString.FWStringHelper.toBase64String(value);
key = fw.fwString.FWStringHelper.toBase64String(key);
var remainder = key.length % fw.fwSafe.FWSafeHelper.ENCRYPT_DIVISOR;
if (remainder < 1) {
remainder = fw.fwSafe.FWSafeHelper.ENCRYPT_DIVISOR
}
;
if (value.length > remainder) {
value = fw.fwString.FWStringHelper.insert(value, remainder, key.substr(remainder - 1, 1))
}
;
if (value.length > fw.fwSafe.FWSafeHelper.ENCRYPT_MUST_INSERT_INDEX) {
value = fw.fwString.FWStringHelper.insert(value, fw.fwSafe.FWSafeHelper.ENCRYPT_MUST_INSERT_INDEX, key.substr(remainder - 1, 1))
}
;encryptCount++
} while (encryptCount < fw.fwSafe.FWSafeHelper.ENCRYPT_COUNT);
break
}
}
;
return value
},
decrypt: function (value, key) {
if (key == undefined || key == null) {
key = fw.fwConfig.FWConfigHelper.dataPublicKey
}
// ;if (fw.fwObject.FWObjectHelper.hasValue(value) && fw.fwObject.FWObjectHelper.hasValue(key)) {
;
if (true) {
switch (Object.prototype.toString.apply(value)) {
case "[object Object]":
var valueResult = {
};
for (var i in value) {
valueResult[fw.fwSafe.FWSafeHelper.decrypt(i, key)] = fw.fwSafe.FWSafeHelper.decrypt(value[i], key)
}
;value = valueResult;
break;
default:
value = value.toString();
var encryptCount = 0;
do {
key = fw.fwString.FWStringHelper.toBase64String(key);
encryptCount++
} while (encryptCount < fw.fwSafe.FWSafeHelper.ENCRYPT_COUNT);
encryptCount = 0;
do {
var remainder = key.length % fw.fwSafe.FWSafeHelper.ENCRYPT_DIVISOR;
if (remainder < 1) {
remainder = fw.fwSafe.FWSafeHelper.ENCRYPT_DIVISOR
}
;
if (value.length > fw.fwSafe.FWSafeHelper.ENCRYPT_MUST_INSERT_INDEX) {
value = fw.fwString.FWStringHelper.remove(value, fw.fwSafe.FWSafeHelper.ENCRYPT_MUST_INSERT_INDEX, 1)
}
;
if (value.length > remainder) {
value = fw.fwString.FWStringHelper.remove(value, remainder, 1)
}
;value = fw.fwString.FWStringHelper.formBase64String(value);
key = fw.fwString.FWStringHelper.formBase64String(key);
encryptCount++
} while (encryptCount < fw.fwSafe.FWSafeHelper.ENCRYPT_COUNT);
break
}
}
;
return value
}
},
FWValidateCodeHelper: {
}
},
fwSelect: {
fwSelectHelper: {
}
},
fwString: {
FWStringHelper: {
empty: "",
toString: function (_String) {
return _String
},
toBoolean: function (_String) {
_String = fw.fwString.FWStringHelper.trim(_String).toLowerCase();
return _String == "true" || _String == "1"
},
toNumber: function (_String) {
if (!isNaN(_String)) {
_String = parseFloat(_String)
} else {
_String = null
}
;
return _String
},
trim: function (value) {
return value.toString().replace(/^\s*|\s$/g, '')
},
remove: function (value, startIndex, count) {
return value.substring(0, startIndex) + value.substring(startIndex + count, value.length)
},
insert: function (value, startIndex, insertValue) {
return value.substring(0, startIndex) + insertValue + value.substring(startIndex, value.length)
},
replaceAll: function (value, StringReplace, StringReplaceTo) {
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
var _RegExp = new RegExp(StringReplace.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g, "\\$1"), "ig");
value = value.replace(_RegExp, StringReplaceTo)
}
;
return value
},
toDateTime: function (value) {
var DateString = fw.fwString.FWStringHelper.trim(value.toString());
if (DateString.indexOf("/Date(") == 0 && DateString.lastIndexOf(")/") == DateString.length - 2) {
return eval('new ' + DateString.replace(/\//g, ''))
}
;DateString = fw.fwString.FWStringHelper.replaceAll(DateString, "T", " ");
var Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
if (Results && Results.length > 3) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]))
}
;Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
if (Results && Results.length > 6) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]), parseFloat(Results[4]), parseFloat(Results[5]), parseFloat(Results[6]))
}
;Results = DateString.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
if (Results && Results.length > 7) {
return new Date(parseFloat(Results[1]), parseFloat(Results[2]) - 1, parseFloat(Results[3]), parseFloat(Results[4]), parseFloat(Results[5]), parseFloat(Results[6]), parseFloat(Results[7]))
}
;
return ""
},
toArray: function (value, separator) {
return value.split(separator)
},
_base64encode: function (str) {
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var out;
var i;
var len;
var c1;
var c2;
var c3;
len = str.length;
i = 0;
out = "";
while (i < len) {
c1 = str.charCodeAt(i++) & 0xff;
if (i == len) {
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt((c1 & 0x3) << 4);
out += "==";
break
}
;c2 = str.charCodeAt(i++);
if (i == len) {
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
out += base64EncodeChars.charAt((c2 & 0xF) << 2);
out += "=";
break
}
;c3 = str.charCodeAt(i++);
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
out += base64EncodeChars.charAt(c3 & 0x3F)
}
;
return out
},
_base64decode: function (str) {
var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
var c1;
var c2;
var c3;
var c4;
var i;
var len;
var out;
len = str.length;
i = 0;
out = "";
while (i < len) {
do {
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]
} while (i < len && c1 == -1);
if (c1 == -1) {
break
}
;
do {
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]
} while (i < len && c2 == -1);
if (c2 == -1) {
break
}
;out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
do {
c3 = str.charCodeAt(i++) & 0xff;
if (c3 == 61) {
return out
}
;c3 = base64DecodeChars[c3]
} while (i < len && c3 == -1);
if (c3 == -1) {
break
}
;out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
do {
c4 = str.charCodeAt(i++) & 0xff;
if (c4 == 61) {
return out
}
;c4 = base64DecodeChars[c4]
} while (i < len && c4 == -1);
if (c4 == -1) {
break
}
;out += String.fromCharCode(((c3 & 0x03) << 6) | c4)
}
;
return out
},
_utf16to8: function (str) {
var out;
var i;
var len;
var c;
out = "";
len = str.length;
for (i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i)
} else {
if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F))
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F))
}
}
}
;
return out
},
_utf8to16: function (str) {
var out;
var i;
var len;
var c;
var char2;
var char3;
out = "";
len = str.length;
i = 0;
while (i < len) {
c = str.charCodeAt(i++);
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
out += str.charAt(i - 1);
break;
case 12:
case 13:
char2 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
char2 = str.charCodeAt(i++);
char3 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break
}
}
;
return out
},
toBase64String: function (str) {
if (fw.fwObject.FWObjectHelper.hasValue(str)) {
return fw.fwString.FWStringHelper._base64encode(fw.fwString.FWStringHelper._utf16to8(str))
}
return str
},
formBase64String: function (str) {
if (fw.fwObject.FWObjectHelper.hasValue(str)) {
return fw.fwString.FWStringHelper._utf8to16(fw.fwString.FWStringHelper._base64decode(str))
}
return str
}
}
},
fwUrl: {
FWUrlHelper: {
encode: function (value) {
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
value = fw.fwString.FWStringHelper.replaceAll(encodeURIComponent(value), "%3D", "%3d")
}
;
return value
},
decode: function (value) {
if (fw.fwObject.FWObjectHelper.hasValue(value)) {
value = decodeURIComponent(value)
}
;
return value
},
param: function (data, encryptKey) {
var resultData = {
};
for (var i in data) {
resultData[fw.fwSafe.FWSafeHelper.encrypt(i, encryptKey)] = fw.fwSafe.FWSafeHelper.encrypt(data[i], encryptKey)
}
;
return $.param(resultData)
}
}
},
scrollLeft: function (Selector, ScrollLeft) {
var SelectorJQ = $(Selector);
if (ScrollLeft == undefined) {
return SelectorJQ.scrollLeft()
} else {
SelectorJQ.scrollLeft(ScrollLeft);
return jQueryExtension.ScrollLeft(SelectorJQ)
}
},
scrollWidth: function (Selector) {
var SelectorJQ = $(Selector);
if (SelectorJQ.length < 1) {
return 0
}
;
return SelectorJQ[0].scrollWidth
},
scrollTop: function (Selector, ScrollTop) {
var SelectorJQ = $(Selector);
if (ScrollTop == undefined) {
return SelectorJQ.scrollTop()
} else {
SelectorJQ.scrollTop(ScrollTop);
return jQueryExtension.ScrollTop(SelectorJQ)
}
},
scrollHeight: function (Selector) {
var SelectorJQ = $(Selector);
if (SelectorJQ.length < 1) {
return 0
}
;
return SelectorJQ[0].scrollHeight
},
fwShell: {
FWShellHelper: {
close: function () {
try {
window.external.close()
} catch (ex) {
}
}
}
}
};
_fw = window.fw = fw
}
)(window);
6.然后我们就可以生成请求的加密参数,可以看出我们自己生成的和网页上的是一致的
var enc_data = {
serviceName: "publish", methodName: "queryOnlineEntCountList", paramsJson: '{"ticket":"451a9846-058b-4944-86c6-fccafdb7d8d0","parameter":{"cantonCode":"321100","cantonLevel":2,"onlineYear":"9999"}}'}
var data = window.fw.fwSafe.FWSafeHelper.encrypt(enc_data, "技术支持:江苏神彩科技股份有限公司");
var str = [];
for (var p in data) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(data[p]));
}
return str.join("&");
7.最后就是响应数据的解密,肯定就是用window.fw.fwSafe.FWSafeHelper.decrypt
方法
// data为响应数据
var res = window.fw.fwSafe.FWSafeHelper.decrypt(data, "技术支持:江苏神彩科技股份有限公司");
return res
总结
工作虽忙但也是要抽空写写博客的~