通过A程序进行配置然后生成B程序
在易语言中使用 子字节集替换即可实现
但是易语言本身就容易被杀毒软件误杀 所以不管你写什么程序 生成后都是风险软件
因为需要 c#中写的软件也需要相似功能 查询一些资料后
在C#中经过测试也可以实现类似功能
如图所示 A是主程序 B是子程序 C是生成后的子程序 执行效果 A读取B程序到字节 然后替换B字节的变量 最终生成C 文件
效果如图
点击 button1 开始读取B程序替换生成
B程序执行效果如图 打开软件即弹出变量内容 确定后程序销毁
C程序执行结果
下面是 测试源码 首先是 B程序 首先变量需要通过资源进行设置 内置变量无法读取
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestFormsApp_B
{
public partial class Form1 : Form
{
//内置变量 经测试无法读取真实结果
string testsn = "☆☆☆☆☆☆☆☆☆☆";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//资源变量 通过资源进行变量设置或者文件 最终都可以进行替换
MessageBox.Show(Properties.Resources.变量);
MessageBox.Show(Properties.Resources.String1);
Close();
}
}
}
B程序 资源变量 文本程序 或者 变量都可以进行替换
如下 是 A程序 代码
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestFormsApp_A
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//寻找已知的变量
byte[] pattern = Encoding.UTF8.GetBytes("0000000000");
string patval = "";
for (int i = 0; i < pattern.Length; i++)
{
patval += pattern[i].ToString("x2").ToUpper() + "";
}
//替换为想要的变量
byte[] maragen = Encoding.UTF8.GetBytes("ababababcc");
string marval = "";
for (int i = 0; i < maragen.Length; i++)
{
marval += maragen[i].ToString("x2").ToUpper() + "";
}
//子程序读取
FileStream fs = new FileStream("TestFormsApp_B.exe", FileMode.Open);
byte[] array = new byte[fs.Length];
fs.Read(array, 0, array.Length);
fs.Close();
string artval = "";
for (int i = 0; i < array.Length; i++)
{
artval += array[i].ToString("x2").ToUpper() + "";
}
//替换文本字节的变量
if(artval.IndexOf(patval) > -1)
{
artval = artval.Replace(patval, marval);
}
//文本字节转为字节
byte[] inputByteArray = new byte[artval.Length / 2];
for (int x = 0; x < artval.Length / 2; x++)
{
int i = (Convert.ToInt32(artval.Substring(x * 2, 2), 16));
inputByteArray[x] = (byte)i;
}
//输出文档
FileStream writeStream = File.Open("TestFormsApp_C.exe", FileMode.Create);
writeStream.Write(inputByteArray, 0, inputByteArray.Length);
writeStream.Close();
MessageBox.Show("导出完毕");
}
}
}
代码完毕
如上即可实现最基本的 子程序变量替换
当然最终执行肯定不能就这么设置应用
因为B程序不加密的情况下通过文本编辑器也可以看到变量
如图 就是资源变量内容
这么明文的变量肯定不是你想要的
那么 加密 混淆 以及 转码都是必要的
另一点就是 A程序下崽功能 理论上是要把B程序放置A程序的资源库的
其实样本程序缺点是很明显的 不是通过字节进行对比替换的 而是转为文本替换的
正常程序肯定会超过1w字符的长度 所以此方法只是演示
实际应用中肯定要字节流进行对比替换 ~~