myli Posted May 4, 2007 Share Posted May 4, 2007 (edited) Hello. Im trying to code a lil remote administration tool. if i use out of the mainloop a Do $mSock = TCPAccept($listeningSock) it works perfectly. I Get 2 packets from the Sender and it can accept them both without any problems. IF i build the $mSock = TCPAccept within my main while loop, then i receive only the first packet. The packets are sent in this row: TCPSend($ratSocket, "1.0:" & $oIP & ":" & $cNICK & ":" & @ComputerName & ":AUTH:" & ":0" & @CRLF) then i wait for the Server for a "AUTH". im receiving that and then.. usually i have to send TCPSend($ratSocket, "1.0:" & $oIP & ":" & $cNICK & ":" & @ComputerName & ":VERSION:" & ":0" & @CRLF) wich works too. just my server wont respnse if the $mSock = TCPAccept($listeningsock) is in my While(1) loop. if it's before in Do $mSock = TcpAccept($listeningSock) Until $mSock <> -1 its working. here is the source.. thanks so far (= expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> ;#include <A3LTreeView.au3> #include "config.au3" ;TCPStartup() TCPStartup() ; GUICreate ;$maingui = GUICreate("Camera", 350, 270) $maingui = GUICreate("Rat Tool by Li",450,250,-1,-1,BitOr($WS_MINIMIZEBOX,$WS_GROUP,$WS_CAPTION,$WS_POPUP,$WS_SYSMENU)) $menutree = GUICtrlCreateTreeView (10,10,100,230) $aboutitem = GUICtrlCreateTreeViewItem ("About", $menutree) $chatitem = GUICtrlCreateTreeViewItem ("Chat",$menutree) $ircchatitem = GUICtrlCreateTreeViewItem ("IRC",$chatitem) $matrixchatitem = GUICtrlCreateTreeViewItem ("Matrix",$chatitem) $captureitem = GUICtrlCreateTreeViewItem("Capture", $menutree) $screencaptureitem = GUICtrlCreateTreeViewItem("Screen", $captureitem) $webcamcaptureitem = GUICtrlCreateTreeViewItem("Webcam", $captureitem) ;Version:ip:botnick:computername:command:slave:pslave ;; ABout Gui $aboutGroup = GUICtrlCreateGroup ("Informationen", 115, 5, 330, 130) $versionLabel = GUICtrlCreateLabel ("Version: ", 130, 25, 80, 20) $versionInput = GuiCtrlCreateInput("", 210, 25, 230, 20, $ES_READONLY) $ipLabel = GUICtrlCreateLabel("IP: ", 130, 50, 80, 20) $ipInput = GuiCtrlCreateInput("", 210, 50, 230, 20, $ES_READONLY) $computerLabel = GUICtrlCreateLabel("Computername", 130, 75, 80, 20) $computerInput = GuiCtrlCreateInput("", 210, 75, 230, 20, $ES_READONLY) $botnickLabel = GuiCtrlCreateLabel("Botnick", 130, 100, 80, 20) $botnickInput = GuiCtrlCreateInput("", 210, 100, 230, 20, $ES_READONLY) $aboutlabel = GUICtrlCreateLabel ("Rat Tool 'n Bot Coded by li (=.",300,225,180,20) $testButton = GUICtrlCreateButton("TestButton", 160,220,100,20) GUICtrlSetColor ($aboutitem, 0xFFFFFF) GUICtrlSetColor($captureitem, 0xB8AE88) GUICtrlSetColor($chatitem, 0xB8AE88) GuiCtrlSetcolor($ircchatitem, 0xFFFFFF) GuiCtrlSetcolor($matrixchatitem, 0xFFFFFF) GuiCtrlSetcolor($screencaptureitem, 0xFFFFFF) GuiCtrlSetcolor($webcamcaptureitem, 0xFFFFFF) GUICtrlSetBkColor ($menutree,0xA49B88) GuiCtrlSetBKColor($versionInput, 0xA49B88) GuiCtrlSetBKColor($ipInput, 0xA49B88) GuiCtrlSetBKColor($computerInput, 0xA49B88) GuiCtrlSetBKColor($botnickInput, 0xA49B88) GUISetState(@SW_SHOW) ; GUIEND ; ******************* ; *** Chat Gui (= *** ; ******************* $IRCchatInputChannel = GUICtrlCreateInput("#Target", 120, 180, 80, 20) $IRCChatInputText = GuiCtrlCreateInput("Your Text (=", 200, 180, 190, 20) $IRCChatGroup = GUICtrlCreateGroup("IRC Chat", 115, 5, 330, 200) $IRCChatEditList = GuiCtrlCreateEdit("", 120, 25, 320, 150, BitOr($ES_AUTOVSCROLL, $ES_READONLY)) $IRCChatButtonSend = GUICtrlCreateButton("Send!", 390, 179, 50, 19) GUIctrlSetState ($IRCChatGroup, $GUI_HIDE) GUIctrlSetState ($IRCChatEditList, $GUI_HIDE) GUIctrlSetState ($IRCChatButtonSend, $GUI_HIDE) GUIctrlSetState ($IRCchatInputChannel, $GUI_HIDE) GUIctrlSetState ($IRCChatInputText, $GUI_HIDE) GUICtrlSetBkColor ($IRCchatInputChannel,0xA49B88) GuiCtrlSetBKColor($IRCChatInputText, 0xA49B88) GuiCtrlSetBKColor($IRCChatButtonSend, 0xA49B9B) GuiCtrlSetBKColor($IRCChatEditList, 0xD0D9EB) ; ******************* ; *** Cam Capture *** ; ******************* $cap = DllCall(DllOpen("avicap32.dll"), "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int",0, "int", 0, "int", 0, "int", 0, "hwnd", $maingui, "int", 1);Msgbox(0,$cap,$cap) DllCall(DllOpen("user32.dll"), "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0) DllCall(DllOpen("user32.dll"), "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0) Func SnapShot() DllCall("user32.dll", "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile) EndFunc $listenSocket = TCPListen(@IPAddress1, $ratPort, 5) if $listenSocket = -1 Then MsgBox(0, "Error", "Cannot listen at Receiver port.") while (1) $mSock = TCPAccept($listenSocket) ;if ($mSock = -1) Then MsgBox(0,@error,@error) $mBuffer = "" $mBuffer = TcpRecv($mSock, 4096) $ratVersion = "" $ratIP = "" $ratComputer = "" $ratSlave = "" $ratSlaveSlave = "" $ratParse = "" $ratcommand = "" if ($mBuffer <> "") Then $mBuffer = StringStripWS ( $mBuffer, 3 ) $ratParse = StringSplit($mBuffer, ":") for $i = 0 to UBound($ratParse) -1 Select Case $i = 1 $ratVersion = $ratParse[$i] Case $i = 2 $ratIP = $ratParse[$i] Case $i = 3 $ratBotnick = $ratParse[$i] Case $i = 4 $ratComputer = $ratParse[$i] Case $i = 5 $ratCommand = $ratParse[$i] Case $i = 6 $ratSlave = $ratParse[$i] Case $i = 7 $ratSlaveslave = $ratParse[$i] EndSelect Next ;MsgBox(0,$ratCommand,$ratCommand) Select Case $ratCommand = "AUTH" TCPSend($mSock, "AUTH:0:" & @crlf) Case $ratCommand = "VERSION" TCPSend($mSock, "VERSION:" & $ClientVersion & ":" & @crlf) EndSelect GUICtrlSetData ($versionInput, $ratVersion) GUICtrlSetData ($computerInput, $ratComputer) GUICtrlSetData ($ipInput, $ratIP) GUICtrlSetData ($botnickInput, $ratBotnick) EndIf $msg = GUIGetMsg() Select Case $msg = $aboutitem GUIctrlSetState ($versionLabel, $GUI_SHOW) GUIctrlSetState ($versionInput, $GUI_SHOW) GUIctrlSetState ($ipLabel, $GUI_SHOW) GUIctrlSetState ($ipInput, $GUI_SHOW) GUIctrlSetState ($computerLabel, $GUI_SHOW) GUIctrlSetState ($computerInput, $GUI_SHOW) GUIctrlSetState ($botnickLabel, $GUI_SHOW) GUIctrlSetState ($botnickInput, $GUI_SHOW) GUIctrlSetState ($IRCchatInputChannel, $GUI_HIDE) GUIctrlSetState ($IRCChatInputText, $GUI_HIDE) GUIctrlSetState ($IRCChatGroup, $GUI_HIDE) GUIctrlSetState ($IRCChatEditList, $GUI_HIDE) GUIctrlSetState ($IRCChatButtonSend, $GUI_HIDE) GUIctrlSetState ($aboutGroup, $GUI_SHOW) Case $msg = $chatitem GUIctrlSetState ($versionLabel, $GUI_HIDE) GUIctrlSetState ($versionInput, $GUI_HIDE) GUIctrlSetState ($ipLabel, $GUI_HIDE) GUIctrlSetState ($ipInput, $GUI_HIDE) GUIctrlSetState ($computerLabel, $GUI_HIDE) GUIctrlSetState ($computerInput, $GUI_HIDE) GUIctrlSetState ($botnickLabel, $GUI_HIDE) GUIctrlSetState ($botnickInput, $GUI_HIDE) GUIctrlSetState ($IRCchatInputChannel, $GUI_HIDE) GUIctrlSetState ($IRCChatInputText, $GUI_HIDE) GUIctrlSetState ($IRCChatGroup, $GUI_HIDE) GUIctrlSetState ($IRCChatEditList, $GUI_HIDE) GUIctrlSetState ($IRCChatButtonSend, $GUI_HIDE) GUIctrlSetState ($aboutGroup, $GUI_HIDE) Case $msg = $ircchatitem GUIctrlSetState ($IRCchatInputChannel, $GUI_SHOW) GUIctrlSetState ($IRCChatInputText, $GUI_SHOW) GUIctrlSetState ($IRCChatGroup, $GUI_SHOW) GUIctrlSetState ($IRCChatEditList, $GUI_SHOW) GUIctrlSetState ($IRCChatButtonSend, $GUI_SHOW) Case $msg = $IRCChatButtonSend if (GUICtrlRead($IRCChatInputText) <> "" AND GUICtrlRead($IRCchatInputChannel) <> "") Then TCPSend($mSock, "IRCSEND:" & GUICtrlRead($IRCchatInputChannel) & ":" & GUICtrlRead($IRCChatInputText) & @CRLF) GUICtrlSetData($IRCChatEditList, "Sent to " & GUICtrlRead($IRCchatInputChannel) & ": " & GUICtrlRead($IRCChatInputText) & @CRLF,"IRCChat") EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop Exit EndSelect DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1) ;*** cleanup WEnd Edited May 4, 2007 by Larry Link to comment Share on other sites More sharing options...
myli Posted May 4, 2007 Author Share Posted May 4, 2007 yeah, but if i look into the documentation it's 1:1 the same. http://www.autoitscript.com/autoit3/docs/f...s/TCPAccept.htm Link to comment Share on other sites More sharing options...
Helge Posted May 4, 2007 Share Posted May 4, 2007 Larry, what about having a helpfile-entry that shows the basics of networking, similar to what's done with GUI (GUI Reference) ?Just an idea I had. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now