Sign in to follow this  
Followers 0
JohnMC

Obj/COM Issue

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

It's not a function it a sub so it can't return value. You'll probably get great crash this way ^^

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

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