Forum: Ruby Obfuscating/suppressing password output in TCPSocket?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nate Smith (Guest)
on 2006-03-09 22:48
(Received via mailing list)
Hello,

I'm attempting to suppress the output of a password that is sent via
a TCPSocket. If I have the following code:

server = TCPServer.new( '127.0.0.1', 8888 )
socket = server.accept()  # socket is now a TCPSocket
password = socket.gets()

is there a simple way to suppress the password on the client side
(I.E., turn off client-side echoing of the password)? I know there is
a way to do this with sockets in C, but can't figure out a way with
TCPSocket. Thanks!

Nate
Bernhard 'elven' Stoeckner (Guest)
on 2006-03-09 23:46
(Received via mailing list)
Nate Smith scribbled on Thursday 09 Mar 2006 21:46:

> (I.E., turn off client-side echoing of the password)? I know there is
> a way to do this with sockets in C, but can't figure out a way with
> TCPSocket. Thanks!
>
> Nate

You'd need to implement the telnet protocol and make your peer use a
telnet
client in order to implement noecho.
Edward F. (Guest)
on 2006-03-10 00:32
(Received via mailing list)
On Fri, Mar 10, 2006 at 05:46:12AM +0900, Nate Smith wrote:
> is there a simple way to suppress the password on the client side
> (I.E., turn off client-side echoing of the password)? I know there is
> a way to do this with sockets in C, but can't figure out a way with
> TCPSocket. Thanks!

The issue isn't with sockets, it's with the client terminal.  You need
to manipulate the terminal settings.  I see ruby-password and
ruby-termios packages on RAA that might do what you want.

http://raa.ruby-lang.org/project/ruby-password/0.5.3

regards,
Ed
Nate Smith (Guest)
on 2006-03-10 08:13
(Received via mailing list)
Hello,

I created a server, accepted a connection via telnet, and if the
client sends a control-c, the TCPSocket hangs. It can still read
data, but writing to it produces no output on the client side. Here's
the code:

server = TCPServer.new( '127.0.0.1', 31337 )
socket = server.accept

# now client (via telnet), sends control-c

socket.print "test" # <-- produces no output on client

Anyone know what's up? I checked for exception throws and there are
none, and the server side keeps running normally, besides this.

Nate
Nate Smith (Guest)
on 2006-03-10 08:31
(Received via mailing list)
Sorry, the code should look like:


server = TCPServer.new( '127.0.0.1', 31337 )
socket = server.accept

data = socket.gets    # added this line
# now client (via telnet), sends control-c

socket.print "test" # <-- produces no output on client
This topic is locked and can not be replied to.