From: Derek Smith on
Eric Wong
>
> You may also want to give '127.0.0.1' a try if you're sure that port is
> listening. IIRC, some newer Linux systems favor IPv6 addresses over
> IPv4 ones.

OK cool thank you!

What if I want to see any data passing over that port, 113 or any other
port? Any adjustments in this code?
SSH port 22 seems to work, well sort of. When connections come in,
shouldn't I see some type of encryption strings?

env ruby -w
require 'socket'
host = 'localhost'
port = 22
#
s = TCPSocket.open(host, port)

while line = s.gets # Read lines from the socket
puts line.chop # And print with platform line terminator
end
s.close # Close the socket when done


derek(a)vaio-ubuntu:~$ sudo ruby port_tst.rb
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1

--
Posted via http://www.ruby-forum.com/.

From: Derek Smith on
> env ruby -w
> require 'socket'
> host = 'localhost'
> port = 22
> #
> s = TCPSocket.open(host, port)
>
> while line = s.gets # Read lines from the socket
> puts line.chop # And print with platform line terminator
> end
> s.close # Close the socket when done
>
>
> derek(a)vaio-ubuntu:~$ sudo ruby port_tst.rb
> SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1

What if I want to see any data passing over that port, 113 or any other
port? Any adjustments in this code?
SSH port 22 seems to work, well sort of. When connections come in,
shouldn't I see some type of encryption strings?
--
Posted via http://www.ruby-forum.com/.

From: Eric Wong on
Derek Smith <derekbellnersmith(a)yahoo.com> wrote:
> > env ruby -w
> > require 'socket'
> > host = 'localhost'
> > port = 22
> > #
> > s = TCPSocket.open(host, port)
> >
> > while line = s.gets # Read lines from the socket
> > puts line.chop # And print with platform line terminator
> > end
> > s.close # Close the socket when done
> >
> >
> > derek(a)vaio-ubuntu:~$ sudo ruby port_tst.rb
> > SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
>
> What if I want to see any data passing over that port, 113 or any other
> port? Any adjustments in this code?

You should actually use something like tcpdump or some other sniffer.
See http://en.wikipedia.org/wiki/Tcpdump for more info.

Since tcpdump uses libpcap, and there are libpcap bindings for Ruby, so
you could probably do this via the Ruby bindings without much
difficulty (I've never tried this).

> SSH port 22 seems to work, well sort of. When connections come in,
> shouldn't I see some type of encryption strings?

No, not at all.

Your current code is opening a new and private connection to a TCP
server (sshd). This is just as if you're normally opening a new ssh
client connection to your server (without actually going through the
handshake.

TCP connections are generally private (unicast). That is when a client
connects to a server, that connection is a bidirectional bytestream
only intended for the client and server to consume.

You need special OS-level tracing tools like libpcap (or knowledge
of obscure syscalls which libpcap uses) to listen into the private
server<->client channel as a 3rd party.

--
Eric Wong

From: Eric Wong on
Eric Wong <normalperson(a)yhbt.net> wrote:
> A better solution might be to use netlink (which I still want to do
> for the project I'm working on), but that involves more work than
> writing a simple text file parser in Ruby :)

Well, I went down that rabbit hole and came out with Raindrops :)
http://mid.gmane.org/20100408011004.GA2358(a)dcvr.yhbt.net

--
Eric Wong

From: Hoodoo Wen on

there is no server side!
--
Posted via http://www.ruby-forum.com/.