Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 static void ScanItem(ScanItemUniquenessChecker UniqueChecker, string LogSource, int LogID)
 {
     try
     {
         Request Req;
         if (LogSource.Equals("Proxy"))
         {
             Req = Request.FromProxyLog(LogID);
         }
         else
         {
             Req = Request.FromProbeLog(LogID);
         }
         if (!CanScan(Req))
         {
             //TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, false, "Skipping previously scanned Request...." + ScanDone.ToString() + " Scan Jobs created", true, false);
             return;
         }
         if (!UniqueChecker.IsUniqueToScan(Req, ScannedRequests, !ScanUrl))
         {
             //TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, false, "Skipping duplicate Request...." + ScanDone.ToString() + " Scan Jobs created", true, false);
             return;
         }
         ScannedRequests.Add(Req.GetClone());
         Scanner Scan = new Scanner(Req);
         Scan = SetSessionPlugin(Scan);
         Scan = SetRecording(Scan);
         Scan = SetFormatPlugin(Scan);
         Scan = AddActivePlugins(Scan);
         Scan = SetInjectionPoints(Scan);
         if (Scan.InjectionPointsCount == 0)
         {
             //TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, false, "Skipping Request as no Injection Points were Identified...." + ScanDone.ToString() + " Scan Jobs created", true, false);
             return;
         }
         Scan.LaunchScan();
         ScanDone++;
         IronUI.UpdateScanBranchStats(ScanDone, false, "Creating and Queueing Scans...." + ScanDone.ToString() + " Scan Jobs created", true, false);
     }
     catch (Exception Exp)
     {
         IronException.Report("ScanBranch Error Creating Scan Job with " + LogSource + " Log ID - " + LogID.ToString(), Exp.Message, Exp.StackTrace);
     }
 }
Esempio n. 3
0
        static void DoScan()
        {
            Spider = new Crawler();
            Spider.PrimaryHost = PrimaryHost;
            Spider.BaseUrl = BaseUrl;
            Spider.StartingUrl = StartingUrl;
            Spider.PerformDirAndFileGuessing = PerformDirAndFileGuessing;
            Spider.IncludeSubDomains = IncludeSubDomains;
            Spider.HTTP = HTTP;
            Spider.HTTPS = HTTPS;
            Spider.UrlsToAvoid = UrlsToAvoid;
            Spider.HostsToInclude = HostsToInclude;

            Spider.Start();
            ScanItemUniquenessChecker UniqueChecker = new ScanItemUniquenessChecker(Mode != ScanMode.Default);
            Thread.Sleep(5000);
            List<int> ScanIDs = new List<int>();
            bool ScanActive = true;
            List<string> ActivePlugins = ActivePlugin.List();
            int TotalRequestsCrawled = 0;
            int TotalScanJobsCreated = 0;
            int TotalScanJobsCompleted = 0;
            List<Request> ScannedRequests = new List<Request>();

            while (ScanActive)
            {
                ScanActive = false;
                List<Request> Requests = Spider.GetCrawledRequests();
                if (Requests.Count > 0 || Spider.IsActive())
                {
                    ScanActive = true;
                    if (CrawlAndScan)
                    {
                        TotalRequestsCrawled = TotalRequestsCrawled + Requests.Count;
                        //update the ui with the number of requests crawled
                        foreach (Request Req in Requests)
                        {
                            if (!CanScan(Req)) continue;
                            if (Mode == ScanMode.UserConfigured && !UniqueChecker.IsUniqueToScan(Req, ScannedRequests, false)) continue;
                            Scanner S = new Scanner(Req);
                            S.CheckAll();
                            S.InjectAll();
                            if (!FormatPlugin.IsNormal(Req))
                            {
                                List<FormatPlugin> RightList = FormatPlugin.Get(Req);
                                if (RightList.Count > 0)
                                {
                                    S.BodyFormat = RightList[0];
                                }
                            }
                            if (S.InjectionPointsCount == 0) continue;
                            TotalScanJobsCreated++;
                            if (Stopped) return;
                            int ScanID = S.LaunchScan();
                            if (ScanID > 0)
                            {
                                ScannedRequests.Add(Req);
                                ScanIDs.Add(ScanID);
                            }
                        }
                    }
                }
                if (CrawlAndScan)
                {
                    List<int> ScanIDsToRemove = new List<int>();
                    List<int> AbortedScanIDs = Scanner.GetAbortedScanIDs();
                    List<int> CompletedScanIDs = Scanner.GetCompletedScanIDs();
                    for (int i = 0; i < ScanIDs.Count; i++)
                    {
                        if (CompletedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                            TotalScanJobsCompleted++;
                        }
                        else if (AbortedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                        }
                    }
                    for (int i = 0; i < ScanIDsToRemove.Count; i++)
                    {
                        ScanIDs.RemoveAt(ScanIDsToRemove[i] - i);
                    }
                }
                if (ScanActive)
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    if (ScanIDs.Count > 0)
                    {
                        ScanActive = true;
                        Thread.Sleep(5000);
                    }
                }
                IronUI.UpdateConsoleCrawledRequestsCount(TotalRequestsCrawled);
                IronUI.UpdateConsoleScanJobsCreatedCount(TotalScanJobsCreated);
                IronUI.UpdateConsoleScanJobsCompletedCount(TotalScanJobsCompleted);
            }
            Stop();
        }
