Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[C#]HWID System With Online/Offline Protection

Hi,

Some of this code is from other people and I've just compiled it together and changed to C# as well as adding online/offline protection. There's two ways to doing this. You will need to host a database.txt file on a website which contains the valid HWID's.

First one :

Step : 1

This is to retrieve the HWID of the computer and paste it into a textBox.(button1_Click) Paste it inside the { and the } when you double click the Get HWID button.

Code
string cpuInfo = string.Empty;
    ManagementClass mc = new ManagementClass("win32_processor");
    ManagementObjectCollection moc = mc.GetInstances();

    foreach (ManagementObject mo in moc)
    {
    if (string.IsNullOrEmpty(cpuInfo))
    {
    cpuInfo = mo["ProcessorID"].ToString();
    break;
    }

    }
    textBox1.Text = cpuInfo;

Step : 2

This is to retrieve the list of HWID's from your database.txt file and check it to the current computers.(button2_Click) Paste it inside the { and the } when you double click the Check/Login button.

Code
try
    {
    string cpuInfo = string.Empty;
    WebClient webClient = new WebClient();
    string strings = null;
    strings = webClient.DownloadString("http://website.com/Database.txt");
    webClient.Dispose();

     if (strings.Contains(cpuInfo))
    {

     // If the HWID is in the file then it will return this.    MessageBox.Show("HWID Valid", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Hide();
    Form1 frm1 = new Form1();
    frm1.ShowDialog();
     }
    else
    {
     // If the HWID isn't in the file then it will return this.
    MessageBox.Show("HWID Invalid", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Close();
    }
    }
    catch (Exception)
    {
    // If not connected to the internet or can't connect to the site then it will return this.
    MessageBox.Show("Unable To Retrieve HWID", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Close();
    }


Second One :


Step : 1


This is to retrieve the HWID of the computer and paste it into a textBox.(button1_Click) Paste it inside the { and the } when you double click the Get HWID button.

Code
string cpuInfo = string.Empty;
    ManagementClass mc = new ManagementClass("win32_processor");
    ManagementObjectCollection moc = mc.GetInstances();

    foreach (ManagementObject mo in moc)
    {
    if (string.IsNullOrEmpty(cpuInfo))
    {
    cpuInfo = mo["ProcessorID"].ToString();
    break;
    }

    }
    textBox1.Text = cpuInfo;

Step : 2

This will handle the checking of if you are connected to the internet.

Code
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;

public static bool isConnectedToTheInternet( )
{

    int Desc ;
    return InternetGetConnectedState( out Desc, 0 ) ;

}


Step : 3


This is to retreive the list of HWID's from your database.txt file and chek it to the current computers.(button2_Click) Paste it inside the { and the } when you double click the Check/Login button.

Code
if (!isConnectedToTheInternet()) //Checks if it isn't connected to internet
    {
    MessageBox.Show("Unable To Retrieve HWID", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Dispose();
    } else
    { //Downloads the database.txt file.
    string cpuInfo = string.Empty;
    WebClient webClient = new WebClient();
    string strings = null;
    strings = webClient.DownloadString("http://website.com/Database.txt");
     webClient.Dispose();

    if (strings.Contains(cpuInfo))//If it contains the HWID in the database.txt file.
    {
    MessageBox.Show("HWID Valid", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Hide();
    Form1 frm1 = new Form1();
    frm1.ShowDialog();
    }
    if (!strings.Contains(cpuInfo))//If it doesn't contain the HWID in the database.txt file.(Could use else method)
    {
    {
    MessageBox.Show("HWID Invalid", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Dispose();
    }
    }

    }
  }

That's it, I recommend the first one for beginners or novice users and second for more experienced users as you have more control.

Enjoy!
I got flamed when i posted it in vb.net...
It's posted alot of time..
But this is C#, hope u not get flamed..
Nice work ;D
(Nov 7, 2010 02:03 AM)xCocaine Wrote:  I got flamed when i posted it in vb.net...
It's posted alot of time..
But this is C#, hope u not get flamed..
Nice work ;D

Thanks although i haven't seen it at all in C# with online/offline protection. People shouldn't flame and be grateful for the contribution as it may help some people.
Updated this, I forgot to add the public static bool isConnectedToTheInternet( )
it doesen't work, doesen't catch if its not in the txt file
Also, this method is very simple to bypass.
Oh god why. This thread is almost 3 years old. The protection sucks, please let this thread die.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by evikingOct 4, 2022 11:57 PM 0 201 Oct 4, 2022 11:57 PM
Last Post: eviking
[.NET] by SIM-4967739Aug 20, 2022 11:46 AM 5 315 Aug 20, 2022 11:46 AM
Last Post: bullets
[.NET] by xZalurexJan 6, 2021 04:58 PM 5 368 Jan 6, 2021 04:58 PM
Last Post: xZalurex