Sign in to follow this  
Followers 0
kenp11w

Telnet Test connections

13 posts in this topic

Does anyone have a script that test Telent connections and logs the error if the conenction fails or connects?

I saw a few scripts that run Telnet in batch reads from an IP list.

I need to the log any errors or succesful connects.

The script opens port xxx 443 for each server if it connects we need to disconnect and mark server as good

if it fails we need to mark server as bad.

AutoItSetOption ( "WinTitleMatchMode" , 2)

#include <file.au3>

Dim $ipfile="servers.txt"

Dim $functionfile="Function.txt"

Dim $ipadress, $function

;read ip address into array

If Not _FileReadToArray($ipfile, $ipadress) Then

MsgBox(4096,"Error", $ipfile & " Not Found")

Exit

EndIf

;read function into array

If Not _FileReadToArray($functionfile, $function) Then

MsgBox(4096,"Error", $functionfile & " Not Found")

Exit

EndIf

;go into loop untill out of ip adresses

For $loop = 1 to $ipadress[0]

Run("telnet " & $ipadress[$loop] & " 443" )

Sleep(1800)

;go into loop untill all functions are done

For $loop2 = 1 to $function[0]

WinActivate("Telnet " & $ipadress[$loop])

WinWaitActive("Telnet " & $ipadress[$loop])

Send($function[$loop2] & "{ENTER}")

Next

If WinExists("Telnet " & $ipadress[$loop]) Then WinClose("Telnet " & $ipadress[$loop])

Next

Share this post


Link to post
Share on other sites



Replace

Run("telnet " & $ipadress[$loop] & " 443" )

with

#include <Process.au3>
_RunDOS("telnet " & $ipadress[$loop] & " 443 >" & @TempDir & "\myoutput.txt")
$FILE = FileOpen(@TempDir & "\myoutput.txt",0)
$DATA = FileRead($FILE)
FileClose($FILE)
MsgBox(0,"",$DATA)

You can adapt the code, replace MsgBox with an if statements. :)


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Replace

Run("telnet " & $ipadress[$loop] & " 443" )

with

#include <Process.au3>
_RunDOS("telnet " & $ipadress[$loop] & " 443 >" & @TempDir & "\myoutput.txt")
$FILE = FileOpen(@TempDir & "\myoutput.txt",0)
$DATA = FileRead($FILE)
FileClose($FILE)
MsgBox(0,"",$DATA)

You can adapt the code, replace MsgBox with an if statements. :)

Thanks. I tried the code replacement and it error'd on line 25 Process.au3

Func_ProcessGenName($i_PID)

Error : "FOR" statement has no matching "Next" statement

My Process.au3 is version ; Include Version:1.59 (04/20/2006) do i need a newer one?

Share this post


Link to post
Share on other sites

Thanks. I tried the code replacement and it error'd on line 25 Process.au3

Func_ProcessGenName($i_PID)

Error : "FOR" statement has no matching "Next" statement

My Process.au3 is version ; Include Version:1.59 (04/20/2006) do i need a newer one?

Put this line first in your script:

#include <Process.au3>

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Func_ProcessGenName ?

Func _ProcessGetName


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks. I tried the code replacement and it error'd on line 25 Process.au3

Func_ProcessGenName($i_PID)

Error : "FOR" statement has no matching "Next" statement

My Process.au3 is version ; Include Version:1.59 (04/20/2006) do i need a newer one?

I changed the Include state ment to the top.

I get a MSsgBox with OK on it and the MYOUPUT files has 0 bytes.

It does not appear to open Telnet at all or DOS sesion

Edited by kenp11w

Share this post


Link to post
Share on other sites

Put this line first in your script:

#include <Process.au3>

I searched for GenName and did not see the text in any file in INCLUDE directory

Share this post


Link to post
Share on other sites

As I stated, it's not GeNName ... It's GeTName


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

As I stated, it's not GeNName ... It's GeTName

Process.au3 has GeTName..... but when I run the script the error shows as GenName. Where is the error coming from?

Share this post


Link to post
Share on other sites

Process.au3 has GeTName..... but when I run the script the error shows as GenName. Where is the error coming from?

From your script, you have a typo.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Kenp11w Nice way to write an automatic exploiter :) . I guess I am the only one here that caught on. PM me because I am working on a few thing myself.

Share this post


Link to post
Share on other sites

From your script, you have a typo.

I changed the Include state ment to the top. The error does not occurr

I get a MSsgBox with OK on it and the MYOUPUT files has 0 bytes.

It does not appear to open Telnet at all or DOS sesion

Share this post


Link to post
Share on other sites

Kenp11w Nice way to write an automatic exploiter :) . I guess I am the only one here that caught on. PM me because I am working on a few thing myself.

Actually we use the script to test 8 domain controllers and the thousands of computers connected.

Our Auditing software cant access som computers so we telnet to ports if netbios does not work

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