public static void SearchDirectory(string directory, FileTool fileTool) { DirectoryInfo directoryInfo = new DirectoryInfo(directory); if (!directoryInfo.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + directory); } FileInfo[] fileInfo = directoryInfo.GetFiles(); foreach (FileInfo file in fileInfo) fileTool.SetFile(file); DirectoryInfo[] sudDirectories = directoryInfo.GetDirectories(); foreach (DirectoryInfo subdir in sudDirectories) { fileTool.SetDirectory(subdir); SearchDirectory(subdir.FullName, fileTool); } }
private string _orderNo = String.Empty, _shootDate = String.Empty, _customerNo = String.Empty, _customerName = String.Empty, _moblePhone = String.Empty, _orderVenueNo = string.Empty; //当前顾客订单信息 private void txtDressbarcode_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { string dressBarCode = txtDressbarcode.Text.Trim(); DataTable dtDressAllInfo = ErpService.DressManagement.DressesManage(dressBarCode).Tables[0]; _imgPath = dtDressAllInfo.Rows[0]["DressImagePath"].ToString(); //照片路径 string themeName = dtDressAllInfo.Rows[0]["Themename"].ToString(); //所属风格 string dressStatues = dtDressAllInfo.Rows[0]["dressStatus"].ToString(); //当前状态 int dressEachdayCnt = dtDressAllInfo.Rows[0]["DressNumberOfUsedToday"].SafeDbValue <int>(); //日使用次数 dtDressAllInfo.Dispose(); if (string.IsNullOrEmpty(_imgPath)) { MessageBox.Show(@"该礼服没有礼服照片!"); return; } if (string.IsNullOrEmpty(themeName)) { MessageBox.Show(@"该礼服没有绑定风格,不能加入购物车"); return; } if (!chkSmall.Checked) { if (string.IsNullOrEmpty(grbInformation.Text)) { MessageBox.Show(@"请选择操作类型!"); return; } if (string.IsNullOrEmpty(dressBarCode) || string.IsNullOrEmpty(_shootDate) || string.IsNullOrEmpty(lblName.Text) || string.IsNullOrEmpty(_orderNo) || string.IsNullOrEmpty(_customerNo) || string.IsNullOrEmpty(_customerName) || string.IsNullOrEmpty(_moblePhone) || string.IsNullOrEmpty(_orderVenueNo) || string.IsNullOrEmpty(txtEmpNO.Text)) { MessageBox.Show(@"操作失败,请完善员工和顾客的信息!"); return; } if (_dressList.Contains(dressBarCode)) { MessageBox.Show(@"已操作的条码,请勿重复操作"); return; } if (lblStyle.Text == btnout.Text) //礼服出件 { DataTable dtDressInfo = ErpService.DressManagement.DressEnableUse(dressBarCode, _shootDate).Tables[0]; if (dtDressInfo.Rows.Count == 0) { MessageBox.Show(@"礼服条码或自编码错误或礼服已送洗,检查后重试!"); return; } if (Convert.ToInt32(dtDressInfo.Rows[0]["DressRemainCnt"]) == 0) { MessageBox.Show(@"该礼服今天没有使用次数!"); return; } if (dressStatues.Equals(DressState.外景出库.ToString())) { MessageBox.Show(@"该礼服已外景出库!"); return; } dtDressInfo.Dispose(); //礼服取出次数判断是否可用 DataTable dtCount = ErpService.DressManagement.GetDressInOut( string.Format(@" and dd.DressBarCode = '{0}' and dd.DressState = '{1}' and DATEDIFF(dd,dd.OperateTime,GETDATE())= 0", dressBarCode, DressState.取出)).Tables[0]; if (dtCount.Rows.Count >= dressEachdayCnt) { MessageBox.Show(@"该礼服取出次数已满!"); return; } dtCount.Dispose(); if (!ErpService.DressManagement.ChoosedInsert(dressBarCode, _orderNo, txtEmpNO.Text, lblName.Text, _orderVenueNo, _customerNo, _shootDate, BaseData.DressId)) { MessageBox.Show(@"数据库操作失败!"); return; } //状态更改 Dictionary <string, string> dressInfo = new Dictionary <string, string> { { dressBarCode, dressStatues } //礼服编号+改前状态 }; if (dressEachdayCnt == 1) //使用次数状态更改 { ErpService.DressManagement.UpdateDressState(dressInfo, DressState.外景出库.ToString(), Information.CurrentUser.EmployeeDepartmentName, txtEmpNO.Text.Trim()); } else { ErpService.DressManagement.UpdateDressState(dressInfo, DressState.拍照中.ToString(), Information.CurrentUser.EmployeeDepartmentName, txtEmpNO.Text.Trim()); } if (ErpService.DressManagement.DressOutOperate(dressBarCode, txtEmpNO.Text.Trim(), lblName.Text, btnout.Text.Trim(), _orderVenueNo, lblStyle.Text)) { dgvShow.Rows.Add(dressBarCode, @"InOutDressBarCode"); _dressList.Add(dressBarCode); txtDressbarcode.Clear(); } } else if (lblStyle.Text == btnIn.Text) //礼服入库 { if (ErpService.DressManagement.DressInOperate(dressBarCode, txtEmpNO.Text, lblStyle.Text, _orderVenueNo, lblStyle.Text)) { dgvShow.Rows.Add(dressBarCode, @"InOutDressBarCode"); _dressList.Add(dressBarCode); txtDressbarcode.Clear(); } if (!ErpService.DressManagement.DeleteChoosedDress(dressBarCode, @" and DressEmployeeNO='" + txtEmpNO.Text + "'", _orderNo, Information.CurrentUser.EmployeeName)) { MessageBox.Show(@"已经送进的礼服,到购物车核对是否已删除!"); txtDressbarcode.Clear(); } //状态更改 Dictionary <string, string> dressInfo = new Dictionary <string, string> { { dressBarCode, dressStatues } //礼服编号+改前状态 }; if (!dressStatues.Equals(DressState.礼服送洗.ToString()))//礼服送洗不改变状态 { ErpService.DressManagement.UpdateDressState(dressInfo, DressState.入库.ToString(), lblName.Text, txtEmpNO.Text.Trim()); } } else { MessageBox.Show(@"请选择操作类型,如点击取出按钮!"); return; } } else if (chkSmall.Checked) //小件出入库 { if (string.IsNullOrEmpty(txtEmpNO.Text) || string.IsNullOrEmpty(lblName.Text)) { MessageBox.Show(@"请录入员工信息!"); return; } if (dtDressAllInfo.Rows.Count == 0) { MessageBox.Show(@"不存在该小件!"); return; } if (lblStyle.Text == btnout.Text) { if (ErpService.DressManagement.DressOutOperate(txtDressbarcode.Text, txtEmpNO.Text, lblName.Text, btnout.Text.Trim(), _orderVenueNo, lblStyle.Text)) { MessageBox.Show(@"操作成功!"); txtDressbarcode.Clear(); } } else if (lblStyle.Text == btnIn.Text) { if (ErpService.DressManagement.DressInOperate(txtDressbarcode.Text, txtEmpNO.Text, lblStyle.Text, _orderVenueNo, lblStyle.Text)) { MessageBox.Show(@"操作成功!"); txtDressbarcode.Clear(); } } else { MessageBox.Show(@"请选择操作类型,如点击取出按钮!"); return; } dtDressAllInfo.Dispose(); } string[] pathInfo = _imgPath.Split(Convert.ToChar(@"\")); Ping strPing = new Ping(); PingReply pingReply = strPing.Send(pathInfo[2]); if (pingReply != null && pingReply.Status != IPStatus.Success) { MessageBox.Show(@"无法访问照片路径!"); return; } picImage.Image = FileTool.ReadImageFile(_imgPath.Replace("JPG", "lf").Replace("jpg", "lf")) .ZoomImage(picImage.Size, true, Color.LightGray); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { Master.Title = "空间占用"; //计算全站占用 long AllFtp = FileTool.GetPathLength(Server.MapPath("/")); //计算文件存储占用 long FilesFtp = FileTool.GetPathLength(Server.MapPath("/Files")); //数据库备份占用 long DataFtp = FileTool.GetPathLength(Server.MapPath("/App_Data")); builder.Append(Out.Tab("<div class=\"title\">", "")); builder.Append("空间占用管理"); builder.Append(Out.Tab("</div>", "<br />")); builder.Append(Out.Tab("<div class=\"text\">", "")); builder.Append("空间总占用:" + FileTool.GetContentLength(AllFtp) + ""); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("", "<br />----------<br />")); builder.Append(Out.Tab("<div>", "")); builder.Append("文件存储:"); builder.Append(Out.Tab("<img src=\"/Files/sys/bar.gif\" height=\"10\" width=\"" + Utils.Percent(FilesFtp, AllFtp).Replace("%", "") + "\" />", "")); builder.Append(Utils.Percent(FilesFtp, AllFtp) + "<br />占用" + FileTool.GetContentLength(FilesFtp) + ""); builder.Append(Out.Tab("</div>", "<br />")); builder.Append(Out.Tab("<div>", "")); builder.Append("备份数据:"); builder.Append(Out.Tab("<img src=\"/Files/sys/bar.gif\" height=\"10\" width=\"" + Utils.Percent(DataFtp, AllFtp).Replace("%", "") + "\" />", "")); builder.Append(Utils.Percent(DataFtp, AllFtp) + "<br />占用" + FileTool.GetContentLength(DataFtp) + ""); builder.Append(Out.Tab("</div>", "<br />")); builder.Append(Out.Tab("<div>", "")); builder.Append("程序文件:"); builder.Append(Out.Tab("<img src=\"/Files/sys/bar.gif\" height=\"10\" width=\"" + Utils.Percent((AllFtp - FilesFtp - DataFtp), AllFtp).Replace("%", "") + "\" />", "")); builder.Append(Utils.Percent((AllFtp - FilesFtp - DataFtp), AllFtp) + "<br />占用" + FileTool.GetContentLength(AllFtp - FilesFtp - DataFtp) + ""); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr())); builder.Append(Out.Tab("<div>", "")); builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">系统服务中心</a><br />"); builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>")); builder.Append(Out.Tab("</div>", "<br />")); }
public void SplitDex(string aimPath) { string smaliPath = aimPath.Replace("\\", "/") + "/smali"; //拷贝android-support-multidex.jar string interfacePath = EditorData.SdkLibPath + "\\Interface\\android-support-multidex.jar"; compileTool.Jar2Smali(interfacePath, aimPath); List <string> list = FileTool.GetAllFileNamesByPath(smaliPath, new string[] { "smali" }); Dictionary <string, string> allMethod = new Dictionary <string, string>(); int maxFuncNum = 65535; //int maxFuncNum = 30000; int currentFuncNum = 0; int currentIndex = 1; for (int i = 0; i < list.Count; i++) { list[i] = list[i].Replace("\\", "/"); if (JudgeMainDex(list[i])) { currentFuncNum += CalcSmaliMethodCountBySmali(list[i], allMethod); //OutPut("主Dex:" + list[i] + " funcnum:" + currentFuncNum); } } for (int i = 0; i < list.Count; i++) { list[i] = list[i].Replace("\\", "/"); //剔除所有不需要分包的类 if (JudgeMainDex(list[i])) { continue; } //计算当前有多少方法 currentFuncNum += CalcSmaliMethodCountBySmali(list[i], allMethod); //OutPut("普通Dex:" + list[i] + " funcnum:" + currentFuncNum); if (currentFuncNum > maxFuncNum) { currentFuncNum = 0; currentIndex++; string newPath = smaliPath + "_classes" + currentIndex; FileTool.CreatPath(newPath); //OutPut("超过上限:" + list[i] + " funcnum:" + currentFuncNum + " currentIndex " + currentIndex); } if (currentIndex > 1) { string newPath = smaliPath + "_classes" + currentIndex; string targetPath = newPath + "" + list[i].Replace(smaliPath, ""); FileTool.CreatFilePath(targetPath); File.Move(list[i], targetPath); //OutPut("分包:" + list[i] + " funcnum:" + currentFuncNum + " currentIndex " + currentIndex); } } }
public string BuildRTable(string aimPath, string name, string sdkPath) { string result = ""; String R_Path = aimPath + "/R_path/"; FileTool.CreatPath(R_Path); //String androidPath = @"D:\AndroidSDK\platforms\android-28\android.jar"; string manifest = aimPath + "/AndroidManifest.xml"; string resPath = aimPath + "/res"; CmdService cmd = new CmdService(OutPut, errorCallBack); //生成R文件 cmd.Execute(EditorData.GetAAPTPath() + " package -f -I " + EditorData.GetAndroidJarPath(29) + " -m -J " + R_Path + " -S " + resPath + " -M " + manifest + ""); //aapt2 //cmd.Execute(EditorData.GetAAPT2Path() + " link -I " + EditorData.GetAndroidJarPath(29) + " --java " + R_Path + " -A " + resPath + " --manifest " + manifest + " -v"); if (FindRPath(R_Path) != null) { string javaPath = FindRPath(R_Path); string jarPath = R_Path + "/" + name + "_R.jar"; string rPath = aimPath + "/R.txt"; ////替换ID ////有时不同aar包的R.id 会冲突,这里使用aar自带的R.id,进行替换,如果还不行再改 //result += RTableUtil.AnalysisRJava(javaPath); //编译R.java文件 cmd.Execute("javac -encoding UTF-8 -source 1.7 -target 1.7 " + javaPath, true, true); //删除掉java文件 FileTool.DeleteFile(javaPath); cmd.Execute("cd " + R_Path); //取第一个文件夹名作为命令开头 string fileName = FileTool.GetDirectoryName(Directory.GetDirectories(R_Path)[0]); //生成的R文件的jar cmd.Execute("jar cvf ./" + name + "_R.jar ./" + fileName, path: R_Path); if (File.Exists(jarPath)) { //复制R文件到库 File.Copy(jarPath, sdkPath + "/" + name + "_R.jar", true); result += "R文件生成完成! "; } } else { result += "R文件生成失败! 请检查清单文件是否正确!"; } //FileTool.SafeDeleteDirectory(R_Path); //Directory.Delete(R_Path); return(result); }
private void crackerService(string crakerstring, string username, string password) { try { string[] crakers = crakerstring.Split(':'); string ip = crakers[0]; int port = int.Parse(crakers[1]); string serviceName = crakers[2]; //跳过无法检查的IP列表,提高效率 //多线程安全 lock (list_ip_break) { if (list_ip_break.Contains(ip + port)) { //LogWarning(ip+"-"+port+"跳过检查!"); Interlocked.Increment(ref allCrackCount); return; } } //多线程安全 lock (list_ip_user_break) { //跳过已经检查的列表,提高效率 if (list_ip_user_break.Contains(ip + port + username)) { LogWarning(ip + "-" + port + "-" + username + "跳过检查!"); Interlocked.Increment(ref allCrackCount); return; } } if (true) { Object[] pramars = { ip, port, username, password, timeOut, retryCount }; int count = 0; Server server = new Server(); while (count <= this.retryCount) { count++; try { //跳过检查,多线程安全 bool cconce = false; lock (list_success_username) { cconce = list_success_username.Contains(ip + serviceName + port); } if (this.crackerOneCount && cconce) { Interlocked.Increment(ref allCrackCount); break; } Stopwatch sw = new Stopwatch(); sw.Start(); if (serviceName.Equals("RDP")) { server = creackRDP(ip, port, username, password, timeOut); } else { CrackService cs = null; if (cs == null) { Type type = Type.GetType("SNETCracker.Model.Crack" + serviceName); if (type != null) { cs = (CrackService)Activator.CreateInstance(type); } } server = cs.creack(ip, port, username, password, timeOut); } sw.Stop(); server.userTime = sw.ElapsedMilliseconds; } catch (IPBreakException ie) { string breakip = ie.Message; lock (list_ip_break) { if (!list_ip_break.Contains(breakip)) { list_ip_break.Add(breakip); } } } catch (IPUserBreakException ie) { lock (list_ip_break) { string breakipuser = ie.Message; if (!list_ip_break.Contains(breakipuser)) { list_ip_user_break.Add(breakipuser); } } } catch (TimeoutException te) { continue; } catch (Exception e) { string logInfo = "检查" + ip + ":" + serviceName + "登录发生异常!" + e.Message; LogWarning(logInfo); FileTool.log(logInfo + e.StackTrace); } break; } if (server.isSuccess) { bool success = false; lock (list_success_username) { success = list_success_username.Contains(ip + serviceName + port + username); } if (!success) { if (this.crackerOneCount) { //多线程安全 lock (list_success_username) { success = list_success_username.Contains(ip + serviceName + port); } } if (!success) { //多线程安全 lock (list_success_username) { list_success_username.Add(ip + serviceName + port); list_success_username.Add(ip + serviceName + port + username); } Interlocked.Increment(ref successCount); addItemToListView(successCount, ip, serviceName, port, username, password, server.banner, server.userTime); String sinfo = ip + "-----" + serviceName + "----" + username + "----" + password + "----" + server.banner + "----成功!"; LogInfo(sinfo); FileTool.AppendLogToFile(Directory.GetCurrentDirectory() + "/cracker_result.log", sinfo); } } } else { //LogWarning(ip + "-----" + serviceName + "----" + username + "----" + password + "失败!"); } } } catch (Exception e) { LogError(e.Message + e.StackTrace); } Interlocked.Increment(ref allCrackCount); }
private void readListFile(Object path) { this.list_import_target = FileTool.readFileToList(path.ToString()); LogInfo("读取检查列表完成,导入地址:" + this.list_import_target.Count + "条!"); this.btn_cracker.Enabled = true; }
public static void CreateGuideWindow() { string UIWindowName = "GuideWindow"; UIType UIType = UIType.TopBar; GameObject uiGo = new GameObject(UIWindowName); Type type = EditorTool.GetType(UIWindowName); GuideWindowBase guideBaseTmp = uiGo.AddComponent(type) as GuideWindowBase; uiGo.layer = LayerMask.NameToLayer("UI"); guideBaseTmp.m_UIType = UIType; Canvas can = uiGo.AddComponent <Canvas>(); uiGo.AddComponent <GraphicRaycaster>(); can.overrideSorting = true; can.sortingLayerName = "Guide"; RectTransform ui = uiGo.GetComponent <RectTransform>(); ui.sizeDelta = Vector2.zero; ui.anchorMin = Vector2.zero; ui.anchorMax = Vector2.one; GameObject BgGo = new GameObject("BG"); BgGo.layer = LayerMask.NameToLayer("UI"); RectTransform Bg = BgGo.AddComponent <RectTransform>(); Bg.SetParent(ui); Bg.sizeDelta = Vector2.zero; Bg.anchorMin = Vector2.zero; Bg.anchorMax = Vector2.one; GameObject rootGo = new GameObject("root"); rootGo.layer = LayerMask.NameToLayer("UI"); RectTransform root = rootGo.AddComponent <RectTransform>(); root.SetParent(ui); root.sizeDelta = Vector2.zero; root.anchorMin = Vector2.zero; root.anchorMax = Vector2.one; GameObject mask = new GameObject("mask"); mask.layer = LayerMask.NameToLayer("UI"); RectTransform maskrt = mask.AddComponent <RectTransform>(); Image img = mask.AddComponent <Image>(); img.color = new Color(0, 0, 0, 0.75f); maskrt.SetParent(root); maskrt.sizeDelta = Vector2.zero; maskrt.anchorMin = Vector2.zero; maskrt.anchorMax = Vector2.one; GameObject tips = new GameObject("Tips"); tips.layer = LayerMask.NameToLayer("UI"); RectTransform tipsrt = tips.AddComponent <RectTransform>(); tipsrt.SetParent(root); guideBaseTmp.m_objectList.Add(tips); GameObject Text_tips = new GameObject("Text_tip"); Text_tips.layer = LayerMask.NameToLayer("UI"); RectTransform txt_tipsrt = Text_tips.AddComponent <RectTransform>(); //Text text = Text_tips.AddComponent<Text>(); txt_tipsrt.SetParent(tipsrt); guideBaseTmp.m_objectList.Add(Text_tips); //guideBaseTmp.m_mask = img; //guideBaseTmp.m_TipText = text; //guideBaseTmp.m_TipTransfrom = txt_tipsrt; guideBaseTmp.m_bgMask = BgGo; guideBaseTmp.m_uiRoot = rootGo; string Path = "Resources/UI/" + UIWindowName + "/" + UIWindowName + ".prefab"; FileTool.CreatFilePath(Application.dataPath + "/" + Path); PrefabUtility.CreatePrefab("Assets/" + Path, uiGo, ReplacePrefabOptions.ConnectToPrefab); ProjectWindowUtil.ShowCreatedAsset(uiGo); }
protected override void doSolve() { initial(); string prob = mop.getName(); if (prob.IndexOf("DTLZ") != -1) { igdValue.Add(QulityIndicator.QulityIndicator.DTLZIGD(mainpop, prob, this.numObjectives)); } else { pofData = FileTool.readData(pofPath + prob); igdValue.Add(QulityIndicator.QulityIndicator.IGD(mainpop, pofData)); } if (GlobalValue.IsShowProcess) { frm = new plotFrm(mainpop, mop.getName()); frm.Show(); frm.Refresh(); } while (!terminated()) { List <MoChromosome> offsPop = new List <MoChromosome>(); for (int i = 0; i < popsize; i++) { MoChromosome offspring; if (GlobalValue.CrossoverType.Equals("SBX")) { offspring = SBXCrossover(i, true);//GeneticOPDE//GeneticOPSBXCrossover } else { offspring = DECrossover(i, true); } this.evaluate(offspring); offsPop.Add(offspring); updateReference(offspring); } List <MoChromosome> Pop = new List <MoChromosome>(); Pop.AddRange(mainpop); Pop.AddRange(offsPop); EnviromentSelection(Pop); if (this.ItrCounter >= Mr * this.TotalItrNum && this.ItrCounter % ((int)(this.TotalItrNum * fr)) == 0) { adjustReferencePoints(); } if (this.ItrCounter % 10 == 0) { if (GlobalValue.IsShowProcess) { frm.refereshPlot(this.ItrCounter, mainpop); frm.Refresh(); } if (prob.IndexOf("DTLZ") != -1) { igdValue.Add(QulityIndicator.QulityIndicator.DTLZIGD(mainpop, prob, this.numObjectives)); } else { igdValue.Add(QulityIndicator.QulityIndicator.IGD(mainpop, pofData)); } } this.ItrCounter++; } Common.FileTool.WritetoFile(mainpop, "gen", 1); Common.FileTool.WritetoFile(mainpop, "obj", 2); Common.FileTool.WritetoFile(igdValue, "igdCurve"); }
/// <summary> /// 上传文件 /// </summary> private void SaveFiles(int meid, int leibie, int NodeId, out int kk) { //允许上传数量 int maxAddNum = Convert.ToInt32(ub.GetSub("UpAddNum", xmlPath)); int AddNum = 0; if (maxAddNum > 0) { //计算今天上传数量 AddNum = new BCW.BLL.Upfile().GetTodayCount(meid); } //遍历File表单元素 System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; // int j = 1; int j = files.Count; int k = 0; try { string GetFiles = string.Empty; //for (int iFile = 0; iFile < files.Count; iFile++) for (int iFile = files.Count - 1; iFile > -1; iFile--) { //检查文件扩展名字 System.Web.HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); string UpExt = ub.GetSub("UpaFileExt", xmlPath); int UpLength = Convert.ToInt32(ub.GetSub("UpaMaxFileSize", xmlPath)); if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName).ToLower(); //检查是否允许上传格式 if (UpExt.IndexOf(fileExtension) == -1) { continue; } //非法上传 if (fileExtension == ".asp" || fileExtension == ".aspx" || fileExtension == ".jsp" || fileExtension == ".php" || fileExtension == ".asa" || fileExtension == ".cer" || fileExtension == ".cdx" || fileExtension == ".htr" || fileExtension == ".exe") { continue; } if (postedFile.ContentLength > Convert.ToInt32(UpLength * 1024)) { continue; } string DirPath = string.Empty; string prevDirPath = string.Empty; string Path = "/Files/bbs/" + meid + "/act/"; string prevPath = "/Files/bbs/" + meid + "/prev/"; int IsVerify = 0; if (FileTool.CreateDirectory(Path, out DirPath)) { //上传数量限制 if (maxAddNum > 0) { if (maxAddNum <= (AddNum + k)) { k = -k; if (k == 0) { k = -999; } break; } } //生成随机文件名 fileName = DT.getDateTimeNum() + iFile + fileExtension; string SavePath = System.Web.HttpContext.Current.Request.MapPath(DirPath) + fileName; postedFile.SaveAs(SavePath); //=============================图片木马检测,包括TXT=========================== string vSavePath = SavePath; if (fileExtension == ".txt" || fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png" || fileExtension == ".bmp") { bool IsPass = true; System.IO.StreamReader sr = new System.IO.StreamReader(vSavePath, System.Text.Encoding.Default); string strContent = sr.ReadToEnd().ToLower(); sr.Close(); string str = "system.|request|javascript|script |script>|.getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language="; foreach (string s in str.Split('|')) { if (strContent.IndexOf(s) != -1) { System.IO.File.Delete(vSavePath); IsPass = false; break; } } if (IsPass == false) { continue; } } //=============================图片木马检测,包括TXT=========================== //审核要求指示 int Verify = Utils.ParseInt(ub.GetSub("UpIsVerify", xmlPath)); //缩略图生成 if (fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png" || fileExtension == ".bmp") { int ThumbType = Convert.ToInt32(ub.GetSub("UpaThumbType", xmlPath)); int width = Convert.ToInt32(ub.GetSub("UpaWidth", xmlPath)); int height = Convert.ToInt32(ub.GetSub("UpaHeight", xmlPath)); if (ThumbType > 0) { try { bool pbool = false; if (ThumbType == 1) { pbool = true; } if (FileTool.CreateDirectory(prevPath, out prevDirPath)) { string prevSavePath = System.Web.HttpContext.Current.Request.MapPath(prevDirPath) + fileName; int IsThumb = 0; if (fileExtension == ".gif") { if (ThumbType > 0) { new BCW.Graph.GifHelper().GetThumbnail(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.GifHelper().SmartWaterMark(SavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.GifHelper().WaterMark(SavePath, "", Server.MapPath(ub.GetSub("UpaWord", xmlPath)), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaTran", xmlPath)));//图片水印 } } } else { if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".jpeg") { if (ThumbType > 0) { new BCW.Graph.ImageHelper().ResizeImage(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.ImageHelper().WaterMark(SavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.ImageHelper().WaterMark(SavePath, "", Server.MapPath(ub.GetSub("UpaWord", xmlPath)), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaTran", xmlPath)));//图片水印 } } } } } } catch { } } //图片审核 if (Verify > 0) { IsVerify = 1; } } else { //文件审核 if (Verify > 1) { IsVerify = 1; } //自动识别出非图片 if (leibie == 1) { leibie = FileTool.GetExtType(fileExtension); } } string Content = Utils.GetRequest("stext" + j + "", "post", 1, "", ""); if (!string.IsNullOrEmpty(Content)) { Content = Utils.Left(Content, 30); } else { Content = ""; } BCW.Model.Upfile model = new BCW.Model.Upfile(); model.Types = leibie; // FileTool.GetExtType(fileExtension); model.NodeId = NodeId; model.UsID = meid; model.ForumID = 0; model.BID = 0; model.ReID = 0; model.Files = DirPath + fileName; if (string.IsNullOrEmpty(prevDirPath)) { model.PrevFiles = model.Files; } else { model.PrevFiles = prevDirPath + fileName; } model.Content = Content; model.FileSize = Convert.ToInt64(postedFile.ContentLength); model.FileExt = fileExtension; model.DownNum = 0; model.Cent = 0; model.IsVerify = IsVerify; model.AddTime = DateTime.Now; new BCW.BLL.Upfile().Add(model); k++; } // j++; j--; } } } catch { } kk = k; }
public static void CreatUI(string UIWindowName, string UIcameraKey, UIType UIType, UILayerManager UILayerManager, bool isAutoCreatePrefab) { GameObject uiGo = new GameObject(UIWindowName); Type type = EditorTool.GetType(UIWindowName); UIWindowBase uiBaseTmp = uiGo.AddComponent(type) as UIWindowBase; uiGo.layer = LayerMask.NameToLayer("UI"); uiBaseTmp.m_UIType = UIType; Canvas canvas = uiGo.AddComponent <Canvas>(); if (EditorExpand.isExistShortLayer(UIType.ToString())) { canvas.overrideSorting = true; canvas.sortingLayerName = UIType.ToString(); } uiGo.AddComponent <GraphicRaycaster>(); RectTransform ui = uiGo.GetComponent <RectTransform>(); ui.sizeDelta = Vector2.zero; ui.anchorMin = Vector2.zero; ui.anchorMax = Vector2.one; GameObject BgGo = new GameObject("BG"); BgGo.layer = LayerMask.NameToLayer("UI"); RectTransform Bg = BgGo.AddComponent <RectTransform>(); Bg.SetParent(ui); Bg.sizeDelta = Vector2.zero; Bg.anchorMin = Vector2.zero; Bg.anchorMax = Vector2.one; GameObject rootGo = new GameObject("root"); rootGo.layer = LayerMask.NameToLayer("UI"); RectTransform root = rootGo.AddComponent <RectTransform>(); root.SetParent(ui); root.sizeDelta = Vector2.zero; root.anchorMin = Vector2.zero; root.anchorMax = Vector2.one; uiBaseTmp.m_bgMask = BgGo; uiBaseTmp.m_uiRoot = rootGo; if (UILayerManager) { UILayerManager.SetLayer(uiBaseTmp); } if (isAutoCreatePrefab) { string Path = "Resources/UI/" + UIWindowName + "/" + UIWindowName + ".prefab"; FileTool.CreatFilePath(Application.dataPath + "/" + Path); PrefabUtility.CreatePrefab("Assets/" + Path, uiGo, ReplacePrefabOptions.ConnectToPrefab); } ProjectWindowUtil.ShowCreatedAsset(uiGo); }
private void PhUploadPage(int meid) { BCW.User.Users.ShowVerifyRole("f", meid); //非验证会员提示 new BCW.User.Limits().CheckUserLimit(BCW.User.Limits.enumRole.Role_Upfile, meid); //会员上传权限 //遍历File表单元素 System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; for (int iFile = 0; iFile < files.Count; iFile++) { //检查文件扩展名字 System.Web.HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); string UpExt = ".gif,.jpg,.jpeg,.png,.bmp"; int UpLength = Convert.ToInt32(ub.GetSub("UpaPhFileSize", xmlPath)); if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName).ToLower(); //检查是否允许上传格式 if (UpExt.IndexOf(fileExtension) == -1) { Response.Write("头像图片格式只允许" + UpExt + "<br/>"); Response.Write(Out.back("返回上一级")); Response.Write("</body></html>"); Response.End(); } if (postedFile.ContentLength > Convert.ToInt32(UpLength * 1024)) { Response.Write("头像大小限" + UpLength + "K内<br/>"); Response.Write(Out.back("返回上一级")); Response.Write("</body></html>"); Response.End(); } string DirPath = string.Empty; string prevDirPath = string.Empty; string Path = "/Files/bbs/" + meid + "/tx/"; string prevPath = Path; if (FileTool.CreateDirectory(Path, out DirPath)) { //生成随机文件名 fileName = DT.getDateTimeNum() + iFile + fileExtension; string SavePath = System.Web.HttpContext.Current.Request.MapPath(DirPath) + fileName; postedFile.SaveAs(SavePath); //=============================图片木马检测,包括TXT=========================== string vSavePath = SavePath; bool IsPass = true; System.IO.StreamReader sr = new System.IO.StreamReader(vSavePath, System.Text.Encoding.Default); string strContent = sr.ReadToEnd().ToLower(); sr.Close(); string str = "system.|request|javascript|script |script>|.getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language="; foreach (string s in str.Split('|')) { if (strContent.IndexOf(s) != -1) { System.IO.File.Delete(vSavePath); IsPass = false; break; } } if (IsPass == false) { Utils.Error("非法图片..", ""); } //=============================图片木马检测,包括TXT=========================== string wh = new BCW.Graph.ImageHelper().GetPicxywh(SavePath, 0); wh = wh.Replace("像素", ""); string[] whTemp = wh.Split('*'); int w = Utils.ParseInt(whTemp[0]); int h = Utils.ParseInt(whTemp[1]); if (w < 15 || h < 15) { System.IO.File.Delete(SavePath); Response.Write("头像宽高尺寸都不能小于15像素<br/>"); Response.Write(Out.back("返回上一级")); Response.Write("</body></html>"); Response.End(); } if (w > 240 || h > 320) { //------缩放图片(比例缩放)----- int width = 240; int height = 320; try { bool pbool = true; if (FileTool.CreateDirectory(prevPath, out prevDirPath)) { string prevSavePath = System.Web.HttpContext.Current.Request.MapPath(prevDirPath) + fileName; if (fileExtension == ".gif") { new BCW.Graph.GifHelper().GetThumbnail(SavePath, prevSavePath, width, height, pbool); } else { if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".jpeg") { new BCW.Graph.ImageHelper().ResizeImage(SavePath, prevSavePath, width, height, pbool); } } } DirPath = prevDirPath; } catch { //删除原图 BCW.Files.FileTool.DeleteFile(DirPath + fileName); Response.Write("头像上传失败,头像图片格式也许已损坏,可以重试一下<br/>"); Response.Write(Out.back("返回上一级")); Response.Write("</body></html>"); Response.End(); } } //删除之前的自定义头像文件 string PhotoFile = new BCW.BLL.User().GetPhoto(meid); if (PhotoFile != "" && PhotoFile.Contains("/tx/")) { BCW.Files.FileTool.DeleteFile(PhotoFile); } new BCW.BLL.User().UpdatePhoto(meid, DirPath + fileName); } else { Response.Write("传出现错误<br/>"); Response.Write(Out.back("返回上一级")); Response.Write("</body></html>"); Response.End(); } } } //动态记录 new BCW.BLL.Action().Add(meid, "在空间设置了[URL=/bbs/uinfo.aspx?uid=" + meid + "]新的头像[/URL]"); Response.Write("上传/设置头像成功!"); Response.Write("<br/><a href=\"" + ReplaceWap(Utils.getUrl("uinfo.aspx")) + "\">>查看效果</a>"); Response.Write("<br/><a href=\"" + ReplaceWap(Utils.getPage("uinfo.aspx")) + "\">返回之前页面</a>"); Response.Write("<br/><a href=\"" + ReplaceWap(Utils.getUrl("default.aspx")) + "\">返回社区首页</a>"); Response.Write("</body></html>"); }
void AddAssetBundle(Object obj, string path) { EditorObject objTmp = new EditorObject(); objTmp.obj = obj; objTmp.path = GetObjectPath(obj); if (isExist_AllBundle(objTmp)) { //Debug.Log(obj.name + " 已经存在!"); } else { EditPackageConfig EditPackageConfigTmp = new EditPackageConfig(); if (obj == null) { Debug.LogError("AddAssetBundle ERROR : path: " + path); return; } EditPackageConfigTmp.name = obj.name; EditorObject mainObjTmp = new EditorObject(); mainObjTmp.obj = obj; mainObjTmp.path = GetObjectPath(obj); EditPackageConfigTmp.mainObject = mainObjTmp; EditPackageConfigTmp.path = GetRelativePath(FileTool.RemoveExpandName(GetObjectPath(obj))); Object[] res = GetCorrelationResource(obj); //判断依赖包中含不含有该资源,如果有,则不将此资源放入bundle中 //依赖包判断 for (int j = 0; j < res.Length; j++) { if (res[j] == null) { Debug.LogWarning(obj + " 有资源丢失!"); continue; } ////过滤掉一些不必要加载进去的组件 //if (ComponentFilter(res[j])) //{ // continue; //} EditorObject tmp = new EditorObject(); tmp.obj = res[j]; tmp.path = GetObjectPath(res[j]); //bool isExistRelyPackage = false; for (int i = 0; i < relyPackages.Count; i++) { if (isExist_Bundle(tmp, relyPackages[i])) { //在依赖包选项中添加此依赖包 EditPackageConfigTmp.relyPackagesMask = EditPackageConfigTmp.relyPackagesMask | 1 << i; //isExistRelyPackage = true; break; } } ////该资源不在依赖包中,并且也与主资源不同时,放入包中 //if (isExistRelyPackage == false // &&!EqualsEditorObject(EditPackageConfigTmp.mainObject,tmp) // ) //{ // EditPackageConfigTmp.objects.Add(tmp); //} } bundles.Add(EditPackageConfigTmp); } }
string GetExportPath(string path, string name) { return(Application.dataPath + "/StreamingAssets/" + GetRelativePath(FileTool.RemoveExpandName(path)) + "." + AssetsBundleManager.c_AssetsBundlesExpandName); }
/// <summary> /// 写入配置文件 /// </summary> /// <param name="filename">配置文件名</param> /// <param name="configParaList">风扇配置</param> public void WriteCfgFile(string filename, List <ConfigPara> configParaList) { FileTool.WriteCfgFile(filename, configParaList); }
public static void CleanAllRecord() { FileTool.DeleteDirectory(Application.persistentDataPath + "/" + RecordManager.c_directoryName); CleanCatch(); }
public List <ConfigPara> ReadCfgFile(string filename) { return(FileTool.ReadCfgFile(filename)); }
public static void CreatUIManager(Vector2 referenceResolution, CanvasScaler.ScreenMatchMode MatchMode, bool isOnlyUICamera, bool isVertical) { //UIManager GameObject UIManagerGo = new GameObject("UIManager"); UIManagerGo.layer = LayerMask.NameToLayer("UI"); //UIManager UIManager = UIManagerGo.AddComponent<UIManager>(); UIManagerGo.AddComponent <UIManager>(); //UIcamera GameObject cameraGo = new GameObject("UICamera"); cameraGo.transform.SetParent(UIManagerGo.transform); cameraGo.transform.localPosition = new Vector3(0, 0, -1000); Camera camera = cameraGo.AddComponent <Camera>(); camera.cullingMask = LayerMask.GetMask("UI"); camera.orthographic = true; if (!isOnlyUICamera) { camera.clearFlags = CameraClearFlags.Depth; camera.depth = 1; } else { camera.clearFlags = CameraClearFlags.SolidColor; camera.backgroundColor = Color.black; } //Canvas Canvas canvas = UIManagerGo.AddComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = camera; //UI Raycaster //GraphicRaycaster Graphic = UIManagerGo.AddComponent<GraphicRaycaster>(); UIManagerGo.AddComponent <GraphicRaycaster>(); //CanvasScaler CanvasScaler scaler = UIManagerGo.AddComponent <CanvasScaler>(); scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; scaler.referenceResolution = referenceResolution; scaler.screenMatchMode = MatchMode; if (isVertical) { scaler.matchWidthOrHeight = 1; } else { scaler.matchWidthOrHeight = 0; } //挂载点 GameObject goTmp = null; RectTransform rtTmp = null; UILayerManager layerTmp = UIManagerGo.GetComponent <UILayerManager>(); goTmp = new GameObject("GameUI"); goTmp.layer = LayerMask.NameToLayer("UI"); goTmp.transform.SetParent(UIManagerGo.transform); goTmp.transform.localScale = Vector3.one; rtTmp = goTmp.AddComponent <RectTransform>(); rtTmp.anchorMax = new Vector2(1, 1); rtTmp.anchorMin = new Vector2(0, 0); rtTmp.anchoredPosition3D = Vector3.zero; rtTmp.sizeDelta = Vector2.zero; layerTmp.m_GameUILayerParent = goTmp.transform; goTmp = new GameObject("Fixed"); goTmp.layer = LayerMask.NameToLayer("UI"); goTmp.transform.SetParent(UIManagerGo.transform); goTmp.transform.localScale = Vector3.one; rtTmp = goTmp.AddComponent <RectTransform>(); rtTmp.anchorMax = new Vector2(1, 1); rtTmp.anchorMin = new Vector2(0, 0); rtTmp.anchoredPosition3D = Vector3.zero; rtTmp.sizeDelta = Vector2.zero; layerTmp.m_FixedLayerParent = goTmp.transform; goTmp = new GameObject("Normal"); goTmp.layer = LayerMask.NameToLayer("UI"); goTmp.transform.SetParent(UIManagerGo.transform); goTmp.transform.localScale = Vector3.one; rtTmp = goTmp.AddComponent <RectTransform>(); rtTmp.anchorMax = new Vector2(1, 1); rtTmp.anchorMin = new Vector2(0, 0); rtTmp.anchoredPosition3D = Vector3.zero; rtTmp.sizeDelta = Vector2.zero; layerTmp.m_NormalLayerParent = goTmp.transform; goTmp = new GameObject("TopBar"); goTmp.layer = LayerMask.NameToLayer("UI"); goTmp.transform.SetParent(UIManagerGo.transform); goTmp.transform.localScale = Vector3.one; rtTmp = goTmp.AddComponent <RectTransform>(); rtTmp.anchorMax = new Vector2(1, 1); rtTmp.anchorMin = new Vector2(0, 0); rtTmp.anchoredPosition3D = Vector3.zero; rtTmp.sizeDelta = Vector2.zero; layerTmp.m_TopbarLayerParent = goTmp.transform; goTmp = new GameObject("PopUp"); goTmp.layer = LayerMask.NameToLayer("UI"); goTmp.transform.SetParent(UIManagerGo.transform); goTmp.transform.localScale = Vector3.one; rtTmp = goTmp.AddComponent <RectTransform>(); rtTmp.anchorMax = new Vector2(1, 1); rtTmp.anchorMin = new Vector2(0, 0); rtTmp.anchoredPosition3D = Vector3.zero; rtTmp.sizeDelta = Vector2.zero; layerTmp.m_PopUpLayerParent = goTmp.transform; //m_UILayerManager = layerTmp; ProjectWindowUtil.ShowCreatedAsset(UIManagerGo); string Path = "Resources/UI/UIManager.prefab"; FileTool.CreatFilePath(Application.dataPath + "/" + Path); PrefabUtility.CreatePrefab("Assets/" + Path, UIManagerGo, ReplacePrefabOptions.ConnectToPrefab); }
private Boolean initDic() { if ("".Equals(this.txt_target.Text)) { MessageBox.Show("请设置需要检查的目标的IP地址或域名!"); return(false); } else if (this.services_list.CheckedItems.Count <= 0) { MessageBox.Show("请选择需要检查服务!"); return(false); } else { if (!"".Equals(this.txt_target.Text)) { bool isTrue = Regex.IsMatch(this.txt_target.Text, "^([\\w\\-\\.]{1,100}[a-zA-Z]{1,8})$|^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})$"); if (isTrue) { this.list_target.Clear(); this.list_target.Add(this.txt_target.Text); } else { isTrue = Regex.IsMatch(this.txt_target.Text, "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\-\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"); if (isTrue) { this.list_target.Clear(); string[] ips = this.txt_target.Text.Split('-'); if (ips.Length == 2) { string startip = ips[0]; string endip = ips[1]; string[] startips = startip.Split('.'); string[] endips = endip.Split('.'); if (startips.Length == 4 && endips.Length == 4) { int startips_3 = int.Parse(startips[2]); int endips_3 = int.Parse(endips[2]); int startips_4 = int.Parse(startips[3]); int endips_4 = int.Parse(endips[3]); if (endips_3 >= startips_3 && endips_3 <= 255 && endips_4 <= 255) { for (int i = startips_3; i <= endips_3; i++) { if (startips_3 == endips_3) { if (startips_4 <= endips_4) { for (int j = startips_4; j <= endips_4; j++) { string ip = startips[0] + "." + startips[1] + "." + startips[2] + "." + j; this.list_target.Add(ip); } } } else { int index_start = 0; int index_end = 255; if (i == startips_3) { index_start = startips_4; } if (i == endips_3) { index_end = endips_4; } for (int j = index_start; j <= index_end; j++) { string ip = startips[0] + "." + startips[1] + "." + i + "." + j; this.list_target.Add(ip); } } } } } } } else { this.list_target = this.list_import_target; } } if (this.list_target.Count <= 0) { MessageBox.Show("目标格式错误!\r\n格式示例:\r\n192.168.1.1\r\nwww.baidu.com\r\n192.168.1.1-192.168.200.1\r\n192.168.1.1-192.168.1.200"); return(false); } } } //加载自定义字典字典 if (notAutoSelectDic) { if (this.txt_username.Text.EndsWith(".txt")) { this.list_username = FileTool.readFileToList(this.txt_username.Text); } else { if (this.txt_username.Text.Length > 0) { this.list_username.Clear(); this.list_username.Add(this.txt_username.Text); } } if (this.txt_password.Text.EndsWith(".txt")) { this.list_password = FileTool.readFileToList(this.txt_password.Text); } else { if (this.txt_password.Text.Length > 0) { this.list_password.Clear(); this.list_password.Add(this.txt_password.Text); } } if (this.list_username.Count <= 0) { MessageBox.Show("请设置需要检查的用户名!"); return(false); } else if (this.list_password.Count <= 0) { MessageBox.Show("请设置检查的密码!"); return(false); } } else { //如果默认字典没有数据则加载默认字典 if (dics.Count <= 0) { LogMessage("根据选择检查的服务自动加载字典......"); foreach (string serviceName in this.services_list.CheckedItems) { ServiceModel sm = this.services[serviceName]; sm.ListUserName = FileTool.readFileToList(Directory.GetCurrentDirectory() + sm.DicUserNamePath); sm.ListPassword = FileTool.readFileToList(Directory.GetCurrentDirectory() + sm.DicPasswordPath); if (sm.ListUserName.Count <= 0) { LogWarning("加载" + serviceName + "用户名字典未发现数据!"); } else if (sm.ListPassword.Count <= 0) { LogWarning("加载" + serviceName + "密码字典未发现数据!"); } else { LogWarning("加载" + serviceName + "字典成功,用户名" + sm.ListUserName.Count + "个,密码" + sm.ListPassword.Count + "个!"); } } LogMessage("根据选择检查的服务自动加载字典完成!"); } } return(true); }
static void SaveScreenShot(string fileName) { FileTool.CreatFilePath(fileName); UnityEngine.ScreenCapture.CaptureScreenshot(fileName); }
public void MergeXMLFile(string PathA, string PathB) { FileTool.CopyDirectory(PathA, PathB, RepeatHandle); }
private void SleepT() { try { Invoke((MethodInvoker) delegate() { this.textBox1.Clear(); btn_Go.Enabled = false; }); FileTool file = new FileTool(); var data = file.Read(); SetTextMesssage(100 * 1 / 5, "开始发送联机(更新)信号,请将分拣架重新上电" + "\r\n"); /*****************************2.发送联机(更新)信号 校验码 4F9 0xF9, 0x4*****************************/ bool isSendSuccess = false; for (int i = 1; i < 100; i++) { try { var write2 = new byte[] { 0x55, 0xAA, 0x1C, 0xC1 }; write2 = Enumerable.Concat(write2, CLCData(write2)).ToArray(); byte[] result2 = OrderSortService.DoloadBoard(write2); if (result2[0] != 0x5F || result2[1] != 0x01 || result2[2] != 0x00 || result2[3] != 0xC1) { throw new Exception($"下载数据失败:"); } isSendSuccess = true; break; } catch { } } if (!isSendSuccess) { throw new Exception($"下载数据失败:联机信号应答失败"); } SetTextMesssage(100 * 2 / 5, "发送联机(更新)信号成功" + "\r\n"); SetTextMesssage(100 * 2 / 5, "开始发送文件大小" + "\r\n"); /******************************3.发送文件大小 ******************************/ byte[] fileSize = BitConverter.GetBytes(Convert.ToInt16(data.Length)); var update3 = new byte[] { 0x55, 0xAA, 0x2C, 0xC2 }; update3 = Enumerable.Concat(update3, fileSize).ToArray(); update3 = Enumerable.Concat(update3, CLCData(update3)).ToArray(); byte[] result3 = OrderSortService.DoloadBoard(update3); if (result3[0] != 0x5F || result3[1] != 0x01 || result3[2] != 0x00 || result3[3] != 0xC2) { throw new Exception($"下载数据失败:发送文件大小应答失败"); } SetTextMesssage(100 * 3 / 5, $"发送文件大小成功" + "\r\n"); /****************************** 4文件传输******************************/ //调整数据为1024的倍数 var dataRe = data.Length % 1024; if (dataRe != 0) { var dataEx = new byte[1024 - data.Length % 1024]; data = Enumerable.Concat(data, dataEx).ToArray(); } int dataLen = data.Length / 1024; SetTextMesssage(100 * 3 / 5, $"开始传输文件数据,共{dataLen}步" + "\r\n"); //5发送数据 for (int i = 1; i <= dataLen; i++) { var writeData = new byte[] { 0x55, 0xAA, 0x3C, 0xC3 }; var partData = GetData(data, i); writeData = Enumerable.Concat(writeData, partData).ToArray(); var clcData = CLCData(writeData); writeData = Enumerable.Concat(writeData, clcData).ToArray(); byte[] result4 = OrderSortService.DoloadBoard(writeData); if (result4[0] != 0x5F || result4[1] != 0x01 || result4[2] != 0x00 || result4[3] != 0xC3) { throw new Exception($"下载数据失败:接收传输数据应答失败:第{i}步"); } SetTextMesssage(100 * 3 / 5 + 40 / (data.Length / 1024) * i, $"第{i}步传输文件数据成功" + "\r\n"); } SetTextMesssage(100 * 5 / 5, "更新成功!" + "\r\n"); } catch (Exception ex) { Invoke((MethodInvoker) delegate() { btn_Go.Enabled = true; }); MessageBox.Show(ex.Message); } }
public void Rebuild_R_Table(string aimPath) { OutPut("创建临时目录"); String R_Path = PathTool.GetCurrentPath() + "/R_path/"; FileTool.CreatPath(R_Path); //OutPut("生成R文件"); //OutPut("生成的R文件的jar"); //OutPut("生成 dex文件"); //OutPut("生成smali文件"); //OutPut("替换smali文件"); //String androidPath = @"D:\AndroidSDK\platforms\android-28\android.jar"; string manifest = aimPath + "/AndroidManifest.xml"; string resPath = aimPath + "/res"; string smaliPath = aimPath + "/smali"; CmdService cmd = new CmdService(OutPut, errorCallBack); OutPut("生成R.java文件"); //OutPut("R_Path " + R_Path + " resPath " + resPath + " manifest " + manifest); //生成R文件 cmd.Execute(EditorData.GetAAPTPath() + " package -f -I " + EditorData.GetAndroidJarPath(29) + " -m -J " + R_Path + " -S " + resPath + " -M " + manifest + " --debug-mode"); //aapt2 //cmd.Execute(EditorData.GetAAPT2Path() + " link -I " + EditorData.GetAndroidJarPath(29) + " -java " + R_Path + " -A " + resPath + " --manifest " + manifest + " -v"); if (FindRPath(R_Path) != null) { //GBK转码 //string java = FileTool.ReadStringByFile(FindRPath(R_Path)); //java = compileTool.RemoveSpecialCode(java); //FileTool.WriteStringByFile(FindRPath(R_Path),java); //转换smli文件 RTableUtil rt = new RTableUtil(); rt.callBack += OutPut; rt.errorCallBack += ErrorOutPut; rt.GenerateRKV(FindRPath(R_Path)); rt.ReplaceRTable(smaliPath); OutPut("编译R.java文件"); //编译R.java文件 cmd.Execute("javac -encoding UTF-8 -source 1.7 -target 1.7 " + FindRPath(R_Path), true, true); //取第一个文件夹名作为命令开头 string fileName = FileTool.GetDirectoryName(Directory.GetDirectories(R_Path)[0]); OutPut("生成的R文件的jar"); //生成的R文件的jar cmd.Execute("jar cvf ./R.jar ./" + fileName, path: R_Path); OutPut("Jar to dex"); //Jar to dex cmd.Execute("java -jar " + EditorData.GetDxPath() + " --dex --output=./R_path/classes.dex ./R_path/R.jar ", true, true); OutPut("dex to smali"); //dex to smali cmd.Execute("java -jar baksmali-2.1.3.jar --o=" + aimPath + "/smali ./R_path/classes.dex"); } else { throw new Exception("R文件生成失败! 请检查清单文件是否正确!"); } FileTool.SafeDeleteDirectory(R_Path); //cmd.Execute("java -jar baksmali-2.1.3.jar classes.dex"); OutPut("创建临时目录"); }
public static Injection testInjection(String url, Config config, Boolean justScanError) { Injection injection = new Injection(); try { int index = url.IndexOf('?'); if (index == -1) { return(injection); } injection.url = url; String testUrl = Uri.EscapeUriString(url); Uri uri = new Uri(url); bool isSSL = url.StartsWith("https", StringComparison.OrdinalIgnoreCase); string queryString = (uri.Query != null && uri.Query.Length > 0) ? uri.Query.Substring(1, uri.Query.Length - 1) : ""; String[] strparams = queryString.Split('&'); int timeout = 0;//超时5次,认为此URL为坏死URL //对参数进行注入测试 foreach (String param in strparams) { if (timeout >= 5) { break;//超时5次,认为此URL为坏死URL } if (param.IndexOf("=") == -1) { continue; } String[] sprarm = param.Split('='); String pramName = sprarm[0]; if (jumpkeyList.Contains(pramName)) { continue;//忽略扫描参数 } if (sprarm.Length <= 1) { continue; } String pramValue = sprarm[1]; String payload = param + "%27"; String curl = uri.PathAndQuery.Replace(param, payload); injection.testUrl = testUrl.Replace(param, payload); injection.paramName = sprarm[0]; String oldrequest = Spider.reqestGetTemplate.Replace("{url}", uri.PathAndQuery).Replace("{host}", uri.Host + ":" + uri.Port); String request = Spider.reqestGetTemplate.Replace("{url}", curl).Replace("{host}", uri.Host + ":" + uri.Port); //通过错误显示判断 ServerInfo errorDBServer = HTTP.sendRequestRetry(isSSL, config.reTry, uri.Host, uri.Port, payload, request, config.timeOut, HTTP.AutoGetEncoding, config.is_foward_302, config.redirectDoGet); if (errorDBServer.runTime > config.timeOut * 1000) { timeout++; } if (errorDBServer.runTime > config.timeOut) { timeout++; } if (errorDBServer.body.Length == 0 | errorDBServer.code == 404) { continue; } foreach (String eop in errorDBList) { List <String> errorKeys = FileTool.readFileToList("config/injection/error/" + eop); foreach (String key in errorKeys) { bool find = Regex.IsMatch(errorDBServer.body, key, RegexOptions.IgnoreCase); if (find) { injection.isInjection = true; injection.dbType = (eop.Replace(".txt", "")); injection.payload = "'"; injection.remark = "错误显示信息判断"; injection.injectType = "错误显示"; injection.dbType = eop; return(injection); } } } if (!injection.isInjection && justScanError == false) { //读取bool payload ServerInfo oserver = HTTP.sendRequestRetry(isSSL, config.reTry, uri.Host, uri.Port, "获取原始页面内容", oldrequest, config.timeOut, HTTP.AutoGetEncoding, config.is_foward_302, config.redirectDoGet); if (oserver.runTime > config.timeOut * 1000) { timeout++; } if (bool_payloads.Count > 0) { foreach (String bool_payload in bool_payloads) { String[] bool_ps = bool_payload.Split(':'); String flasePayload = pramName + "=" + URLEncode.UrlEncode(pramValue + bool_ps[1]); String falseURL = uri.PathAndQuery.Replace(param, flasePayload); injection.paramName = sprarm[0]; injection.testUrl = testUrl.Replace(param, flasePayload); String falserequest = Spider.reqestGetTemplate.Replace("{url}", falseURL).Replace("{host}", uri.Host + ":" + uri.Port); ServerInfo falseServer = HTTP.sendRequestRetry(isSSL, config.reTry, uri.Host, uri.Port, flasePayload, falserequest, config.timeOut, HTTP.AutoGetEncoding, false, config.redirectDoGet); if (falseServer.runTime > config.timeOut * 1000) { timeout++; } decimal pfalse = Tools.getLike(oserver.body, falseServer.body); //静态参数 if (pfalse > 99) { continue; } String truePayload = pramName + "=" + URLEncode.UrlEncode(pramValue + bool_ps[0]); String trueURL = uri.PathAndQuery.Replace(param, truePayload); String truerequest = Spider.reqestGetTemplate.Replace("{url}", trueURL).Replace("{host}", uri.Host + ":" + uri.Port); ServerInfo trueServer = HTTP.sendRequestRetry(isSSL, config.reTry, uri.Host, uri.Port, truePayload, truerequest, config.timeOut, HTTP.AutoGetEncoding, false, config.redirectDoGet); if (trueServer.runTime > config.timeOut * 1000) { timeout++; } //计算相似度 decimal ptrue = Tools.getLike(oserver.body, trueServer.body); if (ptrue < 85) { continue; } if (oserver.runTime > config.timeOut) { timeout++; } injection.payload = bool_ps[1]; injection.injectType = bool_ps[2]; injection.dbType = "未知"; if (oserver.code != 404 && !errer_code.Contains(oserver.code.ToString()) && !errer_code.Contains(trueServer.code.ToString()) && !errer_code.Contains(falseServer.code.ToString()) && trueServer.body.Length > 0 && falseServer.body.Length > 0) { //判断存在bool盲注 //根据状态码判断 if (oserver.code == trueServer.code && trueServer.code != falseServer.code) { injection.isInjection = true; injection.remark = "状态码判断----" + oserver.code + "|" + trueServer.code + "|" + falseServer.code; return(injection); } if (falseServer.body.Length < trueServer.body.Length) { /* * if (ptrue > pfalse) * { * * injection.isInjection = true; * injection.remark = "动态响应长度判断,相似度----" + ptrue + "|" + pfalse + "|" + p + "%"; * return injection; * }*/ if (ptrue == 100) { if (ptrue > pfalse) { injection.isInjection = true; injection.remark = "固定长度,相似度--false|true--" + pfalse + "|" + ptrue + "%"; return(injection); } } else { ServerInfo true1Server = HTTP.sendRequestRetry(isSSL, config.reTry, uri.Host, uri.Port, truePayload, truerequest.Replace("1%3d1", "2%3d2"), config.timeOut, HTTP.AutoGetEncoding, false, config.redirectDoGet); if (true1Server.runTime > config.timeOut * 1000) { timeout++; } decimal p = Tools.getLike(oserver.body, true1Server.body); if (ptrue - pfalse >= 2 && Math.Abs(p - pfalse) >= 2) { injection.isInjection = true; injection.remark = "动态长度,相似度--false|true1|true2--" + pfalse + "|" + ptrue + "|" + p + "%"; return(injection); } } } } } } } } } catch (Exception e) { Tools.SysLog("判断注入发生异常!" + e.Message); } return(injection); }
public void AddItemToListView(ServerInfo svinfo) { //过滤类型不符合的 if (!svinfo.contentType.StartsWith(config.contentType, StringComparison.OrdinalIgnoreCase)) { return; } //过滤长度不符合的 bool filter = false; if (config.contentLength > -2) { switch (config.contentSelect) { case 0: if (svinfo.length < config.contentLength) { filter = true; } break; case 1: if (svinfo.length == config.contentLength) { filter = true; } break; case 2: if (svinfo.length > config.contentLength) { filter = true; } break; } } if (filter) { return; } ListViewItem lvi = new ListViewItem(svinfo.id + ""); lvi.Tag = svinfo.type; lvi.SubItems.Add(svinfo.url); lvi.SubItems.Add(svinfo.code + ""); lvi.SubItems.Add(svinfo.contentType + ""); lvi.SubItems.Add(svinfo.length + ""); lvi.SubItems.Add(svinfo.server + ""); lvi.SubItems.Add(svinfo.powerBy + ""); lvi.SubItems.Add(svinfo.runTime + ""); lvi.SubItems.Add(svinfo.ip + ""); String result = svinfo.url + "----" + svinfo.code; lvi.Tag = svinfo.type; if (svinfo.code.ToString().StartsWith("2")) { lvi.ForeColor = Color.Green; } else if (svinfo.code.ToString().StartsWith("3")) { lvi.ForeColor = Color.Blue; } else if (svinfo.code.ToString().StartsWith("4")) { lvi.ForeColor = Color.Gray; } else if (svinfo.code.ToString().StartsWith("5")) { lvi.ForeColor = Color.Red; } FileTool.AppendLogToFile("logs/scan_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log", result); this.lvw_info.Items.Add(lvi); }
/// <summary> /// 从SHA1文件读取SHA1校验码 /// </summary> /// <param name="sha1s">SHA1文件</param> /// <returns>SHA1校验码</returns> private static IEnumerable <string> GetSHA1Codes(IEnumerable <string> sha1s) { return(from sha1 in sha1s select FileTool.OpenAndReadAllText(sha1)); }
void Start() { Instance = this; }
/// <summary> /// 读取一个工作表的数据 /// </summary> /// <param name="type">要转换的struct或class类型</param> /// <param name="dataTable">读取的工作表数据</param> /// <param name="jsonPath">存储路径</param> private static void ReadSingleSheet(System.Data.DataTable dataTable, string jsonPath) { Assembly assembly = Assembly.LoadFile(Environment.CurrentDirectory + @"\Library\ScriptAssemblies\Assembly-CSharp.dll"); // 获取当前程序集 Type type = assembly.GetType(dataTable.TableName); // 创建类的实例,返回为 object 类型,需要强制类型转换 //string TableNameJson = jsonPath + "/" + TableName + ".json"; //Type type = typeof(T); int rows = dataTable.Rows.Count; int Columns = dataTable.Columns.Count; // 工作表的行数据 DataRowCollection collect = dataTable.Rows; // xlsx对应的数据字段,规定是第二行 string[] jsonFileds = new string[Columns]; // 要保存成Json的obj List <object> objsToSave = new List <object>(); for (int i = 0; i < Columns; i++) { jsonFileds[i] = collect[1][i].ToString(); } // 从第三行开始 for (int i = 3; i < rows; i++) { // 生成一个实例 object objIns = Activator.CreateInstance(type); for (int j = 0; j < Columns; j++) { // 获取字段 FieldInfo field = type.GetField(jsonFileds[j]); if (field != null) { object value = null; try // 赋值 { value = Convert.ChangeType(collect[i][j], field.FieldType); } catch (InvalidCastException e) // 一般到这都是Int数组,当然还可以更细致的处理不同类型的数组 { Console.WriteLine(e.Message); string str = collect[i][j].ToString(); string[] strs = str.Split(','); int[] ints = new int[strs.Length]; for (int k = 0; k < strs.Length; k++) { ints[k] = int.Parse(strs[k]); } value = ints; } field.SetValue(objIns, value); } else { UnityEngine.Debug.LogFormat("有无法识别的字符串:{0}", jsonFileds[j]); } } objsToSave.Add(objIns); } string content = Newtonsoft.Json.JsonConvert.SerializeObject(objsToSave); jsonPath += "_" + dataTable.TableName + ".json"; FileTool.SaveFile(content, jsonPath); }