Example #1
0
 static void Crack(string cipherText, int keylength, byte[] currentKey)
 {
     if (keylength == currentKey.Length)
     {
         BlowFish b         = new BlowFish(currentKey);
         string   plainText = b.Decrypt_ECB(cipherText);
         if (plainText.StartsWith("Hello"))
         {
             Console.WriteLine("plaintext:" + plainText + ", key:" + BitConverter.ToString(currentKey));
         }
         keyCount++;
         if (keyCount % 10240 == 0)
         {
             TimeSpan elapsed = DateTime.Now.Subtract(start);
             long     keyrate = 0;
             if (elapsed.Seconds > 0)
             {
                 keyrate = (keyCount / elapsed.Seconds);
             }
             Console.WriteLine((keyCount / 1099511627776).ToString() + "%, seconds:" + elapsed.Seconds.ToString() + ", " + keyrate.ToString() + "keys/s ->" + BitConverter.ToString(currentKey));
         }
     }
     else
     {
         byte[] key = new byte[currentKey.Length + 1];
         Array.Copy(currentKey, key, currentKey.Length);
         for (int i = 0; i < 256; i++)
         {
             key[key.Length - 1] = (byte)i;
             Crack(cipherText, keylength, key);
         }
     }
 }
Example #2
0
        public void MineKey()
        {
            string appAsarContent = CleanString(File.ReadAllText(Paths.AppAsarFilePath));
            string pattern        = "pass:\"(.*?)\"}";

            MatchCollection matches = Regex.Matches(appAsarContent, pattern);
            List <string>   l       = new List <string>();

            foreach (Match match in matches)
            {
                Trace.TraceInformation(match.Groups[1].Value);
                l.Add(match.Groups[1].Value);
            }
            if (l.Count > 0)
            {
                _EncryptionPassPhrase = l[0];
            }
            else
            {
                throw new DataException("Passphrase not found");
            }
            BlowFish blowFish = new BlowFish(Encoding.ASCII.GetBytes(_EncryptionPassPhrase));

            byte[] data = Convert.FromBase64String(Paths.Rb6Options.options.Dp);
            //string base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data);
            byte[] out1 = blowFish.Decrypt_ECB(data);
            EncryptionKey = System.Text.ASCIIEncoding.ASCII.GetString(out1);
        }
        public void InitRfpToOmmIv(ReadOnlySpan <byte> iv)
        {
            var rfpIv = InitivRfp.AsSpan().ToArray();

            BlowFish.XorBlock(rfpIv, iv);
            RfpToOmmIv = rfpIv;
        }
        public void InitOmmToRfpIv(ReadOnlySpan <byte> iv)
        {
            var ommIv = InitivOmm.AsSpan().ToArray();

            BlowFish.XorBlock(ommIv, iv);
            OmmToRfpIv = ommIv;
        }
Example #5
0
        public EncryptionRoundWindow(string _plainText, bool _isEncrypt)
        {
            InitializeComponent();
            j         = 0;
            step      = 1;
            isEncrypt = _isEncrypt;
            plainText = _plainText;
            plainTextLabel.Content += _plainText;

            if (_isEncrypt == false)
            {
                i = 17;
                fullPlaintextHex = plainText;
            }
            else
            {
                i = 0;

                var plainTextBinary    = BlowFish.ConvertStringToBinary(plainText);
                var newPlainTextBinary = BlowFish.PadPlainText(plainTextBinary);

                if (newPlainTextBinary != plainTextBinary)
                {
                    plainTextLabel.Content = "Padded Plaintext: " + BlowFish.ConvertBinaryToString(newPlainTextBinary);
                }
                plainTextBinaryLabel.Content += newPlainTextBinary;

                fullPlaintextHex           = BlowFish.ConvertBinaryStringToHexString(newPlainTextBinary);
                plainTextHexLabel.Content += fullPlaintextHex;
            }

            nextHexSection();
        }
Example #6
0
 private string encrypt(string part)
 {
     string hexKey = "04B915BA43FEB5B6";
     BlowFish b = new BlowFish(hexKey);
     string encryptedData = b.Encrypt_CBC(part);
     return encryptedData;
 }
