Code:
Public Class bypassclient
Public Enum ProcessAccessFlags As UInteger
All = &H1F0FFF
Terminate = &H1
CreateThread = &H2
VMOperation = &H8
VMRead = &H10
VMWrite = &H20
DupHandle = &H40
SetInformation = &H200
QueryInformation = &H400
Synchronize = &H100000
End Enum
<DllImport("kernel32.dll")> _
Private Shared Function OpenProcess(ByVal dwDesiredAccess As ProcessAccessFlags, _
<MarshalAs(UnmanagedType.Bool)> ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As Integer) As IntPtr
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function CloseHandle(ByVal hObject As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, <Out()> ByRef lpNumberOfBytesWritten As Int32) As Boolean
End Function
Public Declare Function GetProcAddress Lib "kernel32.dll" _
(ByVal hModule As IntPtr, ByVal procName As String) As IntPtr
<DllImport("kernel32.dll")> _
Public Shared Function GetModuleHandle(ByVal lpModuleName As String) As IntPtr
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function LoadLibrary(<MarshalAs(UnmanagedType.LPStr)> ByVal lpFileName As String) As IntPtr
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function FreeLibrary(ByVal hModule As IntPtr) As Boolean
End Function
Public Sub New()
End Sub
Public Function connect2IP(ByVal PID As Integer, ByVal IPAdd As String) As Integer
Dim ws2Handle As IntPtr = LoadLibrary("WS2_32.dll")
If ws2Handle = vbNull Then
FreeLibrary(ws2Handle)
Return 1
End If
Dim cHandle As IntPtr = OpenProcess(ProcessAccessFlags.VMOperation Or ProcessAccessFlags.VMRead Or ProcessAccessFlags.VMWrite Or _
ProcessAccessFlags.All, True, PID)
If cHandle = vbNull Then
FreeLibrary(ws2Handle)
Return 2
End If
Dim inet_addr As IntPtr = GetProcAddress(GetModuleHandle("WS2_32.dll"), "inet_addr")
If inet_addr = vbNull Then
FreeLibrary(ws2Handle)
Return 3
End If
Dim buffer() As Byte = {&HB8, &H0, &H0, &H0, &H0, &HC2, &H4, &H0, &H90, &H90}
Dim byteIPaddress() As Byte = IPAddress.Parse(IPAdd).GetAddressBytes()
System.Buffer.BlockCopy(byteIPaddress, 0, buffer, 1, byteIPaddress.Length)
Dim bytesWritten As Integer = 0
If Not WriteProcessMemory(cHandle, inet_addr, buffer, buffer.Length, bytesWritten) Then
FreeLibrary(ws2Handle)
Return 4
End If
CloseHandle(cHandle)
FreeLibrary(ws2Handle)
Return 0
End Function
End Class
But it will only work only on 32bits and I have no idea how to make it run in 64bits windows 7.