GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering

GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 02-10-2021, 21:12   #1 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
Reading lincense check in c


Anyone here that can c?
Got a license check function i cant understand and need help understanding it.

Dont know if its ok to post code here, If its ok i can post it

Best regards
  Reply With Quote
Old 02-11-2021, 08:50   #2 (permalink)
No Life Poster
 
platforms's Avatar
 
Join Date: Sep 2004
Location: London
Age: 40
Posts: 514
Member: 83090
Status: Offline
Sonork: 1626857
Thanks Meter: 52
Post the code snippet .
  Reply With Quote
The Following User Says Thank You to platforms For This Useful Post:
Old 02-11-2021, 11:40   #3 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
private bool Checkserial(int thekey)
{
string name = "";
this.licensename = "";
string serial = "";
string str3 = thekey.ToString("X").ToUpper();
string[] files = Directory.GetFiles(Application.StartupPath, "*.txt");
for (int i = 0; i < files.Length; i++)
{
files[i] = Path.GetFileName(files[i]);
}
int index = 0;
for (int j = 0; j < files.Length; j++)
{
if (files[j].Contains("License"))
{
index++;
}
}
string[] strArray2 = new string[index];
index = 0;
for (int k = 0; k < files.Length; k++)
{
if (files[k].Contains("License"))
{
strArray2[index] = files[k];
index++;
}
}
int num5 = 0;
while (true)
{
if (num5 < strArray2.Length)
{
this.exec.decrypt(strArray2[num5], out name, out serial);
if (serial.ToUpper() != str3)
{
num5++;
continue;
}
this.licensename = name;
}
return (serial == str3);
}
}
  Reply With Quote
Old 02-11-2021, 11:41   #4 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
internal class CryptorEngine
{
// Token: 0x0600060B RID: 1547 RVA: 0x00076718 File Offset: 0x00074918
public static string Decrypt(string cipherText, string passPhrase)
{
string result;
try
{
byte[] bytes = Encoding.ASCII.GetBytes("qbm1kjgn435gh1lm");
byte[] array = Convert.FromBase64String(cipherText);
PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(passPhrase, null);
byte[] bytes2 = passwordDeriveBytes.GetBytes(32);
ICryptoTransform transform = new RijndaelManaged
{
Mode = CipherMode.CBC
}.CreateDecryptor(bytes2, bytes);
MemoryStream memoryStream = new MemoryStream(array);
CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Read);
byte[] array2 = new byte[array.Length];
int count = cryptoStream.Read(array2, 0, array2.Length);
memoryStream.Close();
cryptoStream.Close();
result = Encoding.UTF8.GetString(array2, 0, count);
}
catch (Exception)
{
result = "invalid";
}
return result;
}

// Token: 0x0400069F RID: 1695
private const string initVector = "qbm1kjgn435gh1lm";

// Token: 0x040006A0 RID: 1696
private const int keysize = 256;
}
  Reply With Quote
Old 02-11-2021, 11:43   #5 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
public class CRC32
{
// Token: 0x06000916 RID: 2326 RVA: 0x000ADFC8 File Offset: 0x000AC1C8
public uint GetCrc32(Stream stream)
{
uint num = uint.MaxValue;
byte[] array = new byte[1024];
int count = 1024;
for (int i = stream.Read(array, 0, 1024); i > 0; i = stream.Read(array, 0, count))
{
for (int j = 0; j < i; j++)
{
num = (num >> 8 ^ this.crc32Table[(int)((UIntPtr)((uint)array[j] ^ (num & 255U)))]);
}
}
return ~num;
}

// Token: 0x06000917 RID: 2327 RVA: 0x000AE034 File Offset: 0x000AC234
public CRC32()
{
uint num = 3988292384U;
this.crc32Table = new uint[256];
for (uint num2 = 0U; num2 < 256U; num2 += 1U)
{
uint num3 = num2;
for (uint num4 = 8U; num4 > 0U; num4 -= 1U)
{
if ((num3 & 1U) == 1U)
{
num3 = (num3 >> 1 ^ num);
}
else
{
num3 >>= 1;
}
}
this.crc32Table[(int)((UIntPtr)num2)] = num3;
}
}

// Token: 0x040009D7 RID: 2519
private const int BUFFER_SIZE = 1024;

// Token: 0x040009D8 RID: 2520
private uint[] crc32Table;
}
  Reply With Quote
