The Search Huts Articles Main Portal
 
Category Menu
Visual Basic
Search Engines
Javascript
Windows Tips
Photography
ASP
 RSS Feeds


Search in news :

Remote Administration Tool PART 1

Category »  Visual Basic
Posted By Guido on 24 March 2006
Comments   |   Print   |   Mail it
Remote Administration Tool PART 1

This article discusses about programming a remote administration utility using Winsock component in Visual Basic 6.

This is the first part of this series and it is for newbies.

This section helps you to build an utility to send messages from client to the server.

In the coming sections we will be discussing about programming advanced features(to the server like making it a FTP server or Telnet server etc…) to make it a perfect remote administration tool.

Coming back to the real part. Any remote administration utility will have two parts i.e., the server and the client.

The server resides a system and open a port (local port) on that system to communicate with the client.

The client connects to that port (remote port) on the remote system and communicates with it. If you have two systems connected to each other that would be great. But you can test this application even if you have a single system by running the server and connecting the client to your local IP i.e., 127.0.0.1.

First we will look to the server code. Start the Visual Basic 6.0 and switch to design view.

Now add a Winsock component and a text-box to the form and switch back to the code window.

Type the code below (it's self explanatory)

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) ‘when a client requests for a connection ‘end the current connection and ‘accept the new connection

If Winsock1.State <> sckClosed

Then

Winsock1.Close Winsock1.Accept requestID

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ‘when data arrives from a client

Dim data As String ‘declare a string variable data Winsock1.GetData data ‘get all the data to the variable data Text1.Text = data & vbCrLf & Text1.Text ‘display the arrived data to the text box End Sub Private Sub Form_Load() Winsock1.LocalPort = 3539 ‘open port 3539 on the system Winsock1.Listen ‘Listen at that port Form1.Caption = "Running at " & Winsock1.LocalIP ‘Changes the caption of the form

Text1.Text = "" ‘clears the text box

End Sub

That’s the end of server code.

Let’s look at the client code.

Start a new project and add a winsock control, two text boxes (rename them to txtip and txtmsg) and two command boxes (rename them to cmdsend and cmdconn).

Copy the following code to the code window.

Private Sub Form_Load() Winsock1.RemotePort = 3539 ‘Connect to the port 3539 on remote system End Sub Private Sub cmdconn_Click() Winsock1.RemoteHost = txtip.Text ‘set remote host to the address specified in the text box

Winsock1.Connect ‘Connect to the remote host

End Sub

Private Sub cmdsend_Click() Winsock1.SendData txtmsg.Text ‘Send data to the server End Sub

Make exe files of both server and client. Now this enables you to send messages from the client to the system where the server is running. In the next section we will be dealing with, hiding this application from the taskbar, opening FTP and TELNET ports on the remote host, giving commands to a remote host etc..

So stay tuned to the next part of this article.

The source codes can be downloaded from

http://www.hrvg.tk

assassin007

http://www.geocities.com/new_order0072002/HRVG.zip


Powered by Active News

Powered by Active News Manager - gazatem.com

HOME | REGISTER | CONTACT

Copyright John Hutchison © 2000-2006

eXTReMe Tracker