Results 1 to 5 of 5
Hello,
I need to encode the contents of a secret cookie (Tor) with hex and use that to AUTHENTICATE a telnet session. I do not know how to do this ...
- 10-27-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 3
Help: hex encode contents of secret cookie and pass on to a program via. bash?
Hello,
I need to encode the contents of a secret cookie (Tor) with hex and use that to AUTHENTICATE a telnet session. I do not know how to do this and I was hoping someone could assist me or get me going in the right direction.
Here's the signal script:
Code:telnet 127.0.0.1 9051 Escape character is '^]'. AUTHENTICATE <Hexed_Cookie_Contents_Here> 250 OK signal NEWNYM 250 OK quit
thank you
- 10-27-2007 #2
Read the top part of this.
Hope this helps.
- 10-28-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 3
Hi wje_lf,
Thank you for the link, it confirmed my assumptions. I wrote a couple of lines to try and automate the process but as I'm fairly new to bash scripting I did not get it right...I'm still trying to figure it out by trail and error. (I didn't add any exit codes, etc, yet as I wanted to make it work first.)
Would you mind looking over these lines? I'm pretty sure I did not write the variable with CAT correctly, nor the use of the variable with AUTHENTICATE.
Code:cd ~/.tor # http://www.warpspeed.com.au/Products/OS2/GU/Manual/hexdump.htm hexdump control_auth_cookie >>hex_cookie_output.txt # Set variable of magic cookie hex dump using CAT HEX_COOKIE="cat $hex_cookie_output.txt" telnet 127.0.0.1 9051 # Is the following line needed? Escape character is '^]'. # Use magic cookie hex dump variable w/authenticate AUTHENTICATE "HEX_COOKIE" 250 OK signal NEWNYM 250 OK quit
Another issue is that 'hexdump' has an output like:...and Tor expects the following hex format with AUTHENTICATE. Should I use a different hex dumping tool? Is there a command or app to remove white space, etc, from 'hexdump' output?Code:0000000 fce4 cb66 1640 d895 9a5b f12c 3ed6 c075 0000010 d4dc c325 4dc7 b33b b82c 02cd e08b c752 0000020
Code:AUTHENTICATE ee10875cb04a837374918510d75ff600f85abc04a33fda23895954dcd69a6a3b
Thank you!
- 10-28-2007 #4
You can solve all your hex dumping problems thus:
Your next problem will be finding a way to feed that to telnet. A simple answer here cannot instruct you fully in that. I recommend you do this at the command line:Code:HEX_COOKIE=$(echo $(hexdump control_auth_cookie | sed -e 's/^.......//') | sed -e 's/ //g')
expect is a program which lets you write scripts which simulate typing keys (as in, typing info to telnet) and reading responses.Code:man expect
- 10-28-2007 #5Just Joined!
- Join Date
- Oct 2007
- Posts
- 3
Hi,
thank you for that code, I have much to learn. I will read the manual of expect.


Reply With Quote