Advertisement
Guest User

NEWNYM signal for Tor (Windows)

a guest
Aug 11th, 2013
1,410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Code adapted from a Tor-talk message by °¤¦¦Ç£ówñ_Ðèvï£_ß󥦦¤° [clowndevil at gmail.com]; Thu Aug 3 17:25:55 UTC 2006 https://lists.torproject.org/pipermail/tor-talk/2006-August/001738.html
  2.  
  3. ' This script is intended to give Windows users a way to send the NEWNYM () signal to Tor. Non-Windows users have other options, including Arm (https://www.torproject.org/projects/arm.html.en).
  4.  
  5. ' As of TorBrowser 3.0alpha1 Vadalia is no longer included, which means we no longer have an easy to send the NEWNYM signal, so I brought this old code back from the dead.
  6. ' This is how I used ot control Tor before Vadalia and other GUI's came along (circa 2006) . . . other signals can be sent, too, e.g. HUP, SHUTDOWN, etc.
  7.  
  8. ' Important comments by Robert Ransom, and others: https://lists.torproject.org/pipermail/tor-talk/2011-March/019725.html
  9.  
  10.  
  11.  
  12. 'Make torsock out socket name
  13. set torsck = CreateObject("Toolsack.Socket")
  14.  
  15. 'Connect to Tor's control port
  16. torsck.Connect "localhost", 9051
  17.  
  18. 'Auth so we can send commands
  19. torsck.Write "AUTHENTICATE" & vbcrlf
  20.  
  21. 'Read the buffer so we know what to do
  22. chktxt = torsck.ReadLine
  23.  
  24. if (chktxt = "250 OK") then
  25.   'If we get an OK then send the NEWNYM signal
  26.  torsck.Write "SIGNAL NEWNYM" & vbcrlf
  27. else
  28.   'Other wise goto a failed message box
  29.  call failed
  30. end if
  31.  
  32. 'Again read the buffer
  33. chktxt = torsck.ReadLine
  34.  
  35. if (chktxt = "250 OK") then
  36.   'If we get an OK then Tor carried out NEWNYM fucntion and user is using a different Exit node
  37.  'As per Lunar'S commonets on the Tor Blog: https://blog.torproject.org/blog/tor-browser-bundle-30alpha3-released#comment-33544
  38.  msgbox "All subsequent connections will appear to be"&_
  39. "different than your old connections. This means the"&_
  40. "subsequent Tor route (circuit) will use a different"&_
  41. "Exit node and therefore a different IP address."&_
  42. ""&_
  43. "WARNING: This script *only* sends the NEWNYM"&_
  44. "signal to Tor, which instructs Tor to use a different"&_
  45. "Exit node (IP address) than the one its currently using."&_
  46. "This script *does not* create unlinkable new pseudoanonymous"&_
  47. "Tor 'identity' for the user! This script is *not* a replacement"&_
  48. "for TorBrowserButton's 'New Identity' feature"&_
  49. ""&_
  50. "As per Lunar: [After using this script with TorBrowser,] any"&_
  51. "cookies that had been [previously] set by a website would make it"&_
  52. "possible to link between the old and the new [Exit node] IP address."&_
  53. "The [TorBrowserButton closes all TorBrowser tabs when a user selects"&_
  54. "its New Identity feature and re-launches TorBrowser so it can reset]"&_
  55. "the internal browser state, [which] is the only way to provide"&_
  56. "unlikable visits to the same site (or ad networks for that matter)."
  57. else
  58.   'Other wise goto failed message box
  59.  call failed2
  60. end if
  61.  
  62. 'Everything went good so finish the connection
  63. call finish
  64.  
  65. sub failed
  66.   'Message box for failed auth
  67.  msgbox "Failed to authenticate to Tor."
  68.   call finish
  69. end sub
  70.  
  71. sub failed2
  72.   'Message box for failed NEWNYM signal
  73.  msgbox "Failed to send NEWNYM signal; you're still using the same Tor route (circuit)."
  74.   call finish
  75. end sub
  76.  
  77. sub finish
  78.   'Send a QUIT command to Tor and close the connection
  79.  torsck.Write "QUIT" & vbcrlf
  80.  
  81.   'Again read the buffer
  82.  chktxt = torsck.ReadLine
  83.  
  84.   if (chktxt = "250 closing connection") then
  85.     'Do nothing because the Tor closed the connection for us
  86.  else
  87.     'Something happen when trying to clsoe the connection so close it anyway
  88.    torsck.Close
  89.   end if
  90. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement