Jump to content

telnet server


7h331337
 Share

Recommended Posts

ok its not finished but its a start lol enjoy

u can use the telnet server to

show the running processes

read a au3/txt file

wright au3/txt file

thats it so far but i am still working on other commands the now

it times out after 10 min of inactivity

telnet.au3

Edited by 7h331337
Link to comment
Share on other sites

I really like what you have done so far I think its great and I'm having a lot of fun fooling around with your idea but I have some suggestions.

For the logins I thought they could be done a bit easier. Here is a code snippet of what I put together. It obviously isn't as in depth because I did not add the GUI front end on my server end but you should be able to grasp the idea.

I used the StringInStr() function to detect the @CRLF and then I did the StringStripCR() and StringStripWS() functions to get rid of the @CRLF so you don't have to go through that wierd GUI read way. Just an idea take what you like.

Anyway can't wait for the rest of the commands.

Global $socket, $recv, $ip, $port, $user, $pass, $acc

$ip = "WHATEVER YOU WANT"
$port = 23
$user = "user"
$pass = "pass"

connect()

Func connect()
    TCPStartup()
    $socket = TCPListen($ip, $port, 1000)
    Sleep(400)
    Do
        $acc = TCPAccept($socket)
    Until $acc > -1
    TCPSend($acc, "            ******************************************" & @CRLF)
    TCPSend($acc, "            **     This server is my test server    **" & @CRLF)
    TCPSend($acc, "            ******************************************" & @CRLF)
    TCPRecv($acc, 100)
    user()
EndFunc

Func user()
    TCPSend($acc, "Username: ")
    Do
        $recv = TCPRecv($acc, 100)
    Until StringInStr($recv, @CRLF)
    $recv = StringStripCR($recv)
    $recv = StringStripWS($recv, 2)
    If $recv = $user Then
        TCPSend($acc, "            **              Success              **" & @CRLF)
        pass()
    EndIf
    $send = TCPSend($acc, "username wrong" & @CRLF)
    user()
EndFunc

Func pass()
    TCPSend($acc, "please type password for user" & @CRLF)
    TCPSend($acc, "password:")
    Do
        $recv = TCPRecv($acc, 10000)
    Until StringInStr($recv, @CRLF)
    $recv = StringStripCR($recv)
    $recv = StringStripWS($recv, 2)
    If $recv = $pass Then
        TCPSend($acc, "connected..." & @CRLF)
        
        TCPSend($acc, @CRLF)
        TCPSend($acc, "**************************************************************************************************************" & @CRLF)
        TCPSend($acc, "*   help shows commands                                                                                      *" & @CRLF)
        TCPSend($acc, "*   process list shows process list                                                                          *" & @CRLF)
        TCPSend($acc, "*   exit just exits                                                                                          *" & @CRLF)
        TCPSend($acc, "*   read reads an txt/au3 file u must putit like this: read au3.au3 :dont forget the spaceat the end         *" & @CRLF)
        TCPSend($acc, "*   new wrights a new file au3 or txt it is the same as above: new au3.au3 :dont forget the space at the end *" & @CRLF)
        TCPSend($acc, "**************************************************************************************************************" & @CRLF)
        
        TCPSend($acc, @ScriptDir & ">")
        sleep(50000)
        ;connected()
    EndIf
    TCPSend($acc, "pass wrong" & @CRLF)
    user()
EndFunc
    
Func OnAutoItExit()
    TCPCloseSocket($socket)
    TCPShutdown()
EndFunc
Edited by SoulA
Link to comment
Share on other sites

I really like what you have done so far I think its great and I'm having a lot of fun fooling around with your idea but I have some suggestions.

For the logins I thought they could be done a bit easier. Here is a code snippet of what I put together. It obviously isn't as in depth because I did not add the GUI front end on my server end but you should be able to grasp the idea.

I used the StringInStr() function to detect the @CRLF and then I did the StringStripCR() and StringStripWS() functions to get rid of the @CRLF so you don't have to go through that wierd GUI read way. Just an idea take what you like.

Anyway can't wait for the rest of the commands.

Global $socket, $recv, $ip, $port, $user, $pass, $acc

$ip = "WHATEVER YOU WANT"
$port = 23
$user = "user"
$pass = "pass"

connect()

Func connect()
    TCPStartup()
    $socket = TCPListen($ip, $port, 1000)
    Sleep(400)
    Do
        $acc = TCPAccept($socket)
    Until $acc > -1
    TCPSend($acc, "            ******************************************" & @CRLF)
    TCPSend($acc, "            **     This server is my test server    **" & @CRLF)
    TCPSend($acc, "            ******************************************" & @CRLF)
    TCPRecv($acc, 100)
    user()
EndFunc

Func user()
    TCPSend($acc, "Username: ")
    Do
        $recv = TCPRecv($acc, 100)
    Until StringInStr($recv, @CRLF)
    $recv = StringStripCR($recv)
    $recv = StringStripWS($recv, 2)
    If $recv = $user Then
        TCPSend($acc, "            **              Success              **" & @CRLF)
        pass()
    EndIf
    $send = TCPSend($acc, "username wrong" & @CRLF)
    user()
EndFunc

Func pass()
    TCPSend($acc, "please type password for user" & @CRLF)
    TCPSend($acc, "password:")
    Do
        $recv = TCPRecv($acc, 10000)
    Until StringInStr($recv, @CRLF)
    $recv = StringStripCR($recv)
    $recv = StringStripWS($recv, 2)
    If $recv = $pass Then
        TCPSend($acc, "connected..." & @CRLF)
        
        TCPSend($acc, @CRLF)
        TCPSend($acc, "**************************************************************************************************************" & @CRLF)
        TCPSend($acc, "*   help shows commands                                                                                      *" & @CRLF)
        TCPSend($acc, "*   process list shows process list                                                                          *" & @CRLF)
        TCPSend($acc, "*   exit just exits                                                                                          *" & @CRLF)
        TCPSend($acc, "*   read reads an txt/au3 file u must putit like this: read au3.au3 :dont forget the spaceat the end         *" & @CRLF)
        TCPSend($acc, "*   new wrights a new file au3 or txt it is the same as above: new au3.au3 :dont forget the space at the end *" & @CRLF)
        TCPSend($acc, "**************************************************************************************************************" & @CRLF)
        
        TCPSend($acc, @ScriptDir & ">")
        sleep(50000)
        ;connected()
    EndIf
    TCPSend($acc, "pass wrong" & @CRLF)
    user()
EndFunc
    
Func OnAutoItExit()
    TCPCloseSocket($socket)
    TCPShutdown()
EndFunc
thanks for ure idea it is realy good the reson i went throu so much crap with the user and pass was becouse i was drunk and i couldent think of anything lol i will put the rest of the commands up soon
Link to comment
Share on other sites

If $ip = "127.0.0.1" Then

$ip = @IPAddress2

EndIf

Can't you just tell it to listen on "0.0.0.0" and it'll listen for all incoming connections? I didn't think you had to put in some sort of exception for a 127.0.0.1.

Link to comment
Share on other sites

Can't you just tell it to listen on "0.0.0.0" and it'll listen for all incoming connections? I didn't think you had to put in some sort of exception for a 127.0.0.1.

true i didnt think of that then thanks i will put that in the script update
Link to comment
Share on other sites

  • 1 month later...

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...