Tor Bridge Randomizer


SUBMITTED BY: jamesd500

DATE: June 28, 2017, 9:22 a.m.

FORMAT: Text only

SIZE: 3.3 kB

HITS: 874

  1. #!/usr/local/bin/python
  2. # -*- coding: utf-8 -*-
  3. from random import randint
  4. ####################################################################################################
  5. '''
  6. Copyright 2017 James Davis
  7. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  9. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  10. '''
  11. ####################################################################################################
  12. file_name="bridge_list.txt" # the name of the file (with extension) containing your list of bridges
  13. nr_bridge=3 # the number of bridges you want to randomly select
  14. ####################################################################################################
  15. selectedbridge=[] # read the bridges from your file line-by-line and strip the '\n' character from it
  16. with open(file_name) as f:
  17. content = f.readlines()
  18. content = [x.strip() for x in content]
  19. max_rows=len(content)
  20. f.close()
  21. ####################################################################################################
  22. print ""
  23. for i in range (0,nr_bridge): # print the randomly selected bridges into the terminal
  24. selectedbridge.append(randint(0,max_rows-1))
  25. print content[selectedbridge[i]]
  26. ####################################################################################################
  27. print ""
  28. print ""
  29. print "--------------------------------------------------------------------------"
  30. print '▪ If these bridges are not good, then delete them from your list, by writing'
  31. print '"Delete" (case-sensitive) in the terminal.'
  32. print ""
  33. print '▪ Otherwise after you have copied them into Tor Network Settings, just hit'
  34. print '"Enter" , and the clipboard will be wiped'
  35. print "--------------------------------------------------------------------------"
  36. ####################################################################################################
  37. keyboard_input=raw_input()
  38. if (keyboard_input=="Delete"): # remove those bridges from the brigde list file
  39. for alpha in range(0,nr_bridge):
  40. f = open(file_name,"r")
  41. lines = f.readlines()
  42. f.close()
  43. f = open(file_name,"w")
  44. for line in lines:
  45. if line!= (content[selectedbridge[alpha]]+"\n"):
  46. f.write(line)
  47. f.close()
  48. else:
  49. import os
  50. os.system("echo "" | xclip -selection clipboard") # empty clipboard

comments powered by Disqus