private void GetHttpPayload(Frameunit frameunit) { string tcpSeqNum = frameunit.fieldUnit.sourceAddr + "_" + frameunit.fieldUnit.destAddr + "_" + frameunit.propertyUnit.tcpSeqNumber; string nextSeqNum = frameunit.fieldUnit.sourceAddr + "_" + frameunit.fieldUnit.destAddr + "_" + (frameunit.propertyUnit.tcpSeqNumber + frameunit.propertyUnit.tcpPayloadLength); string uri = frameunit.propertyUnit.httpserver + frameunit.propertyUnit.httpurilocation; int frameNum = frameunit.frameNum; if (URIResFragments.ContainsKey(uri) && pastFrameNum.Contains(tcpSeqNum) == false) { fragments frag = new fragments(); frag.tcpSeqNum = nextSeqNum; frag.fragmentsInfo = new List <string>(); fragments target = URIResFragments[uri]; if (target.tcpSeqNum == tcpSeqNum) { target.fragmentsInfo.Add(frameNum + "_HTTP"); target.tcpSeqNum = nextSeqNum; URIResFragments[uri] = target; } else { frag.fragmentsInfo.Add(frameNum + "_HTTP"); URIResFragments[uri] = frag; } pastFrameNum.Add(tcpSeqNum); } }
private void Print() { /* * foreach(string uri in packetStats.URIs) * { * Console.WriteLine(uri); * }*/ foreach (KeyValuePair <string, fragments> pair in URIResFragments) { string uri = pair.Key; fragments frag = pair.Value; string str = ""; foreach (string item in frag.fragmentsInfo) { str += item + ", "; } Console.WriteLine(uri); Console.WriteLine(frag.tcpSeqNum + ":" + str + "\n"); } }
private void GetTcpPayload() { List <int> tcpFrames = new List <int>(); bool needAnotherLoop = true; List <int> needLoop = _CommonNums; while (needAnotherLoop) { needAnotherLoop = false; tcpFrames = needLoop; needLoop = new List <int>(); foreach (int tcpframe in tcpFrames) { int frameNum = tcpframe; Frameunit frameunit = _frameNumberDict[frameNum]; string tcpSeqNum = frameunit.fieldUnit.sourceAddr + "_" + frameunit.fieldUnit.destAddr + "_" + frameunit.propertyUnit.tcpSeqNumber; string nextSeqNum = frameunit.fieldUnit.sourceAddr + "_" + frameunit.fieldUnit.destAddr + "_" + (frameunit.propertyUnit.tcpSeqNumber + frameunit.propertyUnit.tcpPayloadLength); if (pastFrameNum.Contains(tcpSeqNum) == false) { if (FindSeqNumInDict(tcpSeqNum) == false) { needLoop.Add(frameNum); } else { fragments target = URIResFragments[_currentUri]; //change target.tcpSeqNum target.tcpSeqNum = nextSeqNum; target.fragmentsInfo.Add(frameNum + "_TCP"); pastFrameNum.Add(tcpSeqNum); needAnotherLoop = true; // some tcp frame might arrive at a wrong order comparing to its seqnumber } } } } }
public void ReConstructingResource(List <Frameunit> allFrames) { _resConstructor = new ConstructRequestRes(allFrames); _frameNumberDict = _resConstructor._frameNumberDict; URIResFragments = _resConstructor.URIResFragments; _payloadProcessing = new PayloadProcessing(_frameNumberDict); CreatOutputFolder(); _csvWriter = new csvWriter(_outputFolder + "\\" + "AllUrls.csv"); _csvAllLines.Add("url,content type"); Console.WriteLine("-----------------------start to create output file-----------------------"); foreach (KeyValuePair <string, fragments> pair in URIResFragments) { string uri = pair.Key; fragments frag = pair.Value; if (frag.fragmentsInfo != null && frag.fragmentsInfo.Count > 0) { Console.WriteLine("uri:" + uri); CreateResource(uri, frag); } } _csvWriter.AddAllLinesToCsv(_csvAllLines); }
private void CreateResource(string uri, fragments frag) { // Console.WriteLine("uri:"+uri); string http_frame = frag.fragmentsInfo[0]; int startframeNum = Int32.Parse(http_frame.Split('_')[0]); Frameunit frameunit = _frameNumberDict[startframeNum]; string contentType = frameunit.propertyUnit.httpcontentType; // Console.WriteLine(contentType); string urilocation = frameunit.propertyUnit.httpurilocation; string outputName = _outputFolder + "\\" + startframeNum + "_" + urilocation.Split('/')[urilocation.Split('/').Length - 2] + "_" + urilocation.Split('/')[urilocation.Split('/').Length - 1]; List <Byte> fragBytes = _payloadProcessing.ConstructFragments(frag.fragmentsInfo, frameunit.propertyUnit.httpcontentEncoding); Console.WriteLine(uri + ":" + frameunit.propertyUnit.httpcontentType + ": " + frameunit.propertyUnit.httpcontentEncoding); string writeline = uri + "," + contentType; // _csvWriter.AddLineToCsv(writeline); _csvAllLines.Add(writeline); Console.WriteLine("transfer type:" + frameunit.propertyUnit.httptransferType); if (fragBytes.Count > 0) { _fileConstructor = new FileConstructor(fragBytes, contentType, frameunit.propertyUnit.httpcontentEncoding, frameunit.propertyUnit.httptransferType, outputName, uri); Console.WriteLine(_fileConstructor.IsSuccessful); if (_fileConstructor.IsSuccessful == false) { string retsr = ""; foreach (string item in frag.fragmentsInfo) { retsr += item + ", "; } Console.WriteLine("uri:" + uri); Console.WriteLine(retsr); Console.WriteLine("\n\n"); } } }
public override string Serialize(fragments.StructuredText.Element element, String content) { return f(element, content); }
public abstract String Serialize(fragments.StructuredText.Element element, String content);
public override String Resolve(fragments.DocumentLink link) { return f(link); }
public abstract String Resolve(fragments.DocumentLink link);
public String GetTitle(fragments.DocumentLink link) { return null; }
public Embed(fragments.Embed obj, String label) : base(label) { this.obj = obj; }
public Image(fragments.Image.View view, String label) : base(label) { this.view = view; }