/*MD5加密函数*/ public string Sign(string paraValue, List<Para> paraValue_list, UserTabpage oPage) { string sign = ""; Regex reg = new Regex(@"(?<={)[^{}]+(?=})"); MatchCollection mc = reg.Matches(paraValue); if(paraValue_list.Count == 0) { foreach (Match m in mc) { if(m.Value == "json") { paraValue = paraValue.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text)); } } } else { foreach (Match m in mc) { foreach (Para para in paraValue_list) { if (m.Value == para.getParaName()) { paraValue = paraValue.Replace("{" + m.Value + "}", para.getParaValue()); }else if(m.Value == "json") { paraValue = paraValue.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text)); }else if(m.Value == "reqBody") { paraValue = paraValue.Replace("{" + m.Value + "}", AutoTamperReqBeforeHandler.rbody); }else if(m.Value == "fKey") { paraValue = paraValue.Replace("{" + m.Value + "}", oPage.getKeyText()); } } } } sign = FormsAuthentication.HashPasswordForStoringInConfigFile(paraValue, "MD5").ToLower(); return sign; }
/*设置返回值*/ public string setResponseBody(string response_ta_value, List<Para> paraValue_list, Session oSession, UserTabpage oPage) { string[] requestPar = null; oSession["ui-color"] = "brown"; if (oPage.getRequestType_cb().Text == "GET") { string url = oSession.url; requestPar = url.Split(new char[2] { '?', '&' }); } else if(oPage.getRequestType_cb().Text == "POST") { string url = oSession.GetRequestBodyAsString(); requestPar = url.Split(new char[1] { '&' }); } foreach (Para para in paraValue_list) { if (para.getParaTypeComboBox().Text == "读取") { foreach (string ii in requestPar) { if (ii.Contains(para.getParaName())) { para.setParaValue(ii.ToString().Substring(ii.ToString().IndexOf("=") + 1)); } } } } oPage.updatepPreview_response1(); if(oPage.getCheckBox2().Checked) { oPage.getResponseTextBoxValue().Text += "|" + oPage.getPreviewTextbox().Text; } /*将大括号中符合规定的值替换*/ Regex reg = new Regex(@"(?<={)[^{}]+(?=})"); MatchCollection mc = reg.Matches(response_ta_value); if (paraValue_list.Count == 0) { foreach (Match m in mc) { if (m.Value == "json") { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text)); } else if (m.Value == "sign") { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(oPage.getSignValue_text().Text, paraValue_list, oPage)); } } } else { foreach (Match m in mc) { foreach(Para para in paraValue_list) { if(m.Value == para.getParaName()) { if (para.getParaTypeComboBox().Text == "MD5") { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(para.getParaValue(), paraValue_list, oPage)); } else { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", para.getParaValue()); } } else if(m.Value == "json") { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.jsonTOurlencode(oPage.getPreviewTextbox().Text)); } else if(m.Value == "sign") { response_ta_value = response_ta_value.Replace("{" + m.Value + "}", this.Sign(oPage.getSignValue_text().Text, paraValue_list, oPage)); } } } } return response_ta_value; }