bool WriteFromServer(string ret) { bool v = false; foreach (Match m in Hex.Matches(ret)) { try { string hv = m.Value; if (hv.Length % 2 != 0) { hv = hv.Insert(2, "0"); } WriteInfo("", "\t" + m.Value + " = " + Encoding.GetString(HexHelper.FromHexString(hv)), ConsoleColor.Magenta); v = true; } catch { } } if (Verbose || v) { WriteInfo(ret); } return(v); }
/// <summary> /// Load TCP Stream from WireShark TCPStreamFormat /// </summary> /// <param name="file">File</param> public static TcpStream FromFile(string file) { TcpStream tcp = null; if (!string.IsNullOrEmpty(file)) { string[] sp = File.ReadAllLines(file); IPEndPoint empty = new IPEndPoint(IPAddress.None, IPEndPoint.MinPort); foreach (string line in sp) { string l = line.TrimStart().Replace(":", ""); ETcpEmisor em = line.StartsWith("\t") ? ETcpEmisor.Server : ETcpEmisor.Client; if (tcp == null) { tcp = new TcpStream(null, em, PhysicalAddress.None, PhysicalAddress.None, empty, empty, null, DateTime.Now); } if (l.Length >= 9 && !l.Substring(0, 8).Contains(" ")) { // remove offset l = l.Substring(8, l.Length - 8).Trim(); } if (l.Length > 48) { l = l.Substring(0, 48); } l = l.Replace(" ", ""); byte[] data = HexHelper.FromHexString(l); if (tcp._Last == null) { tcp._Last = new TcpStreamMessage(DateTime.Now, data, em, null); tcp._InternalList.Add(tcp._Last); } else { // Check if its the same if (tcp._Last.Emisor == em) { tcp._Last.AddData(data, 0, data.Length); } else { // New Packet tcp._Last = new TcpStreamMessage(DateTime.Now, data, em, tcp._Last); tcp._InternalList.Add(tcp._Last); } } } } return(tcp); }
/// <summary> /// Edit the variable before set /// </summary> /// <param name="value">Value</param> public override string PreSetVariable(string value) { if (!string.IsNullOrEmpty(value) && value.StartsWith("0x")) { try { value = Encoding.GetString(HexHelper.FromHexString(value)); } catch { } } return(value); }
/// <summary> /// Load TCP Stream from WireShark TCPStreamFormat /// </summary> /// <param name="file">File</param> public static TcpStream FromFile(string file) { TcpStream tcp = new TcpStream(null); if (!string.IsNullOrEmpty(file)) { string[] sp = File.ReadAllLines(file); foreach (string line in sp) { string l = line.TrimStart().Replace(":", ""); ETcpEmisor em = line.StartsWith(" ") ? ETcpEmisor.A : ETcpEmisor.B; if (l.Length >= 9 && !l.Substring(0, 8).Contains(" ")) { // remove offset l = l.Substring(8, l.Length - 8).Trim(); } if (l.Length > 48) { l = l.Substring(0, 48); } l = l.Replace(" ", ""); byte[] data = HexHelper.FromHexString(l); if (tcp._Last == null) { tcp._Last = new TcpStreamMessage(data, em); tcp._InternalList.Add(tcp._Last); } else { // Check if its the same if (tcp._Last.Emisor == em) { tcp._Last.AddData(data); } else { // New Packet tcp._Last = new TcpStreamMessage(data, em); tcp._InternalList.Add(tcp._Last); } } } } return(tcp); }
bool parse(string line, int filedIdLength, int packetNumLength, out string fileId, out packet packet) { fileId = ""; packet = null; if (string.IsNullOrEmpty(line)) { return(false); } try { Match m = Regex.Match(line, RegexData); if (m == null || !m.Success) { return(false); } string dom; string data = m.Value.Trim(); StringHelper.Split(data, '.', out data, out dom); if (filedIdLength > 0) { fileId = data.Substring(0, filedIdLength); if (string.IsNullOrEmpty(fileId)) { return(false); } } int packetNum = 0; if (packetNumLength > 0) { packetNum = BitConverterHelper.ToInt32(HexHelper.FromHexString(data.Substring(filedIdLength, packetNumLength)), 0); } packet = new packet() { Data = HexHelper.FromHexString(data.Remove(0, filedIdLength + packetNumLength)), Order = packetNum }; return(true); } catch { return(false); } }
public bool CheckPassword(string password) { byte[] key = HexHelper.FromHexString(password); if (key.Length != 6) { throw (new Exception("Password error in (6 bytes): " + password)); } _Config.KeysOne = key; //_Config.KeysZero = key; ICard ic; if (_Reader.GetCard(out ic, _Card.Atr, _Config)) { CardMifare card = (CardMifare)ic; if (card.Sectors[AttackInSectorNum].DataBlocks[(byte)AttackInBlock].IsReaded) { return(true); } } return(false); }
byte[] xxd(string text) { text = text.Replace("\n", "").Replace("\r", "").Replace(" ", ""); return(HexHelper.FromHexString(text)); }
/* * public ushort ReadUShort(byte[] data, int index) * { * byte[] bUshort = new byte[2]; * Array.Copy(data, index, bUshort, 0, 2); * * return BitConverter.ToUInt16(bUshort, 0); * }*/ public bool PreRun() { Salt = HexHelper.FromHexString(HexSalt); Nonce = HexHelper.FromHexString(HexNonce); InputBuffer = HexHelper.FromHexString(HexInputBuffer); Mac = HexHelper.FromHexString(HexMac); // VALORES REQUERIDOS PARA EL CRACK DEL TEST #123456# //Salt = ConvertToByteArray("33 b1 76 41 46 2c 04 5d 3e 55 db d9 c3 43 60 44"); //Nonce = ConvertToByteArray("e0 49 1b 14 4a b7 d0 01 03 00 00 00"); //InputBuffer = ConvertToByteArray("0b 73 ab e8 60 c9 05 c7 57 62 d4 85 1b 0e 49 a0 6d c4 72 d4 99 1f 23 49 30 f9 27 de 50 69 12 66 23 74 d7 cd b5 09 52 66 e2 fd b9 88"); //Mac = ConvertToByteArray("16 21 33 02 af aa 69 2c-4a a3 f8 0b dc b9 54 af"); // ******************************** // VALORES REQUERIDOS PARA EL CRACK DEL REAL! //Salt = ConvertToByteArray("9f 0a ba 66 70 c6 cb 0c b0 75 d4 84 f0 ad 68 34"); //Nonce = ConvertToByteArray("00 6a e1 86 34 45 d0 01 03 00 00 00"); //InputBuffer = ConvertToByteArray("38 3c 76 ea 61 35 3f 23 c5 e0 7e 38 c1 34 c7 d8 5c 7d a7 3a 0d 4f 70 3e 56 9d bb 3d b6 1d eb c1 9e 77 48 a5 e3 93 2b e8 c1 23 cf ca"); //Mac = ConvertToByteArray("e9 bc 37 40 1d 43 2d fe-a7 f1 77 e8 09 88 47 18"); // ******************************** /* * int x = 0; * x++; * * long offSet = -1; * int blockSize = -1; * #region Get Offset of partition * using (Process proc = new Process * { * StartInfo = new ProcessStartInfo * { * FileName = "wmic", * Arguments = "partition get BlockSize, StartingOffset, Name", * UseShellExecute = false, * RedirectStandardOutput = true, * CreateNoWindow = true * } * }) * { * * proc.Start(); * proc.WaitForExit(); * while (!proc.StandardOutput.EndOfStream) * { * string line = proc.StandardOutput.ReadLine(); * if (line.Contains("#" + driveNum.ToString() + ", ")) * { * string[] sp = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); * offSet = Convert.ToInt64(sp[sp.Length - 1]); * blockSize = Convert.ToInt32(sp[0]); * break; * } * // do something with line * } * } #endregion * * //***** * IntPtr handle = CreateFile( * //"\\\\.\\" + drive.ToString() + ":", * @"\\.\PHYSICALDRIVE" + driveNum.ToString(), * FileAccess.Read, FileShare.None, IntPtr.Zero, FileMode.Open, FILE_FLAG_NO_BUFFERING, IntPtr.Zero); * * ushort bytesPerSector, numberOfSectorsPerCluster, metadataLogicalClusterNumber; * * byte[] inBuffer = new byte[blockSize]; * using (FileStream disk = new FileStream(handle, FileAccess.Read)) * { * disk.Seek(offSet, SeekOrigin.Begin); * * disk.Read(inBuffer, 0, blockSize); * //for (int i = 0; i < blockSize; i++) * // inBuffer[i] = (byte)disk.ReadByte(); * * bytesPerSector = ReadUShort(inBuffer, 0xB); * numberOfSectorsPerCluster = ReadUShort(inBuffer, 0xD); * metadataLogicalClusterNumber = ReadUShort(inBuffer, 0x38); * * } * * _bitlocker_header header = BruteForce.FromBytes<_bitlocker_header>(inBuffer); */ /* * C:\Windows\system32>manage-bde -status E: * Cifrado de unidad BitLocker: versión de la herramienta de configuración 6.3.9600 * Copyright (C) 2013 Microsoft Corporation. Todos los derechos reservados. * * Volumen E: [Etiqueta desconocida] * [Volumen de datos] * * Tamaño: Desconocido GB * Versión de BitLocker: 2.0 * Estado de conversión: Desconocido * Porcentaje cifrado: Desconocido% * Método de cifrado: AES 128 * Estado de protección: Desconocido * Estado de bloqueo: Bloqueado * Campo de identificación:Desconocido * Desbloqueo automático: Deshabilitado * Protectores de clave: * Contraseña * Contraseña numérica * * * C:\Windows\system32>manage-bde -protectors -get e: * Cifrado de unidad BitLocker: versión de la herramienta de configuración 6.3.9600 * Copyright (C) 2013 Microsoft Corporation. Todos los derechos reservados. * * Volumen E: [Etiqueta desconocida] * Todos los protectores de clave * * Contraseña: * Id.: {9FFF4471-E895-46A4-A69F-9D3856F78ED3} * Salt: 9f 0a ba 66 70 c6 cb 0c b0 75 d4 84 f0 ad 68 34 * * Contraseña numérica: * Id.: {DAC7EEA6-DD1F-4CA7-B68A-8A8B14D83866} * Salt: 69 24 b5 21 f3 1c 8d 4e 97 b3 c0 86 36 a0 56 0a */ InputBufferLength = InputBuffer.Length; return(true); }