Esempio n. 4
0
 static void ScanItem(ScanItemUniquenessChecker UniqueChecker, string LogSource, int LogID)
 {
     try
     {
         Request Req;
         if(LogSource.Equals("Proxy"))
            Req = Request.FromProxyLog(LogID);
         else
             Req = Request.FromProbeLog(LogID);
         if (!CanScan(Req))
         {
             TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, TotalScans, "Skipping previously scanned Request...." + ScanDone.ToString() + "/" + TotalScans.ToString() + " done", true, false);
             return;
         }
         if (!UniqueChecker.IsUniqueToScan(Req, ScannedRequests, !ScanUrl))
         {
             TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, TotalScans, "Skipping duplicate Request...." + ScanDone.ToString() + "/" + TotalScans.ToString() + " done", true, false);
             return;
         }
         ScannedRequests.Add(Req.GetClone());
         Scanner Scan = new Scanner(Req);
         Scan = SetSessionPlugin(Scan);
         Scan = SetFormatPlugin(Scan);
         Scan = AddActivePlugins(Scan);
         Scan = SetInjectionPoints(Scan);
         if (Scan.InjectionPointsCount == 0)
         {
             TotalScans--;
             IronUI.UpdateScanBranchStats(ScanDone, TotalScans, "Skipping Request as no Injection Points were Identified...." + ScanDone.ToString() + "/" + TotalScans.ToString() + " done", true, false);
             return;
         }
         Scan.LaunchScan();
         ScanDone++;
         IronUI.UpdateScanBranchStats(ScanDone, TotalScans, "Creating and Queueing Scans...." + ScanDone.ToString() + "/" + TotalScans.ToString() + " done", true, false);
     }
     catch (Exception Exp)
     {
         IronException.Report("ScanBranch Error Creating Scan Job with " + LogSource  + " Log ID - " + LogID.ToString(), Exp.Message, Exp.StackTrace);
     }
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
        static void DoScan()
        {
            Spider = new Crawler();
            try
            {
                Spider.PrimaryHost = PrimaryHost;
                Spider.BaseUrl     = BaseUrl;
                Spider.StartingUrl = StartingUrl;
                Spider.PerformDirAndFileGuessing = PerformDirAndFileGuessing;
                Spider.IncludeSubDomains         = IncludeSubDomains;
                Spider.HTTP           = HTTP;
                Spider.HTTPS          = HTTPS;
                Spider.UrlsToAvoid    = UrlsToAvoid;
                Spider.HostsToInclude = HostsToInclude;


                Spider.Start();
            }
            catch (Exception Exp)
            {
                IronException.Report("Error starting Crawler", Exp);
                try
                {
                    Stop();
                }
                catch { }
                return;
            }

            ScanItemUniquenessChecker UniqueChecker = new ScanItemUniquenessChecker(Mode != ScanMode.Default);

            List <int>     ScanIDs                = new List <int>();
            bool           ScanActive             = true;
            List <string>  ActivePlugins          = ActivePlugin.List();
            int            TotalRequestsCrawled   = 0;
            int            TotalScanJobsCreated   = 0;
            int            TotalScanJobsCompleted = 0;
            List <Request> ScannedRequests        = new List <Request>();
            int            SleepCounter           = 0;

            while (ScanActive)
            {
                ScanActive = false;
                List <Request> Requests = Spider.GetCrawledRequests();
                if (Stopped)
                {
                    return;
                }
                if (Requests.Count > 0 || Spider.IsActive())
                {
                    ScanActive = true;
                    if (CrawlAndScan)
                    {
                        TotalRequestsCrawled = TotalRequestsCrawled + Requests.Count;
                        //update the ui with the number of requests crawled
                        foreach (Request Req in Requests)
                        {
                            if (Stopped)
                            {
                                return;
                            }
                            if (!CanScan(Req))
                            {
                                continue;
                            }
                            if (!UniqueChecker.IsUniqueToScan(Req, ScannedRequests, false))
                            {
                                continue;
                            }
                            try
                            {
                                Scanner S = new Scanner(Req);
                                S.CheckAll();

                                if (S.OriginalRequest.Query.Count == 0 && S.OriginalRequest.File.Length != 3 && S.OriginalRequest.File.Length != 4)
                                {
                                    S.InjectUrl();
                                }
                                S.InjectQuery();
                                S.InjectBody();
                                //S.InjectHeaders();
                                //S.InjectCookie();

                                if (!FormatPlugin.IsNormal(Req))
                                {
                                    List <FormatPlugin> RightList = FormatPlugin.Get(Req);
                                    if (RightList.Count > 0)
                                    {
                                        S.BodyFormat = RightList[0];
                                    }
                                }
                                if (S.InjectionPointsCount == 0)
                                {
                                    continue;
                                }
                                TotalScanJobsCreated++;
                                if (Stopped)
                                {
                                    return;
                                }
                                int ScanID = S.LaunchScan();
                                if (Stopped)
                                {
                                    Stop(true);
                                    return;
                                }
                                if (ScanID > 0)
                                {
                                    ScannedRequests.Add(Req);
                                    ScanIDs.Add(ScanID);
                                }
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report(string.Format("Error creating Scan Job with Request - {0}", Req.Url), Exp);
                            }
                        }
                    }
                }
                if (CrawlAndScan)
                {
                    List <int> ScanIDsToRemove  = new List <int>();
                    List <int> AbortedScanIDs   = Scanner.GetAbortedScanIDs();
                    List <int> CompletedScanIDs = Scanner.GetCompletedScanIDs();
                    for (int i = 0; i < ScanIDs.Count; i++)
                    {
                        if (Stopped)
                        {
                            return;
                        }
                        if (CompletedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                            TotalScanJobsCompleted++;
                        }
                        else if (AbortedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                        }
                    }
                    for (int i = 0; i < ScanIDsToRemove.Count; i++)
                    {
                        if (Stopped)
                        {
                            return;
                        }
                        ScanIDs.RemoveAt(ScanIDsToRemove[i] - i);
                    }
                }
                if (ScanActive)
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    if (ScanIDs.Count > 0)
                    {
                        ScanActive = true;
                        Thread.Sleep(5000);
                    }
                    else if (SleepCounter < 10)
                    {
                        ScanActive = true;
                        Thread.Sleep(2000);
                        SleepCounter = SleepCounter + 2;
                    }
                }
                if (Stopped)
                {
                    return;
                }
                IronUI.UpdateConsoleCrawledRequestsCount(TotalRequestsCrawled);
                IronUI.UpdateConsoleScanJobsCreatedCount(TotalScanJobsCreated);
                IronUI.UpdateConsoleScanJobsCompletedCount(TotalScanJobsCompleted);
            }
            if (Stopped)
            {
                return;
            }
            Stop();
        }
