Re: using tcpcat/tcpclient bidirectionally

Bruce Guenter <[email protected]> Mon, 6 Oct 2014 15:09:48 -0600
Newsgroups gmane.org.djb.miscellaneous
Message-ID <[email protected]>
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Sep 30, 2014 at 03:23:28PM +0000, [email protected] wrote:
> Hi I'm trying to use tcpcat/tcpclient as a secure and simple netcat=20
> replacement.
>=20
> At the moment netcat is used this way:
>=20
> nc 127.0.0.1 9051 < "$OUT" > "$IN" &
>=20
> This doesn't work with tcpcat:
>=20
> tcpcat 127.0.0.1 9051 < "$OUT" > "$IN" &
>=20
> How can tcpcat or tcpclient be used to do this?

You could try something like this:

tcpclient 127.0.0.1 9051 sh -c 'cat < "$OUT" >&7 & cat > "$IN" <&6; wait'

or:

tcpclient 127.0.0.1 9051 sh -c 'cat <&0 >&7 & cat <&6; wait' < "$OUT" > "$I=
N"

You probably could use some recipe using multitee, something like:

tcpclient 127.0.0.1 9051 multitee 7-1 0-6 < "$OUT" > "$IN"

What's happening here is that nc opens up the connection and then
manages all the I/O on that socket to stdout and from stdin. tcpclient
on the other hand only opens up the connection, requiring a subsidiary
program to handle the I/O. tcpcat only does the 'cat <&6' part, just
reading from the socket and never writing to it.

--=20
Bruce Guenter <[email protected]>                http://untroubled.org/

--J/dobhs11T7y2rNN
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJUMwUcAAoJEFFRvcnBTTxnL3YQAJoTTNwAkR//wJgETWVTmePR
gteubZ7XaCUWBbrcAAtsKMtwMKGXXoNrA4AVk+KwDq6GqC+qbY7j9zg6MDX+ayZp
890KAlTyRgt6tJcyKarNFMpuaFgvvJKEkko4gEs1nFLZ/0ntGklxspDMuN6clwJ4
4yo7ZD4ldzNmPJCw5CRg8ZJyIqx4yItazWkcRGgtW9rPHa8ffHUQEMFRMRkNDZhr
Hy5G4lZc7iE059kuMDuy8mKodieSW3PizRoHt85coJsFX235s1cgCiP9UVzjjMhl
03iveyiKVZ/kt3sxa6XaHrMYGOima28EG39SxHH37zSy7aLT+kGE/stg6Luutb6Z
LvWDc1L/45VA0ZfXGWtoQs3x9iEVlhVhIJfxXoIDLKIQ6f4b2pblRCjxASM6/InC
b7Lgu5DTNCiT/ShhRxYdr6S82LWwzpW0QLfzzM/6JaZbkb+GKNvZO6GToWlfKiFe
UjTGAHM/NWyzQbBdtOD4VB5aaR77xQjjFtz/I6T9yeqIU9F+t5KzP0sxKCczUvDc
a+LfM+S/a0h2x2pgmeBwqpCmmPFT6XXfay4POCHTaV05S2cdt5zNf2hMDyeXcify
mpnzKbPZdcj/cW2LhW3TZyy9UtDc3QPgvxz848Cn1pt3PvCVaasWDbDorKbCPeiM
UK16jYJoQVapHX3qlBaX
=oZUo
-----END PGP SIGNATURE-----

--J/dobhs11T7y2rNN--