使用Xenocode加壳混淆后,无法“自杀覆盖”的自动更新
2012-02-18 17:29
435 查看
这个难题可是整整搞了我2天时候。
直至目前,才算有一个解决方案。
经过 Xenocode 的 WinForm 程序,如果你想实现一键式自动更新(就是不需要客户点一下点一下),那是相当困难的。
原因是 Xenocode 不但混淆了代码,还进行“加壳”保护了!至于什么是加壳,我个人理解是:在一个程序里运行另外一个程序(没有看过相关的知识,见笑了)。
我来说说我的自动升级构思:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = Application.StartupPath;
info.FileName = "AutoUpdater.exe";
info.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\"",
Process.GetCurrentProcess().Id,
StaticModel.GetServerUrl() + versionAndFilename[1],
versionAndFilename[2]);
// ProgramEx.Mutex.TryDispose();
info.UseShellExecute = false;
Process.Start(info);
Application.ExitThread();
而 AutoUpdater.exe 很简单,到指定网址下载一个 rar,删除当前文件夹里的所有文件并解压。
这里涉及到一个问题:如果不使用混淆加壳,这一段代码,是完全行得通的。
可是一旦保护了,问题就来了,使用 Process.Start 后仍处于Xenocode 加壳进程中。
通俗的说:在加壳混淆后的程序(程序A)里,调用了任何外部程序(程序B)以后,都无法删除源程序(程序A)。
这可忙得我焦头烂额。到网上搜罗无数办法,包括是CreateProcess API,什么拷贝到临时文件,然后再返回来,等等等等……神啊,救救我吧!
其实缓解方案还是有的,就是雷同 ClickOnce ,建立一个“版本文件夹”。但是这个方法比较麻烦,因为我在安装包的时候,就已经创建桌面快捷键,如此一改,将会涉及到更多的问题。
琢磨了2天,直到今晚,无意中想起,Xenocode加壳了,我自己就不能“加壳”?
说干就干,程序很简单,建立一个新的WinForm应用程序:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Process p = new Process();
p.StartInfo.FileName = "AthleticPos2011.Views.exe";
p.StartInfo.Arguments = "1";
p.Start();
p.WaitForExit();
if (File.Exists("update.ath"))
{
Thread.Sleep(1000);
var args = File.ReadAllText("update.ath");
File.Delete("update.ath");
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = Application.StartupPath;
info.FileName = "AutoUpdater.exe";
info.Arguments = args;
info.UseShellExecute = false;
Process.Start(info);
Application.ExitThread();
}
}
而源程序的发现需要更新后的操作变成如下:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->File.WriteAllText("update.ath", string.Format("\"{0}\" \"{1}\" \"{2}\"",
Process.GetCurrentProcess().Id,
StaticModel.GetServerUrl() + versionAndFilename[1],
versionAndFilename[2]));
this.Close();
// ProgramEx.Mutex.TryDispose();
//ProcessStartInfo info = new ProcessStartInfo();
//info.WorkingDirectory = Application.StartupPath;
//info.FileName = "AutoUpdater.exe";
//info.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\"",
// Process.GetCurrentProcess().Id,
// StaticModel.GetServerUrl() + versionAndFilename[1],
// versionAndFilename[2]);
//// ProgramEx.Mutex.TryDispose();
//info.UseShellExecute = false;
//Process.Start(info);
//Application.ExitThread();
好了!!搞定!明天优化一下!大家早点休息吧!
直至目前,才算有一个解决方案。
经过 Xenocode 的 WinForm 程序,如果你想实现一键式自动更新(就是不需要客户点一下点一下),那是相当困难的。
原因是 Xenocode 不但混淆了代码,还进行“加壳”保护了!至于什么是加壳,我个人理解是:在一个程序里运行另外一个程序(没有看过相关的知识,见笑了)。
我来说说我的自动升级构思:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = Application.StartupPath;
info.FileName = "AutoUpdater.exe";
info.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\"",
Process.GetCurrentProcess().Id,
StaticModel.GetServerUrl() + versionAndFilename[1],
versionAndFilename[2]);
// ProgramEx.Mutex.TryDispose();
info.UseShellExecute = false;
Process.Start(info);
Application.ExitThread();
而 AutoUpdater.exe 很简单,到指定网址下载一个 rar,删除当前文件夹里的所有文件并解压。
这里涉及到一个问题:如果不使用混淆加壳,这一段代码,是完全行得通的。
可是一旦保护了,问题就来了,使用 Process.Start 后仍处于Xenocode 加壳进程中。
通俗的说:在加壳混淆后的程序(程序A)里,调用了任何外部程序(程序B)以后,都无法删除源程序(程序A)。
这可忙得我焦头烂额。到网上搜罗无数办法,包括是CreateProcess API,什么拷贝到临时文件,然后再返回来,等等等等……神啊,救救我吧!
其实缓解方案还是有的,就是雷同 ClickOnce ,建立一个“版本文件夹”。但是这个方法比较麻烦,因为我在安装包的时候,就已经创建桌面快捷键,如此一改,将会涉及到更多的问题。
琢磨了2天,直到今晚,无意中想起,Xenocode加壳了,我自己就不能“加壳”?
说干就干,程序很简单,建立一个新的WinForm应用程序:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Process p = new Process();
p.StartInfo.FileName = "AthleticPos2011.Views.exe";
p.StartInfo.Arguments = "1";
p.Start();
p.WaitForExit();
if (File.Exists("update.ath"))
{
Thread.Sleep(1000);
var args = File.ReadAllText("update.ath");
File.Delete("update.ath");
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = Application.StartupPath;
info.FileName = "AutoUpdater.exe";
info.Arguments = args;
info.UseShellExecute = false;
Process.Start(info);
Application.ExitThread();
}
}
而源程序的发现需要更新后的操作变成如下:
代码
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->File.WriteAllText("update.ath", string.Format("\"{0}\" \"{1}\" \"{2}\"",
Process.GetCurrentProcess().Id,
StaticModel.GetServerUrl() + versionAndFilename[1],
versionAndFilename[2]));
this.Close();
// ProgramEx.Mutex.TryDispose();
//ProcessStartInfo info = new ProcessStartInfo();
//info.WorkingDirectory = Application.StartupPath;
//info.FileName = "AutoUpdater.exe";
//info.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\"",
// Process.GetCurrentProcess().Id,
// StaticModel.GetServerUrl() + versionAndFilename[1],
// versionAndFilename[2]);
//// ProgramEx.Mutex.TryDispose();
//info.UseShellExecute = false;
//Process.Start(info);
//Application.ExitThread();
好了!!搞定!明天优化一下!大家早点休息吧!
相关文章推荐
- 记:使用Xenocode加壳混淆后,无法“自杀覆盖”的自动更新
- 使用xenocode代码混淆加密的操作步骤
- C# 使用xenocode混淆加密
- Win8.1无法安装KB2825630补丁使用自动更新也失败
- WordPress无法使用自动更新,提示填写FTP信息的解决方法。
- C# 使用xenocode混淆加密【转】
- 如何使用 Xenocode 、 Dotfuscator 混淆asp.net程序??
- Xenocode Postbuild 2010 for .NET 混淆工具的详细使用步骤【转】
- 【转载】之 破解 (【原创】Xenocode Postbuild 2009 加壳破解 (不断更新中...))
- Xenocode Postbuild 2010 for .NET 混淆工具的详细使用步骤
- Xenocode Postbuild 2007 Evaluation 对DLL混淆的使用方法
- C#混淆 xenocode使用说明
- Xenocode Postbuild 2010 for .NET 混淆工具的详细使用步骤
- C#混淆 xenocode使用说明
- 使用xenocode代码混淆加密的操作步骤
- Outlook异常之:无法使用邮件答录机(自动回复)功能
- Ubuntu 16.04使用“从互联网自动获取”时间无法写入硬件BIOS的奇怪问题
- 自使用移动端rem适配--并且vscode-px自动转化成rem
- 一小段JS代码实现静态页面点击数的自动更新(使用AJAX)
- Android混淆打包后openFileChooser无法使用找不到的解决方法