本帖最后由 zyjsuper 于 2021-8-2 22:34 编辑
C#源码:
[C#] 纯文本查看 复制代码 internal static class Class1
{
// Token: 0x06000072 RID: 114 RVA: 0x0000A274 File Offset: 0x00008474
public static string smethod_0(string string_0)
{
if (string_0.IndexOf('-') < 0)
{
return string_0;
}
string str = "DBV";
string_0 = string_0.Replace("-", string.Empty);
string_0 = string_0.Replace('Q', '4');
string_0 = string_0.Replace('G', '4');
string_0 = string_0.Replace('V', '0');
string_0 = string_0.Replace('N', '3');
str + string_0;
byte[] array = new byte[string_0.Length / 2];
for (int i = 0; i < string_0.Length; i += 2)
{
byte b;
byte.TryParse(new string(new char[]
{
string_0[i],
string_0[i + 1]
}), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b);
array[i / 2] = b;
}
string text = Encoding.ASCII.GetString(array);
text = text.Insert(1, ":");
text = text.Insert(5, ":");
text = text.Insert(9, ":");
if (text.Length > 13)
{
text = text.Insert(13, ":");
}
return text;
}
// Token: 0x06000073 RID: 115 RVA: 0x0000A384 File Offset: 0x00008584
public static bool smethod_1(string string_0)
{
bool flag = true;
string a = string_0.Substring(4, 5);
if (a == "IALV")
{
flag = false;
}
if (string_0[0] != 'F')
{
flag = false;
}
int num = int.Parse(string_0[2].ToString(), NumberStyles.HexNumber);
if (num > 16)
{
flag = false;
}
if (a != "I:ALV")
{
flag = false;
}
num = int.Parse(string_0[3].ToString(), NumberStyles.HexNumber);
if (num > 16)
{
flag = false;
}
if (!int.TryParse(string_0.Substring(10, 3), out num))
{
flag = false;
}
if (string_0.Length <= 14)
{
throw new ApplicationException("Invalid Unlock Code");
}
int num2 = int.Parse(string_0.Substring(15, 1));
if (num2 != 2 && num2 != 3)
{
throw new ApplicationException("Incorrect Code for Version");
}
string s = string_0.Substring(0, 16);
string b = string_0.Substring(16);
int num3 = 0;
byte[] bytes = Encoding.ASCII.GetBytes(s);
for (int i = 0; i < bytes.Length; i++)
{
if (bytes[i] % 2 == 0)
{
num3++;
}
}
return !(num3.ToString("00") != b) && flag;
}
}
自己整理的python代码,只是按照源码转义,不具备算号能力
[Python] 纯文本查看 复制代码 class generate_unlockcode:
def smethod_0(self,string_0):
if string_0.count('-') < 0:
return string_0
#str_pre = 'DBV'
string_0 = string_0.replace("-", "")
string_0 = string_0.replace('Q', '4')
string_0 = string_0.replace('G', '4')
string_0 = string_0.replace('V', '0')
string_0 = string_0.replace('N', '3')
#string_0 = str_pre + string_0
b = []
for i in range(0, len(string_0), 2):
b.append(string_0[i:i + 2])
#print(b)
try:
result = [chr(int(i,16)) for i in b]
result.insert(1,':')
result.insert(5,':')
result.insert(9,':')
if len(result)> 13:
result.insert(13,':')
result = ''.join(result)
return result
except:
pass
def smethod_1(self):
string_0 = self.smethod_0('46363449414C56-39343434333132')
flag = True
a = string_0[4:9]
if a == "IALV":
flag = False
return flag
if string_0[0] != 'F':
flag = False
return flag
num = int(str(string_0[2]),16)
if num > 16:
flag = False
return flag
if a != "I:ALV":
flag = False
return flag
num1 = int(str(string_0[3]), 16)
if num1 > 16:
flag = False
return flag
str1 = string_0[10:13]
#print(str1.isdecimal())
if str1.isdecimal() == False:
flag = False
return flag
if len(string_0) <= 14:
print("Invalid Unlock Code")
flag = False
return flag
num2 = int(string_0[15])
if num2 != 2 and num2 != 3:
print("Incorrect Code for Version")
flag = False
return flag
result = []
s = string_0[0:16]
b = string_0[16:]
num3 = 0
for i in s:
if i.isdecimal() != True:
result.append(ord(i))
else:
result.append(int(i,16))
for i in range(0,len(result)):
if result[i] %2 == 0:
num3 += 1
if int(num3) != int(b):
flag = False
print(flag)
return flag
if __name__ == '__main__':
obj = generate_unlockcode()
obj.smethod_1()
|