473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

hack that key validation.

I've got a homework to do for a next week, and cannot pass it.
I had to create key which pass the validation for name
"sample.domain.com".
Any idea to simple reverse it ?

Here is a code:
########################
Imports System
Imports System.Collections
Imports System.Net
Imports System.Text
Namespace WebCon.WebParts.ColorCalendar
Friend Class CodeValidate
' Methods
Public Sub New(ByVal code As String)
Me.key = code
End Sub
Private Function CheckDate(ByVal data As String, ByVal s_sign
As Char) As Boolean
Dim str As String = ""
Dim flag As Boolean = False
data = Me.ConvertIc_Replace(data)
Dim bytes As Byte() = Encoding.ASCII.GetBytes(data)
Dim przesuwacz As Integer = s_sign
Dim i As Integer
For i = 0 To 4 - 1
Dim str2 As String =
Convert.ToString(Me.GetModulo(Convert.ToChar(bytes (i)), przesuwacz))
If (str2 = "15") Then
Me.isTrial = False
flag = False
Exit For
End If
Select Case i
Case 0
If (str2 = "-1") Then
flag = True
goto Label_011F
End If
If (str2.Length >= 2) Then
str = (str & "20" & str2 & "-")
Else
str = (str & "200" & str2 & "-")
End If
Exit Select
Case 1
If (str2 = "-1") Then
flag = True
goto Label_011F
End If
If (str2.Length >= 2) Then
str = (str & str2 & "-")
Else
str = (str & "0" & str2 & "-")
End If
Exit Select
End Select
If (i 1) Then
If (str2 = "-1") Then
flag = True
Exit For
End If
str = (str & str2)
End If
Next i
Label_011F:
If (Me.isTrial AndAlso Not flag) Then
Me.trialTime = Convert.ToDateTime(str)
End If
Return flag
End Function
Private Function CheckMiszung(ByVal kodProduktu As String,
ByVal domena As String, ByVal stala As String, ByVal key As String,
ByVal s_sign As Char) As Boolean
Dim flag As Boolean = False
domena = (domena & Convert.ToString(s_sign))
stala = (stala & Convert.ToString(s_sign))
kodProduktu = (kodProduktu & Convert.ToString(s_sign))
Dim replaceKey As String = New Md5((domena & stala &
kodProduktu)).getMd5
replaceKey = Me.ic_Replace(replaceKey).Substring(10, 3)
If ((Convert.ToChar(Encoding.ASCII.GetBytes(key)
(0)).ToString & replaceKey.ToUpper) = key) Then
flag = True
End If
Return flag
End Function
Private Function CompareMd5Modules(ByVal group As String,
ByVal stringToMd5 As String, ByVal s_sign As Char, ByVal lastModule
As
Boolean) As Boolean
stringToMd5 = (stringToMd5 & Convert.ToString(s_sign))
Dim replaceKey As String = New Md5(stringToMd5).getMd5
replaceKey = Me.ic_Replace(replaceKey)
If Not lastModule Then
replaceKey = replaceKey.Substring(1, 4)
Else
replaceKey = (replaceKey.Substring(1, 3) &
Convert.ToString(s_sign))
End If
Return (group = replaceKey)
End Function
Private Function ConvertIc_Replace(ByVal replaceKey As
String)
As String
replaceKey = replaceKey.Replace("Z", "0")
replaceKey = replaceKey.Replace("K", "1")
replaceKey = replaceKey.Replace("T", "6")
Return replaceKey.ToUpper
End Function
Private Function CreateKey(ByVal ch As Char, ByVal domena As
String, ByVal stala As String, ByVal kodProduktu As String, ByVal
group As String()) As Boolean
Dim flag As Boolean = True
If Not Me.ValidateDomainName(group(1), ch) Then
Me.ErrorCode = String.Format("Invalid domain name.
{0}, {1}", domena, Me.key)
Return False
End If
If Not Me.CompareMd5Modules(group(2), kodProduktu, ch,
False) Then
Me.ErrorCode = String.Format("Invalid product code.
{0}, {1}", Me.validateDomainName, Me.key)
Return False
End If
If Not Me.CompareMd5Modules(group(4), stala, ch, True)
Then
Me.ErrorCode = String.Format("Invalid special
character. {0}, {1}", Me.validateDomainName, Me.key)
Return False
End If
If Me.CheckDate(group(3), ch) Then
Me.ErrorCode = String.Format("Invalid date. {0},
{1}",
Me.validateDomainName, Me.key)
Return False
End If
If Me.isTrial Then
Dim trialTime As DateTime = Me.trialTime
Dim span As TimeSpan = DirectCast((DateTime.Today -
trialTime), TimeSpan)
If (span.Days 0) Then
Me.ErrorCode = String.Format("Your trial version
has expired {0} days ago, to buy full version", span.Days)
Return False
End If
Return flag
End If
If Not Me.CheckMiszung(kodProduktu,
Me.validateDomainName,
"COMPANYNAME", group(3), ch) Then
Me.ErrorCode = String.Format("Invalid special
characters. {0}, {1}", domena, Me.key)
Return False
End If
Return flag
End Function
Private Function GetDomainName() As String
Return Dns.GetHostEntry("LocalHost").HostName
End Function
Private Function GetModulo(ByVal [mod] As Char, ByVal
przesuwacz As Integer) As Integer
Dim num As Integer = Convert.ToInt32([mod].ToString,
&H10)
Dim chArray As Char() = New Char() { "0"c, "1"c, "2"c,
"3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "A"c, "B"c, "C"c, "D"c,
"E"c, "F"c }
Dim i As Integer
For i = 0 To &H10 - 1
Dim newAsciiNumber As Integer =
Me.GetNewAsciiNumber(chArray(i))
If (newAsciiNumber = -1) Then
newAsciiNumber = chArray(i)
End If
If (((newAsciiNumber + przesuwacz) Mod &H10) = num)
Then
Return i
End If
Next i
Return -1
End Function
Private Function GetNewAsciiNumber(ByVal ascii As Char) As
Integer
Select Case ascii
Case "A"c
Return &H3A
Case "B"c
Return &H3B
Case "C"c
Return 60
Case "D"c
Return &H3D
Case "E"c
Return &H3E
Case "F"c
Return &H3F
End Select
Return -1
End Function
Private Function ic_Replace(ByVal replaceKey As String) As
String
replaceKey = replaceKey.Replace("0", "Z")
replaceKey = replaceKey.Replace("1", "K")
replaceKey = replaceKey.Replace("6", "T")
Dim userDomainName As String = Environment.UserDomainName
Return replaceKey.ToUpper
End Function
Public Function IsKeyValidated() As Boolean
Dim flag As Boolean = True
Try
Me.groupKey(0) = Me.key.Split(New Char() { "-"c })(0)
Me.groupKey(1) = Me.key.Split(New Char() { "-"c })(1)
Me.groupKey(2) = Me.key.Split(New Char() { "-"c })(2)
Me.groupKey(3) = Me.key.Split(New Char() { "-"c })(3)
Me.groupKey(4) = Me.key.Split(New Char() { "-"c })(4)
Me.key = Me.key.Replace("-", "")
Catch exception As Exception
Me.ErrorCode = (exception.Message & " " &
exception.StackTrace)
Return False
End Try
Dim bytes As Byte() = Encoding.ASCII.GetBytes(Me.key)
Dim domena As String = Me.GetDomainName.ToUpper
Dim stala As String = "COMPANYNAME"
Dim kodProduktu As String = "PRODUKT_NAME"
If Not Me.CreateKey(Convert.ToChar(bytes(&H13)), domena,
stala, kodProduktu, Me.groupKey) Then
flag = False
End If
Return flag
End Function
Private Function ValidateDomainName(ByVal group As String,
ByVal ch As Char) As Boolean
Dim flag As Boolean = False
Dim domainName As String = Me.GetDomainName
New ArrayList
If (domainName.Split(New Char() { "."c }).Length 0)
Then
Dim index As Integer = domainName.IndexOf(".")
domainName = domainName.Remove(0, (index + 1))
End If
flag = Me.CompareMd5Modules(group, domainName.ToUpper,
ch,
False)
Me.validateDomainName = domainName.ToUpper
Return (flag OrElse flag)
End Function
' Properties
Public Property ErrorCode As String
Get
Return Me.errorCode
End Get
Set(ByVal value As String)
Me.errorCode = value
End Set
End Property
' Fields
Private errorCode As String
Private groupKey As String() = New String(5 - 1) {}
Private isTrial As Boolean = True
Private key As String
Private trialTime As DateTime
Private validateDomainName As String
End Class
End Namespace
####################################
END CODE

Aug 13 '07 #1
1 1576
Pawel do dupy

Spierdalaj ty chuju - odpierdol sie


<pa******@hotmail.comwrote in message
news:11**********************@b79g2000hse.googlegr oups.com...
I've got a homework to do for a next week, and cannot pass it.
I had to create key which pass the validation for name
"sample.domain.com".
Any idea to simple reverse it ?

Here is a code:
########################
Imports System
Imports System.Collections
Imports System.Net
Imports System.Text
Namespace WebCon.WebParts.ColorCalendar
Friend Class CodeValidate
' Methods
Public Sub New(ByVal code As String)
Me.key = code
End Sub
Private Function CheckDate(ByVal data As String, ByVal s_sign
As Char) As Boolean
Dim str As String = ""
Dim flag As Boolean = False
data = Me.ConvertIc_Replace(data)
Dim bytes As Byte() = Encoding.ASCII.GetBytes(data)
Dim przesuwacz As Integer = s_sign
Dim i As Integer
For i = 0 To 4 - 1
Dim str2 As String =
Convert.ToString(Me.GetModulo(Convert.ToChar(bytes (i)), przesuwacz))
If (str2 = "15") Then
Me.isTrial = False
flag = False
Exit For
End If
Select Case i
Case 0
If (str2 = "-1") Then
flag = True
goto Label_011F
End If
If (str2.Length >= 2) Then
str = (str & "20" & str2 & "-")
Else
str = (str & "200" & str2 & "-")
End If
Exit Select
Case 1
If (str2 = "-1") Then
flag = True
goto Label_011F
End If
If (str2.Length >= 2) Then
str = (str & str2 & "-")
Else
str = (str & "0" & str2 & "-")
End If
Exit Select
End Select
If (i 1) Then
If (str2 = "-1") Then
flag = True
Exit For
End If
str = (str & str2)
End If
Next i
Label_011F:
If (Me.isTrial AndAlso Not flag) Then
Me.trialTime = Convert.ToDateTime(str)
End If
Return flag
End Function
Private Function CheckMiszung(ByVal kodProduktu As String,
ByVal domena As String, ByVal stala As String, ByVal key As String,
ByVal s_sign As Char) As Boolean
Dim flag As Boolean = False
domena = (domena & Convert.ToString(s_sign))
stala = (stala & Convert.ToString(s_sign))
kodProduktu = (kodProduktu & Convert.ToString(s_sign))
Dim replaceKey As String = New Md5((domena & stala &
kodProduktu)).getMd5
replaceKey = Me.ic_Replace(replaceKey).Substring(10, 3)
If ((Convert.ToChar(Encoding.ASCII.GetBytes(key)
(0)).ToString & replaceKey.ToUpper) = key) Then
flag = True
End If
Return flag
End Function
Private Function CompareMd5Modules(ByVal group As String,
ByVal stringToMd5 As String, ByVal s_sign As Char, ByVal lastModule
As
Boolean) As Boolean
stringToMd5 = (stringToMd5 & Convert.ToString(s_sign))
Dim replaceKey As String = New Md5(stringToMd5).getMd5
replaceKey = Me.ic_Replace(replaceKey)
If Not lastModule Then
replaceKey = replaceKey.Substring(1, 4)
Else
replaceKey = (replaceKey.Substring(1, 3) &
Convert.ToString(s_sign))
End If
Return (group = replaceKey)
End Function
Private Function ConvertIc_Replace(ByVal replaceKey As
String)
As String
replaceKey = replaceKey.Replace("Z", "0")
replaceKey = replaceKey.Replace("K", "1")
replaceKey = replaceKey.Replace("T", "6")
Return replaceKey.ToUpper
End Function
Private Function CreateKey(ByVal ch As Char, ByVal domena As
String, ByVal stala As String, ByVal kodProduktu As String, ByVal
group As String()) As Boolean
Dim flag As Boolean = True
If Not Me.ValidateDomainName(group(1), ch) Then
Me.ErrorCode = String.Format("Invalid domain name.
{0}, {1}", domena, Me.key)
Return False
End If
If Not Me.CompareMd5Modules(group(2), kodProduktu, ch,
False) Then
Me.ErrorCode = String.Format("Invalid product code.
{0}, {1}", Me.validateDomainName, Me.key)
Return False
End If
If Not Me.CompareMd5Modules(group(4), stala, ch, True)
Then
Me.ErrorCode = String.Format("Invalid special
character. {0}, {1}", Me.validateDomainName, Me.key)
Return False
End If
If Me.CheckDate(group(3), ch) Then
Me.ErrorCode = String.Format("Invalid date. {0},
{1}",
Me.validateDomainName, Me.key)
Return False
End If
If Me.isTrial Then
Dim trialTime As DateTime = Me.trialTime
Dim span As TimeSpan = DirectCast((DateTime.Today -
trialTime), TimeSpan)
If (span.Days 0) Then
Me.ErrorCode = String.Format("Your trial version
has expired {0} days ago, to buy full version", span.Days)
Return False
End If
Return flag
End If
If Not Me.CheckMiszung(kodProduktu,
Me.validateDomainName,
"COMPANYNAME", group(3), ch) Then
Me.ErrorCode = String.Format("Invalid special
characters. {0}, {1}", domena, Me.key)
Return False
End If
Return flag
End Function
Private Function GetDomainName() As String
Return Dns.GetHostEntry("LocalHost").HostName
End Function
Private Function GetModulo(ByVal [mod] As Char, ByVal
przesuwacz As Integer) As Integer
Dim num As Integer = Convert.ToInt32([mod].ToString,
&H10)
Dim chArray As Char() = New Char() { "0"c, "1"c, "2"c,
"3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "A"c, "B"c, "C"c, "D"c,
"E"c, "F"c }
Dim i As Integer
For i = 0 To &H10 - 1
Dim newAsciiNumber As Integer =
Me.GetNewAsciiNumber(chArray(i))
If (newAsciiNumber = -1) Then
newAsciiNumber = chArray(i)
End If
If (((newAsciiNumber + przesuwacz) Mod &H10) = num)
Then
Return i
End If
Next i
Return -1
End Function
Private Function GetNewAsciiNumber(ByVal ascii As Char) As
Integer
Select Case ascii
Case "A"c
Return &H3A
Case "B"c
Return &H3B
Case "C"c
Return 60
Case "D"c
Return &H3D
Case "E"c
Return &H3E
Case "F"c
Return &H3F
End Select
Return -1
End Function
Private Function ic_Replace(ByVal replaceKey As String) As
String
replaceKey = replaceKey.Replace("0", "Z")
replaceKey = replaceKey.Replace("1", "K")
replaceKey = replaceKey.Replace("6", "T")
Dim userDomainName As String = Environment.UserDomainName
Return replaceKey.ToUpper
End Function
Public Function IsKeyValidated() As Boolean
Dim flag As Boolean = True
Try
Me.groupKey(0) = Me.key.Split(New Char() { "-"c })(0)
Me.groupKey(1) = Me.key.Split(New Char() { "-"c })(1)
Me.groupKey(2) = Me.key.Split(New Char() { "-"c })(2)
Me.groupKey(3) = Me.key.Split(New Char() { "-"c })(3)
Me.groupKey(4) = Me.key.Split(New Char() { "-"c })(4)
Me.key = Me.key.Replace("-", "")
Catch exception As Exception
Me.ErrorCode = (exception.Message & " " &
exception.StackTrace)
Return False
End Try
Dim bytes As Byte() = Encoding.ASCII.GetBytes(Me.key)
Dim domena As String = Me.GetDomainName.ToUpper
Dim stala As String = "COMPANYNAME"
Dim kodProduktu As String = "PRODUKT_NAME"
If Not Me.CreateKey(Convert.ToChar(bytes(&H13)), domena,
stala, kodProduktu, Me.groupKey) Then
flag = False
End If
Return flag
End Function
Private Function ValidateDomainName(ByVal group As String,
ByVal ch As Char) As Boolean
Dim flag As Boolean = False
Dim domainName As String = Me.GetDomainName
New ArrayList
If (domainName.Split(New Char() { "."c }).Length 0)
Then
Dim index As Integer = domainName.IndexOf(".")
domainName = domainName.Remove(0, (index + 1))
End If
flag = Me.CompareMd5Modules(group, domainName.ToUpper,
ch,
False)
Me.validateDomainName = domainName.ToUpper
Return (flag OrElse flag)
End Function
' Properties
Public Property ErrorCode As String
Get
Return Me.errorCode
End Get
Set(ByVal value As String)
Me.errorCode = value
End Set
End Property
' Fields
Private errorCode As String
Private groupKey As String() = New String(5 - 1) {}
Private isTrial As Boolean = True
Private key As String
Private trialTime As DateTime
Private validateDomainName As String
End Class
End Namespace
####################################
END CODE

Aug 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Haines Brown | last post by:
I thought I had understood this issue and implemented a work around, but now when I check on IE5, it is not working: ... #IE-hack { margin-left: auto; margin-right: auto; width: 20em;...
3
by: cr88192 | last post by:
for various reasons, I added an imo ugly hack to my xml parser. basically, I wanted the ability to have binary payload within the xml parse trees. this was partly because I came up with a binary...
11
by: Chris Beall | last post by:
Here's the problem: http://pages.prodigy.net/chris_beall/Demo/theproblem.html The page contains inline text, then some additional pairs of text which are floated right and left. (This is a...
2
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have about 50 code behind *.vb files from which i have created a single *.dll file. This single *.dll file and all the *.aspx files i will put on a clients computer. So i just...
5
by: Nmx | last post by:
Hi everyone, I'm writing a patch to a search engine (aspseek http://www.aspseek.org/) compile under gcc 3.4.4 on FC3. At some point, I found this piece of code: -- // Dirty hack to avoid...
0
by: Xah Lee | last post by:
In this article, i explain how the use of bit masks is a hack in many imperative languages. Often, a function will need to take many True/False parameters. For example, suppose i have a function...
1
by: jswain | last post by:
Hi, Not sure if anyone can help with this or whether i'm posting in the correct section but here goes: I run my own server (windows 2003) and write most of my sites in ASP. I have thr friendly...
7
by: badc0de4 | last post by:
Is this a stupid hack or a clever hack? Is it a "hack" at all? ==================== #include <stdio.h> /* !!HACK!! */ /* no parenthesis on the #define'd expression */ #define...
0
by: freehackers | last post by:
FreeHackers Group : Only 6 Steps to get cracked your target password 1- Fill in the E-Mail Cracking order form , to the best of your knowledge “contact us to freehackers.007gmail.com with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.