/// <summary> /// Adds the Data base /// </summary> /// <param name="strDBName"></param> /// <returns></returns> public Boolean AddData(NetworkData data) { //Declarations Boolean blnFlag = false; MongoDatabase objDB = GetServer().GetDatabase(_dbName); try { //Get the table MongoCollection objTable = objDB.GetCollection(_tableName); //Insert the data objTable.Insert(data); objTable.Save(data); blnFlag = true; } catch (Exception ex) { Logger.Log("AddData: " + ex.Message); } return blnFlag; }
/// <summary> /// Gets triggered before the request has been made /// </summary> /// <param name="objSession"></param> private void FiddlerApplication_BeforeRequest(Session objSession) { try { CreateCertificateIfRequired(); //Declarations String strContentType = String.Empty; String strRequestedParameters = String.Empty; //Get the flag whether its an allowable URL Website website = _snifferConfigHandler.GetWebsite(objSession.fullUrl); //Check whether a matching website was found _IsAllowedURL = website != null; //Sniff out only if this URL was in the list of websites if (_IsAllowedURL) { //Get the content type strContentType = objSession.oRequest.headers["Accept"]; //If its not a capture onl only HTML requests or it has to be HTML only content //Get the request headers HTTPRequestHeaders objRequestHeaders = objSession.oRequest.headers; //Construct the network data NetworkData objNetworkData = new NetworkData { URLFullPath = objSession.fullUrl, IsHTTPS = objSession.isHTTPS, SentOn = objSession.Timers.ClientBeginRequest.ToString(), Site = website }; //Get the request body String strRequestBody = objSession.GetRequestBodyAsString(); //If its a POST request if (objRequestHeaders.HTTPMethod == "POST") //Get the request parameters strRequestedParameters = strRequestBody; else if (objRequestHeaders.HTTPMethod == "GET") { String[] arrQueryString = objNetworkData.URLFullPath.Split(new Char[] { '?' }); if (arrQueryString.Length > 1) strRequestedParameters = arrQueryString[1]; } //TO DO: Capture only if the content has any PII data if (objNetworkData.ContainsPII(_snifferConfigHandler.Person, strRequestedParameters)) //Update the capture to Mongo DB _DBUtility.AddData(objNetworkData); } else { //Uncomment this if tampering of response is required //objSession.bBufferResponse = true; //objSession.Abort(); } } catch (ThreadAbortException ex) { ShutDown(); } catch (Exception ex) { Utility.Logger.Log("FiddlerApplication_BeforeRequest: " + ex.Message); ShutDown(); } }