コード例 #1
0
        public static void decryptFile(string encryptedFilePath)
        {
            string str = Program.MakePath(encryptedFilePath, "");

            try
            {
                string      s1              = "";
                string      s2              = "";
                long        lOrgFileSize    = 0;
                string      stringFromBytes = Encipher.GetStringFromBytes(Encipher.GetHeaderBytesFromFile(encryptedFilePath));
                XmlDocument xmlDocument     = new XmlDocument();
                xmlDocument.LoadXml(stringFromBytes);
                foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAA"))
                {
                    s1 = xmlNode.InnerText;
                }
                foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AA"))
                {
                    s2 = xmlNode.InnerText;
                }
                foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAAAAAAAAAAAAAAAAA"))
                {
                    lOrgFileSize = Convert.ToInt64(xmlNode.InnerText);
                }
                byte[] key = Encipher.RSADescryptBytes(Convert.FromBase64String(s1), Program.privkey);
                byte[] iv  = Encipher.RSADescryptBytes(Convert.FromBase64String(s2), Program.privkey);
                Encipher.DecryptFile(encryptedFilePath, str, key, iv, lOrgFileSize);
            }
            catch (FormatException ex)
            {
                Console.WriteLine("\r\n[-] Decryption key is not correct -> " + encryptedFilePath + ex.Message);
                if (!File.Exists(str))
                {
                    return;
                }
                File.Delete(str);
            }
            catch (XmlException ex)
            {
                Console.WriteLine("\r\n[-] Encrypted data is not correct -> " + encryptedFilePath + ex.Message);
                if (!File.Exists(str))
                {
                    return;
                }
                File.Delete(str);
            }
        }
コード例 #2
0
        public static void DecryptFile(string encryptedFilePath, string decryptedFilePath, byte[] key, byte[] iv, long lOrgFileSize)
        {
            if (File.Exists(decryptedFilePath))
            {
                File.Delete(decryptedFilePath);
            }
            long length = new FileInfo(encryptedFilePath).Length;
            long num1   = (long)(int)(length / (long)Encipher.chunkSize + 1L);
            bool flag   = true;

            try
            {
                for (long index = 0; index < num1; ++index)
                {
                    int    readCount;
                    byte[] bytesFromFile = Encipher.GetBytesFromFile(encryptedFilePath, (long)Encipher.headerSize + index * (long)Encipher.chunkSize, out readCount);
                    if (readCount > 0)
                    {
                        byte[] cipherText = new byte[readCount];
                        Buffer.BlockCopy((Array)bytesFromFile, 0, (Array)cipherText, 0, readCount);
                        byte[] _ByteArray = Encipher.DecryptStringFromBytes(cipherText, key, iv, readCount);
                        flag = Encipher.WriteBytesToFile(decryptedFilePath, _ByteArray);
                        if (!flag)
                        {
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    return;
                }
                long       num2       = length - (long)Encipher.headerSize - lOrgFileSize;
                FileInfo   fileInfo   = new FileInfo(decryptedFilePath);
                FileStream fileStream = fileInfo.Open(FileMode.Open);
                fileStream.SetLength(Math.Max(0L, fileInfo.Length - num2));
                fileStream.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #3
0
        public static void DecryptFile(string encryptedFilePath, string decryptedFilePath, byte[] key, byte[] iv, long lOrgFileSize)
        {
            int num;

            if (File.Exists(decryptedFilePath))
            {
                File.Delete(decryptedFilePath);
            }
            long length = (new FileInfo(encryptedFilePath)).Length;
            long num1   = (long)((int)(length / (long)Encipher.chunkSize + (long)1));
            bool file   = true;

            try
            {
                for (long i = (long)0; i < num1; i = i + (long)1)
                {
                    byte[] bytesFromFile = Encipher.GetBytesFromFile(encryptedFilePath, (long)Encipher.headerSize + i * (long)Encipher.chunkSize, out num);
                    if (num > 0)
                    {
                        byte[] numArray = new byte[num];
                        Buffer.BlockCopy(bytesFromFile, 0, numArray, 0, num);
                        byte[] numArray1 = Encipher.DecryptStringFromBytes(numArray, key, iv, num);
                        file = Encipher.WriteBytesToFile(decryptedFilePath, numArray1);
                        if (!file)
                        {
                            break;
                        }
                    }
                }
                if (file)
                {
                    long       num2       = length - (long)Encipher.headerSize - lOrgFileSize;
                    FileInfo   fileInfo   = new FileInfo(decryptedFilePath);
                    FileStream fileStream = fileInfo.Open(FileMode.Open);
                    fileStream.SetLength(Math.Max((long)0, fileInfo.Length - num2));
                    fileStream.Close();
                }
            }
            catch (Exception exception)
            {
            }
        }
コード例 #4
0
 private static void Main(string[] args)
 {
     if (args.Length < 1)
     {
         Console.WriteLine("\r\n[+] Usage:\r\n\t" + Program.selfname + " private.keyxml\r\n");
     }
     else
     {
         if (args.Length == 1)
         {
             Console.WriteLine("\r\n====================================================================");
             Console.WriteLine("\r\n[+] Please be Patient, It May Take Several Minutes or Hours");
             Console.WriteLine("[+] Searching For Affected Files.\r\n[+] Please Wait.");
             Thread.Sleep(3000);
             try
             {
                 Program.privkey = File.ReadAllText(args[0]);
                 Program.go_to_dec();
                 Console.WriteLine("\r\n====================================================================\r\nTry");
                 Program.dec2(Program.bad_dec);
                 Program.mylist.Clear();
                 Program.delete_desktop_helps();
                 Console.WriteLine("\r\n[+] All File Decrypted.");
                 Thread.Sleep(3000);
             }
             catch
             {
             }
         }
         if (args.Length != 3)
         {
             return;
         }
         if (args[0] == "-f")
         {
             Program.privkey = File.ReadAllText(args[1]);
             Program.recursivegetfiles(args[2]);
             if (Program.mylist.Count > 0)
             {
                 try
                 {
                     Program.dec(Program.mylist);
                     // Program.dec(Program.mylist);
                     // Program.dec(Program.mylist);
                     Program.mylist.Clear();
                     Console.WriteLine("\r\n[+] All File Decrypted.");
                     Thread.Sleep(3000);
                 }
                 catch
                 {
                 }
             }
         }
         if (!(args[0] == "-k"))
         {
             return;
         }
         foreach (string file in Directory.GetFiles(args[2]))
         {
             Program.privkey = File.ReadAllText(file);
             try
             {
                 string      s1 = "";
                 string      s2 = "";
                 string      stringFromBytes = Encipher.GetStringFromBytes(Encipher.GetHeaderBytesFromFile(args[1]));
                 XmlDocument xmlDocument     = new XmlDocument();
                 xmlDocument.LoadXml(stringFromBytes);
                 foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAA"))
                 {
                     s1 = xmlNode.InnerText;
                 }
                 foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AA"))
                 {
                     s2 = xmlNode.InnerText;
                 }
                 foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAAAAAAAAAAAAAAAAA"))
                 {
                     Convert.ToInt64(xmlNode.InnerText);
                 }
                 byte[] numArray = Encipher.RSADescryptBytes(Convert.FromBase64String(s1), Program.privkey);
                 Encipher.RSADescryptBytes(Convert.FromBase64String(s2), Program.privkey);
                 if (numArray.Length != 0)
                 {
                     Console.WriteLine("\r\nCORRECT KEY IS:" + file);
                 }
             }
             catch
             {
             }
         }
     }
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: ThePhenom27/sdec4.6.2
        //private static List<string> bad_dec = new List<string>();

        private static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("\r\n[+] Usage:\r\n\t" + Program.selfname + " private.keyxml\r\n");
            }
            else
            {
                if (args.Length == 1)
                {
                    Thread.Sleep(3000);
                    try {
                        Program.privkey = File.ReadAllText(args[0]);
                        foreach (DriveInfo drive in DriveInfo.GetDrives())
                        {
                            try {
                                if (drive.IsReady)
                                {
                                    Program.recursivegetfiles(drive.Name);
                                }
                            } catch { }
                        }
                        Console.WriteLine("\r\n[+] All File Decrypted.");
                        Thread.Sleep(3000);
                    } catch { }
                }
                if (args.Length != 3)
                {
                    return;
                }
                if (args[0] == "-f")
                {
                    Program.privkey = File.ReadAllText(args[1]);
                    Program.recursivegetfiles(args[2]);

                    Console.WriteLine("\r\n[+] All File Decrypted.");
                    Thread.Sleep(3000);
                }
                if (!(args[0] == "-k"))
                {
                    return;
                }
                foreach (string file in Directory.GetFiles(args[2]))
                {
                    Program.privkey = File.ReadAllText(file);
                    try {
                        string      s1 = "";
                        string      s2 = "";
                        string      stringFromBytes = Encipher.GetStringFromBytes(Encipher.GetHeaderBytesFromFile(args[1]));
                        XmlDocument xmlDocument     = new XmlDocument();
                        xmlDocument.LoadXml(stringFromBytes);
                        foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAA"))
                        {
                            s1 = xmlNode.InnerText;
                        }
                        foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AA"))
                        {
                            s2 = xmlNode.InnerText;
                        }
                        foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("AAAAAAAAAAAAAAAAAA"))
                        {
                            Convert.ToInt64(xmlNode.InnerText);
                        }
                        byte[] numArray = Encipher.RSADescryptBytes(Convert.FromBase64String(s1), Program.privkey);
                        Encipher.RSADescryptBytes(Convert.FromBase64String(s2), Program.privkey);
                        if (numArray.Length != 0)
                        {
                            Console.WriteLine("\r\nCORRECT KEY IS:" + file);
                        }
                    } catch { }
                }
            }
        }