Old 02-11-2021, 11:46   #6 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
public class Devicesel : Form
{
// Token: 0x06000520 RID: 1312 RVA: 0x00073DF4 File Offset: 0x00071FF4
public Devicesel()
{
this.devtypelist = new List<UC123.DeviceType>();
this.Haslicensekey = new List<bool>();
this.Licensename = new List<string>();
this.Serialnumber = new List<string>();
this.Wasdisabled = new List<bool>();
this.InitializeComponent();
}

// Token: 0x06000521 RID: 1313 RVA: 0x00073E4C File Offset: 0x0007204C
public void Adddevice(int devtype, int devserial, string licensename, bool Haslicensekey, bool disabledillegal)
{
this.devtypelist.Add((UC123.DeviceType)devtype);
this.Licensename.Add(licensename);
this.Haslicensekey.Add(Haslicensekey);
this.Serialnumber.Add(devserial.ToString("X").ToUp per());
this.Wasdisabled.Add(disabledillegal);
if (Haslicensekey)
{
if (disabledillegal)
{
this.devlistbox.Items.Add(string.Concat(new object[]
{
"Device type: ",
(UC123.DeviceType)devtype,
" serial No.:",
devserial.ToString("X"),
" (Disabled)"
}));
return;
}
this.devlistbox.Items.Add(string.Concat(new object[]
{
"Device type: ",
(UC123.DeviceType)devtype,
" serial No.:",
devserial.ToString("X")
}));
return;
}
else
{
if (devtype <= 0)
{
this.devlistbox.Items.Add("Device type: " + (UC123.DeviceType)devtype);
return;
}
this.devlistbox.Items.Add(string.Concat(new object[]
{
"Device type: ",
(UC123.DeviceType)devtype,
" serial No.:",
devserial.ToString("X"),
" (No license key)"
}));
return;
}
}

// Token: 0x06000522 RID: 1314 RVA: 0x00073FBC File Offset: 0x000721BC
public int SelectitembySerial(string serial)
{
serial = serial.ToUpper();
for (int i = 0; i < this.Serialnumber.Count; i++)
{
if (serial == this.Serialnumber[i])
{
this.selecteddevnumber = i + 1;
this.selecteddevtype = this.devtypelist[i];
return i + 1;
}
}
return -1;
}

// Token: 0x06000523 RID: 1315 RVA: 0x00005309 File Offset: 0x00003509
public void SelectitembyID(int itemnumber)
{
this.devlistbox.SelectedIndex = itemnumber;
this.selecteddevnumber = itemnumber + 1;
this.selecteddevtype = this.devtypelist[itemnumber];
}

// Token: 0x06000524 RID: 1316 RVA: 0x00005332 File Offset: 0x00003532
private void Devicesel_Load(object sender, EventArgs e)
{
this.devlistbox.Focus();
}

// Token: 0x06000525 RID: 1317 RVA: 0x00005340 File Offset: 0x00003540
private void Devicesel_FormClosing(object sender, FormClosingEventArgs e)
{
this.selecteddevnumber = this.devlistbox.SelectedIndex + 1;
this.selecteddevtype = this.devtypelist[this.devlistbox.SelectedIndex];
}

// Token: 0x06000526 RID: 1318 RVA: 0x00005371 File Offset: 0x00003571
private void continuebutton_Click(object sender, EventArgs e)
{
this.OKclicked = true;
base.Close();
}

// Token: 0x06000527 RID: 1319 RVA: 0x00002050 File Offset: 0x00000250
private void devlistbox_SelectedIndexChanged(object sender, EventArgs e)
{
}

// Token: 0x06000528 RID: 1320 RVA: 0x00005380 File Offset: 0x00003580
private void devlistbox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
this.OKclicked = true;
base.Close();
}
}

// Token: 0x06000529 RID: 1321 RVA: 0x00005399 File Offset: 0x00003599
private void Devicesel_Shown(object sender, EventArgs e)
{
base.Focus();
base.Activate();
}

// Token: 0x0600052A RID: 1322 RVA: 0x000053A8 File Offset: 0x000035A8
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
{
this.components.Dispose();
}
base.Dispose(disposing);
}

// Token: 0x0600052B RID: 1323 RVA: 0x00074020 File Offset: 0x00072220
private void InitializeComponent()
{
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(Devicesel));
this.devlistbox = new ListBox();
this.continuebutton = new Button();
this.label1 = new Label();
base.SuspendLayout();
this.devlistbox.Font = new Font("Microsoft Sans Serif", 12f, FontStyle.Regular, GraphicsUnit.Point, 238);
this.devlistbox.FormattingEnabled = true;
this.devlistbox.ItemHeight = 20;
this.devlistbox.Location = new Point(12, 39);
this.devlistbox.Name = "devlistbox";
this.devlistbox.Size = new Size(570, 304);
this.devlistbox.TabIndex = 0;
this.devlistbox.SelectedIndexChanged += this.devlistbox_SelectedIndexChanged;
this.devlistbox.KeyPress += this.devlistbox_KeyPress;
this.continuebutton.Font = new Font("Microsoft Sans Serif", 12f, FontStyle.Regular, GraphicsUnit.Point, 238);
this.continuebutton.Location = new Point(225, 355);
this.continuebutton.Name = "continuebutton";
this.continuebutton.Size = new Size(150, 40);
this.continuebutton.TabIndex = 1;
this.continuebutton.Text = "Continue";
this.continuebutton.UseVisualStyleBackColor = true;
this.continuebutton.Click += this.continuebutton_Click;
this.label1.AutoSize = true;
this.label1.Font = new Font("Microsoft Sans Serif", 12f, FontStyle.Regular, GraphicsUnit.Point, 238);
this.label1.Location = new Point(91, 9);
this.label1.Name = "label1";
this.label1.Size = new Size(389, 20);
this.label1.TabIndex = 2;
this.label1.Text = "Select the motion controller device to use from the list:";
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
base.ClientSize = new Size(594, 404);
base.Controls.Add(this.label1);
base.Controls.Add(this.continuebutton);
base.Controls.Add(this.devlistbox);
base.FormBorderStyle = FormBorderStyle.FixedDialog;
base.Icon = (Icon)componentResourceManager.GetObject("$this.Ic on");
base.Name = "Devicesel";
base.StartPosition = FormStartPosition.CenterScreen;
this.Text = "Device selection";
base.FormClosing += this.Devicesel_FormClosing;
base.Load += this.Devicesel_Load;
base.Shown += this.Devicesel_Shown;
base.ResumeLayout(false);
base.PerformLayout();
}

// Token: 0x0400054F RID: 1359
public bool OKclicked;

// Token: 0x04000550 RID: 1360
public int selecteddevnumber = 1;

// Token: 0x04000551 RID: 1361
public UC100.DeviceType selecteddevtype;

// Token: 0x04000552 RID: 1362
private List<UC100.DeviceType> devtypelist;

// Token: 0x04000553 RID: 1363
public List<bool> Haslicensekey;

// Token: 0x04000554 RID: 1364
public List<string> Licensename;

// Token: 0x04000555 RID: 1365
public List<string> Serialnumber;

// Token: 0x04000556 RID: 1366
public List<bool> Wasdisabled;

// Token: 0x04000557 RID: 1367
private IContainer components;

// Token: 0x04000558 RID: 1368
private ListBox devlistbox;

// Token: 0x04000559 RID: 1369
private Button continuebutton;

// Token: 0x0400055A RID: 1370
private Label label1;
}
  Reply With Quote
Old 02-11-2021, 17:23   #7 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
What i can understand is that Checkserial read file Licencse*.txt

And then i think serial check is in function crc32,
num = (num >> 8 ^ this.crc32Table[(int)((UIntPtr)((uint)array[j] ^ (num & 255U)))]);

Creates array of 1024 rows with 0x00 <- some value

num changes for every try example : num 0x783BCB80
[j] counts from 0 to 400
i = 0x00000400


But dont undertsand c so just guesing at this point

Function CryptorEngine is never called before i get into demo mode, perhaps because i can not pass crc32 because of wrong product key

Devicesel: will probably show hardware if serial on hardware and in license file is matching

Last edited by forhike; 02-11-2021 at 17:31.
  Reply With Quote
Old 02-11-2021, 17:45   #8 (permalink)
No Life Poster
 
forhike's Avatar
 
Join Date: Aug 2002
Posts: 897
Member: 14934
Status: Offline
Thanks Meter: 79
if num is: 0x982F33AB
something happends with the array of 1024 rows

but still now have a clue what it is =)
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 



All times are GMT +1. The time now is 11:53.



Powered by Searchlight © 2021 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2017 -
Page generated in 0.17987 seconds with 8 queries

SEO by vBSEO