Exemple #1
0
        string convert_NTLM(string ntlm)
        {
            /*
             * An MD4 signature is then taken of this string, and which results in 128-bit code.
             * While a vast improvement on the horrible LM hash, there was no place for a salt value,
             * so once an intruder knew the mapping between the hashed value and the original password,
             * they would easily map them. If you are interested, here is MD2 and MD4 [MD4]
             *
             * When you go this link, select "Unicode Little Endian format" and, for "hello", you should get:
             *
             * 066DDFD4EF0E9CD7C256FE77191EF43C
             */
            Org.BouncyCastle.Crypto.Digests.MD4Digest md = new Org.BouncyCastle.Crypto.Digests.MD4Digest();

            byte[] unicodePassword = Encoding.Convert(Encoding.ASCII, Encoding.Unicode, Encoding.ASCII.GetBytes(ntlm));

            md.BlockUpdate(unicodePassword, 0, unicodePassword.Length);
            byte[] hash = new byte[16];
            md.DoFinal(hash, 0);
            return(ntlm = BitConverter.ToString(hash));

            /*
             * We can check these with a Python script:
             *
             *      import passlib.hash;
             *      string= "hello"
             *      print "LM Hash:" + passlib.hash.lmhash.encrypt(string)
             *      print "NT Hash:" + passlib.hash.nthash.encrypt(string)
             *
             *      which gives:
             *
             *      LM Hash:fda95fbeca288d44aad3b435b51404ee
             *      NT Hash:066ddfd4ef0e9cd7c256fe77191ef43c
             */
        }
Exemple #2
0
        protected override byte[] HashFinal()
        {
            byte[] output = new byte[dig.GetDigestSize()];
            dig.DoFinal(output, 0);

            return(output);
        }
Exemple #3
0
 ////////////////////////////////////////////////////////////////////////////////
 //
 ////////////////////////////////////////////////////////////////////////////////
 internal static Byte[] GenerateNTLM(String password)
 {
     Byte[] bPassword = Encoding.Unicode.GetBytes(password);
     Org.BouncyCastle.Crypto.Digests.MD4Digest md4Digest = new Org.BouncyCastle.Crypto.Digests.MD4Digest();
     md4Digest.BlockUpdate(bPassword, 0, bPassword.Length);
     Byte[] result = new Byte[md4Digest.GetDigestSize()];
     md4Digest.DoFinal(result, 0);
     return(result);
 }
Exemple #4
0
        public static byte[] MyHash(byte[] input)
        {
            Org.BouncyCastle.Crypto.Digests.MD4Digest dig = new Org.BouncyCastle.Crypto.Digests.MD4Digest();

            byte[] output = new byte[dig.GetDigestSize()];

            dig.BlockUpdate(input, 0, input.Length);
            dig.DoFinal(output, 0);

            return(output);
        }
Exemple #5
0
 ////////////////////////////////////////////////////////////////////////////////
 //
 ////////////////////////////////////////////////////////////////////////////////
 public static void GenerateNTLMString(String password)
 {
     try
     {
         Byte[] bPassword = Encoding.Unicode.GetBytes(password);
         Org.BouncyCastle.Crypto.Digests.MD4Digest md4Digest = new Org.BouncyCastle.Crypto.Digests.MD4Digest();
         md4Digest.BlockUpdate(bPassword, 0, bPassword.Length);
         Byte[] result = new Byte[md4Digest.GetDigestSize()];
         md4Digest.DoFinal(result, 0);
         Console.WriteLine(BitConverter.ToString(result).Replace("-", ""));
     }
     catch (Exception ex)
     {
         Console.WriteLine("[-] Unhandled Exception Occured");
         Console.WriteLine("[-] {0}", ex.Message);
     }
 }