[VB.NET]突破Disable按鈕的封鎖與限制
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]> VB.NETImports System.Runtime.InteropServices Public Class Form1 <DllImport(“user32.dll”)> _Private Shared Function ChildWindowFromPoint(ByVal hWndParent As IntPtr, ByVal Point As Point) As IntPtr End Function <DllImport(“user32.dll”, SetLastError:=True)> _Private Shared Function GetForegroundWindow() As IntPtr End Function <DllImport(“user32.dll”)> _Private Shared Function IsWindowEnabled(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function Declare Function EnableWindow Lib “user32” (ByVal hwnd As IntPtr, ByVal fEnable As Integer) As Integer <DllImport(“user32.dll”, SetLastError:=True)> _Private Shared Function ScreenToClient(ByVal hWnd As IntPtr, ByRef lpPoint As Point) As Boolean End Function Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim p As Point = MousePosition Dim hWnd, hWndChild As IntPtr hWnd = GetForegroundWindow() ScreenToClient(hWnd, p) hWndChild = ChildWindowFromPoint(hWnd, p) If Not IsWindowEnabled(hWndChild) Then EnableWindow(hWndChild, 1) End If End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged Timer1.Enabled = CheckBox1.Checked End SubEnd Class <![CDATA[
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]><![CDATA[
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]> 執行後我們把滑鼠移到Disable的按鈕上,按鈕就會被強制變回Enable狀態了。變回Enable的按鈕也變得可以按下與執行。 執行步驟Step1.開啟按鈕突破程式 Step2.開啟欲突破的程式 Step3.啟動按鈕突破功能 Step4.把滑鼠移到欲突破的按鈕上當滑鼠移到欲突破的Disable按鈕上,按鈕會被強制設回Enable。 P.S.上述範例對.NET程式的按鈕無效,請使用非.NET程式來測試。雖範例無法達到突破.NET按鈕,但這不代表.NET程式不需注意這問題。因為能突破.NET按鈕的工具確實存在(e.x. Enable.NET)。雖範例只能把Disable按鈕設為Enable,但其實運用同樣的概念也可以把隱藏的元件顯示出來。 Conclusion此篇的主旨不是要教程式員破解,而是要提醒設計員在程式的設計上不是只要把按鈕給Disable掉就安全了。還是要額外利用Code去判斷是否可以執行才是較為安全的作法,尤其是程式中重要的功能更是要加以防堵。