Post: C# Serial Key Help
08-30-2015, 05:15 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); So im making a program that requires serial keys.
I got it to read the serial keys but i want it so it reads to see if the key is banned.

the txt file has keys in every line but i want it to be like
    EXAMPLE:
key:NotBanned
1337:Banned


This is my code:
    
private void button3_Click(object sender, EventArgs e)
{
if (keyBOX.Text != "")
{
if (isValid(keyBOX.Text))
{
MessageBox.Show("Valid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Invalid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Enter a key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}

}

public bool isValid(string key)
{
if(String.IsNullOrEmpty(key))
{
return false;
}
using (WebClient wb = new WebClient())
{
foreach (string mKey in wb.DownloadString("the txt file").Split('\n'Winky Winky)
if (mKey == key) return true;
return false;
}
}


I hope someone can help me with the ban system Smile

Sincerly, MrMods.
(adsbygoogle = window.adsbygoogle || []).push({});
08-30-2015, 05:16 PM #2
Kam
Investor - Future Millionaire
Originally posted by xMrMods View Post
So im making a program that requires serial keys.
I got it to read the serial keys but i want it so it reads to see if the key is banned.

the txt file has keys in every line but i want it to be like
    EXAMPLE:
key:NotBanned
1337:Banned


This is my code:
    
private void button3_Click(object sender, EventArgs e)
{
if (keyBOX.Text != "")
{
if (isValid(keyBOX.Text))
{
MessageBox.Show("Valid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Invalid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Enter a key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}

}

public bool isValid(string key)
{
if(String.IsNullOrEmpty(key))
{
return false;
}
using (WebClient wb = new WebClient())
{
foreach (string mKey in wb.DownloadString("the txt file").Split('\n'Winky Winky)
if (mKey == key) return true;
return false;
}
}


I hope someone can help me with the ban system Smile

Sincerly, MrMods.


Have you tried using the NetSeal system?
08-30-2015, 05:22 PM #3
Tustin
Balls of Steel
Not really sure what you're trying to do here. You're using webclient to read a local file which isn't necessary at all. You should be using File.ReadAllLines, which returns the contents of a txt file in an array for you to sort through.

For example (excuse any syntax errors):
    
bool check(string key) {
string[] contents = File.ReadAllLines("keys.txt");
foreach(string the_key in contents) {
if (key == the_key)
return true;
}
}



or are you trying to read a text file off your server? if so, let me know.
08-30-2015, 05:22 PM #4
Originally posted by Kilam View Post
Have you tried using the NetSeal system?


NetSeal can be bypassed easily so i have decided not to using it and use my method
08-30-2015, 05:22 PM #5
Originally posted by Tustin View Post
Not really sure what you're trying to do here. You're using webclient to read a local file which isn't necessary at all. You should be using File.ReadAllLines, which returns the contents of a txt file in an array for you to sort through.

For example (excuse any syntax errors):
    
bool check(string key) {
string[] contents = File.ReadAllLines("keys.txt");
foreach(string the_key in contents) {
if (key == the_key)
return true;
}
}



its reading a txt from my server
08-30-2015, 05:26 PM #6
Tustin
Balls of Steel
Originally posted by xMrMods View Post
its reading a txt from my server

Right, I figured that after I posted that reply. Your best bet is NOT to store your keys in plaintext as, well, anyone who can deobfuscate your program can get access to every key.

What I would do is create a database for your site with a users table to store their username, key and whatever else you want. Then instead of reading a text file, make a PHP script that accepts a GET parameter with a key. In that script just check your users table to see if the key exists and if so, return some success message. Security is non-existent here so you'll have to work on that yourself.

As for banning, if you use what I mentioned above, you can just make a column for is_banned or something, and if it's true then you can have another column for ban_message, although this is completely optional. Just make another check before spitting out the success message to check if they're banned. If so, then just output their ban message.
08-30-2015, 05:29 PM #7
Scouse Power
Knowledge is power
Originally posted by xMrMods View Post
its reading a txt from my server


    public bool isValid(string Key)
{
if (String.IsNullOrEmpty(Key)) return false;
using (WebClient wb = new WebClient())
{
foreach (string mKey in wb.DownloadString("yoursite").Split('\n'Winky Winky)
{
string[] mBits = mKey.Split('|'Winky Winky;
if(mBits.Length == 2)
{
MessageBox.Show("Your key is banned, reason: \n" + mBits[1]);
return false;
}
if (mKey == Key) return true;
}
}
return false;
}


text file structure e.g.
    3948239845394
4258934485
23423092
example_key
9234309934|ur not cool.
ridksfjdjfgfd


In this example 9234309934 will be invalid key but will show a message saying he's banned. The reason being "ur not cool""
08-30-2015, 05:34 PM #8
Originally posted by StackOverflow View Post
    public bool isValid(string Key)
{
if (String.IsNullOrEmpty(Key)) return false;
using (WebClient wb = new WebClient())
{
foreach (string mKey in wb.DownloadString("yoursite").Split('\n'Winky Winky)
{
string[] mBits = mKey.Split('|'Winky Winky;
if(mBits.Length == 2)
{
MessageBox.Show("Your key is banned, reason: \n" + mBits[1]);
return false;
}
if (mKey == Key) return true;
}
}
return false;
}


text file structure e.g.
    3948239845394
4258934485
23423092
example_key
9234309934|ur not cool.
ridksfjdjfgfd


In this example 9234309934 will be invalid key but will show a message saying he's banned. The reason being "ur not cool""


Thanks you bro <3
08-30-2015, 05:50 PM #9
Scouse Power
Knowledge is power
Originally posted by xMrMods View Post
Thanks you bro <3


However Tustin has a point. Even if you obfuscate your program, they can easily run a packet sniffer and figure out the page you are requesting which stores all your keys. In your case they are all stored in plain text so you can easily find a valid key. I suggest you look into some form of encryption which can be used in both PHP and C# (for my past program I used rundael). Then I suggest you use a database to validate the keys or use an array and something like in_array to determine if the key is in the array. To add additional security, I suggest you add a time stamp to the encrypted response, and check this on you c# application as well (as anyone with a valid key can just copy the response and in a matter of create a page and rewrite your page to there own in host file).

I may make something and release in elite section later.
08-30-2015, 06:13 PM #10
Originally posted by StackOverflow View Post
However Tustin has a point. Even if you obfuscate your program, they can easily run a packet sniffer and figure out the page you are requesting which stores all your keys. In your case they are all stored in plain text so you can easily find a valid key. I suggest you look into some form of encryption which can be used in both PHP and C# (for my past program I used rundael). Then I suggest you use a database to validate the keys or use an array and something like in_array to determine if the key is in the array. To add additional security, I suggest you add a time stamp to the encrypted response, and check this on you c# application as well (as anyone with a valid key can just copy the response and in a matter of create a page and rewrite your page to there own in host file).

I may make something and release in elite section later.


Theres a bug on it.
When the key is banned it says banned but then it says invalid.

    
private void flatButton3_Click(object sender, EventArgs e)
{
if (keyBOX.Text != "")
{
if (isValid(keyBOX.Text))
{
MessageBox.Show("Valid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Visible = false;
Form1 main = new Form1();
main.Visible = true;
}
else
{
MessageBox.Show("Invalid key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Enter a key!", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public bool isValid(string Key)
{
if (String.IsNullOrEmpty(Key)) return false;
using (WebClient wb = new WebClient())
{
foreach (string mKey in wb.DownloadString("site").Split('\n'Winky Winky)
{
string[] mBits = mKey.Split('|'Winky Winky;
if (mBits.Length == 2)
{
MessageBox.Show("Reason for ban:\n\n" + mBits[1]);
return false;
}
if (mKey == Key) return true;
}
}
return false;
}

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo