Getting the pre-login banner from server with VBScript (wodSSH / wodSSH.NET)

by Marvin, (1402 days ago)

Hi,
I am testing using wodSSH to replace w3sock in vbscripts that i use telnet and ssh. I am able to make wodSSH work with my testing vbscripts, however there is one issue i cannot figure out how to do. How to get the pre-login banner sent by the telnet or ssh server. I need the banner data to choose the login credentials and choose script telnet actions. Can you help me with getting the pre-login banner? Here is a sample of what i am using for testing (which works well):
[code]
On Error Resume Next
Set connTelnet = CreateObject("WeOnlyDo.wodSSHCom")
connTelnet.Hostname = 10.10.1.100
connTelnet.Protocol = 1 'telnet
connTelnet.Blocking = True
connTelnet.StripANSI = True
connTelnet.Login = "user"
connTelnet.Password = "password"
connTelnet.Prompt = "user>"
connTelnet.AllocatePty = False
connTelnet.DataReady = 0
err.Clear
connTelnet.Connect
telnetErr = err.Description
'banner = connTelnet.Banner <- doesn't work, hangs right here
'wscript.echo banner <- returns blank
connTelnet.WaitFor "user>"
buffOpen = connTelnet.Execute("ipconfig /all" & VbCrLf)
connTelnet.Execute "exit" & VbCrLf, "\n"
connTelnet.Disconnect
wscript.echo "telnetErr = " & telnetErr '& VbCrLf & "buffOpen: " & buffOpen
[/code]

locked

Getting the pre-login banner from server with VBScript

by Jasmine, (1401 days ago) @ Marvin

Hi.

There is no banner property - only banner event, and it works only with SSH protocol.

If you use telnet, then wodSSH cannot say what is banner, what is prompt, what is other type of info - from it's perspective it's just data that has arrived.

I would suggest you read out everything that arrives before the Waitfor, at least for the test. Also, did you try to print what's returned with Waitfor?

Jasmine

locked

Getting the pre-login banner from server with VBScript

by Marvin, (1401 days ago) @ Jasmine

Thank you Jasmine. What would be the best way to do this?

locked

Getting the pre-login banner from server with VBScript

by Jasmine, (1401 days ago) @ Marvin

Hi.

For a test, use Receive method (several times) after the Connect and dump it to the screen to see at least if data is there.

Jasmine

locked

Getting the pre-login banner from server with VBScript

by Marvin, (1401 days ago) @ Jasmine

Thanks for the suggestions Jasmine. After taking your testing advices, i finally got the following to work. I had to remove the Login and Password properties and replace them with a series of WaitFor and Send's to handle the telnet login process. I also had to delay the Prompt property until after the login was complete. But by capturing the return from the first WaitFor, i was able to snag the banner data which had exactly what i needed. Below is the vbscript code that i got working and i'm providing it as a sample in case anyone else might find it of use.
[code]On Error Resume Next
Set connTelnet = CreateObject("WeOnlyDo.wodSSHCom")
connTelnet.Hostname = 10.10.1.100
connTelnet.Protocol = 1 'telnet
connTelnet.Blocking = True
connTelnet.StripANSI = True
connTelnet.AllocatePty = False
connTelnet.DataReady = 0
err.Clear
connTelnet.Connect
telnetErr = err.Description
banner = connTelnet.WaitFor("login:")
connTelnet.Send "user" & VbCrLf
connTelnet.WaitFor "password:"
connTelnet.Send "password" & VbCrLf
connTelnet.WaitFor "user>"
wscript.echo "banner: " & VbCrLf& banner
connTelnet.Prompt = "user>"
buffOpen = connTelnet.Execute("ipconfig /all" & VbCrLf)
connTelnet.Execute "exit" & VbCrLf, "\n"
connTelnet.Disconnect
wscript.echo "telnetErr = " & telnetErr & VbCrLf & "buffOpen: " & buffOpen
[/code]

locked