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

.NET 

[TUT] Protect your VB.NET file with serial key registration! [VB.NET+PHP]

Alright, so, I didn't really feel like actually putting this source together, so I decided that I'll just make a tutorial on how to make it. Bear with me, it's a simple process. The tutorial might be a little long, but that's just because I've got the habit of rambling on. Anyways!

You're gonna want to create 4 files that are going to be uploaded to a free hosting service (SPAM, BinHoster, etc.). The files are:
  • useserial.php - This is the file that we're going to use when someone uses a serial key.

  • hwid.php - This file is going to log the HWID of the user after they use a serial key.

  • serials.txt - This file will contain a bunch of different serial keys that are valid. These will be the serial keys that you give to your customers or whoever wants to register your software.

  • hwid.txt - This file will be the log of all people who have already registered your software, so they don't have to register their software every time they open it.

  • used.txt - This file will contain all of the already used serial keys, so that they can't be used more than once.



All of that may seem confusing, but once you get all of it put together, it'll make a lot more sense.

So now, we're going to put this code into useserial.php:
PHP Code

<?php
$serial 
= $_GET["serial"];
$fh = fopen("used.txt", 'a');
fwrite($fh, $serial . "\n");
fclose($fh);
?>

This basically takes the serial code that you give it and writes it to used.txt, so that it can't be used again.

Now we're going to put a very similar code into hwid.php:
PHP Code

<?php
$hwid 
= $_GET["id"];
$fh = fopen("hwid.txt", 'a');
fwrite($fh, $hwid . "\n");
fclose($fh);
?>

Alright! Now all you have to do is put all of the different serial keys that you want to use into serials.txt.

So, now you need to upload all of these to your free web hosting service that I mentioned above.

Now it's time to make your application. Make a new project in VB.NET 2008, named whatever. On Form1, make one textbox, one label, and one button.
On Button1's text, make it "Register"
On Label1's text, make it "Status"

Now, go to Project, and then click on Add Reference. Find System.Management, click it, and then click OK.

Now double click on Form1's title bar or somewhere in the background, and the Form's coding should come up. On the very top, above "Public Class Form1", put this code:
Code
Imports System.Management
Imports System.Net

And right under "Public Class Form1", insert this code:
Code
Dim cpuInfo As String 'This is required
Function GetHWID()
Dim mc As New ManagementClass("win32_processor")
Dim moc As ManagementObjectCollection = mc.GetInstances
For Each mo As ManagementObject In moc
If cpuInfo = "" Then
cpuInfo = mo.Properties("processorID").Value.ToString
Exit For
End If
Next
Return cpuInfo
End Function

All of that is how you're going to get the user's HWID. Now, right under "Private Sub Form1_Load..." you need to put this code:
Code
Dim client As WebClient = New WebClient()
Dim registeredhwids As String = client.DownloadString("http://yourfreewebhosting.com/hwid.txt")
If registeredhwids.Contains(GetHWID) Then
Label1.Text = "Software Registered!"
End If

Now, go back to Form1's designer and double-click Button1, the one that says "Register". Put the code:
Code
Dim serial As String = Textbox1.Text
Dim client As WebClient = New WebClient()
Dim usedserials As String = client.DownloadString("http://yourfreewebhosting.com/used.txt")
If usedserials.Contains(serial) Then
Msgbox("Registration failed. This serial key has already been used.")
Return
End If
Dim client1 As WebClient = New WebClient()
Dim serials As String = client.DownloadString("http://yourfreewebhosting.com/serials.txt")
If serials.Contains(serial) = False Then
Msgbox("Registration failed. This serial key is not valid.")
Return
End If
Msgbox("Your software has been registered!")
Dim z as new WebBrowser
z.Navigate("http://yourfreewebhosting.com/useserial.php?serial=" + serial)
Dim d as new WebBrowser
d.Navigate("http://yourfreewebhosting.com/hwid.php?id=" + GetHWID)

Now you can go on ahead and test out your software! I'd try to wrap this thread up better, but I'm in a hurry, and I've already told everyone what I need to tell them.

Leave comments!
This looks very cool! I might even use it in an upcoming project.
Sadly that is easy to get the keys best to use a Database for the keys (-:
Nice tutorial, can be reversed easily though, but overall it looks good(:
Oh, there's no doubt that this can be abused or reversed. I'd suggest for people to use a database for the keys, but this was a lot easier to type out. c:
Can anyone help me? Im using SPAM and i cant find my like serials.txt I uploaded it just cant find the link =/
(Nov 29, 2011 07:04 PM)1700block Wrote:  Can anyone help me? Im using SPAM and i cant find my like serials.txt I uploaded it just cant find the link =/

upload your files to a direct dl link
Very nice share dude I will be using this
can easily be reversed but still a vey nice share.
This is highly insecure and easily patched. I do not suggest this method in a production environment.
[Image: RtaNL.png]
(Nov 29, 2011 09:46 PM)AirKode Wrote:  This is highly insecure and easily patched. I do not suggest this method in a production environment.

Totally agree. Sniffing that URL and its over.
(Nov 29, 2011 11:58 PM)T3chN9n3 Wrote:  Totally agree. Sniffing that URL and its over.

I'd like to personally thank you for necroposting a thread that's been dead for quite a while.

I've already made it clear that it's an inefficient concept of protecting a VB.NET program, however, that simply means that you can just ignore the thread and it's inefficiency and not revive it.

EDIT: Excuse me, no. I didn't look at past posts before yours. Excuse my rudeness.
(Nov 30, 2011 12:41 AM)Funhouse Wrote:  I'd like to personally thank you for necroposting a thread that's been dead for quite a while.

I've already made it clear that it's an inefficient concept of protecting a VB.NET program, however, that simply means that you can just ignore the thread and it's inefficiency and not revive it.

EDIT: Excuse me, no. I didn't look at past posts before yours. Excuse my rudeness.

Yes I didn't revive it sorry for that confusion
i was kinda wondering on how to do that
Thank you for this TUTO !
I love this method !
Thans you ! :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Robert RougeSep 24, 2026 10:02 AM 4 220 Sep 24, 2026 10:02 AM
Last Post: Anonynuk
[Python] by joshuagress12345Mar 12, 2024 08:15 AM 4 323 Mar 12, 2024 08:15 AM
Last Post: Hackers
[C] by murtNov 16, 2020 11:43 AM 0 142 Nov 16, 2020 11:43 AM
Last Post: murt