NET反编译出来的C#关键代码
本帖最后由 zzcl558 于 2020-2-2 02:39 编辑using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using MySql.Data.MySqlClient;
private string Encriptar(string texto)
{
string result;
if (Operators.CompareString(Strings.Trim(texto), "", false) == 0)
{
result = "";
}
else
{
this.des.Key = this.hashmd5.ComputeHash(new UnicodeEncoding().GetBytes(Module1.d(this.myKey)));
this.des.Mode = CipherMode.ECB;
ICryptoTransform cryptoTransform = this.des.CreateEncryptor();
byte[] bytes = Encoding.ASCII.GetBytes(texto);
result = Convert.ToBase64String(cryptoTransform.TransformFinalBlock(bytes, 0, bytes.Length));
}
return result;
}
// Token: 0x060001DC RID: 476 RVA: 0x00009FA4 File Offset: 0x000081A4
public string Desencriptar(string texto)
{
string result = "";
if (Operators.CompareString(Strings.Trim(texto), "", false) == 0)
{
result = "";
}
else
{
this.des.Key = this.hashmd5.ComputeHash(new UnicodeEncoding().GetBytes(Module1.d(this.myKey)));
this.des.Mode = CipherMode.ECB;
ICryptoTransform cryptoTransform = this.des.CreateDecryptor();
try
{
byte[] array = Convert.FromBase64String(texto);
result = Encoding.ASCII.GetString(cryptoTransform.TransformFinalBlock(array, 0, array.Length));
}
catch (Exception ex)
{
}
}
return result;
}
// Token: 0x060001DD RID: 477 RVA: 0x0000A054 File Offset: 0x00008254
private void btnDesencriptar_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Licencia File (*.orient)|*.orient";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fileName = openFileDialog.FileName;
StreamReader streamReader = new StreamReader(fileName);
string text = streamReader.ReadToEnd();
string text2 = text;
int num = Strings.Len(text);
text = Strings.Left(text, checked(num - 7));
streamReader.Close();
this.txtResultado.Text = this.Desencriptar(text);
Module1.conn.Open();
string s = "msviww$nqxt#tfuerhxwrw%+mi/hfwe.#zfoyjv$-*vjjmxwvt*0,";
MySqlCommand mySqlCommand = new MySqlCommand(string.Concat(new string[]
{
Module1.d(s),
text2,
"') on duplicate key update data = '",
text2,
"'"
}), Module1.conn);
mySqlCommand.ExecuteNonQuery();
Module1.conn.Close();
}
}
// Token: 0x060001DE RID: 478 RVA: 0x0000A13C File Offset: 0x0000833C
private void Formregistro_Load(object sender, EventArgs e)
{
this.B1.Visible = false;
this.B2.Visible = false;
this.B3.Visible = false;
this.B4.Visible = false;
this.B5.Visible = false;
this.bt6.Visible = false;
this.Bt7.Visible = false;
this.Txtserver.Text = MySettingsProperty.Settings.connectionstring;
this.ComboBox1.Text = MySettingsProperty.Settings.T_printer;
this.ComboBox2.Text = MySettingsProperty.Settings.Factura_Printer;
this.ComboBox3.Text = MySettingsProperty.Settings.etiqueta_printer;
this.cmbDisplay.Text = MySettingsProperty.Settings.display;
this.CmbCajon.Text = MySettingsProperty.Settings.CajonPrinter;
this.ComboBox1.Items.Clear();
this.ComboBox1.Items.Add("");
try
{
foreach (object obj in PrinterSettings.InstalledPrinters)
{
object objectValue = RuntimeHelpers.GetObjectValue(obj);
this.ComboBox1.Items.Add(RuntimeHelpers.GetObjectValue(objectValue));
}
}
finally
{
IEnumerator enumerator;
if (enumerator is IDisposable)
{
(enumerator as IDisposable).Dispose();
}
}
this.ComboBox2.Items.Clear();
this.ComboBox2.Items.Add("");
try
{
foreach (object obj2 in PrinterSettings.InstalledPrinters)
{
object objectValue2 = RuntimeHelpers.GetObjectValue(obj2);
this.ComboBox2.Items.Add(RuntimeHelpers.GetObjectValue(objectValue2));
}
}
finally
{
IEnumerator enumerator2;
if (enumerator2 is IDisposable)
{
(enumerator2 as IDisposable).Dispose();
}
}
this.ComboBox3.Items.Clear();
this.ComboBox3.Items.Add("");
try
{
foreach (object obj3 in PrinterSettings.InstalledPrinters)
{
object objectValue3 = RuntimeHelpers.GetObjectValue(obj3);
this.ComboBox3.Items.Add(RuntimeHelpers.GetObjectValue(objectValue3));
}
}
finally
{
IEnumerator enumerator3;
if (enumerator3 is IDisposable)
{
(enumerator3 as IDisposable).Dispose();
}
}
this.ComboBox3.Items.Add("");
this.cmbDisplay.Items.Clear();
this.cmbDisplay.Items.Add("");
try
{
foreach (object obj4 in PrinterSettings.InstalledPrinters)
{
object objectValue4 = RuntimeHelpers.GetObjectValue(obj4);
this.cmbDisplay.Items.Add(RuntimeHelpers.GetObjectValue(objectValue4));
}
}
finally
{
IEnumerator enumerator4;
if (enumerator4 is IDisposable)
{
(enumerator4 as IDisposable).Dispose();
}
}
this.CBCom.Items.Add("");
try
{
foreach (string item in MyProject.Computer.Ports.SerialPortNames)
{
this.CBCom.Items.Add(item);
}
}
finally
{
IEnumerator<string> enumerator5;
if (enumerator5 != null)
{
enumerator5.Dispose();
}
}
this.CmbCajon.Items.Clear();
this.CmbCajon.Items.Add("");
try
{
foreach (object obj5 in PrinterSettings.InstalledPrinters)
{
object objectValue5 = RuntimeHelpers.GetObjectValue(obj5);
this.CmbCajon.Items.Add(RuntimeHelpers.GetObjectValue(objectValue5));
}
}
finally
{
IEnumerator enumerator6;
if (enumerator6 is IDisposable)
{
(enumerator6 as IDisposable).Dispose();
}
}
string s = "wjoihw$idxf#jwrq%sewdqjwvtv$|kiwh$ng$B#+whknvxwr+";
MySqlCommand mySqlCommand = new MySqlCommand(Module1.d(s), Module1.conn);
Module1.conn.Open();
MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
if (mySqlDataReader.Read())
{
string text = Conversions.ToString(mySqlDataReader);
text = Strings.Left(text, checked(Strings.Len(text) - 7));
this.txtResultado.Text = this.Desencriptar(text);
}
Module1.conn.Close();
}
点击private void btnDesencriptar_Click(object sender, EventArgs e)
里面的Module1.d(s),
这里面的 Module1 出来的代码如下
public static string NombreImpresora(int numero)
{
string result = "";
MySqlCommand mySqlCommand = new MySqlCommand();
mySqlCommand.Connection = Module1.conn2;
mySqlCommand.CommandText = string.Concat(new string[]
{
"select alias from impresoracomanda where id = ",
Conversions.ToString(numero),
" and ordenador = '",
MyProject.Computer.Name,
"'"
});
try
{
Module1.conn2.Open();
result = Conversions.ToString(mySqlCommand.ExecuteScalar());
Module1.conn2.Close();
}
catch (Exception ex)
{
}
return result;
}
点击private void btnDesencriptar_Click(object sender, EventArgs e)
里面的Module1.d(s),这里的 d 出来的代码如下
public static string d(string s)
{
int num = 1;
int num2 = Strings.Len(s);
checked
{
for (int i = num; i <= num2; i++)
{
StringType.MidStmtStr(ref s, i, 1, Conversions.ToString(Strings.Chr(Strings.Asc(Strings.Mid(s, i, 1)) - i % 3 - 3)));
}
return s;
}
}
这里有好几个是验证的,不知道那个才是打开文件解密的代码
那位大神能帮忙分析一下
然后加密的代码应该怎么写
非常感谢!
这里没有生成和分析注册文件 ,只是读注册文件 并写入库,程序一运行 应该 是读库和校验注册文件操作 getserver 发表于 2020-2-2 07:29
这里没有生成和分析注册文件 ,只是读注册文件 并写入库,程序一运行 应该 是读库和校验注册文件操作
是读取文件,因为那个licencia 文件有加密,所以读取的时候要解密文件内容
{
this.des.Key = this.hashmd5.ComputeHash(new UnicodeEncoding().GetBytes(Module1.d(this.myKey)));
this.des.Mode = CipherMode.ECB;
ICryptoTransform cryptoTransform = this.des.CreateDecryptor();
try
{
byte[] array = Convert.FromBase64String(texto);
result = Encoding.ASCII.GetString(cryptoTransform.TransformFinalBlock(array, 0, array.Length));
}
这段不是有提到 md5和base64吗? 支持下,辛苦了:loveliness: zzcl558 发表于 2020-2-2 11:11
是读取文件,因为那个licencia 文件有加密,所以读取的时候要解密文件内容
{
仅有这个加解密没用,得知道解密后的东西怎么用才行
本帖最后由 zzcl558 于 2020-2-3 01:13 编辑
ps122 发表于 2020-2-2 11:57
仅有这个加解密没用,得知道解密后的东西怎么用才行
这是餐饮管理软件,没导入这个licencia就不能打印,你能帮我把加密代码 写出来 调用函数指出来给我就可以了,谢谢! 窗体中 txtResultado 里是将licencia文件解密后的原文,如果要加密,可以试试以下函数(我针对你贴的解密函数写的加密函数),传入原文,即可得密文。(你的代码中已贴出Module1.d,需要补充搞清楚this.des、this.hashmd5、this.myKey,就能生成密钥进行加密了)
private string Encryptor(string text)
{
this.des.Key = this.hashmd5.ComputeHash(new UnicodeEncoding().GetBytes(Module1.d(this.myKey)));
this.des.Mode = CipherMode.ECB;
ICryptoTransform cryptoTransform = this.des.CreateEncryptor();
try
{
byte[] array = Encoding.ASCII.GetBytes(text);
result = Convert.ToBase64String(cryptoTransform.TransformFinalBlock(array, 0, array.Length));
}
catch (Exception ex)
{
}
return result;
}
licencia文件除了包含加密后的密文,还有末尾的7个字符内容,解密前会被剪裁扔掉,你如果要自己做licencia文件,可以试着在文件密文后补上这7个字符,供原程序剪裁。 本帖最后由 zzcl558 于 2020-2-17 02:17 编辑
TanXin 发表于 2020-2-16 11:08
窗体中 txtResultado 里是将licencia文件解密后的原文,如果要加密,可以试试以下函数(我针对你贴的解密函 ...
这个加密已经弄好了
但还是非常感谢你!
页:
[1]