Example #7
0
        protected static void MineKey()
        {
            // Load App.asar and clean/stripe it to better find what we're looking for
            string appAsarContent = Regex.Replace(File.ReadAllText(Rekordbox6Paths.AppAsarFilePath), @"[^\u0000-\u007F]+", string.Empty)
                                    .Replace(" ", string.Empty)
                                    .Replace("\n", string.Empty)
                                    .Replace("\r", string.Empty);;

            string pattern = "pass:\"(.*?)\",?}";

            MatchCollection matches = Regex.Matches(appAsarContent, pattern);
            List <string>   l       = new List <string>();

            foreach (Match match in matches)
            {
                l.Add(match.Groups[1].Value);
            }
            if (l.Count > 0)
            {
                _EncryptionPassPhrase = l[0];
            }
            else
            {
                throw new System.Data.DataException("Passphrase not found");
            }
            BlowFish blowFish = new BlowFish(Encoding.ASCII.GetBytes(_EncryptionPassPhrase));

            byte[] data = Convert.FromBase64String(Rekordbox6Paths.Rb6Options.options.Dp);
            //string base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data);
            byte[] out1 = blowFish.Decrypt_ECB(data);
            EncryptionKey = System.Text.ASCIIEncoding.ASCII.GetString(out1);
        }
Example #8
0
            public string Encrypt(string data, string IV)
            {
                BlowFish fish   = new BlowFish(IV);
                string   result = fish.Encrypt_CBC(data);

                return(result);
            }
        public bool Initialize(Address address, string baseKey)
        {
            _logger.LogCoreInfo("Loading Config.");
            Config = new Config("Settings/GameInfo.json");

            _server = new Host();
            _server.Create(address, 32, 32, 0, 0);

            var key = System.Convert.FromBase64String(baseKey);

            if (key.Length <= 0)
            {
                return(false);
            }

            Blowfish             = new BlowFish(key);
            PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager);
            Map            = new SummonersRift(this);
            PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager);
            ApiFunctionManager.SetGame(this);
            IsRunning = false;

            foreach (var p in Config.Players)
            {
                _playerManager.AddPlayer(p);
            }
            return(true);
        }
Example #10
0
        public static void Initialize()
        {
            m_clients = new Dictionary <uint, LoLClient>();
            if (enet_initialize() < 0)
            {
                throw new Exception("Unable to initialize ENet...");
            }

            var address = new ENetAddress();

            address.host = SERVER_HOST;
            address.port = ConfigurationProvider.Instance.Configuration.ServerPort;

            _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0);

            if (_server == null)
            {
                throw new Exception("Unable to start ENet server...");
            }

            var key = Convert.FromBase64String(SERVER_KEY);

            if (key.Length <= 0)
            {
                throw new Exception("Unable to convert SERVER_KEY...");
            }

            BlowFish = new BlowFish(key);
        }
Example #11
0
 public MainWindow()
 {
     InitializeComponent();
     me           = this;
     areKeysSetup = false;
     blowFish     = new BlowFish();
 }
Example #12
0
        public void Initialize(Address address, string blowfishKey, Config config)
        {
            _logger.LogCoreInfo("Loading Config.");
            Config = config;

            _chatCommandManager.LoadCommands();
            _server = new Host();
            _server.Create(address, 32, 32, 0, 0);

            var key = Convert.FromBase64String(blowfishKey);

            if (key.Length <= 0)
            {
                throw new InvalidKeyException("Invalid blowfish key supplied");
            }

            Blowfish             = new BlowFish(key);
            PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager);

            RegisterMap((byte)Config.GameConfig.Map);

            PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager);
            ApiFunctionManager.SetGame(this);
            IsRunning = false;

            foreach (var p in Config.Players)
            {
                _playerManager.AddPlayer(p);
            }


            _logger.LogCoreInfo("Game is ready.");
        }
Example #13
0
        private static SymmetricAlgorithm CreateCipher(CipherAlgorithm ca, string encryptionKey)
        {
            SymmetricAlgorithm sa = null;

            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(encryptionKey, new byte[]
                                                            { 21, 221, 125, 99, 18, 200, 181, 116, 158, 30, 180, 73, 108 });

            switch (ca)
            {
            case CipherAlgorithm.AES128:
                sa = Aes.Create();
                break;

            case CipherAlgorithm.AES256:
                sa = Aes.Create();
                break;

            case CipherAlgorithm.TwoFish128:
                sa = new Twofish();
                break;

            case CipherAlgorithm.BlowFish256:
                sa = new BlowFish();
                break;

            case CipherAlgorithm.Serpent128:
                sa = new SerpentEngine();
                break;
            }

            sa.Key = pdb.GetBytes(sa.KeySize / 8);
            sa.IV  = pdb.GetBytes(sa.BlockSize / 8);

            return(sa);
        }
