-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.py
117 lines (87 loc) · 3.65 KB
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Nicholas Sjöqvist Obucina
# Max length of the serial key is 25 characters
# 89h ; ‰
# 0C4h ; Ä
# 0FEh ; þ
firstEncryptionArray = [int(x, 16) for x in ["AA", "89", "0C4", "0FE", "46"]]
secondEncryptionArray = [int(x, 16) for x in ["78", "0F0", "0D0", "3", "0E7"]]
thirdEncryptionArray = [int(x, 16) for x in ["0F7", "FD", "F4", "E7", "0B9"]]
fourthEncryptionArray = [int(x, 16) for x in ["0B5", "1B", "C9", "50", "73"]]
def firstencryptThisArray(nameToArray=[], encryptArray=[]):
returnArray = [nameToArray[0]]
nameToArray.append(0)
countVariable = 0
for x in range(1, len(nameToArray)):
val = (nameToArray[x] ^ encryptArray[countVariable])
returnArray.append(val)
encryptArray[countVariable] = nameToArray[x]
if(countVariable == 4):
countVariable = 0
else:
countVariable = countVariable + 1
return returnArray
def secondencryptThisArray(nameToArray=[], encryptArray=[]):
returnArray = []
countVariable = 0
for x in range(len(nameToArray) - 1, 0, -1):
val = (encryptArray[countVariable] ^ nameToArray[x])
returnArray.insert(0, val)
encryptArray[countVariable] = nameToArray[x]
if(countVariable == 4):
countVariable = 0
else:
countVariable = countVariable + 1
returnArray.insert(0, nameToArray[0])
return returnArray
def createIntRepresentationOfStringFromDecimalValues(array=[]):
# EAX = int(("".join([hex(x).lstrip("0x") for x in arrayToReturn])), 16)
temporaryReturnArray = []
for eachElement in array:
returnValue = hex(eachElement).lstrip("0x")
if(len(returnValue) < 2):
returnValue = "0" + returnValue
temporaryReturnArray.append(returnValue)
return int(("".join(temporaryReturnArray)), 16)
Username = input("Type your username: ")
if(len(Username) < 4):
print("Your username is to short")
else:
ArrayOfName = []
for x in Username:
ArrayOfName.append(ord(x))
firstEcryptionOfUserName = firstencryptThisArray(
ArrayOfName, firstEncryptionArray)
secondEncryptionOfUserName = secondencryptThisArray(
firstEcryptionOfUserName, secondEncryptionArray)
thirdEncryptionOfUserName = firstencryptThisArray(
secondEncryptionOfUserName, thirdEncryptionArray)[:-1]
finalEncryptionOfUserName = secondencryptThisArray(
thirdEncryptionOfUserName, fourthEncryptionArray)
arrayToReturn = [0, 0, 0, 0]
for eachIteration in range(0, len(finalEncryptionOfUserName) - 1):
firstArray = finalEncryptionOfUserName.copy()
firstArray.insert(0, 0)
ECX = bin(eachIteration & 3)
bl = arrayToReturn[3 - (eachIteration - (int(eachIteration / 4) * 4))]
cl = finalEncryptionOfUserName[eachIteration + 1]
bl = bl + cl
if(bl > 256):
bl = bl - (int(bl/256) * 256)
arrayToReturn[3 - (eachIteration - (int(eachIteration / 4) * 4))] = bl
userNameStringRepresentation = []
EAX = createIntRepresentationOfStringFromDecimalValues(arrayToReturn)
i = 0
while(EAX != 0):
EDX = EAX % int("0xA", 16)
EAX = int(EAX / int("0xA", 16))
userNameStringRepresentation.append(EDX + 30)
i = i + 1
# The serial key is the username's representation but in reverse.
serialKeyStringRepresentation = userNameStringRepresentation.copy()[::-1]
#####################
# Final REVERSING STEPS
#####################
stringArray = "".join([str(thefinals - 30)
for thefinals in serialKeyStringRepresentation])
print("Your reg.code: " + stringArray)
input("Press any key to exit")