473,748 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collecti ons
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_Re place(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.ToStrin g(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.ToDateT ime(str)
End If
Return flag
End Function
Private Function CheckMiszung(By Val 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.ToStrin g(s_sign))
stala = (stala & Convert.ToStrin g(s_sign))
kodProduktu = (kodProduktu & Convert.ToStrin g(s_sign))
Dim replaceKey As String = New Md5((domena & stala &
kodProduktu)).g etMd5
replaceKey = Me.ic_Replace(r eplaceKey).Subs tring(10, 3)
If ((Convert.ToCha r(Encoding.ASCI I.GetBytes(key)
(0)).ToString & replaceKey.ToUp per) = key) Then
flag = True
End If
Return flag
End Function
Private Function CompareMd5Modul es(ByVal group As String,
ByVal stringToMd5 As String, ByVal s_sign As Char, ByVal lastModule
As
Boolean) As Boolean
stringToMd5 = (stringToMd5 & Convert.ToStrin g(s_sign))
Dim replaceKey As String = New Md5(stringToMd5 ).getMd5
replaceKey = Me.ic_Replace(r eplaceKey)
If Not lastModule Then
replaceKey = replaceKey.Subs tring(1, 4)
Else
replaceKey = (replaceKey.Sub string(1, 3) &
Convert.ToStrin g(s_sign))
End If
Return (group = replaceKey)
End Function
Private Function ConvertIc_Repla ce(ByVal replaceKey As
String)
As String
replaceKey = replaceKey.Repl ace("Z", "0")
replaceKey = replaceKey.Repl ace("K", "1")
replaceKey = replaceKey.Repl ace("T", "6")
Return replaceKey.ToUp per
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.ValidateDoma inName(group(1) , ch) Then
Me.ErrorCode = String.Format(" Invalid domain name.
{0}, {1}", domena, Me.key)
Return False
End If
If Not Me.CompareMd5Mo dules(group(2), kodProduktu, ch,
False) Then
Me.ErrorCode = String.Format(" Invalid product code.
{0}, {1}", Me.validateDoma inName, Me.key)
Return False
End If
If Not Me.CompareMd5Mo dules(group(4), stala, ch, True)
Then
Me.ErrorCode = String.Format(" Invalid special
character. {0}, {1}", Me.validateDoma inName, Me.key)
Return False
End If
If Me.CheckDate(gr oup(3), ch) Then
Me.ErrorCode = String.Format(" Invalid date. {0},
{1}",
Me.validateDoma inName, Me.key)
Return False
End If
If Me.isTrial Then
Dim trialTime As DateTime = Me.trialTime
Dim span As TimeSpan = DirectCast((Dat eTime.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.validateDoma inName,
"COMPANYNAM E", 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.GetHostEntr y("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.GetNewAsciiN umber(chArray(i ))
If (newAsciiNumber = -1) Then
newAsciiNumber = chArray(i)
End If
If (((newAsciiNumb er + przesuwacz) Mod &H10) = num)
Then
Return i
End If
Next i
Return -1
End Function
Private Function GetNewAsciiNumb er(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(ByVa l replaceKey As String) As
String
replaceKey = replaceKey.Repl ace("0", "Z")
replaceKey = replaceKey.Repl ace("1", "K")
replaceKey = replaceKey.Repl ace("6", "T")
Dim userDomainName As String = Environment.Use rDomainName
Return replaceKey.ToUp per
End Function
Public Function IsKeyValidated( ) As Boolean
Dim flag As Boolean = True
Try
Me.groupKey(0) = Me.key.Split(Ne w Char() { "-"c })(0)
Me.groupKey(1) = Me.key.Split(Ne w Char() { "-"c })(1)
Me.groupKey(2) = Me.key.Split(Ne w Char() { "-"c })(2)
Me.groupKey(3) = Me.key.Split(Ne w Char() { "-"c })(3)
Me.groupKey(4) = Me.key.Split(Ne w Char() { "-"c })(4)
Me.key = Me.key.Replace( "-", "")
Catch exception As Exception
Me.ErrorCode = (exception.Mess age & " " &
exception.Stack Trace)
Return False
End Try
Dim bytes As Byte() = Encoding.ASCII. GetBytes(Me.key )
Dim domena As String = Me.GetDomainNam e.ToUpper
Dim stala As String = "COMPANYNAM E"
Dim kodProduktu As String = "PRODUKT_NA ME"
If Not Me.CreateKey(Co nvert.ToChar(by tes(&H13)), domena,
stala, kodProduktu, Me.groupKey) Then
flag = False
End If
Return flag
End Function
Private Function ValidateDomainN ame(ByVal group As String,
ByVal ch As Char) As Boolean
Dim flag As Boolean = False
Dim domainName As String = Me.GetDomainNam e
New ArrayList
If (domainName.Spl it(New Char() { "."c }).Length 0)
Then
Dim index As Integer = domainName.Inde xOf(".")
domainName = domainName.Remo ve(0, (index + 1))
End If
flag = Me.CompareMd5Mo dules(group, domainName.ToUp per,
ch,
False)
Me.validateDoma inName = domainName.ToUp per
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 validateDomainN ame As String
End Class
End Namespace
############### ############### ######
END CODE

Aug 13 '07 #1
1 1614
Pawel do dupy

Spierdalaj ty chuju - odpierdol sie


<pa******@hotma il.comwrote in message
news:11******** **************@ b79g2000hse.goo glegroups.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.Collecti ons
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_Re place(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.ToStrin g(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.ToDateT ime(str)
End If
Return flag
End Function
Private Function CheckMiszung(By Val 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.ToStrin g(s_sign))
stala = (stala & Convert.ToStrin g(s_sign))
kodProduktu = (kodProduktu & Convert.ToStrin g(s_sign))
Dim replaceKey As String = New Md5((domena & stala &
kodProduktu)).g etMd5
replaceKey = Me.ic_Replace(r eplaceKey).Subs tring(10, 3)
If ((Convert.ToCha r(Encoding.ASCI I.GetBytes(key)
(0)).ToString & replaceKey.ToUp per) = key) Then
flag = True
End If
Return flag
End Function
Private Function CompareMd5Modul es(ByVal group As String,
ByVal stringToMd5 As String, ByVal s_sign As Char, ByVal lastModule
As
Boolean) As Boolean
stringToMd5 = (stringToMd5 & Convert.ToStrin g(s_sign))
Dim replaceKey As String = New Md5(stringToMd5 ).getMd5
replaceKey = Me.ic_Replace(r eplaceKey)
If Not lastModule Then
replaceKey = replaceKey.Subs tring(1, 4)
Else
replaceKey = (replaceKey.Sub string(1, 3) &
Convert.ToStrin g(s_sign))
End If
Return (group = replaceKey)
End Function
Private Function ConvertIc_Repla ce(ByVal replaceKey As
String)
As String
replaceKey = replaceKey.Repl ace("Z", "0")
replaceKey = replaceKey.Repl ace("K", "1")
replaceKey = replaceKey.Repl ace("T", "6")
Return replaceKey.ToUp per
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.ValidateDoma inName(group(1) , ch) Then
Me.ErrorCode = String.Format(" Invalid domain name.
{0}, {1}", domena, Me.key)
Return False
End If
If Not Me.CompareMd5Mo dules(group(2), kodProduktu, ch,
False) Then
Me.ErrorCode = String.Format(" Invalid product code.
{0}, {1}", Me.validateDoma inName, Me.key)
Return False
End If
If Not Me.CompareMd5Mo dules(group(4), stala, ch, True)
Then
Me.ErrorCode = String.Format(" Invalid special
character. {0}, {1}", Me.validateDoma inName, Me.key)
Return False
End If
If Me.CheckDate(gr oup(3), ch) Then
Me.ErrorCode = String.Format(" Invalid date. {0},
{1}",
Me.validateDoma inName, Me.key)
Return False
End If
If Me.isTrial Then
Dim trialTime As DateTime = Me.trialTime
Dim span As TimeSpan = DirectCast((Dat eTime.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.validateDoma inName,
"COMPANYNAM E", 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.GetHostEntr y("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.GetNewAsciiN umber(chArray(i ))
If (newAsciiNumber = -1) Then
newAsciiNumber = chArray(i)
End If
If (((newAsciiNumb er + przesuwacz) Mod &H10) = num)
Then
Return i
End If
Next i
Return -1
End Function
Private Function GetNewAsciiNumb er(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(ByVa l replaceKey As String) As
String
replaceKey = replaceKey.Repl ace("0", "Z")
replaceKey = replaceKey.Repl ace("1", "K")
replaceKey = replaceKey.Repl ace("6", "T")
Dim userDomainName As String = Environment.Use rDomainName
Return replaceKey.ToUp per
End Function
Public Function IsKeyValidated( ) As Boolean
Dim flag As Boolean = True
Try
Me.groupKey(0) = Me.key.Split(Ne w Char() { "-"c })(0)
Me.groupKey(1) = Me.key.Split(Ne w Char() { "-"c })(1)
Me.groupKey(2) = Me.key.Split(Ne w Char() { "-"c })(2)
Me.groupKey(3) = Me.key.Split(Ne w Char() { "-"c })(3)
Me.groupKey(4) = Me.key.Split(Ne w Char() { "-"c })(4)
Me.key = Me.key.Replace( "-", "")
Catch exception As Exception
Me.ErrorCode = (exception.Mess age & " " &
exception.Stack Trace)
Return False
End Try
Dim bytes As Byte() = Encoding.ASCII. GetBytes(Me.key )
Dim domena As String = Me.GetDomainNam e.ToUpper
Dim stala As String = "COMPANYNAM E"
Dim kodProduktu As String = "PRODUKT_NA ME"
If Not Me.CreateKey(Co nvert.ToChar(by tes(&H13)), domena,
stala, kodProduktu, Me.groupKey) Then
flag = False
End If
Return flag
End Function
Private Function ValidateDomainN ame(ByVal group As String,
ByVal ch As Char) As Boolean
Dim flag As Boolean = False
Dim domainName As String = Me.GetDomainNam e
New ArrayList
If (domainName.Spl it(New Char() { "."c }).Length 0)
Then
Dim index As Integer = domainName.Inde xOf(".")
domainName = domainName.Remo ve(0, (index + 1))
End If
flag = Me.CompareMd5Mo dules(group, domainName.ToUp per,
ch,
False)
Me.validateDoma inName = domainName.ToUp per
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 validateDomainN ame 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
3508
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; text-align: center; }
3
1967
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 xml format (mentioned more later), and thought it would be "useful" to be able to store binary data inline with this format, and still wanted to keep things balanced (whatever the binary version can do, the textual version can do as well). the...
11
2135
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 transcript of a historical legal document with signatures on the right and witnesses on the left). The 'document' ends with no additional inline text. The background of the entire document should be brown inside a white body, (in this test the body...
2
3521
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 wanted to know if they can hack it ? I know that there should be a way to hack it but only i want to know if it is simple enough. I mean if my client's programmer can just go to the web, download some utility and hack it ? Thanks in advance Raja
5
2235
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 non-threadsafeness of string class // We set ref to big value here so it will not reach 0
0
2099
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 that can draw a rainbow, and each color of the rainbow can be turned on or off individually. My function specification can be of this form: “rainbow(red, orange, yellow, green, blue, violet, purple)”. Each parameter is a true or false value....
1
1609
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 500:100 error for the visitor but any error is also emailed to myself with specifics so that i can debug any genuine errors. I get lost of emails with Error on "website" page = "url address" Error Type: CDO.Message.1 (0x8004020D) At least one...
7
2257
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 MY_FLOAT_CONSTANT_HACKED 15 / 4
0
3702
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 victims details (complete name ,email address ,country) Replace by @ in the email address. 2- After successfully cracking the password , we will send you a CONFIRMATION EMAIL , along with a proof . We will also send you a follow-up for the...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.