Jump to content

Obj/COM Issue


JohnMC
 Share

Recommended Posts

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

Link to comment
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
Link to comment
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
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 Builder
Misc 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 Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Link to comment
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?

Link to comment
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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...