Example #14
0
        public async Task CanDecryptAxiPassword()
        {
            using (var reader = new OmmConfReader("omm_conf.txt"))
            {
                var user = await reader.GetValueAsync("XAC", "name", "axi", CancellationToken.None);

                var passwd  = user["passwd"];
                var bf_key  = new byte[] { 0x09, 0x6B, 0xA9, 0x87, 0x98, 0x90, 0xB6, 0x7A, 0x18, 0x93, 0xE3, 0x97, 0xB9, 0x77, 0xF3, };
                var bf      = new BlowFish(bf_key);
                var crypted = HexEncoding.HexToByte(passwd);

                HexEncoding.SwapEndianess(crypted);

                var plain = bf.Decrypt_ECB(crypted);

                HexEncoding.SwapEndianess(plain.Span);


                var eos = plain.Span.IndexOf((byte)0);
                if (eos >= 0)
                {
                    passwd = Encoding.UTF8.GetString(plain.Slice(0, eos).Span);
                }

                _output.WriteLine(plain.ToHex());
                Assert.Equal("axi", passwd);
            }
        }
Example #15
0
    public void BlowfishDTest()
    {
        string   result   = "";
        BlowFish blowFish = new BlowFish(key);

        result = blowFish.Decrypt(d);
        Debug.Log(result);
    }
Example #16
0
 internal BlowFish MakeBlowFish()
 {
     if (_fish == null)
     {
         _fish = new BlowFish(_key);
     }
     return(_fish);
 }
Example #17
0
        /**
         * ENS ENCRIPTA LA CONTRASSENYA BĂ€SICA D'UN ADMINISTRADOR
         **/
        public static String encriptarContrassenyaAdmins()
        {
            BlowFish b = new BlowFish("04B915BA43FEB5B6");
            String   c = b.Encrypt_CBC("administrador");


            return(c);
        }
Example #18
0
 public BlowFish GetCrypt(string key)
 {
     if (crypts.TryGetValue(key, out BlowFish fish) == false)
     {
         fish = new BlowFish(key);
         crypts.Add(key, fish);
     }
     return(fish);
 }
Example #19
0
        private byte[] Decrypt(byte[] data)
        {
            string   kh  = "0000011100fa00010034ba2145000032";
            BlowFish bfd = new BlowFish(kh);

            bfd.IV = this.IV;

            return(bfd.DecryptCBC(data));
        }
Example #20
0
 public DummyGame()
 {
     _blowfish             = new BlowFish(Encoding.Default.GetBytes("UnitTests stinks"));
     _packetHandlerManager = new PacketHandlerManager(this);
     _map            = new Map(this, 1, 1, 1, true, 1);
     _packetNotifier = new PacketNotifier(this);
     _server         = new Host();
     _server.Create(12345, 123);
 }
Example #21
0
        void openProject_FileOk(object sender, CancelEventArgs e)
        {
            byte[]   data = File.ReadAllBytes(openProject.FileName);
            BlowFish bf   = new BlowFish("C3Y14AD5955928NC");

            data = bf.Decrypt_ECB(data);

            MessageBox.Show(ASCIIEncoding.ASCII.GetString(data));
        }
Example #22
0
        public static void Encrypt(object sender, EventArgs e)
        {
            var tsi = sender as ToolStripMenuItem;

            if (!Shared.PrepareFiles("Open a decrypted " + tsi?.Tag + " file...", "Save your encrypted file...", ".dec", out var openFile, out var saveFile, true))
            {
                return;
            }

            try
            {
                using (var openFs = new BinaryReaderX(openFile))
                    using (var outFs = new BinaryWriterX(saveFile))
                        switch (tsi?.Tag)
                        {
                        case Types.BlowFishCBC:
                            var key = InputBox.Show("Input encryption key:", "Encrypt Blowfish");

                            if (key == String.Empty)
                            {
                                throw new Exception("Key can't be empty!");
                            }
                            var bf = new BlowFish(key);
                            outFs.Write(bf.Encrypt_CBC(openFs.ReadAllBytes()));
                            break;

                        case Types.BlowFishECB:
                            key = InputBox.Show("Input encryption key:", "Encrypt Blowfish");

                            if (key == String.Empty)
                            {
                                throw new Exception("Key can't be empty!");
                            }
                            bf = new BlowFish(key);
                            outFs.Write(bf.Encrypt_ECB(openFs.ReadAllBytes()));
                            break;

                        case Types.MTMobile:
                            var key1 = InputBox.Show("Input 1st encryption key:", "Encrypt MTMobile");
                            var key2 = InputBox.Show("Input 2nd encryption key:", "Encrypt MTMobile");

                            if (key1 == String.Empty || key2 == String.Empty)
                            {
                                throw new Exception("Keys can't be empty!");
                            }
                            outFs.Write(MTFramework.Encrypt(openFs.BaseStream, key1, key2));
                            break;
                        }

                MessageBox.Show($"Successfully encrypted {Path.GetFileName(openFile.Name)}.", tsi.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), tsi?.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                File.Delete(saveFile.Name);
            }
        }
