Jump to content

PC Beacon


Bert
 Share

Recommended Posts

yes. You'd have to deploy the compiled .exe to your entire network in such a way that it is always running on every computer (Startup script, service, etc). Then, as admin, you'd telnet into the computer you want to find by OPENing the IP address of the computer you want to locate.

I wonder if you could use PSExec to kick off the beacon telnet program and then use it from there. The only problem I see is that if the machine is locked then you are going to have to rely on the beeps or CD tray popping out. Very cool.

Link to comment
Share on other sites

Here's my variation on Manadar's telnet version of the PC Beacon, with the changes I noted a few posts back:

Opt("GUIOnEventMode", 1)
#include <StaticConstants.au3>


;; The global constants here need to be changed according to your preferences, before compile time.

;; SETTINGS HERE, CHANGE THESE
Global Const $sAdminPass = "manadar" ;; Admin password. Change this please.
Global $bOpenCDTray = False ;; This is a good visual identifier if people have their monitors turned off.
Global $bPlayBeeps = False ;; Plays a short beep every second. WARNING: HIGHLY ANNOYING.
;; END OF SETTINGS, STOP CHANGING!!

;; Do not touch these "settings" / global variables
Global Const $nWelcomeMessage = "PC Beacon ( Localizer ) [Version 1.0]" & @CRLF & "© Copyright 2008 Manadar.com"

Dim $sMaxConnections = 50
Dim $sSocket[$sMaxConnections], $sBuffer[$sMaxConnections], $iAuth[$sMaxConnections]
Dim $nWidth = @DesktopWidth * 1.2
Dim $nHeigth = @DesktopHeight * 1.2
Dim $nHwnd

;; Set up our GUI

$hWnd = GUICreate("PC Locator", $nWidth, $nHeigth, -1, -1)
GUISetBkColor(0x3A6EA5)
GUISetFont(28, 800)
GUICtrlCreateLabel("The IT department is currently looking for this computer." & @CRLF & @CRLF & "Sit back for just a moment. Grab a coffee or two." & @CRLF & "( One for you, one for your friendly IT support.)" & @CRLF & @CRLF & "Or stare at this soothing blue screen ... " & @CRLF & @CRLF & @CRLF & @CRLF & "Ctrl + Alt + C to close this window.", ($nWidth/2)-(@DesktopWidth/2), ($nHeigth/2)-300, @DesktopWidth, 600, $SS_CENTER)

;; Set up our listening port
TCPStartup()

$sMainSocket = TCPListen(@IPAddress1,23,5)

While 1
    
    ;; Accept new incoming clients, and ask them to authorise.
    $sNewSocket = TCPAccept($sMainSocket)
    If $sNewSocket > -1 Then
        For $x = 0 to UBound($sSocket)-1
            If Not $sSocket[$x] Then
                $sSocket[$x] = $sNewSocket
                $iAuth[$x] = 0
                TCPSend($sSocket[$x],$nWelcomeMessage & @CRLF & @CRLF)
                TCPSend($sSocket[$x],"Please enter the administrator password" & @CRLF & ">")
                ExitLoop
            EndIf
        Next
    EndIf
    
    ;; Loop through existing connections, check if they sent us any data
    For $x = 0 to UBound($sSocket)-1
        If $sSocket[$x] Then
            
            ;; Handle incoming data
            $sData = TCPRecv($sSocket[$x],100)
            $sBuffer[$x] &= $sData
            If @error Then
                TCPCloseSocket($sSocket[$x])
                $sSocket[$x] = ""
                $sBuffer[$x] = ""
                $iAuth[$x] = 0
                Exit
            ElseIf Asc($sData) = 0x8 Then ;backspace received
                $len = StringLen($sBuffer[$x])
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2) ; trim the buffer
                If $len = 1 Then
                    TCPSend($sSocket[$x],">")
                Else
                    TCPSend($sSocket[$x]," " & Chr(0x8))
                EndIf
            EndIf
            
            ;; Handle data, in case data is complete: ended with newline
            If StringInStr($sBuffer[$x],@CRLF) Then
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2)
                
                ;; Check if user is authorised
                If $iAuth[$x] == 0 Then
                    ;; Not authorised, user is typing password
                    If ($sBuffer[$x] == $sAdminPass) Then
                        $iAuth[$x] = 1
                        TCPSend($sSocket[$x],"Administrator authorisation granted." & @CRLF & @CRLF & "Type 'help' for a list of the available commands." & @CRLF & ">")
                    Else
                        TCPSend($sSocket[$x],"Access denied." & @CRLF & ">")
                    EndIf
                    
                Else
                    ;; Is authorised with password, do some commands
                    Switch $sBuffer[$x]
                        Case "quit", "q", "exit"
                            ; Closes the server on the remote client
                            TCPCloseSocket($sSocket[$x])
                            $sSocket[$x] = ""
                            $sBuffer[$x] = ""
                            $iAuth[$x] = 0
                        Case "shutdown"
                            TCPSendAll(@CRLF & "Server shutting down. Bye bye!" & @CRLF)
                            Exit
                        Case "locate"
                            ShowGUI()
                        Case "stoplocate"
                            CloseGUI()
                        Case "status"
                            If BitAND(WinGetState($hWnd),2) Then
                                TCPSend($sSocket[$x],"This computer is currently being searched for.")
                            Else
                                TCPSend($sSocket[$x],"This computer is not being searched for.")
                            EndIf
                        Case "?", "help"
                            TCPSend($sSocket[$x],@CRLF & "quit" & @TAB & @TAB & "Closes connection to the terminal." & @CRLF & _
                                    "shutdown" & @TAB & "Closes the remote server" & @CRLF & _
                                    "locate" & @TAB & @TAB & "Starts locating the remote computer." & @CRLF & _
                                    "status" & @TAB & @TAB & "Returns the status of the device." & @CRLF & _
                                    "configure" & @TAB & "Configures the method for locating the computer" & @CRLF & _
                                    "stoplocate" & @TAB & "Remotely stops the locating process" _
                                    )
                        Case "c", "config", "configure"
                            $sData=""
                            $sBuffer[$x]=""
                            If $bPlayBeeps Then
                                TCPSend($sSocket[$x],@CRLF&"Beep [on] or off:")
                            Else
                                TCPSend($sSocket[$x],@CRLF&"Beep on or [off]:")
                            EndIf
                            Do
                                $sData = TCPRecv($sSocket[$x],100)
                                If Asc($sData)=0x8 Then
                                    If StringLen($sBuffer[$x]) > 0 Then
                                        TCPSend($sSocket[$x],0x8)
                                        $sBuffer[$x]=StringTrimRight($sBuffer[$x],1)
                                    Else
                                        TCPSend($sSocket[$x],":")
                                    EndIf
                                Else
                                    $sBuffer[$x]=$sBuffer[$x]&$sData
                                EndIf
                            Until StringInStr($sBuffer[$x],@CRLF) > 0
                            $sBuffer[$x]=StringTrimRight($sBuffer[$x],2)
                            If $sBuffer[$x] = "on" Then
                                $bPlayBeeps=True
                            ElseIf $sBuffer[$x] = "off" Then
                                $bPlayBeeps=False
                            EndIf
                            If $bPlayBeeps Then
                                TCPSend($sSocket[$x],"Beeps are ON")
                            Else
                                TCPSend($sSocket[$x],"Beeps are OFF")
                            EndIf
                            
                            $sData=""
                            $sBuffer[$x]=""
                            If $bOpenCDTray Then
                                TCPSend($sSocket[$x],@CRLF&@CRLF&"Open CD tray on locate: [on] or off:")
                            Else
                                TCPSend($sSocket[$x],@CRLF&@CRLF&"Open CD tray on locate: on or [off]:")
                            EndIf
                            Do
                                $sData = TCPRecv($sSocket[$x],100)
                                If Asc($sData)=0x8 Then
                                    If StringLen($sBuffer[$x]) > 0 Then
                                        TCPSend($sSocket[$x],0x8)
                                        $sBuffer[$x]=StringTrimRight($sBuffer[$x],1)
                                    Else
                                        TCPSend($sSocket[$x],":")
                                    EndIf
                                Else
                                    $sBuffer[$x]=$sBuffer[$x]&$sData
                                EndIf
                            Until StringInStr($sBuffer[$x],@CRLF) > 0
                            $sBuffer[$x]=StringTrimRight($sBuffer[$x],2)
                            If $sBuffer[$x] = "on" Then
                                $bOpenCDTray=True
                            ElseIf $sBuffer[$x] = "off" Then
                                $bOpenCDTray=False
                            EndIf
                            If $bOpenCDTray Then
                                TCPSend($sSocket[$x],"CD tray opener is ON"&@CRLF)
                            Else
                                TCPSend($sSocket[$x],"CD tray opener is OFF"&@CRLF)
                            EndIf
                        Case Else
                            TCPSend($sSocket[$x],"Invalid command. Please type 'help' for a list of commands.")
                    EndSwitch
                    TCPSend($sSocket[$x],@CRLF & ">")
                EndIf
                $sBuffer[$x] = ""
            EndIf
        EndIf
    Next
