nyxnor / tor-ctrl

Raw use of tor's controller
Other
5 stars 3 forks source link

`SAFECOOKIE` authentication method #1

Open nyxnor opened 2 years ago

nyxnor commented 2 years ago

It is not working currently because it can't read the replies because all commands are sent, piped to networking tool (netcat/socat/telnet) then it is analyzed by tor;s controller, because of this I am having a bad time to get the ServerNonce without closing the connection, which would result on a new servernonce next time.

https://stem.torproject.org/faq.html#i-m-using-safe-cookie-authentication

nyxnor commented 2 years ago

post from 2007 that may help https://www.linuxquestions.org/questions/programming-9/shell-script-to-automate-telnet-573950/

You can use following bash script as an example:
http://tiocu.svn.sourceforge.net/vie...il?revision=58. Function `wait4ack()' and lines below `echo connecting...' are of interest for you.

Shortly speaking we run telnet process in background and associate file descriptors 3 and 4 with its stdin and stdout using something like this:
Code:

mkfifo $FIFO
exec 4< <(telnet $SERVER 25  < $FIFO 2> /dev/null &)
exec 3>$FIFO

Now we can send commands to telnet through 3'rd fd and recieve responses through 4'th one:
Code:

echo $comm        >&3
wait4ack "$optn"  <&4

wait4ack() reads its stdin (i.e. 4'th file descriptor) until something like '+OK' in POP3 protocol or 250 in SMTP (see corresponding RFC document).

Hope, this helps.

firstfire == agre.
nyxnor commented 2 years ago

pfetch redirection might also help https://github.com/dylanaraps/pfetch/blob/master/pfetch

nyxnor commented 2 years ago

exec man https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_20