title: ApacheLogsView破解笔记
categories:


本文作者Sp4ce,转自https://0x20h.com/p/a73d.html

Apache Log Viewer 5.X 注册机

抽空研究了下ALV的注册机制,写了个注册机

分析

ALV的注册方法是unlockCodeToolStripMenuItem_Click方法,当点击Unlock按钮时会触发注册事件并调用Class2类中的smethod_1smethod_02个方法进行校验,详细流程见如下代码
unlockCodeToolStripMenuItem_Click方法

  1. private void unlockCodeToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. string text = this.prefs_0.Key;
  4. if (!InputForm.smethod_3("Apache Logs Viewer | " + Class96.smethod_264(), Class96.smethod_143(), ref text))
  5. {
  6. return;
  7. }
  8. if (text != null)
  9. {
  10. text = text.Trim();
  11. }
  12. if (string.IsNullOrEmpty(text))
  13. {
  14. this.prefs_0.Key = string.Empty;
  15. this.bool_0 = false;
  16. Prefs.Save(Prefs.Filename, this.prefs_0);
  17. this.method_2(this.bool_0);
  18. return;
  19. }
  20. try
  21. {
  22. this.Cursor = Cursors.WaitCursor;
  23. if (text.Length < 22)//检查key长度是否大于22
  24. {
  25. throw new ApplicationException("Failed");
  26. }
  27. if (Class2.smethod_1(Class2.smethod_0(text)))//重点位置
  28. {
  29. this.prefs_0.Key = text;
  30. this.method_23();
  31. Prefs.Save(Prefs.Filename, this.prefs_0);
  32. this.Cursor = Cursors.Default;
  33. this.lbStatusStripNotify.Text = Class96.smethod_253() + " Apache Logs Viewer.";
  34. MessageBox.Show(this, Class96.smethod_253() + " Apache Logs Viewer.", "Apache Logs Viewer", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  35. this.bool_0 = true;
  36. }
  37. else
  38. {
  39. MessageBox.Show(this, Class96.smethod_117(), "Apache Logs Viewer | " + Class96.smethod_264(), MessageBoxButtons.OK, MessageBoxIcon.Hand);
  40. this.bool_0 = false;
  41. }
  42. }
  43. catch (Exception)
  44. {
  45. this.Cursor = Cursors.Default;
  46. MessageBox.Show(this, Class96.smethod_90(), "Apache Logs Viewer | " + Class96.smethod_264(), MessageBoxButtons.OK, MessageBoxIcon.Hand);
  47. this.bool_0 = false;
  48. }
  49. finally
  50. {
  51. this.Cursor = Cursors.Default;
  52. }
  53. this.method_2(this.bool_0);
  54. }

Class2.smethod_0方法,

  1. public static string smethod_0(string string_0)
  2. {
  3. if (string_0.IndexOf('-') < 0)//检查注册代码中是否有-
  4. {
  5. return string_0;
  6. }
  7. string str = "DBV";
  8. string_0 = string_0.Replace("-", string.Empty);//将字符-转为空
  9. string_0 = string_0.Replace('Q', '4');//Q转为4
  10. string_0 = string_0.Replace('G', '4');//G转为4
  11. string_0 = string_0.Replace('V', '0');//V转为0
  12. string_0 = string_0.Replace('N', '3');//N转为3
  13. str + string_0;//无用语句
  14. byte[] array = new byte[string_0.Length / 2];//新建个数组,长度是去掉-后的注册码长度的一半
  15. for (int i = 0; i < string_0.Length; i += 2)
  16. {
  17. byte b;
  18. byte.TryParse(new string(new char[]
  19. {
  20. string_0[i],
  21. string_0[i + 1]
  22. }), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b);//每两位进行拼接并转回字符串形式并依次存入b
  23. array[i / 2] = b;
  24. }
  25. string text = Encoding.ASCII.GetString(array);//将注册码转为字符串形式,传入的注册码为hex后的ascii值
  26. text = text.Insert(1, ":");//第2位插入:
  27. text = text.Insert(5, ":");//第6位插入:
  28. text = text.Insert(9, ":");//第10位插入:
  29. if (text.Length > 13)
  30. {
  31. text = text.Insert(13, ":");//如果注册码长度大于13则在第13位插入:
  32. }
  33. return text;
  34. }

Class2.smethod_1方法,

  1. public static bool smethod_1(string string_0)
  2. {
  3. bool flag = true;
  4. string a = string_0.Substring(4, 5);//取经过smethod_0处理后的字符串中的第4到8位
  5. //如果a为IALV或注册码第一位不为F或第3位转为int型大于16或a不为I:ALV或注册码第4位转为int型大于16则抛出注册码错误
  6. if (a == "IALV")
  7. {
  8. flag = false;
  9. }
  10. if (string_0[0] != 'F')
  11. {
  12. flag = false;
  13. }
  14. int num = int.Parse(string_0[2].ToString(), NumberStyles.HexNumber);
  15. if (num > 16)
  16. {
  17. flag = false;
  18. }
  19. if (a != "I:ALV")
  20. {
  21. flag = false;
  22. }
  23. num = int.Parse(string_0[3].ToString(), NumberStyles.HexNumber);
  24. if (num > 16)
  25. {
  26. flag = false;
  27. }
  28. if (!int.TryParse(string_0.Substring(10, 3), out num))
  29. {
  30. flag = false;
  31. }
  32. //处理后的注册码如果长度小于14则抛错
  33. if (string_0.Length <= 14)
  34. {
  35. throw new ApplicationException("Invalid Unlock Code");
  36. }
  37. //命名num2变量,值为注册码的第15位,并判断num2是否为2或3,不是就抛错
  38. int num2 = int.Parse(string_0.Substring(15, 1));
  39. if (num2 != 2 && num2 != 3)
  40. {
  41. throw new ApplicationException("Incorrect Code for Version");
  42. }
  43. string s = string_0.Substring(0, 16);//s为1~17位
  44. string b = string_0.Substring(16);//b为17位后的校验位
  45. int num3 = 0;
  46. byte[] bytes = Encoding.ASCII.GetBytes(s);//将s转为字节码并存入数组
  47. for (int i = 0; i < bytes.Length; i++)
  48. {
  49. if (bytes[i] % 2 == 0)//每一位进行模2运算,为0则num3+1
  50. {
  51. num3++;
  52. }
  53. }
  54. return !(num3.ToString("00") != b) && flag;//num3向上取整后与校验位作比较,比较成功则返回真
  55. }

Keygen

有了注册机制就可以写注册机了,这里用python写了一个

  1. '''
  2. @Author : Sp4ce
  3. @Date : 2020-02-19 19:17:59
  4. @LastEditors : Sp4ce
  5. @LastEditTime : 2020-02-19 23:27:40
  6. @Description : Challenge Everything.
  7. '''
  8. import random
  9. import binascii
  10. def banner():
  11. print(r"""
  12. _ __ __ _ __ _____
  13. /\ | |\ \ / / | |/ / / ____|
  14. / \ | | \ \ / / | ' / ___ _ _| | __ ___ _ __
  15. / /\ \ | | \ \/ / | < / _ \ | | | | |_ |/ _ \ '_ \
  16. / ____ \| |___\ / | . \ __/ |_| | |__| | __/ | | |
  17. /_/ \_\______\/ |_|\_\___|\__, |\_____|\___|_| |_|
  18. __/ |
  19. |___/
  20. Apache Log Viewer 5.X KeyGen
  21. By:Sp4ce
  22. """)
  23. def genLicenseCode(data):
  24. try:
  25. hexdata = data.replace('-', ':')
  26. data = "".join(data.split('-'))
  27. num = 0
  28. for i in hexdata:
  29. a = binascii.b2a_hex(i.encode('utf-8')).decode('utf-8')
  30. if int(a, 16) % 2 == 0:
  31. num = num+1
  32. hexData = binascii.b2a_hex((data+str(num)).encode('utf-8')) .decode('utf-8')
  33. hexData = list(hexData)
  34. hexData.insert(2, '-')
  35. hexData.insert(9, '-')
  36. hexData.insert(16, '-')
  37. hexData.insert(23, '-')
  38. licenseCode = ''.join(hexData)
  39. print("[+] License Code Generate Success!\nYour License Code: ->["+licenseCode.upper()+"]<-")
  40. except:
  41. print("[-] License Code Generate Failed!")
  42. def main():
  43. banner()
  44. data = []
  45. data.append('F') # 第一位必须:F
  46. data.append('-') # 第一个-
  47. data.append(random.randint(1, 9)) # 第3位转为int后必须小于16
  48. data.append(random.randint(1, 9)) # 第4位转为int后必须小于16
  49. data.append('I') # I
  50. data.append('-') # 第二个-
  51. data.append('ALV') # ALV
  52. data.append('-') # 第三个-
  53. data.append(random.randint(100, 999)) # 第11~13位必须为int型
  54. data.append('-') # 第四个-
  55. data.append(random.randint(1, 9)) # 第14位随机
  56. data.append(random.randint(2, 3)) # 第15位必须为2或3
  57. data = "".join('%s' % i for i in data).upper()
  58. genLicenseCode(data)
  59. if __name__ == "__main__":
  60. main()

运行后

  1. _ __ __ _ __ _____
  2. /\ | |\ \ / / | |/ / / ____|
  3. / \ | | \ \ / / | ' / ___ _ _| | __ ___ _ __
  4. / /\ \ | | \ \/ / | < / _ \ | | | | |_ |/ _ \ '_ \
  5. / ____ \| |___\ / | . \ __/ |_| | |__| | __/ | | |
  6. /_/ \_\______\/ |_|\_\___|\__, |\_____|\___|_| |_|
  7. __/ |
  8. |___/
  9. Apache Log Viwer 5.X KeyGen
  10. By:Sp4ce
  11. [+] License Code Generate Success!
  12. Your License Code: ->[46-313449-414C56-353934-33323130]<-

后话

该软件注册机制还有第二种方案,抽空再写