WEnd

Func TCPSendAll($sMsg)
    For $n = 0 to UBound($sSocket)-1
        If $sSocket[$n] Then
            TCPSend($sSocket[$n],$sMsg)
        EndIf
    Next
EndFunc

Func ShowGUI()
    TCPSendAll(@CRLF & "This computer is being localized." & @CRLF & ">")
    
    GUISetState(@SW_SHOW, $hWnd)
    WinSetOnTop($hWnd,"",1)
    
    If ($bOpenCDTray) Then
        $aDrives = DriveGetDrive("CDROM")
        For $m = 1 to $aDrives
            CDTray ( $aDrives[$m], "open")
        Next
    EndIf
    
    If ($bPlayBeeps) Then
        AdlibEnable("PlayBeep", 1000)
    EndIf
    
    HotKeySet("^!c", "CloseGUIclient")
EndFunc

Func CloseGUIClient()
    Local $sPassCheck=InputBox("Enter password:","Please enter the administrator password:","","*",-1,-1,-1,-1,-1,$hWnd)
    If $sPassCheck=$sAdminPass Then CloseGUI()
EndFunc

Func CloseGUI()
    TCPSendAll(@CRLF & "This computer has been found." & @CRLF & ">")
    
    HotKeySet("^!c")
    
    If ($bPlayBeeps) Then
        AdlibDisable()
    EndIf
    
    GUISetState(@SW_HIDE,$hWnd)
EndFunc

Func PlayBeep()
    Beep(500,50)
EndFunc
Edit:cleaned up the Config part of the code in an attempt to get them as nice as Manadar's functions :mellow: Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

I've taken your version as 1.1. I love the changes you made!

Edit: Updated to version 1.2

Changes:

x Server no longer closes on client disconnect. ( This was a feature when testing. )

x Fixed bug where you could backspace too far when configurating.

x Added a few command line options.

x Removed the default tray menu, and added one that says "PC Beacon [Version ...]" and does nothing. ( Give me some feedback whether a tray icon is desired or not. )

New command line options:

/locatenow

Sets up the remote PC as a beacon immediately. Useful with PsExec or Remote Terminal. Does not start a server, and the program closes after the PC has been found.

/beep

Starts up the program with beeping enabled.

/trayopen

Starts up the program with opening the CD tray enabled.

/cdopen

Same as /trayopen.

/ip ( Untested )

Specifies the IP address to listen on. ( Could be useful if you only want to accept connections from the machine it is running, specify: /ip 127.0.0.1 )

/port

Specifies the port to listen on. ( Useful when you already have a telnet server on port 23 )

Example command line:

pcbeacon.exe /locatenow /beep

Starts the PC Beacon, immediately starts beeping and shows the default blue screen for localizing.

pcbeacon.exe /port 50 /trayopen /beep

Starts the PC Beacon on port 50, enable opening the CD Tray by default, enable beeping by default.

Opt("GUIOnEventMode", 1)

Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)

#include <StaticConstants.au3>
#Include <Constants.au3>


;; The global constants here need to be changed according to your preferences, before compile time.

;; SETTINGS HERE, CHANGE THESE
Global Const $sAdminPass = "manadar" ;; Admin password. Change this please.
Global $bOpenCDTray = False ;; This is a good visual identifier if people have their monitors turned off.
Global $bPlayBeeps = False ;; Plays a short beep every second. WARNING: HIGHLY ANNOYING.
;; END OF SETTINGS, STOP CHANGING!!

;; Do not touch these "settings" / global variables
Global Const $sAppName = "PC Beacon"
Global Const $nVersion = 1.2
Global Const $sWelcomeMessage = $sAppName & " [Version " & $nVersion & "]" & @CRLF & "(c) Copyright 2008 Manadar.com"