Example #23
0
        private byte[] Encrypt(byte[] data)
        {
            string   kh  = "0000011100fa00010034ba2145000032";
            BlowFish bfc = new BlowFish(kh);

            this.IV = bfc.SetRandomIV();


            return(bfc.EncryptCBC(data));
        }
        public PacketHandlerManager(Logger logger, BlowFish blowfish, Host server, PlayerManager playerManager)
        {
            _logger          = logger;
            _blowfish        = blowfish;
            _server          = server;
            _playerManager   = playerManager;
            _teamsEnumerator = Enum.GetValues(typeof(TeamId)).Cast <TeamId>().ToList();

            InitHandlers();
        }
    static void Main(string[] args)
    {
        BlowFish b          = new BlowFish("12345678abcdefgmypassword");
        string   plainText  = "ABCDEFG12345678";
        string   cipherText = b.Encrypt_CBC(plainText);

        MessageBox.Show(cipherText);
        plainText = b.Decrypt_CBC(cipherText);
        byte[] myByteArray = HexToByte(cipherText);
        MessageBox.Show(plainText);
    }
Example #26
0
        public static string Decrypt()
        {
            Console.WriteLine("Input key (up to 28 char):");
            string key = KeyParse();

            Console.WriteLine("Input string to decrypt:");
            string chipherText = Console.ReadLine();

            BlowFishCS.BlowFish b = new BlowFish(key);
            return(b.Decrypt_CBC(chipherText));
        }
Example #27
0
        public void Initialize(Address address, string blowfishKey, Config config)
        {
            _logger.LogCoreInfo("Loading Config.");
            Config = config;

            _gameScriptTimers = new List <GameScriptTimer>();

            _chatCommandManager.LoadCommands();
            _server = new Host();
            _server.Create(address, 32, 32, 0, 0);

            var key = Convert.FromBase64String(blowfishKey);

            if (key.Length <= 0)
            {
                throw new InvalidKeyException("Invalid blowfish key supplied");
            }

            Blowfish             = new BlowFish(key);
            PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager,
                                                            _packetHandlerProvider);


            ObjectManager = new ObjectManager(this);
            Map           = new Map(this);

            PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager);
            ApiFunctionManager.SetGame(this);
            ApiEventManager.SetGame(this);
            IsRunning           = false;
            disconnectedPlayers = 0;

            _logger.LogCoreInfo("Loading C# Scripts");

            LoadScripts();

            Map.Init();

            foreach (var p in Config.Players)
            {
                _playerManager.AddPlayer(p);
            }

            _pauseTimer = new Timer
            {
                AutoReset = true,
                Enabled   = false,
                Interval  = 1000
            };
            _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--;
            PauseTimeLeft        = 30 * 60; // 30 minutes

            _logger.LogCoreInfo("Game is ready.");
        }
Example #28
0
        public static string Encrypt()
        {
            Console.WriteLine("Input key (up to 28 char):");
            string key = KeyParse();

            Console.WriteLine("Input string to encrypt:");
            string   plainText = Console.ReadLine();
            BlowFish b         = new BlowFish(key);

            return(b.Encrypt_CBC(plainText));
        }
        public IActionResult Get()
        {
            BlowFish      blowFish      = new BlowFish("@dm1n1z7r@t0r!!!");
            EncryptResult encryptResult = new EncryptResult();

            encryptResult.serverName = blowFish.Encrypt_CBC("localhost");
            encryptResult.dbName     = blowFish.Encrypt_CBC("DatingApp");
            encryptResult.userName   = blowFish.Encrypt_CBC("sa");
            encryptResult.password   = blowFish.Encrypt_CBC("password1");

            return(Ok(encryptResult));
        }
Example #30
0
        public bool Initialize(Address address, string baseKey)
        {
            Logger.LogCoreInfo("Loading Config.");
            Config = new Config("Settings/GameInfo.json");

            ItemManager    = ItemManager.LoadItems(this);
            ChatboxManager = new ChatboxManager(this);

            _server = new Host();
            _server.Create(address, 32, 32, 0, 0);

            var key = System.Convert.FromBase64String(baseKey);

            if (key.Length <= 0)
            {
                return(false);
            }

            Blowfish             = new BlowFish(key);
            PacketHandlerManager = new PacketHandlerManager(this);
            _map           = new SummonersRift(this);
            PacketNotifier = new PacketNotifier(this);
            ApiFunctionManager.SetGame(this);

            var id = 1;

            foreach (var p in Config.Players)
            {
                var player = new ClientInfo(p.Value.Rank, ((p.Value.Team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.Ribbon, p.Value.Icon);

                player.SetName(p.Value.Name);

                player.SetSkinNo(p.Value.Skin);
                player.UserId = id; // same as StartClient.bat
                id++;

                player.SetSummoners(StrToId(p.Value.Summoner1), StrToId(p.Value.Summoner2));

                var c   = new Champion(this, p.Value.Champion, GetNewNetID(), (uint)player.UserId);
                var pos = c.getRespawnPosition();

                c.setPosition(pos.Item1, pos.Item2);
                c.setTeam((p.Value.Team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE);
                c.LevelUp();

                player.SetChampion(c);
                var pair = new Pair <uint, ClientInfo>();
                pair.Item2 = player;
                _players.Add(pair);
            }
            return(true);
        }
Example #31
0
        public static Boolean desencriptarContrassenya(String contrassenya, String contrassenyaComparar)
        {
            Boolean  verdader = false;
            BlowFish b        = new BlowFish("04B915BA43FEB5B6");
            String   c        = b.Decrypt_CBC(contrassenya);

            if (c.Equals(contrassenyaComparar))
            {
                verdader = true;
            }

            return(verdader);
        }
Example #32
0
        /// <summary>
        /// Prepares the server to start
        /// </summary>
        /// <param name="ipEndPoint">Server ip and port</param>
        /// <param name="serverKey">The server key to join</param>
        /// <param name="teamBluePlayers">The players on the blue team</param>
        /// <param name="teamRedPlayers">The players on the red team</param>
        public GameInitializer(IPEndPoint ipEndPoint, string serverKey, List<PlayerInitJson> teamBluePlayers, List<PlayerInitJson> teamRedPlayers)
        {
            //Load team players in
            _bluePlayers = teamBluePlayers;
            _redPlayers = teamRedPlayers;

            //Stop the program from closing
            Console.CancelKeyPress += ConsoleOnCancelKeyPress;

            //Add the users to the database
            foreach (var basicPlayer in teamBluePlayers)
            {
                GlobalData.TeamOnePlayers.Add(new Player
                {
                    //Load champion id
                    ChampId = basicPlayer.ChampId,

                    //Load champion data
                    PlayerChamp = new PlayerChamp
                    {
                        BaseChamp = BaseChamp.GetFromId(basicPlayer.ChampId)
                    },

                    //Load player username
                    Username = basicPlayer.Username,

                    //Load player user id
                    UserId = basicPlayer.UserId
                });
            }

            //Add the users to the database
            foreach (var basicPlayer in teamRedPlayers)
            {
                GlobalData.TeamOnePlayers.Add(new Player
                {
                    //Load champion id
                    ChampId = basicPlayer.ChampId,

                    //Load champion data
                    PlayerChamp = new PlayerChamp
                    {
                        BaseChamp = BaseChamp.GetFromId(basicPlayer.ChampId)
                    },

                    //Load player username
                    Username = basicPlayer.Username,

                    //Load player user id
                    UserId = basicPlayer.UserId
                });
            }

            //Create the server
            Server = new UdpClient(ipEndPoint);

            //Create the key
            var key = Convert.ToBase64String(Encoding.ASCII.GetBytes(serverKey));
            if (key.Length <= 0){

                //Tells that server is not accepting connections
                Initialized = false;

                //Close the server
                Server.Close();
                return;
            }
            //Server can be allowed to accept connections
            Initialized = true;

            //Because why not
            Server.EnableBroadcast = true;

            //Load encryption
            BlowFish = new BlowFish(Encoding.ASCII.GetBytes(key));
        }