internal static bool CanScan(Request Req) { string Signature = ""; try { Signature = MakeSignature(Req); } catch (Exception Exp) { IronException.Report("ScanBranch error creating signatures", Exp.Message, Exp.StackTrace); return(true);//empty signature should not be added and checked } if (NewRequestSignatures.Contains(Signature)) { return(false); } else { NewRequestSignatures.Add(Signature); if (SkipScanned) { if (RequestSignatures.Contains(Signature)) { return(false); } } return(true); } }
internal static void StartBranchScan() { try { ScanDone = 0; TotalScans = ProxyLogIDs.Count; NewRequestSignatures.Clear(); ScanItemUniquenessChecker UniqueChecker = new ScanItemUniquenessChecker(true); foreach (int i in ScanBranch.ProxyLogIDs) { ScanItem(UniqueChecker, "Proxy", i); } foreach (int i in ScanBranch.ProbeLogIDs) { ScanItem(UniqueChecker, "Probe", i); } foreach (string Signature in NewRequestSignatures) { if (!RequestSignatures.Contains(Signature)) { RequestSignatures.Add(Signature); } } NewRequestSignatures.Clear(); IronUI.UpdateScanBranchStats(0, 0, "All Scan Jobs Created && Queued. Close this Window.", false, true); } catch (ThreadAbortException) { // } catch (Exception Exp) { IronException.Report("Scan Branch Exception", Exp.Message, Exp.StackTrace); } }
internal static void AddScanRequest(Request Request) { if (Request != null) { try { Request ClonedRequest = Request.GetClone(true); if (ClonedRequest != null) { lock (ScanRequestQ) { ScanRequestQ.Enqueue(ClonedRequest); } } else { Tools.Trace("IronUpdater", "Null Scan Request"); } } catch (Exception Exp) { IronException.Report("Error adding Scan Request for updating", Exp.Message, Exp.StackTrace); } } }
private void CodeTextBox_Load(object sender, EventArgs e) { Editor.ShowTabs = false; Editor.ShowEOLMarkers = false; Editor.ShowSpaces = false; Editor.ShowInvalidLines = false; Editor.TabIndent = 2; try { if (this.LangCode == 1) { Editor.SetHighlighting("Python"); } else { Editor.SetHighlighting("Ruby"); } } catch (Exception Exp) { IronException.Report("Unable to set Syntax Highlighting", Exp); } Editor.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(Editor_KeyUp); }
void SerializeNewXmlWithFormatPlugin(object PluginNameObject) { string PluginName = PluginNameObject.ToString(); try { Request Req = DisplayedRequest.GetClone(true); FormatPlugin FP = FormatPlugin.Get(PluginName); Request NewRequest = FP.ToRequestFromXml(Req, CurrentFormatXml); this.DisplayedRequest = NewRequest; ShowStatusMsg(""); this.SetNonFormatPluginRequestFields(NewRequest); ShowProgressBar(false); } catch (ThreadAbortException) { ShowStatusMsg(""); } catch (Exception Exp) { IronException.Report(string.Format("Error converting {0} to Request", PluginName), Exp); ShowErrorMsg(string.Format("Unable to update edited values in {0}", PluginName)); ShowProgressBar(false); } }
internal static void DoStop() { try { Stopped = true; if (ScanManagerThread != null) { if (ScanManagerThread.ThreadState == ThreadState.Running && !CanStop) { //ask if user is sure about stopping scan and then call... EndAll(); } else { EndAll(); } } else { IronUI.UpdateConsoleControlsStatus(false); } } catch (Exception Exp) { IronException.Report("Error stopping the Scan", Exp); } }
public static void Add(FormatPlugin FP) { if ((FP.Name.Length > 0) && !(FP.Name.Equals("All") || FP.Name.Equals("None") || FP.Name.Equals("Normal"))) { if (!List().Contains(FP.Name)) { if (FP.FileName != "Internal") { FP.FileName = PluginEngine.FileName; } Collection.Add(FP); } } else { if (FP.Name.Length == 0) { IronException.Report("Invalid Format Plugin Name", "The Format Plugin's name is empty so it cannot be loaded."); } else { IronException.Report("Invalid Format Plugin Name", string.Format("The Format Plugin's name is '{0}' which is an invalid value. Set a different name.", FP.Name)); } } }
void ShowSelectedLog(object SelectedLogInfoObject) { object[] SelectedLogInfo = (object[])SelectedLogInfoObject; string Source = SelectedLogInfo[0].ToString(); int LogId = (int)SelectedLogInfo[1]; try { Session Session = Session.FromLog(LogId, Source); if (Session.Request != null) { RequestView.SetRequest(Session.Request); if (Session.Response != null) { ResponseView.SetResponse(Session.Response, Session.Request); } } } catch (ThreadAbortException) { } catch (Exception Exp) { IronException.Report("Error loading Selected Log info in Log Analyzer", Exp); } finally { EndLogLoad(); } }
static void MarkForJavaScriptTesting(object Details) { try { object[] DetailsArray = (object[])Details; RequestSource Source = (RequestSource)DetailsArray[0]; int ID = (int)DetailsArray[1]; Session IrSe = GetLog(Source, ID); if (IrSe == null) { IronUI.ShowLogStatus("Unable to read Response from log", true); return; } if (IrSe.Response == null) { IronUI.ShowLogStatus("Unable to read Response from log", true); return; } IronUI.FillAndShowJavaScriptTester(IrSe.Response.BodyString); } catch (Exception Exp) { IronUI.ShowLogStatus("Unable to read Response from Log", true); IronException.Report("Error reading from log", Exp.Message, Exp.StackTrace); } }
internal static void Initialise() { try { PyAPI.Load(string.Format("{0}//APIdoc_Py.xml", Config.Path)); } catch (Exception Exp) { IronException.Report("Unable to load Python API Doc", Exp.Message, Exp.StackTrace); } try { RbAPI.Load(string.Format("{0}//APIdoc_Rb.xml", Config.Path)); } catch (Exception Exp) { IronException.Report("Unable to load Ruby API Doc", Exp.Message, Exp.StackTrace); } try { BuildPyAPITrees(); } catch (Exception Exp) { IronException.Report("Unable to build Python API Doc tree", Exp.Message, Exp.StackTrace); } try { BuildRbAPITrees(); } catch (Exception Exp) { IronException.Report("Unable to build Python API Doc tree", Exp.Message, Exp.StackTrace); } }
internal static void AddScanResponse(Response Response) { if (Response != null) { try { Response ClonedResponse = Response.GetClone(true); if (ClonedResponse != null) { lock (ScanResponseQ) { ScanResponseQ.Enqueue(ClonedResponse); } } else { Tools.Trace("IronUpdater", "Null Scan Response"); } } catch (Exception Exp) { IronException.Report("Error adding Scan Response for updating", Exp.Message, Exp.StackTrace); } } }
internal static void SerializeRequestBody(object BFPObject) { string PluginName = ""; try { BodyFormatParamters BFP = (BodyFormatParamters)BFPObject; Request Request = BFP.Request; FormatPlugin Plugin = BFP.Plugin; PluginName = Plugin.Name; string XML = BFP.XML; Request NewRequest = Plugin.ToRequestFromXml(Request, XML); IronUI.FillMTRequestWithNewRequestFromFormatXML(NewRequest, PluginName); } catch (ThreadAbortException) { // } catch (Exception Exp) { IronException.Report("Error Serializing 'Manual Testing' Request using Format Plugin - " + PluginName, Exp.Message, Exp.StackTrace); IronUI.ShowMTException("Error Serializing"); } }
static void Executor() { while (On) { try { On = false; if (QueuedCommands.Length > 0) { InteractiveShellResult Result = IronScripting.ExecuteMultiLineShellInput(QueuedCommands); IronUI.UpdateInteractiveShellResult(Result); } else { InteractiveShellResult Result = IronScripting.ExecuteInteractiveShellInput(QueuedCommand); IronUI.UpdateInteractiveShellResult(Result); } } catch (ThreadAbortException) { } catch (Exception exp) { IronException.Report("Error executing Scripting Shell commands", exp.Message, exp.StackTrace); } MSR.Reset(); MSR.WaitOne(); } }
void DeserializeWithFormatPlugin(object PluginNameObject) { string PluginName = PluginNameObject.ToString(); try { Request Req = DisplayedRequest.GetClone(true); FormatPlugin FP = FormatPlugin.Get(PluginName); CurrentFormatXml = FP.ToXmlFromRequest(Req); CurrentXmlNameValueArray = FormatPlugin.XmlToArray(CurrentFormatXml); ShowStatusMsg(""); SetDeserializedDataInUi(PluginName, CurrentFormatXml, CurrentXmlNameValueArray); this.ResetBodyParametersChangedStatus(); ShowProgressBar(false); } catch (ThreadAbortException) { ShowStatusMsg(""); } catch (Exception Exp) { IronException.Report(string.Format("Error converting Request to {0}", PluginName), Exp); ShowErrorMsg(string.Format("Unable to parse Request body as {0}", PluginName)); ShowProgressBar(false); } }
void LoadAndFill() { if (this.Trace == null) { this.Trace = IronDB.GetScanTrace(this.TraceId); } try { List <object[]> Rows = IronTrace.GetGridRowsFromTraceAndOverviewXml(Trace.OverviewXml, Trace.MessageXml); StringBuilder SB = new StringBuilder(@"{\rtf1{\colortbl ;\red0\green77\blue187;\red247\green150\blue70;\red255\green0\blue0;\red0\green200\blue50;\red255\green255\blue255;}"); SB.Append(Tools.RtfSafe(Trace.GetScanTracePrettyMessage())); this.SetTraceData(Rows, SB.ToString()); } catch (Exception Exp) { IronException.Report("Error loading Scan Trace", Exp); this.CloseTraceWindow(); } if (this.UiResults == null) { DoAnalysis(); } else { SetAnalysisUiResults(this.UiResults); } }
static void DownloadModule(string ModuleName, string PseudoName) { Request ModuleFetchReq = new Request(ModuleDownloadBaseUrl + "/" + PseudoName); ModuleFetchReq.Source = RequestSource.Stealth; Response ModuleFetchRes = ModuleFetchReq.Send(); if (!ModuleFetchRes.IsSslValid) { throw new Exception("Invalid SSL Certificate provided by the server"); } if (ModuleFetchRes.Code != 200) { throw new Exception("Downloading updated modules failed"); } try { ModuleFetchRes.SaveBody(Config.Path + "\\updates\\modules\\" + ModuleName + ".zip"); using (ZipFile ZF = ZipFile.Read(Config.Path + "\\updates\\modules\\" + ModuleName + ".zip")) { ZF.ExtractAll(Config.Path + "\\updates\\modules\\"); } NewUpdateAvailable = true; } catch (Exception Exp) { IronException.Report(string.Format("Error Downloading Module: {0} - {1} ", ModuleName, PseudoName), Exp); } }
void SetUpDirAndFileDictionaries() { try { StreamReader Reader = File.OpenText(Config.RootDir + "/DirNamesDictionary.txt"); string DirList = Reader.ReadToEnd(); Reader.Close(); DirNamesToCheck = new List <string>(DirList.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); } catch (Exception Exp) { IronException.Report("Error loading DirNamesDictionary.txt", Exp); } try { StreamReader Reader = File.OpenText(Config.RootDir + "/FileNamesDictionary.txt"); string FileList = Reader.ReadToEnd(); Reader.Close(); FileNamesToCheck = new List <string>(FileList.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); } catch (Exception Exp) { IronException.Report("Error loading FileNamesDictionary.txt", Exp); } }
static void MarkForScanning(object Details) { try { object[] DetailsArray = (object[])Details; RequestSource Source = (RequestSource)DetailsArray[0]; int ID = (int)DetailsArray[1]; Session IrSe = GetLog(Source, ID); if (IrSe == null) { IronUI.ShowLogStatus("Unable to read Request from log", true); return; } if (IrSe.Request == null) { IronUI.ShowLogStatus("Unable to read Request from log", true); return; } int ScanID = Interlocked.Increment(ref Config.ScanCount); IronDB.CreateScan(ScanID, IrSe.Request); IronUI.CreateScan(ScanID, "Not Started", IrSe.Request.Method, IrSe.Request.FullUrl); IronUI.ShowScanJobsQueue(); } catch (Exception Exp) { IronUI.ShowLogStatus("Unable to read Request from Log", true); IronException.Report("Error reading from log", Exp.Message, Exp.StackTrace); } }
static void CopyResponse(object Details) { try { object[] DetailsArray = (object[])Details; RequestSource Source = (RequestSource)DetailsArray[0]; int ID = (int)DetailsArray[1]; Session IrSe = GetLog(Source, ID); if (IrSe == null) { IronUI.ShowLogStatus("Unable to read Response from log", true); return; } if (IrSe.Response == null) { IronUI.ShowLogStatus("Unable to read Response from log", true); return; } IronUI.SetClipBoard(IrSe.Response.ToString()); } catch (Exception Exp) { IronUI.ShowLogStatus("Unable to read Request from Log", true); IronException.Report("Error reading from log", Exp.Message, Exp.StackTrace); } }
private static void ModUi_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { try { IronException.Report("Unhandled Exception in ModUi Thread", e.Exception); MessageBox.Show("Unhanled Exception was encountered in this Module/Script. Exception details are available under the Exception node."); } catch { } }
void SyntaxChecker() { try { while (Open) { string EditorText = ""; lock (EditorTextStack) { if (EditorTextStack.Count > 0) { EditorText = EditorTextStack.Pop(); EditorTextStack.Clear(); } } string ErrorMessage = ""; try { string IndentError = ""; if (CurrentLanguage.Equals("py")) { IndentError = CheckPythonIndentation(EditorText)[0]; } ScriptSource Source = Engine.CreateScriptSourceFromString(EditorText); ScriptErrorReporter CompileErrors = new ScriptErrorReporter(); Source.Compile(CompileErrors); ErrorMessage = CompileErrors.GetErrors(); if (IndentError.Length > 0) { ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage); ShowHideIndentationFixMenu(true); } else { ShowHideIndentationFixMenu(false); } if (ErrorMessage.Length == 0) { ErrorMessage = "0"; } } catch (Exception Exp) { ErrorMessage = Exp.Message; } IronUI.ShowPluginCompilerError(ErrorMessage); MRE.Reset(); MRE.WaitOne(); } } catch (ThreadAbortException) { } catch (Exception Exp) { IronException.Report("Error performing Syntax checking", Exp); } }
private static void ModUi_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { Exception Exp = (Exception)e.ExceptionObject; IronException.Report("Unhandled Exception in ModUi", Exp); MessageBox.Show("Unhanled Exception was encountered in this Module/Script. Exception details are available under the Exception node."); } catch { } }
static void LoadPlugin(string PluginFile, ScriptEngine Engine) { try { ScriptSource PluginSource; CompiledCode CompiledPlugin; ScriptErrorReporter CompileErrors = new ScriptErrorReporter(); string ErrorMessage = ""; fileName = PluginFile.Substring(PluginFile.LastIndexOf('\\') + 1); if (StartUp) { IronUI.ShowLoadMessage("Loading Plugin - " + fileName); } if (PluginFile.EndsWith(".py", StringComparison.CurrentCultureIgnoreCase)) { Engine.Runtime.TryGetEngine("py", out Engine); PluginSource = Engine.CreateScriptSourceFromFile(PluginFile); string IndentError = PluginEditor.CheckPythonIndentation(PluginSource.GetCode())[1]; CompiledPlugin = PluginSource.Compile(CompileErrors); ErrorMessage = CompileErrors.GetErrors(); if (IndentError.Length > 0) { ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage); } if (ErrorMessage.Length == 0) { PluginSource.ExecuteProgram(); } } else if (PluginFile.EndsWith(".rb", StringComparison.CurrentCultureIgnoreCase)) { Engine.Runtime.TryGetEngine("rb", out Engine); PluginSource = Engine.CreateScriptSourceFromFile(PluginFile); CompiledPlugin = PluginSource.Compile(CompileErrors); ErrorMessage = CompileErrors.GetErrors(); if (ErrorMessage.Length == 0) { PluginSource.ExecuteProgram(); } } if (ErrorMessage.Length > 0) { IronException.Report("Syntax error in Plugin - " + PluginFile, ErrorMessage); } } catch (Exception Exp) { IronException.Report("Error loading plugin - " + PluginFile, Exp.Message, Exp.StackTrace); } finally { fileName = ""; } }
private void NewDesignToolStripMenuItem_Click(object sender, EventArgs e) { try { CreateDesigner(true, ""); } catch (Exception Exp) { IronException.Report("Error Creating New Design", Exp); } }
public static void RunWith(string Executable, string Arguments) { try { Process.Start(Executable, Arguments); } catch (Exception Exp) { IronException.Report("Unable to start external application", Exp); } }
internal static string GetRbDecription(TreeNode Node) { try { return(GetDecription(Node, RbAPI)); } catch (Exception Exp) { IronException.Report("Error reading Ruby API Doc information", Exp.Message, Exp.StackTrace); return(""); } }
void DoDiff() { try { if (FetchFromLogs) { this.A = Session.FromLog(this.ALogId, this.LogSource); this.B = Session.FromLog(this.BLogId, this.LogSource); } string RequestA = ""; string RequestB = ""; string ResponseA = ""; string ResponseB = ""; if (A != null) { if (A.Request != null) { RequestA = A.Request.ToString(); } if (A.Response != null) { ResponseA = A.Response.ToString(); } } if (B != null) { if (B.Request != null) { RequestB = B.Request.ToString(); } if (B.Response != null) { ResponseB = B.Response.ToString(); } } string[] RequestSidebySideResults = DiffWindow.DoSideBySideDiff(RequestA, RequestB); string[] ResponseSidebySideResults = DiffWindow.DoSideBySideDiff(ResponseA, ResponseB); string RequestSinglePageResults = DiffWindow.DoSinglePageDiff(RequestA, RequestB); string ResponseSinglePageResults = DiffWindow.DoSinglePageDiff(ResponseA, ResponseB); RequestDRV.ShowDiffResults(RequestSinglePageResults, RequestSidebySideResults[0], RequestSidebySideResults[1]); ResponseDRV.ShowDiffResults(ResponseSinglePageResults, ResponseSidebySideResults[0], ResponseSidebySideResults[1]); } catch (Exception Exp) { IronException.Report("Error doing diff on Sessions", Exp); ShowError(); } EndDiff(); }
private void NewRbScriptFileToolStripMenuItem_Click(object sender, EventArgs e) { try { PluginEditorTE.Text = File.ReadAllText(Config.RootDir + "\\NewRubyScriptTemplate.txt"); } catch (Exception Exp) { PluginEditorTE.Text = ""; IronException.Report("Script Editor Template Error", Exp); } SetLanguageAsIronRuby(); OpenedFile = new FileInfo(Config.RootDir + "\\Plugins\\Enter an unique name.rb"); }
private void LogTraceViewer_Load(object sender, EventArgs e) { try { MainLoadProgressBar.Visible = true; AnalysisProgressBar.Visible = true; AnalysisThread = new Thread(LoadAndFill); AnalysisThread.Start(); } catch (Exception Exp) { IronException.Report("Error loading Scan Trace", Exp); } }
void DoAnalysis() { try { BehaviourAnalysis BA = new BehaviourAnalysis(ScanTraceBehaviourAnalysis.DefaultErrorKeywords, ScanTraceBehaviourAnalysis.DefaultResponseTimeChange, ScanTraceBehaviourAnalysis.DefaultResponseTimeChangeFactor, ScanTraceBehaviourAnalysis.DefaultCharsCount); BA.Analyze(this.Trace.OverviewXml, this.Trace.Section); ScanTraceBehaviourAnalysisResultsUiInformation UiReslts = ScanTraceBehaviourAnalysis.GetUiDisplayResults(BA.ResultsXml, BA.BaseLineSession.Response.Code.ToString(), BA.BaseLineRoundtripTime.ToString()); SetAnalysisUiResults(UiReslts); } catch (Exception Exp) { IronException.Report("Error calculating Payload Effect Analysis", Exp); SetAnalysisUiResults(new ScanTraceBehaviourAnalysisResultsUiInformation()); } }