;; TCP Variables
Dim $sMaxConnections = 10
Dim $sSocket[$sMaxConnections], $sBuffer[$sMaxConnections], $iAuth[$sMaxConnections]

;; GUI Variables
Dim $nWidth = @DesktopWidth * 1.2
Dim $nHeigth = @DesktopHeight * 1.2
Dim $nHwnd

;; TCP Options
Dim $sIPAddress = @IPAddress1, $nPort = 23

;; Command line options
Dim $bLocateNow = False

;; Check for some command line arguments.

If ($CmdLine[0] >= 1) Then
    For $n = 1 to UBound($CmdLine)-1
        Switch $CmdLine[$n]
            Case "/locatenow"
                ;; Starts the locate process immediately.
                $bLocateNow = True
            Case "/beep"
                $bPlayBeeps = True
            Case "/cdopen", "/trayopen"
                $bOpenCDTray = True
            Case "/ip"
                ;; Change the listening IP ( I guess you could change it to 127.0.0.1 so you can only locate it if you are on the machine. 8) )
                If ( $n+1 >= (UBound($CmdLine)-1) ) Then
                    $sNextVar = $CmdLine[$n+1]
                    $sIPAddress = $sNextVar
                Else
                    ;; Not enough arguments
                    _FatalError("Not enough arguments for the '/ip' argument: Expecting IP address." & @CRLF & "You entered: " & $CmdLineRaw)
                EndIf
            Case "/port"
                ;; Change the listening port. Useful when you already have a telnet server running.
                If ( $n+1 >= (UBound($CmdLine)-1) ) Then
                    $sNextVar = $CmdLine[$n+1]
                    $nPort = $sNextVar
                Else
                    ;; Not enough arguments
                    _FatalError("Not enough arguments for the '/port' argument: Expecting Port number." & @CRLF & "You entered: " & $CmdLineRaw)
                EndIf
        EndSwitch
    Next
EndIf


;; Set up our GUI

$hWnd = GUICreate("PC Locator", $nWidth, $nHeigth, -1, -1)
GUISetBkColor(0x3A6EA5)
GUISetFont(28, 800)
GUICtrlCreateLabel("The IT department is currently looking for this computer." & @CRLF & @CRLF & "Sit back for just a moment. Grab a coffee or two." & @CRLF & "( One for you, one for your friendly IT support.)" & @CRLF & @CRLF & "Or stare at this soothing blue screen ... " & @CRLF & @CRLF & @CRLF & @CRLF & "Ctrl + Alt + C to close this window.", ($nWidth / 2) - (@DesktopWidth / 2), ($nHeigth / 2) - 300, @DesktopWidth, 600, $SS_CENTER)

;; Set up tray icon
TrayCreateItem($sAppName & " [Version" & $nVersion & "]")
TrayItemSetState(-1,$TRAY_DISABLE)

If ($bLocateNow) Then
    ShowGUI()
EndIf

If (Not $bLocateNow) Then
    ;; Set up our listening port
    TCPStartup()

    $sMainSocket = TCPListen($sIPAddress, $nPort, 5)
    If @error Then
        Switch @error
            Case 1
                _FatalError("The listening address was incorrect (Possibly another server was already running): " & $sIPAddress)
            Case 2
                _FatalError("The listening port was incorrect (Possibly another server was already running): " & $nPort)
            Case Else
                _FatalError("Unable to set up a listening server on " & $sIPAddress & ":" & $nPort)
        EndSwitch
    EndIf
EndIf

