c#實現的破解程式--針對軟體使用時間限制
自己搗騰了一天,弄了一個修改軟體過期的小程式,主要是自己有幾款有時間限制的軟體,每次改時間很麻煩。有了這個程式就可以一勞永逸了。
前提:只適用於修改作業系統時間後,程式就能夠正常使用的那種軟體。如Lingoes,reflector,這兩款我測試是可以的。
在Win7下必需用管理員的方式啟動。
思路很簡單:
1,修改作業系統時間到軟體過期前。
2,啟動軟體。
3,改回作業系統時間。
程式類似於網上的一款好像叫RunAsDate的軟體,沒用過,只大概記得它的介面,決定自己實現類似的功能。
該程式的亮點是
1,可以生成破解程式的快捷方式到桌面上,生成的快捷方式圖示和原來的程式一樣(有輕度的失真),生成這個快捷方式後,就不用這個破解程式了,這個才是我要的一勞永逸的東西。
2,對原來的程式exe檔案做了備份,避免因破解不成功,軟體自身因過期啟動自我銷燬的情況。如:Refletor就是其中一例。
先看一張程式介面圖:
基本操作:
破解啟動:介面功能很簡單,一看就會用。有效時間一般不知道有效時間,不要指定。選中待破解的程式路徑,點“破解啟動”按鈕,就可以啟動程式,但是這種方式只能單次啟動,也就是每次都要啟動這個破解程式。
快捷方式生成:在“破解啟動”成功的前提下,生成的快捷方式才可用。這種方式可以一勞永逸的生成桌面圖示,下次也不用啟動這個破解程式了。
下面這兩個是生成的快捷方式圖示:
快捷方式名稱欄,可以輸入名稱來生成快捷方式。
如下圖:
點快捷方式生成後:
不錯,以後我就可以在桌面上直接啟動這些過期的軟體了。
下面貼出主要的程式碼程式:
Win32API
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Runtime.InteropServices;
- namespace ApplicationActive
- {
- [StructLayout(LayoutKind.Sequential)]
- public struct SYSTEMTIME
- {
- public ushort wYear;
- public ushort wMonth;
- public ushort wDayOfWeek;
- public ushort wDay;
- public ushort wHour;
- public ushort wMinute;
- public ushort wSecond;
- public ushort wMilliseconds;
- public void FromDateTime(DateTime dateTime)
- {
- wYear = (ushort)dateTime.Year;
- wMonth = (ushort)dateTime.Month;
- wDayOfWeek = (ushort)dateTime.DayOfWeek;
- wDay = (ushort)dateTime.Day;
- wHour = (ushort)dateTime.Hour;
- wMinute = (ushort)dateTime.Minute;
- wSecond = (ushort)dateTime.Second;
- wMilliseconds = (ushort)dateTime.Millisecond;
- }
- public DateTime ToDateTime()
- {
- return new DateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond);
- }
- }
- [Flags]
- enum SHGFI : int
- {
- /// <summary>get icon</summary>
- Icon = 0x000000100,
- /// <summary>get display name</summary>
- DisplayName = 0x000000200,
- /// <summary>get type name</summary>
- TypeName = 0x000000400,
- /// <summary>get attributes</summary>
- Attributes = 0x000000800,
- /// <summary>get icon location</summary>
- IconLocation = 0x000001000,
- /// <summary>return exe type</summary>
- ExeType = 0x000002000,
- /// <summary>get system icon index</summary>
- SysIconIndex = 0x000004000,
- /// <summary>put a link overlay on icon</summary>
- LinkOverlay = 0x000008000,
- /// <summary>show icon in selected state</summary>
- Selected = 0x000010000,
- /// <summary>get only specified attributes</summary>
- Attr_Specified = 0x000020000,
- /// <summary>get large icon</summary>
- LargeIcon = 0x000000000,
- /// <summary>get small icon</summary>
- SmallIcon = 0x000000001,
- /// <summary>get open icon</summary>
- OpenIcon = 0x000000002,
- /// <summary>get shell size icon</summary>
- ShellIconSize = 0x000000004,
- /// <summary>pszPath is a pidl</summary>
- PIDL = 0x000000008,
- /// <summary>use passed dwFileAttribute</summary>
- UseFileAttributes = 0x000000010,
- /// <summary>apply the appropriate overlays</summary>
- AddOverlays = 0x000000020,
- /// <summary>Get the index of the overlay in the upper 8 bits of the iIcon</summary>
- OverlayIndex = 0x000000040,
- }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- public struct SHFILEINFO
- {
- public SHFILEINFO(bool b)
- {
- hIcon = IntPtr.Zero;
- iIcon = 0;
- dwAttributes = 0;
- szDisplayName = "";
- szTypeName = "";
- }
- public IntPtr hIcon;
- public int iIcon;
- public uint dwAttributes;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
- public string szDisplayName;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
- public string szTypeName;
- };
- class Win32API
- {
- [DllImport("user32.dll", EntryPoint = "FindWindow")]
- public static extern IntPtr FindWindows(string lpClassName, string lpWindowName);
- [DllImport("kernel32.dll")]
- public static extern bool SetLocalTime(ref SYSTEMTIME Time);
- [DllImport("shell32.dll", CharSet = CharSet.Auto)]
- public static extern int SHGetFileInfo(
- string pszPath,
- int dwFileAttributes,
- out SHFILEINFO psfi,
- uint cbfileInfo,
- SHGFI uFlags);
- }
- }
建立圖示,備份,啟動用的共通類
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using System.Text;
- using System.Drawing;
- using System.Runtime.InteropServices;
- using IWshRuntimeLibrary;
- using System.IO;
- using System.Diagnostics;
- namespace ApplicationActive
- {
- class CommonFunction
- {
- public enum StartMode
- {
- WinForm,
- ShortCut
- }
- public static readonly string CRACK_FOLDER_NAME = "xsw_Crack";
- public static readonly string CONFIG_NAME = "xsw_Crack.xml";
- public static StartMode Mode = StartMode.WinForm;
- private static Icon GetIcon(string strPath, bool bSmall)
- {
- SHFILEINFO info = new SHFILEINFO(true);
- int cbFileInfo = Marshal.SizeOf(info);
- SHGFI flags;
- if (bSmall)
- flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes;
- else
- flags = SHGFI.Icon | SHGFI.LargeIcon;
- Win32API.SHGetFileInfo(strPath, 256, out info, (uint)cbFileInfo, flags);
- return Icon.FromHandle(info.hIcon);
- }
- public static string GetCrackFolderPath(string strPath)
- {
- string dirName = Path.GetDirectoryName(strPath);
- dirName += "\\" + CRACK_FOLDER_NAME;
- if (!Directory.Exists(dirName))
- {
- Directory.CreateDirectory(dirName);
- }
- return dirName;
- }
- public static void CreateShortCut(string strPath, string shortcutName)
- {
- string shortcutPath;
- string shortcutIconLocation;
- string crackFolder;
- crackFolder = GetCrackFolderPath(strPath);
- shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + shortcutName + ".lnk";
- shortcutIconLocation = crackFolder + "\\" + shortcutName + ".ico";
- //create Icon
- Icon shortcutIcon = GetIcon(strPath, false);
- FileStream fs = new FileStream(shortcutIconLocation, FileMode.OpenOrCreate, FileAccess.Write);
- shortcutIcon.Save(fs);
- fs.Close();
- //copy crack program file
- string crackFileName = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Name;
- if (!System.IO.File.Exists(crackFolder + "\\" + crackFileName))
- {
- System.IO.File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location, crackFolder + "\\" + crackFileName, true);
- }
- System.IO.File.Copy(Application.StartupPath + "\\" + CommonFunction.CONFIG_NAME, crackFolder + "\\" + CommonFunction.CONFIG_NAME,true);
- BackupTargetFile(strPath);
- WshShell shell = new WshShell();
- IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);
- shortcut.Arguments = "\"" + strPath + "\"";
- shortcut.TargetPath = crackFolder + "\\" + crackFileName;
- shortcut.WorkingDirectory = crackFolder;
- shortcut.WindowStyle = 1; //normal
- shortcut.IconLocation = shortcutIconLocation;
- shortcut.Save();
- }
- public static void BackupTargetFile(string strPath)
- {
- string strFileTo = GetCrackFolderPath(strPath) +"\\" + new FileInfo(strPath).Name;
- if (!System.IO.File.Exists(strFileTo))
- {
- System.IO.File.Copy(strPath, strFileTo);
- }
- }
- public static void StartProgram(string path, DateTime? settingDate)
- {
- System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
- DateTime NowDate = DateTime.Now;
- stopWatch.Start();
- //back up EXE file
- BackupTargetFile(path);
- FileInfo fileInfo = new System.IO.FileInfo(path);
- DateTime validDateTime = fileInfo.CreationTime > fileInfo.LastWriteTime ? fileInfo.LastWriteTime : fileInfo.CreationTime;
- if (settingDate.HasValue)
- {
- validDateTime = settingDate.Value;
- }
- //update date
- SYSTEMTIME st = new SYSTEMTIME();
- st.FromDateTime(validDateTime);
- Win32API.SetLocalTime(ref st);
- System.Threading.Thread.Sleep(1000);
- try
- {
- //start program
- ProcessStartInfo PstartInfoExe = new ProcessStartInfo();
- PstartInfoExe.FileName = path;
- PstartInfoExe.WindowStyle = ProcessWindowStyle.Minimized;
- PstartInfoExe.UseShellExecute = false;
- Process p = new Process();
- p.StartInfo = PstartInfoExe;
- p.Start();
- p.WaitForInputIdle(10000);
- System.Threading.Thread.Sleep(2000);
- if (CommonFunction.Mode == StartMode.WinForm)
- {
- ConfigManager.GetInstance().FilePath = path;
- if (settingDate.HasValue)
- {
- ConfigManager.GetInstance().ExpireDate = validDateTime;
- }
- ConfigManager.GetInstance().Save();
- }
- }
- catch
- {
- }
- finally
- {
- //update to old date
- stopWatch.Stop();
- NowDate.Add(stopWatch.Elapsed);
- st.FromDateTime(NowDate);
- Win32API.SetLocalTime(ref st);
- }
- }
- }
- }
xml儲存用
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.IO;
- using System.Xml;
- namespace ApplicationActive
- {
- class ConfigManager
- {
- private static ConfigManager instance = null;
- public static ConfigManager GetInstance()
- {
- if (instance == null)
- instance = new ConfigManager();
- return instance;
- }
- private DateTime? _expireDate = null;
- public DateTime? ExpireDate
- {
- get { return _expireDate; }
- set { _expireDate = value; }
- }
- private string _filePath = string.Empty;
- public string FilePath
- {
- get { return _filePath; }
- set { _filePath = value; }
- }
- private ConfigManager()
- {
- GetXml();
- }
- public void Save()
- {
- string xmlPath = Application.StartupPath + "\\" + CommonFunction.CONFIG_NAME;
- if (this._filePath == string.Empty)
- {
- return;
- }
- XmlWriter xmlWriter = XmlWriter.Create(xmlPath);
- xmlWriter.WriteStartElement("Root");
- xmlWriter.WriteElementString("ExePath", _filePath);
- if (_expireDate.HasValue)
- {
- xmlWriter.WriteElementString("ExpireDate", this._expireDate.Value.ToString("yyyy/MM/dd HH:mm:ss"));
- }
- xmlWriter.WriteEndElement();
- xmlWriter.Close();
- }
- public void GetXml()
- {
- string xmlPath = Application.StartupPath + "\\" + CommonFunction.CONFIG_NAME; ;
- if (!System.IO.File.Exists(xmlPath))
- {
- return;
- }
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.Load(xmlPath);
- XmlNode xmlNode = xmlDoc.SelectSingleNode("Root");
- for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
- {
- if (xmlNode.ChildNodes[i].Name == "ExePath")
- {
- this._filePath = xmlNode.ChildNodes[i].InnerText;
- }
- if (xmlNode.ChildNodes[i].Name == "ExpireDate")
- {
- try
- {
- this._expireDate = Convert.ToDateTime(xmlNode.ChildNodes[i].InnerText);
- }
- catch
- {
- }
- }
- }
- }
- }
- }
Form 類
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.IO;
- using System.Xml;
- using System.Runtime.InteropServices;
- using IWshRuntimeLibrary;
- namespace ApplicationActive
- {
- public partial class FrmSetting : Form
- {
- public FrmSetting()
- {
- InitializeComponent();
- }
- private void FrmSetting_Load(object sender, EventArgs e)
- {
- if (ConfigManager.GetInstance().FilePath != string.Empty)
- {
- this.tbx_pgmPath.Text = ConfigManager.GetInstance().FilePath;
- }
- if (ConfigManager.GetInstance().ExpireDate.HasValue)
- {
- this.chkExpire.Checked = true;
- this.dtpExpireDate.Value = ConfigManager.GetInstance().ExpireDate.Value;
- }
- }
- private void btnFile_Click(object sender, EventArgs e)
- {
- OpenFileDialog fileDialog = new OpenFileDialog();
- fileDialog.Filter = "file (*.exe)|*.exe";
- if (fileDialog.ShowDialog() == DialogResult.OK)
- {
- this.tbx_pgmPath.Text = fileDialog.FileName;
- }
- }
- private void btn_startPgm_Click(object sender, EventArgs e)
- {
- if (InputCheck() == false)
- return;
- if (this.dtpExpireDate.Enabled)
- {
- CommonFunction.StartProgram(this.tbx_pgmPath.Text, this.dtpExpireDate.Value);
- }
- else
- {
- CommonFunction.StartProgram(this.tbx_pgmPath.Text, null);
- }
- }
- private void btn_CreateIcon_Click(object sender, EventArgs e)
- {
- if (InputCheck() == false)
- return;
- string shortcutName = "";
- if (this.tbx_IconName.Text == string.Empty)
- {
- shortcutName = new System.IO.FileInfo(this.tbx_pgmPath.Text).Name.Substring(0, new System.IO.FileInfo(this.tbx_pgmPath.Text).Name.Length - 4);
- }
- else
- {
- shortcutName = this.tbx_IconName.Text;
- }
- try
- {
- CommonFunction.CreateShortCut(this.tbx_pgmPath.Text, shortcutName);
- MessageBox.Show("生成成功!",this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- catch
- {
- MessageBox.Show("生成失敗!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void chkExpire_CheckedChanged(object sender, EventArgs e)
- {
- if (chkExpire.Checked)
- {
- this.dtpExpireDate.Enabled = true;
- }
- else
- {
- this.dtpExpireDate.Enabled = false;
- }
- }
- private void btn_Close_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private bool InputCheck()
- {
- string filePath = this.tbx_pgmPath.Text;
- if (filePath == "")
- {
- MessageBox.Show("file is not seleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false ;
- }
- if (!System.IO.File.Exists(filePath))
- {
- string backupFile = System.IO.Path.GetDirectoryName(filePath) + "\\" + CommonFunction.CRACK_FOLDER_NAME + "\\" + filePath.Substring(filePath.LastIndexOf("\\") + 1);
- if (System.IO.File.Exists(backupFile))
- {
- try
- {
- System.IO.File.Copy(backupFile, filePath);
- }
- catch
- {
- MessageBox.Show("file is not found!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
- return false ;
- }
- }
- else
- {
- MessageBox.Show("file is not found!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
- return false ;
- }
- }
- return true;
- }
- }
- }
program類
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- namespace ApplicationActive
- {
- static class Program
- {
- /// <summary>
- /// アプリケーションのメイン エントリ ポイントです。
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- ConfigManager.GetInstance().GetXml();
- if (args.Length > 0)
- {
- CommonFunction.Mode = CommonFunction.StartMode.ShortCut;
- string filePath = args[0];
- if (!System.IO.File.Exists(filePath))
- {
- string backupFile = System.IO.Path.GetDirectoryName(filePath) + "\\" + CommonFunction.CRACK_FOLDER_NAME + "\\" + filePath.Substring(filePath.LastIndexOf("\\") + 1);
- if (System.IO.File.Exists(backupFile))
- {
- try
- {
- System.IO.File.Copy(backupFile, filePath);
- }
- catch
- {
- MessageBox.Show("file:<" + filePath + ">" + " not found!", "error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- else
- {
- MessageBox.Show("file:<" + filePath + ">" + " not found!", "error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- CommonFunction.StartProgram(filePath, ConfigManager.GetInstance().ExpireDate);
- }
- else
- {
- CommonFunction.Mode = CommonFunction.StartMode.WinForm;
- Application.Run(new FrmSetting());
- }
- }
- }
- }
以上程式是用vs2005,在xp環境下編譯的,在win7上轉化成vs2008後發現不能正常執行,其原因是win7的UAC賬戶控制,必需要以管理員的方式啟動才能執行,於是在vs2008中加入一個app.manifest檔案,配置修改如下:
- <?xml version="1.0" encoding="utf-8"?>
- <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
- <security>
- <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
- <!-- UAC 清單選項
- 如果希望更改 Windows 使用者帳戶控制級別,請用以下節點之一替換
- requestedExecutionLevel 節點。
- <requestedExecutionLevel level="asInvoker" uiAccess="false" />
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
- <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
- 如果您希望利用檔案和登錄檔虛擬化提供
- 向後相容性,請刪除 requestedExecutionLevel 節點。
- -->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
- </requestedPrivileges>
- </security>
- </trustInfo>
- </asmv1:assembly>
關鍵是這句:<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
重新編譯後在Win7下就能正常執行了。
轉載請註明出處:http://blog.csdn.net/xiashengwang/article/details/7096715
相關文章
- 一個典型的時間限制軟體的破解 (4千字)
- 用VB“破解”有時間限制的程式 (轉)
- xp下軟體限制策略限制軟體以及破解方法
- windbg的時間旅行實現對 C# 程式的終極除錯C#除錯
- 使用 Element+vue實現開始時間結束時間限制Vue
- C#實現無法破解的軟體註冊碼演算法C#演算法
- C# 登錄檔法-限制軟體使用次數C#
- 破解 Windows 2000 RC3 的時間限制Windows
- VSFTP針對不同的使用者限制不同的速度FTP
- McAfee針對GandCrab勒索軟體的分析
- 轉貼:破解時間限制的老文章(一) (2千字)
- 轉貼:破解時間限制的老文章(二) (2千字)
- 巨好的俄羅斯方塊時間限制破解 (1千字)
- C#軟體開發例項.私人訂製自己的螢幕截圖工具(五)針對拖拽時閃爍卡頓現象的優化...C#優化
- Django 中介軟體實現使用者認證與IP頻率限制Django
- 軟體中關於使用IP的限制
- Dotfuscator針對C#程式碼混淆方法總結C#
- 用Axure實現對時間段的篩選
- 針對Excel表格檔案操作的程式設計實現 (轉)Excel程式設計
- 軟體設計深度挖掘(二)(僅針對windows平臺)實現雜談篇 (轉)Windows
- 針對資訊竊取惡意軟體AZORult的分析
- 微軟稱發現針對烏克蘭的破壞性惡意軟體微軟
- C#中實現窗體間傳值方法C#
- 在使用alter system switch log的時候無時間限制的等待
- 也談.Net中間語言——破解Delphi2CS行數和時間限制
- 暴力破解Paragon CD Emulator時間及功能限制 (7千字)Go
- 破解WorkgroupMail 的30天的時間限制(FCG作業)---高手莫入! (10千字)AI
- C#程式實現軟體開機自動啟動的兩種常用方法C#
- 針對雲服務的勒索軟體攻擊的未來
- 針對Linux和Windows使用者的新型多平臺惡意軟體LinuxWindows
- 能否通過軟體來實現顯示螢幕的視角限制?
- 請問怎麼限制軟體的使用期限?
- 軟體破解
- 直播軟體搭建,當前時間、既定時間後的時間及時間比較大小
- JS實現順時針列印陣列JS陣列
- ModelMaker CodeExplorer Expert 1.05 Demo時間限制破解 (32千字)
- 使用AIDL實現程式間的通訊AI
- c#針對文字檔案之StreamRead和StreamWriter出現的理由C#