/// <summary> /// Injects Casaba Request Sessions into Fiddler.. /// </summary> /// <param name="?"></param> /// <returns></returns> public static void CasabaSessionFiddlerInjector(Secsay.Session s) { Fiddler.HTTPRequestHeaders reqHeaders = new Fiddler.HTTPRequestHeaders(); StringDictionary flags = new StringDictionary(); string sc; foreach (string key in s.Request.Headers.Keys) { List <string> values = s.Request.Headers[key]; foreach (string v in values) { reqHeaders.Add(key, v); } } reqHeaders.RequestPath = s.Request.Path; reqHeaders.HTTPMethod = s.Request.HttpMethod; if (s.ContainsCodePoint) { sc = s.Chr.ToString(); //Here and i put the code point as text string.. } else { sc = ""; } flags[UASettings.casabaFlag] = sc; Fiddler.FiddlerApplication.oProxy.InjectCustomRequest(reqHeaders, s.Request.BodyBytes, flags); }
/// <summary> /// This method adds a session to the outgoing queue. /// </summary> /// <param name="session">The session to enqueue.</param> public void Enqueue(Secsay.Session session) { lock (m_outstandingRequests) { Debug.WriteLine("Queuing a session..."); m_outstandingRequests.Enqueue(session); Debug.WriteLine(String.Format("{0} sessions queued.", m_outstandingRequests.Count)); } }
/// <summary> /// This method performs the throttled request injection. /// </summary> private void RequestProcessingThread() { while (true) { // If we're throttling requests, pause for the user-specified delay interval. // Otherwise, pause for the default delay interval. If the exit signal has // been raised during this period, exit. if (m_signal.WaitOne(Throttle ? Delay : DEFAULT_DELAY, false)) { break; } lock (m_outstandingRequests) { // Determine the number of requests to inject. If we're not throttling, // this will be ther number of requests we ultimately inject. int requestsToInject = m_outstandingRequests.Count; // If there are no outstanding requests, resume the wait. if (requestsToInject < 1) { continue; } // If we're throttling and the number of requests to inject is greater // than the batch size, inject a maximum of BatchSize requests. else if (Throttle && requestsToInject > BatchSize) { requestsToInject = BatchSize; } Debug.WriteLine(String.Format("Performing injection of {0} out of {1} total sessions in the queue...", requestsToInject, m_outstandingRequests.Count)); // Inject the next batch of requests for (int n = 0; n < requestsToInject; ++n) { Secsay.Session session = m_outstandingRequests.Dequeue(); Secsay.xss.FiddlerUtils.CasabaSessionFiddlerInjector(session); } Debug.WriteLine(String.Format("{0} sessions remaining in queue.", m_outstandingRequests.Count)); } } }