JohnMC Posted February 4, 2009 Share Posted February 4, 2009 the below code is a simplified version of some code from a client script im making, the server is an autoit script using the standard TCP library, the client forms a connection to the server and in this test sends a string, the test string invokes a responce of the string "SUCCESS".... ive tried every data type and combination of code i can think of.. just to make sure im not crazy i tried to make this code in js and it works! so here is the js code that works and the autoit code that fails, the autoit code does set $Len to equal the sength of "SUCCESS" but will not return the data itself. oWinsock = new ActiveXObject("OSWINSCK.Winsock"); WScript.ConnectObject(oWinsock, "oWinsock_"); oWinsock.Connect("192.168.0.1","2021"); function oWinsock_OnConnect() { oWinsock.SendData('TESTJAVA[-]PING'); } function oWinsock_OnDataArrival(bytesTotal) { var sBuffer = oWinsock.GetDataBuffer(); WScript.Echo(sBuffer); } WScript.Sleep(3000); $oSocket = ObjCreate("OSWINSCK.Winsock") ObjEvent($oSocket, "_TCP_") $oSocket.Connect("192.168.0.1",2021) Sleep(3000) Func _TCP_OnConnect() $oSocket.SendData("TESTSCRIPT[-]PING") EndFunc Func _TCP_OnDataArrival($Len) $data=$oSocket.GetDataBuffer() MsgBox(0,"Data",$data) EndFunc i just dont get it, its the same! any help or ideas would be great! i would hate to have to execute js from my autoit script https://johnscs.com Link to comment Share on other sites More sharing options...
Authenticity Posted February 4, 2009 Share Posted February 4, 2009 Hi, Read again about the GetDataBuffer(), they state that it's only supported under JS or similar languages (C++, etc..). If you can do the same in VBScript it should work under AutoIt. From my tests all I can say is that it's one giant annoying COM obj. Link to comment Share on other sites More sharing options...
JohnMC Posted February 4, 2009 Author Share Posted February 4, 2009 ok i tried the vbs method, a3 version still doesnt return anything so here is the code: Dim $data $oSocket = ObjCreate("OSWINSCK.Winsock") ObjEvent($oSocket, "_TCP_") $oSocket.Connect("192.168.0.1",2021) Sleep(3000) Func _TCP_OnConnect() $oSocket.SendData("TESTSCRIPT[-]PING") EndFunc Func _TCP_OnDataArrival($Len) $oSocket.GetData($data) MsgBox(0,"Data",$data) EndFunc Dim oWinsock 'As OSWINSCK.Winsock Dim sBuffer 'As String Set oWinsock = CreateObject("OSWINSCK.Winsock") WScript.ConnectObject oWinsock, "oWinsock_" oWinsock.Connect CStr("192.168.0.1"), CLng("2021") Sub oWinsock_OnConnect() oWinsock.SendData "TESTVBS[-]PING" End Sub Sub oWinsock_OnDataArrival(ByVal bytesTotal) oWinsock.GetData sBuffer WScript.Echo sBuffer End Sub WScript.Sleep 3000 https://johnscs.com Link to comment Share on other sites More sharing options...
spudw2k Posted February 5, 2009 Share Posted February 5, 2009 Does this have the same result? Dim $data $oSocket = ObjCreate("OSWINSCK.Winsock") ObjEvent($oSocket, "_TCP_") $oSocket.Connect("192.168.0.1",2021) Sleep(3000) Func _TCP_OnConnect() $oSocket.SendData("TESTSCRIPT[-]PING") EndFunc Func _TCP_OnDataArrival($Len) $data = $oSocket.GetData MsgBox(0,"Data",$data) EndFunc Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
Authenticity Posted February 5, 2009 Share Posted February 5, 2009 It's not a function it a sub so it can't return value. You'll probably get great crash this way ^^ Link to comment Share on other sites More sharing options...
JohnMC Posted February 5, 2009 Author Share Posted February 5, 2009 It's not a function it a sub so it can't return value. You'll probably get great crash this way ^^yes i got a crash, i assume that it acts like ByRef, modifying the variable specified as a parameter, has thier been known issues with this befor?regardless, i take it you dont see any obvious explanation?... in respect to converting VBS to A3, my code is correct is it not? https://johnscs.com Link to comment Share on other sites More sharing options...
Authenticity Posted February 5, 2009 Share Posted February 5, 2009 It can't be like ByRef because it's completely different address spaces (most of the time it is completely different machines). Because my TCP/IP protocol knowledge aspiring zero I don't know how to start think of what TCPSend is doing behind the scenes so I can't give a better help for this one. I've dropped using this object to develop anything other than fast timeout port scan, Use TCP* library instead, it's much better and actually works. Link to comment Share on other sites More sharing options...
JohnMC Posted February 5, 2009 Author Share Posted February 5, 2009 It can't be like ByRef because it's completely different address spaces (most of the time it is completely different machines).Because my TCP/IP protocol knowledge aspiring zero I don't know how to start think of what TCPSend is doing behind the scenes so I can't give a better help for this one. I've dropped using this object to develop anything other than fast timeout port scan, Use TCP* library instead, it's much better and actually works.ya.. i give up, sucks for my first obj/com experience... well thanks for all the help https://johnscs.com 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