private void SavePage(object sender, WaitWindowEventArgs e) { string output = ""; List <RequestWrapper> resources = uiTabbedBrowserControl.CurrentTab.Browser.ResourcesSet().OrderBy(q => q.Identifier).ToList(); List <HeaderWrapper> headers = uiTabbedBrowserControl.CurrentTab.Browser.ResponseHeaders().OrderBy(q => q.Identifer).ToList(); List <HeaderWrapper> requestHeaders = uiTabbedBrowserControl.CurrentTab.Browser.RequestHeaders().OrderBy(q => q.Identifer).ToList(); string saveFolder = new Uri(uiTabbedBrowserControl.CurrentTab.Browser.URL).Host.Replace(".", "_") + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff"); string savePath = Path.Combine(GSettings.Load().SaveDirectory, saveFolder); string logSavePath = Path.Combine(savePath, "_complete_log"); Directory.CreateDirectory(savePath); Directory.CreateDirectory(logSavePath); output += "=================================================================================\r\n"; output += "Capture started: " + DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss.fff") + "\r\n"; output += "URL: " + uiTabbedBrowserControl.CurrentTab.Browser.URL + "\r\n"; output += "IP(s): " + OsirtHelper.GetIpFromUrl(uiTabbedBrowserControl.CurrentTab.Browser.URL).Replace("\r\n", " ") + "\r\n"; output += "Screenshot Hash: " + OsirtHelper.GetFileHash(Constants.TempImgFile) + "\r\n"; output += "=================================================================================\r\n"; ulong count = 0; foreach (var resource in resources) { Directory.CreateDirectory($@"{savePath}\{resource.ResourceType}"); string filename = resource.ResourceType == ResourceType.MainFrame ? "mainframe.html" : OsirtHelper.GetSafeFilename(resource.RequestUrl, resource.MimeType); e.Window.Message = "Saving: " + filename + "...Please Wait"; if (File.Exists($@"{savePath}\{resource.ResourceType}\{filename}")) { filename = $"{++count}_{filename}"; } File.WriteAllBytes($@"{savePath}\{resource.ResourceType}\{filename}", resource.Data); output += "=================================================================================\r\n"; output += "Request ID: " + resource.Identifier + "\r\n"; output += "Request URL: " + resource.RequestUrl + "\r\n"; output += "Request URL IP(s): " + OsirtHelper.GetIpFromUrl(resource.RequestUrl).Replace("\r\n", " ") + "\r\n"; output += "Resource Type: " + resource.ResourceType + "\r\n"; output += "Mime Type: " + resource.MimeType + "\r\n"; output += "File Saved Location: " + $@"{savePath}\{resource.ResourceType}\{filename}" + "\r\n"; output += $"Hash [{UserSettings.Load().Hash.ToUpper()}]: " + OsirtHelper.GetFileHash(resource.Data) + "\r\n"; output += "Save completed at: " + DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss.fffffff") + "\r\n"; output += "=================================================================================\r\n"; e.Result = savePath; } output += "=================================================================================\r\n"; output += "Capture finished: " + DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss.fff") + "\r\n"; output += "=================================================================================\r\n"; File.AppendAllText($@"{logSavePath}\_capture.txt", output); File.Copy(Constants.TempImgFile, $@"{logSavePath}\_website.png"); if (GSettings.Load().SaveHttpHeaders) { string headerOutput = ""; foreach (var k in headers) { headerOutput += "====================================================\r\n"; headerOutput += "Request ID: " + k.Identifer + "\r\n"; foreach (KeyValuePair <string, string> kv in k.Headers) { headerOutput += $"{kv.Key} : {kv.Value}" + "\r\n"; } headerOutput += "====================================================\r\n"; } File.AppendAllText($@"{logSavePath}\_headers.txt", headerOutput); //string reqheaderOutput = ""; //foreach (var k in requestHeaders) //{ // reqheaderOutput += "====================================================\r\n"; // reqheaderOutput += "Request ID: " + k.Identifer + "\r\n"; // foreach (KeyValuePair<string, string> kv in k.Headers) // { // reqheaderOutput += $"{kv.Key} : {kv.Value}" + "\r\n"; // } // reqheaderOutput += "====================================================\r\n"; //} //File.AppendAllText($@"{logSavePath}\_request_headers.txt", reqheaderOutput); } CopyPageSaveToCase(savePath, e); }