Sign in to follow this  
Followers 0
The713

Home Network Script

2 posts in this topic

Currently I am just messing around with my scripts and learning the tcp/ip function and getting to know how to make em cooperate with my scripts. I was wondering if there was a way for me to send AutoIT functionality to another computer on my home network without previously installing any client or server scripts to them.

My Current Server and Client Script are below.

test_Server.au3

CODE

;server

#include <GUIConstants.au3>

; Set Some reusable info

; Set your Public IP address (@IPAddress1) here.

Dim $szIPADDRESS = @IPAddress1

Dim $nPORT = 33891

; Start The TCP Services

;==============================================

TCPStartUp()

; Create a Listening "SOCKET".

; Using your IP Address and Port 33891.

;==============================================

$MainSocket = TCPListen($szIPADDRESS, $nPORT)

; If the Socket creation fails, exit.

If $MainSocket = -1 Then Exit

; Create a GUI for messages

;==============================================

Dim $GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")",300,200)

Dim $edit = GUICtrlCreateEdit("",10,10,280,180)

GUISetState()

; Initialize a variable to represent a connection

;==============================================

Dim $ConnectedSocket = -1

;Wait for and Accept a connection

;==============================================

Do

$ConnectedSocket = TCPAccept($MainSocket)

Until $ConnectedSocket <> -1

; Get IP of client connecting

Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

Dim $msg, $recv

; GUI Message Loop

;==============================================

While 1

$msg = GUIGetMsg()

; GUI Closed

;--------------------

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

; Try to receive (up to) 2048 bytes

;----------------------------------------------------------------

$recv = TCPRecv( $ConnectedSocket, 2048 )

; If the receive failed with @error then the socket has disconnected

;----------------------------------------------------------------

If @error Then ExitLoop

; Update the edit control with what we have received

;----------------------------------------------------------------

If $recv <> "" Then

_Command($recv)

GUICtrlSetData($edit, $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit))

EndIf

WEnd

If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket )

TCPShutDown()

; Function to return IP Address from a connected socket.

;----------------------------------------------------------------------

Func SocketToIP($SHOCKET)

Local $sockaddr = DLLStructCreate("short;ushort;uint;char[8]")

Local $aRet = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET, _

"ptr",DLLStructGetPtr($sockaddr),"int_ptr",DLLStructGetSize($sockaddr))

If Not @error And $aRet[0] = 0 Then

$aRet = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3))

If Not @error Then $aRet = $aRet[0]

Else

$aRet = 0

EndIf

$sockaddr = 0

Return $aRet

EndFunc

;Function To Determine Commands

;---------------------------------------------------------------------

Func _Command($string)

$cmdparams = StringSplit($string, ".")

If $cmdparams[1] = "beep" Then

_Beep($cmdparams[2], $cmdparams[3], $cmdparams[4])

ElseIf $cmdparams[1] = "msg" Then

_Msg($cmdparams[2], $cmdparams[3], $cmdparams[4], $cmdparams[5])

ElseIf $cmdparams[1] = "mouse" Then

_Mouse($cmdparams[2], $cmdparams[3], $cmdparams[4], $cmdparams[5])

ElseIf $cmdparams[1] = "tooltip" Then

_ToolTip($cmdparams[2], $cmdparams[3], $cmdparams[4])

ElseIf $cmdparams[1] = "speak" Then

_Speak($cmdparams[2])

EndIf

EndFunc

Func _Beep($freq, $time, $looped)

$x = 0

While $x < $looped

Beep($freq, $time)

$x = $x + 1

WEnd

EndFunc

Func _Msg($string, $flag, $title, $looped)

$x = 0

While $x < $looped

MsgBox($flag, $title, $string)

$x = $x + 1

WEnd

EndFunc

Func _Mouse($x, $y, $looped, $wait)

$a = 0

While $a < $looped

MouseMove($x, $y)

Sleep($wait)

$a = $a + 1

WEnd

EndFunc

Func _ToolTip($string, $x, $y)

ToolTip($string, $x, $y)

EndFunc

Func _Speak($text)

Dim $voice = ObjCreate("Sapi.SpVoice")

$voice.Speak($text)

EndFunc

test_Client.au3

CODE
;client

;CLIENT! Start Me after starting the SERVER!!!!!!!!!!!!!!!

; see TCPRecv example

#include <GUIConstants.au3>

; Start The TCP Services

;==============================================

TCPStartUp()

; Set Some reusable info

;--------------------------

Dim $szIP = InputBox("Connecting", "Enter I.P. To Connect To", "")

; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address

Dim $szIPADDRESS = $szIP

Dim $nPORT = 33891

; Initialize a variable to represent a connection

;==============================================

Dim $ConnectedSocket = -1

;Attempt to connect to SERVER at its IP and PORT 33891

;=======================================================

$ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT)

Dim $szData

; If there is an error... show it

If @error Then

MsgBox(4112,"Error","TCPConnect failed with WSA error: " & @error)

; If there is no error loop an inputbox for data

; to send to the SERVER.

Else

;Loop forever asking for data to send to the SERVER

While 1

; InputBox for data to transmit

$szData = InputBox("Data for Server",@LF & @LF & "Enter data to transmit to the SERVER:")

; If they cancel the InputBox or leave it blank we exit our forever loop

If @error Or $szData = "" Then ExitLoop

; We should have data in $szData... lets attempt to send it through our connected socket.

TCPSend($ConnectedSocket,$szData)

; If the send failed with @error then the socket has disconnected

;----------------------------------------------------------------

If @error Then ExitLoop

WEnd

EndIf

I realize that they are pretty much ripped right from the Help file it's self but I havn't really started messing with changing things up to much.

These scripts work fine as long as I put the server script on another computer and make it run. I can use the client script to connect and use any of the function of the server script thanks to the String functions.

I would like to be able to use the functions of the server script without the need of the server script.

(i.e. I could use the _Speak function, type in what I would like to say from my computer and a computer at another IP would say it without having the server script or any other script on it.) I know this sounds rather devious but what learning without a little fun. Plus it would really freak my brother out when he is up at night playing games and his computer starts talking to him. xD

any help would be much appreciated with this, clues, or points in the right direction. Even if its not possible, someone please inform me. Thanks.

P.S. I realize I am rather terrible at commenting my programs. I really must work on getting in the habit of commenting functions I create and such.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can use a telnet client to comunicate with your servers.

Look at my Chatserver inn my signature, im sure there are things there you could get use for.

Starting a process on your "brothers" mchine is possible if you have his password or admin password, else you need to create a app for him where you camuflage your "evil" server, make sure you make your server run at all times,

pretty obvios if you allways ask him to start your program then short after you start joking with him <_<

Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0