Page 2 of 2

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 11 Aug 2013, 14:05
by joppiesaus
Progress on 0.3:
Code: Select all
v 0.3
- Code fixes. Instead of adding a new line in every function, just add a new line in the command function.
- Improved set system, less code and more efficient.
- You can now start a process directly from a path(C:\ for example);
- Added a new command THROW (pretty useless)
* throw [Exception] - Throws an exception
- Added a new command GAME
* game <game> - plays a game
* if you play fourinarow, you type exit as a row, it will exit.
- Bug with a set argument fixed

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 12 Aug 2013, 09:19
by Conor
Here is something else.

It allows you to encrypt and decrypt messages using a password.

/encrypt [password] [message]
/decrypt [password] [message]

The command method is an example, I'm not sure how you are going to code it exactly into your source, but there is an example of how the if statement will work.

The other methods are used to operate the command.

Code: Select all
       private void command(string message)
        {
            if (message.IndexOf('/') == 0)
            {
                message = message.Substring(1).TrimStart();

                if (message.Contains(" ") && message.Split(' ').Length >= 2)
                {
                    if (message.Split(' ')[0].ToLower() == "encrypt")
                    {
                        onEncrypt(message.Split(' ')[1], message.Split(new char[] { ' ' }, 3)[2]);
                    }
                    else if (message.Split(' ')[0].ToLower() == "decrypt")
                    {
                        // Can just use Split[2] here as encrypted strings do not have any spaces within them
                        onDecrypt(message.Split(' ')[1], message.Split(' ')[2]);
                    }
                }

            }
            command(Console.ReadLine());
        }

        private void onEncrypt(string code, string toEncrypt)
        {
            string Encrypted = Encrypt(toEncrypt, code);
            Console.WriteLine("Encrypted message: ");
            Console.WriteLine(Encrypted);
            Clipboard.SetText(Encrypted);
            Console.WriteLine("This message has been copied to your clipboard.");
        }

        private void onDecrypt(string code, string toDecrypt)
        {
            string Decrypted = Decrypt(toDecrypt, code);
            Console.WriteLine("Decrypted message: ");
            Console.WriteLine(Decrypted);
        }

        // If you change this, byte[] array must be >= 8
        private readonly byte[] _salt = Encoding.ASCII.GetBytes("Conor12345:D");

        private string Encrypt(string toEncrypt, string EncryptionCode)
        {
            try
            {
                string toReturn = null;
                RijndaelManaged aesAlg = null;

                try
                {
                    Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(EncryptionCode, _salt);

                    aesAlg = new RijndaelManaged();
                    aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);
                    aesAlg.IV = key.GetBytes(aesAlg.BlockSize / 8);

                    ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);

                    using (MemoryStream msEncrypt = new MemoryStream())
                    {
                        using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                        {
                            using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                            {
                                swEncrypt.Write(toEncrypt);
                            }
                        }
                        toReturn = Convert.ToBase64String(msEncrypt.ToArray());
                    }
                }
                finally
                {
                    if (aesAlg != null)
                    {
                        aesAlg.Clear();
                    }
                }
                return toReturn;
            }
            catch { return "Error"; }
        }

        private string Decrypt(string toDecrypt, string EncryptionCode)
        {
            try
            {
                RijndaelManaged aesAlg = null;
                string DecryptedString = null;

                try
                {
                    Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(EncryptionCode, _salt);

                    aesAlg = new RijndaelManaged();
                    aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);
                    aesAlg.IV = key.GetBytes(aesAlg.BlockSize / 8);

                    ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);

                    byte[] bytes = Convert.FromBase64String(toDecrypt);
                    using (MemoryStream msDecrypt = new MemoryStream(bytes))
                    {
                        using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                        {
                            using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                            {
                                DecryptedString = srDecrypt.ReadToEnd();
                            }
                        }
                    }
                }
                finally
                {
                    if (aesAlg != null)
                    {
                        aesAlg.Clear();
                    }
                }
                return DecryptedString;
            }
            catch { return "Error"; }
        }


Dependable references:
Code: Select all
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;


In case you can't figure out why System.Windows.Forms won't appear; a console application does not automatically add a reference to System.Windows.Forms.dll, right-click your project in Solution Explorer and select Add reference, and then find System.Windows.Forms and add it.

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 12 Aug 2013, 09:27
by joppiesaus
Conor wrote:ninja'd

Wow! This is something cool! Thank you!
I am going to use it in some way.
But why do you need
Code: Select all
System.Windows.Forms
?

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 12 Aug 2013, 17:31
by Conor
joppiesaus wrote:
Conor wrote:ninja'd

Wow! This is something cool! Thank you!
I am going to use it in some way.
But why do you need
Code: Select all
System.Windows.Forms
?


For the one usage of the Clipboard class.

You can put it directly into the code instead, if you'd prefer.
Code: Select all
System.Windows.Forms.Clipboard.SetText(Encrypted);

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 22 Aug 2013, 13:45
by joppiesaus
I am planning to liquidate this project due to lack of interest(And also my interest).
It was nice as long as it took. I thank Conor for all his code.

And the release of 0.3:
Code: Select all
v 0.3   -     14:40 22-8-2013
- Code fixes. Instead of adding a new line in every function, just add a new line in the command function.
- Improved set system, less code and more efficient.
- You can now start a process directly from a path(C:\ for example);
- Added a new command THROW (pretty useless)
* throw [Exception] - Throws an exception
- Added a new command GAME
* game <game> - plays a game
* if you play fourinarow, you type exit as a row, it will exit.
- Bug with a set argument fixed


Source code:
CyberCriminal Source 0_3.zip
CyberCriminal Source code v 0.3
(12.67 KiB) Downloaded 39 times


Executable:
CyberCriminal.zip
CyberCriminal Executable v 0.3
(10.31 KiB) Downloaded 45 times



CyberCriminal will be liquidated in two weeks unless there will be more interest in this project.

Thank you all.

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 24 Aug 2013, 01:07
by lucasds12
Incredible program, you have grew so much since you joined here, you used to be a coder that has to learn code from other users', in public, you generated such finery in code this year, your work is outstanding, we are all very proud to have you here Yoppie.
-Lucas

Re: CyberCriminal - A C# project where you can be a part of

PostPosted: 02 Oct 2013, 17:46
by _Retaliate_
So...this was liquidated? :( sad.