While 1
    
    If (Not $bLocateNow) Then
        ;; Accept new incoming clients, and ask them to authorise.
        $sNewSocket = TCPAccept($sMainSocket)
        If $sNewSocket > -1 Then
            For $x = 0 To UBound($sSocket) - 1
                If Not $sSocket[$x] Then
                    $sSocket[$x] = $sNewSocket
                    $iAuth[$x] = 0
                    TCPSend($sSocket[$x], $sWelcomeMessage & @CRLF & @CRLF)
                    TCPSend($sSocket[$x], "Please enter the administrator password" & @CRLF & ">")
                    ExitLoop
                EndIf
            Next
        EndIf

        ;; Loop through existing connections, check if they sent us any data
        For $x = 0 To UBound($sSocket) - 1
            If $sSocket[$x] Then

                ;; Handle incoming data
                $sData = TCPRecv($sSocket[$x], 100)
                $sBuffer[$x] &= $sData
                If @error Then
                    TCPCloseSocket($sSocket[$x])
                    $sSocket[$x] = ""
                    $sBuffer[$x] = ""
                    $iAuth[$x] = 0
                ElseIf Asc($sData) = 0x8 Then ;backspace received
                    $len = StringLen($sBuffer[$x])
                    $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2) ; trim the buffer
                    If $len = 1 Then
                        TCPSend($sSocket[$x], ">")
                    Else
                        TCPSend($sSocket[$x], " " & Chr(0x8))
                    EndIf
                EndIf

                ;; Handle data, in case data is complete: ended with newline
                If StringInStr($sBuffer[$x], @CRLF) Then
                    $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2)

                    ;; Check if user is authorised
                    If $iAuth[$x] == 0 Then
                        ;; Not authorised, user is typing password
                        If ($sBuffer[$x] == $sAdminPass) Then
                            $iAuth[$x] = 1
                            TCPSend($sSocket[$x], "Administrator authorisation granted." & @CRLF & @CRLF & "Type 'help' for a list of the available commands." & @CRLF & ">")
                        Else
                            TCPSend($sSocket[$x], "Access denied." & @CRLF & ">")
                        EndIf

                    Else
                        ;; Is authorised with password, do some commands
                        Switch $sBuffer[$x]
                            Case "quit", "q", "exit"
                                ; Closes the server on the remote client
                                TCPCloseSocket($sSocket[$x])
                                $sSocket[$x] = ""
                                $sBuffer[$x] = ""
                                $iAuth[$x] = 0
                            Case "shutdown"
                                TCPSendAll(@CRLF & "Server shutting down. Bye bye!" & @CRLF)
                                Exit
                            Case "locate"
                                ShowGUI()
                            Case "stoplocate"
                                CloseGUI()
                            Case "status"
                                If BitAND(WinGetState($hWnd), 2) Then
                                    TCPSend($sSocket[$x], "This computer is currently being searched for.")
                                Else
                                    TCPSend($sSocket[$x], "This computer is not being searched for.")
                                EndIf
                            Case "?", "help"
                                TCPSend($sSocket[$x], @CRLF & "quit" & @TAB & @TAB & "Closes connection to the terminal." & @CRLF & _
                                        "shutdown" & @TAB & "Closes the remote server" & @CRLF & _
                                        "locate" & @TAB & @TAB & "Starts locating the remote computer." & @CRLF & _
                                        "status" & @TAB & @TAB & "Returns the status of the device." & @CRLF & _
                                        "config" & @TAB & @TAB & "Configures the method for locating the computer" & @CRLF & _
                                        "stoplocate" & @TAB & "Remotely stops the locating process" _
                                        )
                            Case "c", "config", "configure", "conf"
                                $sData = ""
                                $sBuffer[$x] = ""
                                If $bPlayBeeps Then
                                    TCPSend($sSocket[$x], @CRLF & "Beep [on] or off:")
                                Else
                                    TCPSend($sSocket[$x], @CRLF & "Beep on or [off]:")
                                EndIf
                                
                                Do
                                    $sData = TCPRecv($sSocket[$x], 100)
                                    $sBuffer[$x] &= $sData
                                    If @error Then
                                        TCPCloseSocket($sSocket[$x])
                                        $sSocket[$x] = ""
                                        $sBuffer[$x] = ""
                                        $iAuth[$x] = 0
                                        ExitLoop
                                    ElseIf Asc($sData) = 0x8 Then ;backspace received
                                        $len = StringLen($sBuffer[$x])
                                        $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2) ; trim the buffer
                                        If $len = 1 Then
                                            TCPSend($sSocket[$x], ":")
                                        Else
                                            TCPSend($sSocket[$x], " " & Chr(0x8))
                                        EndIf
                                    EndIf
                                Until StringInStr($sBuffer[$x], @CRLF) > 0
                                
                                $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2)
                                If $sBuffer[$x] = "on" Then
                                    $bPlayBeeps = True
                                ElseIf $sBuffer[$x] = "off" Then
                                    $bPlayBeeps = False
                                EndIf
                                If $bPlayBeeps Then
                                    TCPSend($sSocket[$x], "Beeps are ON")
                                Else
                                    TCPSend($sSocket[$x], "Beeps are OFF")
                                EndIf

                                $sData = ""
                                $sBuffer[$x] = ""
                                If $bOpenCDTray Then
                                    TCPSend($sSocket[$x], @CRLF & @CRLF & "Open CD tray on locate: [on] or off:")
                                Else
                                    TCPSend($sSocket[$x], @CRLF & @CRLF & "Open CD tray on locate: on or [off]:")
                                EndIf
                                
                                Do
                                    $sData = TCPRecv($sSocket[$x], 100)
                                    $sBuffer[$x] &= $sData
                                    If @error Then
                                        TCPCloseSocket($sSocket[$x])
                                        $sSocket[$x] = ""
                                        $sBuffer[$x] = ""
                                        $iAuth[$x] = 0
                                        ExitLoop
                                    ElseIf Asc($sData) = 0x8 Then ;backspace received
                                        $len = StringLen($sBuffer[$x])
                                        $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2) ; trim the buffer
                                        If $len = 1 Then
                                            TCPSend($sSocket[$x], ":")
                                        Else
                                            TCPSend($sSocket[$x], " " & Chr(0x8))
                                        EndIf
                                    EndIf
                                Until StringInStr($sBuffer[$x], @CRLF) > 0
                                
                                $sBuffer[$x] = StringTrimRight($sBuffer[$x], 2)
                                If $sBuffer[$x] = "on" Then
                                    $bOpenCDTray = True
                                ElseIf $sBuffer[$x] = "off" Then
                                    $bOpenCDTray = False
                                EndIf
                                
                                If $bOpenCDTray Then
                                    TCPSend($sSocket[$x], "CD tray opener is ON" & @CRLF)
                                Else
                                    TCPSend($sSocket[$x], "CD tray opener is OFF" & @CRLF)
                                EndIf
                                
                            Case Else
                                TCPSend($sSocket[$x], "Invalid command. Please type 'help' for a list of commands.")
                        EndSwitch
                        TCPSend($sSocket[$x], @CRLF & ">")
                    EndIf
                    $sBuffer[$x] = ""
                EndIf
            EndIf
        Next
    Else
        Sleep(100)
    EndIf
WEnd

Func TCPSendAll($sMsg)
    If (Not $bLocateNow) Then
        For $n = 0 To UBound($sSocket) - 1
            If $sSocket[$n] AND $iAuth[$n] == 1 Then
                TCPSend($sSocket[$n], $sMsg)
            EndIf
        Next
    EndIf
EndFunc   ;==>TCPSendAll

Func ShowGUI()
    TCPSendAll(@CRLF & "This computer is being localized." & @CRLF & ">")

    GUISetState(@SW_SHOW, $hWnd)
    WinSetOnTop($hWnd, "", 1)

    If ($bOpenCDTray) Then
        $aDrives = DriveGetDrive("CDROM")
        For $m = 1 To $aDrives
            CDTray($aDrives[$m], "open")
        Next
    EndIf

    If ($bPlayBeeps) Then
        AdlibEnable("PlayBeep", 1000)
    EndIf

    HotKeySet("^!c", "CloseGUIclient")
EndFunc   ;==>ShowGUI

Func CloseGUIClient()
    AdlibDisable()
    Local $sPassCheck = InputBox("Enter password:", "Please enter the administrator password:", "", "*", -1, -1, -1, -1, -1, $hWnd)
    If $sPassCheck == $sAdminPass Then 
        CloseGUI()
    ElseIf ($bPlayBeeps) Then
        AdlibEnable("PlayBeep", 1000)
    EndIf
EndFunc   ;==>CloseGUIClient

Func CloseGUI()
    TCPSendAll(@CRLF & "This computer has been found." & @CRLF & ">")

    HotKeySet("^!c")

    If ($bPlayBeeps) Then
        AdlibDisable()
    EndIf

    GUISetState(@SW_HIDE, $hWnd)
    
    If ($bLocateNow) Then
        Exit
    EndIf
EndFunc   ;==>CloseGUI

Func PlayBeep()
    Beep(500, 50)
EndFunc   ;==>PlayBeep

Func _FatalError($msg)
    ConsoleWrite(@CRLF & "! " & $msg & @CRLF)
    MsgBox(0, $sAppName & $nVersion, "A fatal error has occured and " & $sAppName & " has to be closed with the error message: " & @CRLF & $msg)
EndFunc
Edited by Manadar
Link to comment
Share on other sites

I've taken your version as 1.1. I love the changes you made!

Glad you liked them :mellow: I thought I'd kicked the backspace bugs in the config section... Oh well.

Here's a few more changes: Just replace the conditional checks where the input is received (match up your comments) with the following:

;; Loop through existing connections, check if they sent us any data
    For $x = 0 to UBound($sSocket)-1
        If $sSocket[$x] Then
            
            ;; Handle incoming data
            $sData = TCPRecv($sSocket[$x],100)
            $sBuffer[$x] &= $sData
            If @error OR (Asc($sData) = 0x3 AND $iAuth[$x] == 0) Then;0x3 is ctrl+c (cancel)
                If Asc($sData) = 0x3 Then TCPSend($sSocket[$x],Chr(0x8))
                TCPCloseSocket($sSocket[$x])
                $sSocket[$x] = ""
                $sBuffer[$x] = ""
                $iAuth[$x] = 0
            ElseIf Asc($sData) = 0x8 Then ;backspace received
                $len = StringLen($sBuffer[$x])
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2) ; trim the buffer
                If $len = 1 Then
                    TCPSend($sSocket[$x],">")
                Else
                    TCPSend($sSocket[$x]," " & Chr(0x8))
                EndIf
            ElseIf $iAuth[$x] == 0 AND Not StringInStr($sBuffer[$x],@CRLF) AND StringLen($sBuffer[$x]) > 0 Then
                TCPSend($sSocket[$x],Chr(0x8)&"*")
            EndIf

This allows someone to back out of the login process with the typical ctrl+c (cancel) keystroke, and replaces the inputted password characters with * for "over-the-shoulder" security.

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

  • 1 month later...

This is great! Taking simple idea and making it even better! I was thinking of the CD-ROM opening and closing as a visual queue. Only issue is the model CR-DOMs that open with a click, and you have to close them manually. Still the improvements everyone has mad is excellent!

Link to comment
Share on other sites

Oh, I do know a simple method to keep the PC from going to sleep. I made this simple script to keep my PC from kicking up the Screen Saver when I was doing stuff and not touching the controls of my PC

Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)

HotKeySet("!{esc}", "_exit")
$exit   = TrayCreateitem("Exit")
TrayItemSetOnEvent(-1,"_exit")
TraySetState()
while 1
$m = MouseGetPos()
MouseMove($m[0], $m[1]+1, 0)
MouseMove($m[0], $m[1], 0)
sleep(1000*60)
WEnd

func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

  • 2 years later...

Glad you liked them :unsure: I thought I'd kicked the backspace bugs in the config section... Oh well.

Here's a few more changes: Just replace the conditional checks where the input is received (match up your comments) with the following:

;; Loop through existing connections, check if they sent us any data
    For $x = 0 to UBound($sSocket)-1
        If $sSocket[$x] Then
            
            ;; Handle incoming data
            $sData = TCPRecv($sSocket[$x],100)
            $sBuffer[$x] &= $sData
            If @error OR (Asc($sData) = 0x3 AND $iAuth[$x] == 0) Then;0x3 is ctrl+c (cancel)
                If Asc($sData) = 0x3 Then TCPSend($sSocket[$x],Chr(0x8))
                TCPCloseSocket($sSocket[$x])
                $sSocket[$x] = ""
                $sBuffer[$x] = ""
                $iAuth[$x] = 0
            ElseIf Asc($sData) = 0x8 Then ;backspace received
                $len = StringLen($sBuffer[$x])
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2) ; trim the buffer
                If $len = 1 Then
                    TCPSend($sSocket[$x],">")
                Else
                    TCPSend($sSocket[$x]," " & Chr(0x8))
                EndIf
            ElseIf $iAuth[$x] == 0 AND Not StringInStr($sBuffer[$x],@CRLF) AND StringLen($sBuffer[$x]) > 0 Then
                TCPSend($sSocket[$x],Chr(0x8)&"*")
            EndIf

This allows someone to back out of the login process with the typical ctrl+c (cancel) keystroke, and replaces the inputted password characters with * for "over-the-shoulder" security.

The hidden password only work once, the second time if you type the password you can see it.

PS. You can only login to the server if you type the password twice, the first time it doesn't work. (bug)

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