Skip to content

Instantly share code, notes, and snippets.

@ahxxm
Created December 9, 2015 09:52
Show Gist options
  • Save ahxxm/699fc0f0371cee09622b to your computer and use it in GitHub Desktop.
Save ahxxm/699fc0f0371cee09622b to your computer and use it in GitHub Desktop.
tor_vote.py
import json
import requests
import random
import socket
import socks
import time
from subprocess import call
# Mount Tor proxy into requests
ip='localhost'
port = 9050
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, ip, port)
socket.socket = socks.socksocket
# Create a used_ip_address list, since this program is blind to
# Tor...
already_used_ip = set()
already_used_ip.add('0.0.0.0')
# Different browser headers
# https://raw.githubusercontent.com/selwin/python-user-agents/master/user_agents/devices.json
with open('devices.json') as devices_list:
devices = json.load(devices_list)
devices_list = list(devices.keys())
# Get referer url then do actual vote
referer_url = ''
vote_post_url = ''
def get_my_ip():
r = requests.get(r'http://jsonip.com')
ip = r.json()['ip']
return ip
def vote(voted=0):
try:
ip = get_my_ip()
except:
ip = '0.0.0.0'
print(ip)
if ip in already_used_ip:
print('ip {} already used.'.format(ip))
return voted
else:
session = requests.session()
actual_header = devices[devices_list[random.randint(0, len(devices_list) - 1)]]['ua_string']
headers = {
'User-Agent': actual_header,
'Referer': referer_url
}
session.get(referer_url)
rr = session.get(vote_post_url, headers=headers)
if rr.status_code == 200:
voted += 1
already_used_ip.add(ip)
print('vote count: {}'.format(voted))
return voted
voted = 0
while True:
try:
voted = vote(voted)
time.sleep(1)
call(["""(echo authenticate '""'; echo signal newnym; echo quit) | nc localhost 9051"""], shell=True)
if voted == 300:
break
except KeyboardInterrupt:
break
@ahxxm
Copy link
Author

ahxxm commented Apr 15, 2019

SocksPort 0.0.0.0:9050
LearnCircuitBuildTimeout 1
NewCircuitPeriod 1
MaxCircuitDirtiness 1
MaxClientCircuitsPending 500
ControlPort 9051
CircuitPriorityHalflife 1

CircuitBuildTimeout 10

HardwareAccel 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment