locked
C# Issues / Questions RRS feed

  • Question

  • So i'm having an issue, with C#. I'm new and only started coding GUI programs. I like to prank my friends. So i had an idea to create a Jigsaw virus that is no armful.
    All it does it "encrypt" ;) the user desktop files and then asks for password to decrypt them. Its hidden into a binary key.
    So you need to put the password into a textbox which needs to check if its the password (JigsawHasWon)
    Though i have got the code to check but it doesn't work it says 
    "CS0642  Possible mistaken empty statement" when not...
    Here's the code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;


    namespace Alien_Ransomware_V1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void button3_Click(object sender, EventArgs e)
            {
                MessageBox.Show("I love binaries....they are cool."); // hint button.
            }


            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if(textBox1.Text == ("JigsawHasWon")) ;
                {
                    MessageBox.Show("Good job, you got the password!");
                    Console.WriteLine("Decrypting files...")
                    <Decrypt function which i'm asking after>
                }
            }
        }
    }




    As you see there is the if statement and it doesn't detect the condition.
    I'm coding into Bash on linux so i know how a bit other languages works. And == means equals a string = means bools so numbers. So like what am i doing wrong?


    2. Question
    Anyone know how to encrypt file making it unreadable just for desktop file and how to get all the files in desktop and then decrypt them?
    Encrypt: AES-256 // if possible thanks you
    Of course this "virus" is not to be malicious but be a prank of course its why it will only encrypt the desktop files not system32 etc..


    Please someone help me!
    Lots of love!
    Friday, June 22, 2018 1:20 AM

All replies

  • You can fix the "if" statement by removing the semi-colon at the end of the line. The executed part of an "if" can either be in parentheses or up to a semi-colon, but not both.

    if(something)
       DoSomething(); // One line after the "if", terminated by a semi-colon is okay (and just one line, not more).
    
    
    if(something) DoSomething(); // Or it could be on the same line.
    
    
    if(something)
    {
       DoSomething(); // Or we can use braces.
    }
    
    
    if(something)
    {
       DoSomething();
       DoSomethingElse(); // We must use braces for more than one line.
    }

    But I'm not going to tell you how to do the encryption, and I hope nobody on this blog will help you. Viruses aren't funny, even if they're just meant to be pranks. They are malicious code, and you shouldn't be trying to write one.
    Friday, June 22, 2018 2:38 AM
  • Thanks and yes i totally understand about encryption its just that i work into cyber-security etc and i though of doing little pranks like that and also make programs that can SECURELY encrypt a file etc 

    I feel i'm gonna to have trouble learning that but thanks anyways!

    And sorry like i said i'm new to C# so i don't have a f*cking idea of what is a semi-colon thingy sorry...

    So can you please like take the part of my if code and replace on how it should be to fix it? Thanks you!!

    Between i probably wont do encryption but only rename the file into .jigsaw extension... which is better right? Not malicious?

    Friday, June 22, 2018 2:44 AM
  • Oh sh*t the second one 

    if(something) DoSomething(); // Or it could be on the same line.
    

    Works BUT! when i hit enter nothing happens only a error sound in the background? Any ideas i think i know i need to code the part where it takes what the user has put right? then check or something?

    Sorry for all my questions i wanted to get in C# for a long time now but i'm a bit lost..

    Friday, June 22, 2018 2:49 AM
  •            if(textBox1.Text == ("JigsawHasWon")) // No semi-colon here.
                {
                    MessageBox.Show("Good job, you got the password!");
                    Console.WriteLine("Decrypting files...")
                    <Decrypt function which i'm asking after>
                }

    Friday, June 22, 2018 3:12 AM
  • Sorry.... it works but the console isn't opening.... is C# unstable or me being bad? XD
    Friday, June 22, 2018 3:18 AM
  • The Console class only works for console applications. You can't use it in a Windows Forms application. That is, you can use windows or you can use a console, but not both.

    At least, as far as I know. There may be a way to open a console in a WinForms app, but I have never done it.

    Friday, June 22, 2018 3:41 AM
  • Oh ok thanks ;D i had a look at AES encryption since now i moved on the virus since its malicious as you said i wanted to do a software that encrypts and decrypts any AES-256 encrypted file... though i had a look at the code AND BRUH i don't understand a single thing... C# is scaring me.
    Friday, June 22, 2018 4:56 AM
  • I'm afraid your post is in violation of the T&Cs of the MSDN forums. Questions related to the creation of viruses (funny or not), malware (friends or not) and other malicious software is forbidden in these forums.


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, June 22, 2018 1:58 PM
    Moderator