/// <summary> /// Sets a standard content for the request. /// </summary> /// <param name="postData">The content string</param> /// <param name="contentType">The content type</param> /// <param name="method">The HTTP method</param> /// <param name="encodeContent">Whether to URLencode the content automatically</param> /// <param name="log">The log (if any)</param> /// <returns>The request itself</returns> public Request SetStandardContent(string postData, string contentType, HttpMethod method = HttpMethod.POST, bool encodeContent = false, List <LogEntry> log = null) { this.contentType = contentType; var pData = Regex.Replace(postData, @"(?<!\\)\\n", Environment.NewLine).Unescape(); if (HttpRequest.CanContainRequestBody(method)) { if (encodeContent) { // Very dirty but it works Random rand = new Random(); var nonce = rand.Next(1000000, 9999999); pData = pData.Replace("&", $"{nonce}&{nonce}").Replace("=", $"{nonce}={nonce}"); pData = string.Join("", BlockFunction.SplitInChunks(pData, 2080) .Select(s => Uri.EscapeDataString(s))) .Replace($"{nonce}%26{nonce}", "&").Replace($"{nonce}%3D{nonce}", "="); } content = new StringContent(pData); content.ContentType = contentType; if (log != null) { log.Add(new LogEntry($"Post Data: {pData}", Colors.MediumTurquoise)); } } return(this); }
public PageBlockFunction(BlockFunction block) { InitializeComponent(); vm = block; DataContext = vm; foreach (var t in Enum.GetNames(typeof(BlockFunction.Function))) { functionTypeCombobox.Items.Add(t); } functionTypeCombobox.SelectedIndex = (int)vm.FunctionType; foreach (var h in Enum.GetNames(typeof(Hash))) { hashTypeCombobox.Items.Add(h); hmacHashTypeCombobox.Items.Add(h); kdfAlgorithmCombobox.Items.Add(h); } hashTypeCombobox.SelectedIndex = (int)vm.HashType; hmacHashTypeCombobox.SelectedIndex = (int)vm.HashType; kdfAlgorithmCombobox.SelectedIndex = (int)vm.KdfAlgorithm; foreach (var b in Enum.GetNames(typeof(UserAgent.Browser))) { randomUABrowserCombobox.Items.Add(b); } randomUABrowserCombobox.SelectedIndex = (int)vm.UserAgentBrowser; foreach (var m in Enum.GetNames(typeof(CipherMode))) { aesModeCombobox.Items.Add(m); } aesModeCombobox.SelectedIndex = (int)vm.AesMode - 1; foreach (var p in Enum.GetNames(typeof(PaddingMode))) { aesPaddingCombobox.Items.Add(p); } aesPaddingCombobox.SelectedIndex = (int)vm.AesPadding - 1; dictionaryRTB.AppendText(vm.GetDictionary()); }
public List <ConfigViewModel> GetConfigsFromSources() { var list = new List <ConfigViewModel>(); foreach (var source in Globals.obSettings.Sources.Sources) { try { WebClient wc = new WebClient(); switch (source.Auth) { case Source.AuthMode.ApiKey: wc.Headers.Add(HttpRequestHeader.Authorization, source.ApiKey); break; case Source.AuthMode.UserPass: var header = BlockFunction.Base64Encode($"{source.Username}:{source.Password}"); wc.Headers.Add(HttpRequestHeader.Authorization, $"Basic {header}"); break; default: break; } var file = wc.DownloadData(source.ApiUrl); using (var zip = new ZipArchive(new MemoryStream(file), ZipArchiveMode.Read)) { foreach (var entry in zip.Entries) { using (var stream = entry.Open()) { using (TextReader tr = new StreamReader(stream)) { var text = tr.ReadToEnd(); var cfg = IOManager.DeserializeConfig(text); list.Add(new ConfigViewModel("", "Remote", cfg, true)); } } } } } catch { } } return(list); }
private void LRRTB_KeyUp(object sender, KeyEventArgs e) { // Sentry-like auto LR try { if (e.Key == Key.LeftShift) { var begin = LRRTB.Document.ContentStart; var start = (new TextRange(begin, LRRTB.Selection.Start)).Text.Length; var len = LRRTB.Selection.Text.Length; var end = start + len - 1; var left = ""; var right = ""; var index = start; do { if (index == 0) { break; } left = LRRTB.GetText()[index - 1] + left; index--; }while (BlockFunction.CountStringOccurrences(LRRTB.GetText(), left) > 1); index = end; do { if (index == LRRTB.GetText().Length - 1) { break; } right += LRRTB.GetText()[index + 1]; index++; }while (BlockFunction.CountStringOccurrences(LRRTB.GetText(), right) > 1); vm.LeftString = left; vm.RightString = right; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public PageBlockFunction(BlockFunction block) { InitializeComponent(); vm = block; DataContext = vm; foreach (var t in Enum.GetNames(typeof(BlockFunction.Function))) { functionTypeCombobox.Items.Add(t); } functionTypeCombobox.SelectedIndex = (int)vm.FunctionType; foreach (var h in Enum.GetNames(typeof(BlockFunction.Hash))) { hashTypeCombobox.Items.Add(h); hmacHashTypeCombobox.Items.Add(h); } hashTypeCombobox.SelectedIndex = (int)vm.HashType; hmacHashTypeCombobox.SelectedIndex = (int)vm.HashType; dictionaryRTB.AppendText(vm.GetDictionary()); }
private static T Mock <T>(BlockFunction functions = BlockFunction.None, Action <T> options = null, params String[] zones) where T : class, new() { if (!typeof(MockTerminalBlock).IsAssignableFrom(typeof(T))) { throw new InvalidOperationException(); } var serializer = new MyIni(); var block = new T() as MockTerminalBlock; block.EntityId = NextEntityId++; var name = $"{typeof(T).Name.Substring(4)}"; if (functions != BlockFunction.None) { serializer.Set("SSM Configuration", "functions", Convert.ToInt32(functions)); name += $" ({functions})"; } if (zones.Any()) { serializer.Set("SSM Configuration", "zones", String.Join("\n", zones)); name += $" [{String.Join(", ", zones)}]"; } block.CustomName = name; block.DisplayName = name; block.CustomData = serializer.ToString(); var cast = block as T; options?.Invoke(cast); return(cast); }
private string GetHitChecksum(Hit hit) { return(BlockFunction.GetHash(hit.Data + hit.ConfigName + hit.WordlistName, BlockFunction.Hash.MD5)); }
public List <ConfigViewModel> GetConfigsFromSources() { var list = new List <ConfigViewModel>(); cachedConfigs = new List <ConfigViewModel>(); foreach (var source in Globals.obSettings.Sources.Sources) { WebClient wc = new WebClient(); switch (source.Auth) { case Source.AuthMode.ApiKey: wc.Headers.Add(HttpRequestHeader.Authorization, source.ApiKey); break; case Source.AuthMode.UserPass: var header = BlockFunction.Base64Encode($"{source.Username}:{source.Password}"); wc.Headers.Add(HttpRequestHeader.Authorization, $"Basic {header}"); break; default: break; } byte[] file = new byte[] { }; try { file = wc.DownloadData(source.ApiUrl); } catch (Exception ex) { MessageBox.Show($"Could not contact API {source.ApiUrl}\r\nReason: {ex.Message}"); continue; } var status = wc.ResponseHeaders["Result"]; if (status != null && status == "Error") { MessageBox.Show($"Error from API {source.ApiUrl}\r\nThe server says: {Encoding.ASCII.GetString(file)}"); continue; } try { using (var zip = new ZipArchive(new MemoryStream(file), ZipArchiveMode.Read)) { foreach (var entry in zip.Entries) { var subCategory = Path.GetDirectoryName(entry.FullName).Replace("\\", " - "); var category = subCategory == "" ? "Remote" : $"Remote - {subCategory}"; using (var stream = entry.Open()) { using (TextReader tr = new StreamReader(stream)) { var text = tr.ReadToEnd(); var cfg = IOManager.DeserializeConfig(text); list.Add(new ConfigViewModel("", category, cfg, true)); cachedConfigs.Add(new ConfigViewModel("", category, cfg, true)); } } } } } catch { } } return(list); }
public PageBlockFunction(BlockFunction block) { InitializeComponent(); vm = block; DataContext = vm; foreach (var t in Enum.GetNames(typeof(BlockFunction.Function))) functionTypeCombobox.Items.Add(t); functionTypeCombobox.SelectedIndex = (int)vm.FunctionType; foreach (var h in Enum.GetNames(typeof(Hash))) { hashTypeCombobox.Items.Add(h); hmacHashTypeCombobox.Items.Add(h); kdfAlgorithmCombobox.Items.Add(h); } hashTypeCombobox.SelectedIndex = (int)vm.HashType; hmacHashTypeCombobox.SelectedIndex = (int)vm.HashType; kdfAlgorithmCombobox.SelectedIndex = (int)vm.KdfAlgorithm; foreach (var b in Enum.GetNames(typeof(UserAgent.Browser))) { randomUABrowserCombobox.Items.Add(b); } randomUABrowserCombobox.SelectedIndex = (int)vm.UserAgentBrowser; foreach (var m in Enum.GetNames(typeof(CipherMode))) { aesModeCombobox.Items.Add(m); } aesModeCombobox.SelectedIndex = (int)vm.AesMode - 1; foreach (var p in Enum.GetNames(typeof(PaddingMode))) { aesPaddingCombobox.Items.Add(p); } foreach (var d in Enum.GetNames(typeof(DateToUnixTimeType))) { dateToUnixTimeCombobox.Items.Add(d); } encCombobox.Items.Add("utf-8"); encCombobox.Items.Add("windows-1251"); encCombobox.Items.Add(1251); foreach (var e in Enum.GetNames(typeof(EncodingMethods))) { encFuncCombobox.Items.Add(e); } foreach (var e in Enum.GetNames(typeof(ScryptMethods))) { if (e == nameof(ScryptMethods.Encode)) { scryptMethods.Items.Add(e); break; } } foreach (var e in Enum.GetNames(typeof(BCryptMethods))) { bcryptMethods.Items.Add(e); } bcryptMethods.SelectedIndex = (int)vm.BCryptMeth; aesPaddingCombobox.SelectedIndex = (int)vm.AesPadding - 1; dictionaryRTB.AppendText(vm.GetDictionary()); }