[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Telnet Acrobatics



What follows are two small programs which I thought might be of interest to
cypherpunks.  The first (socket.c) is a simple daemon which binds a port
and accepts connections, and then forks child processes for each one.
The second (relay.c) is a simple telnet program which opens a connection to
the specified remote host and port number.  Put together they can be used
as a telnet relay ("proxy server") that works like the term redir command.
This in itself is useful, if you want to hide where you're coming in from,
bypass a broken router or get through a firewall.  But, take a look at the
loop at the end of the second program.  It simply reads input from one
socket and writes it to another.  It would seem to me very easy to add
an encryptor/decryptor to this process and encrypt your telnet sessions.
You'd just need to exchange a key (via PGP) with the remote system, and
decide on a port number, then run crypt/dec daemons on both systems.  The
socket.c program might also be useful for socket-based remailing.  (Tho
you can set it up in your inetd.conf instead, if you have root access.)

However, I'm having a bit of trouble compiling these on some platforms.
I do not know who the original author is.  (These came out of a toolkit
for breaking system security and the author did not want to be known.)
After including a few additional libraries, I was able to compile both
under Linux, and it seems to work reasonably well.  They'll also
compile under SunOS, if you include <sys/termios.h>, but it won't
handle non-blocking I/O correctly, and can hang.  I can't get relay.c
to compile under Ultrix, though socket.c seems to work.  socket.c also
has a tendency to leave zombie processes hanging under Linux.

Anyone want to take a shot at debugging/porting it on other platforms
or adding crypto?

begin 644 socket.c
M(VEN8VQU9&4@/'-Y<R]T>7!E<RYH/@HC:6YC;'5D92`\<WES+W-I9VYA;"YH
M/@HC:6YC;'5D92`\<WES+W-O8VME="YH/@HC:6YC;'5D92`\;F5T:6YE="]I
M;BYH/@HC:6YC;'5D92`\;F5T9&(N:#X*(VEN8VQU9&4@/'-Y<R]T:6UE+F@^
M("\J(%)E<75I<F5D(&9O<B!,:6YU>"`H8G5T(&YO="!3=6Y/4RD@*B\*(VEN
M8VQU9&4@/'5N:7-T9"YH/B`O*B!297%U:7)E9"!F;W(@3&EN=7@@*&)U="!N
M;W0@4W5N3U,I("HO"B`@("`@("`@("`@("`@(`IR96%P*"E["B`@("`@("`@
M:6YT(',["B`@("`@("`@=VAI;&4H=V%I="@F<RDA/2TQ*3L*?0IM86EN*&%C
M+&%V*6EN="!A8SL*:6YT("HJ878["GL*("`@("`@("!S=')U8W0@<V]C:V%D
M9')?:6X@;7EA.PH@("`@("`@('-T<G5C="!S97)V96YT("IS<`H@("`@("`@
M(#L*("`@("`@("!F9%]S970@;75F.PH@("`@("`@(&EN="!M>69D+&YE=RQX
M+&UA>&9D/6=E=&1T86)L97-I>F4H*3L*("`@("`@("!S:6=N86PH4TE'0TQ$
M+')E87`I.PH@("`@("`@(&EF*"AM>69D/7-O8VME="A!1E])3D54+%-/0TM?
M4U1214%-+`H@("`@("`@("`@("`P*2D\,"EE>&ET*#$I.PH@("`@("`@(&UY
M82YS:6Y?9F%M:6QY/4%&7TE.150["B`@("`@("`@8GIE<F\H)FUY82YS:6Y?
M861D<BP*("`@("`@("`@("`@<VEZ96]F*&UY82YS:6Y?861D<BDI.PH@("`@
M("`@(&EF*"AS<#UG971S97)V8GEN86UE*&%V6S%=+")T8W`B*2D*("`@("`@
M("`@("`@/3TH<W1R=6-T('-E<G9E;G0@*BDP*7L*("`@("`@("`@("`@("`@
M(&EF*&%T;VDH879;,5TI/#TP*65X:70H,2D["B`@("`@("`@("`@("`@("!M
M>6$N<VEN7W!O<G0*("`@("`@("`@("`@("`@("`@("`]:'1O;G,H871O:2AA
M=ELQ72DI.PH@("`@("`@('T@96QS92!M>6$N<VEN7W!O<G0]<W`M/G-?<&]R
M=#L*("`@("`@("!I9BAB:6YD*&UY9F0L"B`@("`@("`@("`@("AS=')U8W0@
M<V]C:V%D9'(@*BDF;7EA+'-I>F5O9BAM>6$I*2EE>&ET*#$I.PH@("`@("`@
M(&EF*&QI<W1E;BAM>69D+`H@("`@("`@("`@("`Q*3PP*65X:70H,2D["FQO
M;W`Z(`H@("`@("`@($9$7UI%4D\H)FUU9BD["B`@("`@("`@1D1?4T54*&UY
M9F0L)FUU9BD["B`@("`@("`@:68*("`@("`@("`H<V5L96-T*&UY9F0K,2PF
M;75F+#`L,"PP*2$],7Q\(49$7TE34T54*&UY9F0L)FUU9BDI9V]T;PH@("`@
M("`@("`@("!L;V]P.PH@("`@("`@(&EF*"AN97<]86-C97!T*&UY9F0L,"PP
M*2D\,"EG;W1O(&QO;W`["B`@("`@("`@:68H9F]R:R@I"B`@("`@("`@("`@
M(#T],"E["B`@("`@("`@("`@("`@("!F;W(H>#TR.W@\;6%X9F0[>"LK*6EF
M*'@A/6YE=REC;&]S92AX*3L*("`@("`@("`@("`@("`@(&9O<BAX/3`[>#P*
M("`@("`@("`@("`@("`@("`@("!.4TE'.W@K*RES:6=N86PH>"Q324=?1$9,
M*3L*("`@("`@("`@("`@("`@(&1U<#(H;F5W+#`I.PH@("`@("`@("`@("`@
M("`@8VQO<V4H;F5W*3L*("`@("`@("`@("`@("`@(&1U<#(*("`@("`@("`@
M("`@("`@("`@("`H,"PQ*3L*("`@("`@("`@("`@("`@(&1U<#(H,"PR*3L*
M("`@("`@("`@("`@("`@(&5X96-V*&%V6S)=+&%V*S(I.PH@("`@("`@("`@
M("`@("`@97AI="@Q*3L*("`@("`@("!]"B`@("`@("`@8VQO<V4H;F5W*3L*
5("`@("`@("!G;W1O(&QO;W`["GT*
`
end
begin 644 relay.c
M(VEN8VQU9&4@/'-T9&EO+F@^"B-I;F-L=61E(#QN971D8BYH/@HC:6YC;'5D
M92`\<WES+W1Y<&5S+F@^"B-I;F-L=61E(#QS>7,O9FEL92YH/@HC:6YC;'5D
M92`\;F5T:6YE="]I;BYH/@HC:6YC;'5D92`\<WES+W-O8VME="YH/@HC:6YC
M;'5D92`\97)R;F\N:#X*(VEN8VQU9&4@/&9C;G1L+F@^"B-I;F-L=61E(#QS
M>7,O:6]C=&PN:#X*(VEN8VQU9&4@/'5N:7-T9"YH/@HC:6YC;'5D92`\<WES
M+W1I;64N:#X*+RHC:6YC;'5D92`\<WES+W1E<FUI;W,N:#XJ+R`@+RH@4F5Q
M=6ER960@9F]R(%-U;D]3("AB=70@;F]T($QI;G5X*2`J+PH*=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B`@=&EO<W1R+F-?;V9L86<]
M,#L*("!I;V-T;"AR96UO=&5F9"P@5$-31513+"`F=&EO<W1R*3L*("`*("!&
M1%]:15)/*"9W<FET969D<RD["B`@1D1?6D523R@F97AC97!T9F1S*3L*("`*
M("!W:&EL92AR(3TP)B9W(3TP*2!["B`@("!&1%]:15)/*"9R96%D9F1S*3L*
M("`@($9$7U-%5"AF9"P@)G)E861F9',I.PH@("`@1D1?4T54*')E;6]T969D
M+"`F<F5A9&9D<RD["B`@("!S96QE8W0H,38L("9R96%D9F1S+"`F=W)I=&5F
M9',L("9E>&-E<'1F9',L*'-T<G5C="!T:6UE=F%L("HI,"D["B`@("`O*B!4
M:&ES('=O<FMS(&)U="!I<R!W87D@=&]O('-L;W<N+BX@*B\*("`@("\J=SUR
M96%D*&9D+"9C+#$I.VEF("AW/C`I('=R:71E*')E;6]T969D+"9C+#$I.RHO
M"B`@("`O*G(]<F5A9"AR96UO=&5F9"PF8RPQ*3MI9B`H<CXP*2!W<FET92AF
M9"PF8RPQ*3LJ+PH@("`@=SUR96%D*&9D+&)U9F9E<BPQ,#(T*3MI9B`H=SXP
M*0H@("`@>PH@("`@("!O/3`["B`@("`@('=H:6QE*&\\=RD@;SUW<FET92AR
M96UO=&5F9"QB=69F97(K;RQW+6\I.PH@("`@?0H@("`@<CUR96%D*')E;6]T
M969D+&)U9F9E<BPQ,#(T*3MI9B`H<CXP*0H@("`@>PH@("`@("!O/3`["B`@
M("`@('=H:6QE*&\\<BD@;SUW<FET92AF9"QB=69F97(K;RQR+6\I.PH@("`@
L?0H@('T*"B`@8VQO<V4H<F5M;W1E9F0I.PH@(&-L;W-E*&9D*3L*("`*?0H@
`
end