Esempio n. 7
0
        static void DoScan()
        {
            Spider = new Crawler();
            try
            {
                Spider.PrimaryHost = PrimaryHost;
                Spider.BaseUrl = BaseUrl;
                Spider.StartingUrl = StartingUrl;
                Spider.PerformDirAndFileGuessing = PerformDirAndFileGuessing;
                Spider.IncludeSubDomains = IncludeSubDomains;
                Spider.HTTP = HTTP;
                Spider.HTTPS = HTTPS;
                Spider.UrlsToAvoid = UrlsToAvoid;
                Spider.HostsToInclude = HostsToInclude;
                Spider.SpecialHeader = SpecialHeader;

                Spider.Start();
            }
            catch(Exception Exp)
            {
                IronException.Report("Error starting Crawler", Exp);
                try
                {
                    Stop();
                }
                catch { }
                return;
            }

            ScanItemUniquenessChecker UniqueChecker = new ScanItemUniquenessChecker(CanPromptUser);

            List<int> ScanIDs = new List<int>();
            bool ScanActive = true;
            List<string> ActivePlugins = ActivePlugin.List();
            int TotalRequestsCrawled = 0;
            int TotalScanJobsCreated = 0;
            int TotalScanJobsCompleted = 0;
            List<Request> ScannedRequests = new List<Request>();
            int SleepCounter = 0;

            while (ScanActive)
            {
                ScanActive = false;
                List<Request> Requests = Spider.GetCrawledRequests();
                if (Stopped) return;
                if (Requests.Count > 0 || Spider.IsActive())
                {
                    ScanActive = true;
                    if (CrawlAndScan)
                    {
                        TotalRequestsCrawled = TotalRequestsCrawled + Requests.Count;
                        //update the ui with the number of requests crawled
                        foreach (Request Req in Requests)
                        {
                            if (Stopped) return;
                            if (!CanScan(Req)) continue;
                            if (!UniqueChecker.IsUniqueToScan(Req, ScannedRequests, false)) continue;
                            try
                            {
                                Scanner S = new Scanner(Req);
                                foreach (string Check in Checks)
                                {
                                    S.AddCheck(Check);
                                }
                                if (InjectQuery)
                                {
                                    if (QueryWhiteList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Query.GetNames())
                                        {
                                            if (QueryWhiteList.Contains(Name)) S.InjectQuery(Name);
                                        }
                                    }
                                    else if (QueryBlackList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Query.GetNames())
                                        {
                                            if (!QueryBlackList.Contains(Name)) S.InjectQuery(Name);
                                        }
                                    }
                                    else
                                    {
                                        S.InjectQuery();
                                    }
                                }

                                if (InjectBody)
                                {
                                    if (BodyWhiteList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Body.GetNames())
                                        {
                                            if (BodyWhiteList.Contains(Name)) S.InjectBody(Name);
                                        }
                                    }
                                    else if (BodyBlackList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Body.GetNames())
                                        {
                                            if (!BodyBlackList.Contains(Name)) S.InjectBody(Name);
                                        }
                                    }
                                    else
                                    {
                                        S.InjectBody();
                                    }
                                }

                                if (InjectCookie)
                                {
                                    if (CookieWhiteList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Cookie.GetNames())
                                        {
                                            if (CookieWhiteList.Contains(Name)) S.InjectCookie(Name);
                                        }
                                    }
                                    else if (CookieBlackList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Cookie.GetNames())
                                        {
                                            if (!CookieBlackList.Contains(Name)) S.InjectCookie(Name);
                                        }
                                    }
                                    else
                                    {
                                        S.InjectCookie();
                                    }
                                }

                                if (InjectHeaders)
                                {
                                    if (HeaderWhiteList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Headers.GetNames())
                                        {
                                            if (HeaderWhiteList.Contains(Name)) S.InjectHeaders(Name);
                                        }
                                    }
                                    else if (HeaderBlackList.Count > 0)
                                    {
                                        foreach (string Name in S.OriginalRequest.Headers.GetNames())
                                        {
                                            if (!HeaderBlackList.Contains(Name)) S.InjectHeaders(Name);
                                        }
                                    }
                                    else
                                    {
                                        S.InjectHeaders();
                                    }
                                }

                                if (InjectUrlPathParts)
                                {
                                    if (S.OriginalRequest.Query.Count == 0 && S.OriginalRequest.File.Length == 0)
                                        S.InjectUrl();
                                }

                                if (S.InjectionPointsCount == 0) continue;
                                TotalScanJobsCreated++;
                                if (Stopped) return;
                                int ScanID = S.LaunchScan();
                                if (Stopped)
                                {
                                    Stop(true);
                                    return;
                                }
                                if (ScanID > 0)
                                {
                                    ScannedRequests.Add(Req);
                                    ScanIDs.Add(ScanID);
                                }
                            }
                            catch(Exception Exp)
                            {
                                IronException.Report(string.Format("Error creating Scan Job with Request - {0}", Req.Url), Exp);
                            }
                        }
                    }
                }
                if (CrawlAndScan)
                {
                    List<int> ScanIDsToRemove = new List<int>();
                    List<int> AbortedScanIDs = Scanner.GetAbortedScanIDs();
                    List<int> CompletedScanIDs = Scanner.GetCompletedScanIDs();
                    for (int i = 0; i < ScanIDs.Count; i++)
                    {
                        if (Stopped) return;
                        if (CompletedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                            TotalScanJobsCompleted++;
                        }
                        else if (AbortedScanIDs.Contains(ScanIDs[i]))
                        {
                            ScanIDsToRemove.Add(i);
                        }
                    }
                    for (int i = 0; i < ScanIDsToRemove.Count; i++)
                    {
                        if (Stopped) return;
                        ScanIDs.RemoveAt(ScanIDsToRemove[i] - i);
                    }
                }
                if (ScanActive)
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    if (ScanIDs.Count > 0)
                    {
                        ScanActive = true;
                        Thread.Sleep(5000);
                    }
                    else if (SleepCounter < 10)
                    {
                        ScanActive = true;
                        Thread.Sleep(2000);
                        SleepCounter = SleepCounter + 2;
                    }
                }
                if (Stopped) return;
                IronUI.UpdateConsoleCrawledRequestsCount(TotalRequestsCrawled);
                IronUI.UpdateConsoleScanJobsCreatedCount(TotalScanJobsCreated);
                IronUI.UpdateConsoleScanJobsCompletedCount(TotalScanJobsCompleted);
            }
            if (Stopped) return;
            Stop();
        }
