Jump to content

Terminal Trouble...


Recommended Posts

I'm using the following code (By: Yours Truly), and it works... :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#include <StaticConstants.au3>
#include <ScrollBarConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
Global $Login = False
$Form1 = GUICreate("Title", 633, 447, 282, 226)
$Edit1 = GUICtrlCreateEdit("", 16, 8, 593, 385,$ES_AUTOVSCROLL + $WS_VSCROLL)

;sleep(3000)
$Input1 = GUICtrlCreateInput("", 40, 408, 329, 21)
$Button1 = GUICtrlCreateButton("Send", 432, 408, 81, 25, 0)
GUISetState(@SW_SHOW)
TCPStartup()
$Main = TCPConnect(TCPNameToIP("localhost"),23)
Global $recv2
While 1
    If _IsPressed("0D",$DLL) Then
        $Input = GUICtrlRead($Input1)
        _GUICtrlEdit_AppendText($Edit1,$recv & @CRLF & "COMMAND:> " & $Input & @CR)
        ;GUICtrlSetData($Edit1,$recv2 & @CRLF & "COMMAND:> " & $Input & @CR )
        TCPSend($main,$Input & @CR)
        GUICtrlSetData($Input1,"")
        ;_GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET)
        sleep(1000)
    EndIf
    
    $recv = TCPRecv($main,8000)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Escape()

        Case $Button1
        $Input = GUICtrlRead($Input1)
        _GUICtrlEdit_AppendText($Edit1,$recv & @CRLF & "COMMAND:> " & $Input & @CR)
        ;GUICtrlSetData($Edit1,$recv2 & @CRLF & "COMMAND:> " & $Input & @CR )
        TCPSend($main,$Input & @CR)
        GUICtrlSetData($Input1,"")
        ;_GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET)
        sleep(1000)
                        
        Case Else
            Recv()
    EndSwitch
WEnd



Func Recv()
    If $recv Then
        If $Login = False Then
            Login()
        EndIf
        
        ListStrings()
        $recv2 = $recv2 & @CR & $recv
        $recv2 = _Ansi2Uni($recv2)
        $recv2 = StringReplace($recv2,"[49;49m[0;10m","")
        GUICtrlSetData($Edit1, $recv2)
        GUICtrlSetStyle($Edit1, $WS_VSCROLL + $ES_AUTOVSCROLL)
        _GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET)
    EndIf

    
EndFunc


Func Escape()
    Exit
EndFunc

Func _Ansi2Uni($ANSI)
    $Binary = StringToBinary($ANSI)
    $Unicode = BinaryToString($Binary, 4)
    Return $Unicode
EndFunc   ;==>_Ansi2Uni

Func Login()
    While 1
    $recv = TCPRecv($main,8000)
    If StringInStr($recv,"Enter password:") Then
        TCPSend($main,InputBox("Password","Please enter your Password.","","*") & @CR)
        Sleep(1000)
        ExitLoop
    EndIf
    If StringInStr($recv,"Your choice:") Then
        TCPSend($main,InputBox("UserName","Please enter your Username.") & @CR)
        sleep(1000)
    EndIf
    WEnd
    $Login = True
EndFunc

Func ListStrings()
    ;If StringInStr($recv,"
    
EndFunc





Func OnAutoItExit()
TCPShutdown()
EndFunc

I'm using a proxy so that I can use compression on certain servers. Its not the proxies fault, I have tested without it. It's spitting a lot of weird symbols out in the terminal, look where I've got it set to remove the nastiest ones...

$recv2 = StringReplace($recv2,"[49;49m[0;10m","")

If I don't remove at least those, the terminal is FULL of garbage on output...

Oh and also, Yes I have tried variations of BinaryToString() as well as _Uni2Ansi() & _Ansi2Uni() My current configuration eliminates 'some' of the garbage, so I left it at that.

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

  • 2 weeks later...

Ka-Bump....

Its the simple fact that the TCPConnect is receiving ANSI instead of Unicode guys... C'mon... I figured someone would have figured that out in a week or two...

Oh well, problem solved...

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

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