Esempio n. 8
0
        internal static void StartBranchScan()
        {
            try
            {
                ScanDone = 0;
                //TotalScans = ProxyLogIDs.Count;
                NewRequestSignatures.Clear();
                ScanItemUniquenessChecker UniqueChecker = new ScanItemUniquenessChecker(PromptUser);

                if (PickFromProxyLog)
                {
                    IronUI.UpdateScanBranchStats(ScanDone, false, "Searching Proxy Logs for Requests to scan", true, false);
                    foreach (LogRow Row in IronDB.GetRecordsFromProxyLogMatchingFilters(new List <string>()
                    {
                        HostName
                    }, new List <string>()
                    {
                    }, ""))
                    {
                        if (CanScan(Row, "Proxy"))
                        {
                            ScanItem(UniqueChecker, "Proxy", Row.ID);
                        }
                    }
                }
                if (PickFromProbeLog)
                {
                    IronUI.UpdateScanBranchStats(ScanDone, false, "Searching Probe Logs for Requests to scan", true, false);
                    foreach (LogRow Row in IronDB.GetRecordsFromProbeLogMatchingFilters(new List <string>()
                    {
                        HostName
                    }, new List <string>()
                    {
                    }, ""))
                    {
                        if (CanScan(Row, "Probe"))
                        {
                            ScanItem(UniqueChecker, "Probe", Row.ID);
                        }
                    }
                }

                /*
                 * 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, true, "All Scan Jobs Created && Queued. Close this Window.", false, true);
            }
            catch (ThreadAbortException)
            {
                //
            }
            catch (Exception Exp)
            {
                IronException.Report("Scan Branch Exception", Exp.Message, Exp.StackTrace);
            }
        }