Skip to content

Instantly share code, notes, and snippets.

@Saleh7
Created November 17, 2016 07:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saleh7/282ac5891b1d53f1c0d56f31ae5b129b to your computer and use it in GitHub Desktop.
Save Saleh7/282ac5891b1d53f1c0d56f31ae5b129b to your computer and use it in GitHub Desktop.
Fake voting pollcode.com :( requests using Python over Tor
import time, os, requests
num = input( "\x1b[1;31;50m How many poll:\x1b[0m" )
if(int(num)):
def pollcode():
Proxy = {
'http' : "socks5://127.0.0.1:9050",
'https' :"socks5://127.0.0.1:9050"
}
Post = {'answer': '3'} # change answer
url = 'http://poll.pollcode.com/45138481' # change url poll
res = requests.post(url, proxies=Proxy, data=Post, timeout=100, verify=False)
ip = requests.get('http://icanhazip.com',proxies=Proxy)
print('\x1b[6;30;42m' + 'Success!' + '\x1b[0m ' + ip.text)
os.system("killall -HUP tor")
time.sleep(0.3)
for i in range(0, num):
pollcode()
@Saleh7
Copy link
Author

Saleh7 commented Nov 17, 2016

apt-get install tor
nano /etc/tor/torrc
Uncomment the : ControlPort 9051

pip install -U requests[socks]

@safeerk007
Copy link

num line 18 error first, after changing num to 1000, other many errors:
1st error befoe correcting num integer:
�[1;31;50m How many poll:�[0m10
Traceback (most recent call last):
File "C:\Users\safeer\Desktop\pull.py", line 18, in
for i in range(0, num):
TypeError: 'str' object cannot be interpreted as an integer

2nd time error after putting value in line18 num field:
================== RESTART: C:\Users\safeer\Desktop\pull.py ==================
�[1;31;50m How many poll:�[0m10
Traceback (most recent call last):
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\socks.py", line 832, in connect
super(socksocket, self).connect(proxy_addr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\contrib\socks.py", line 88, in _new_conn
**extra_kw
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\socks.py", line 262, in create_connection
raise err
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\socks.py", line 252, in create_connection
sock.connect((remote_host, remote_port))
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\socks.py", line 100, in wrapper
return function(*args, **kwargs)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\socks.py", line 844, in connect
raise ProxyConnectionError(msg, error)
socks.ProxyConnectionError: Error connecting to SOCKS5 proxy 127.0.0.1:9050: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 956, in send
self.connect()
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\contrib\socks.py", line 110, in _new_conn
"Failed to establish a new connection: %s" % error
urllib3.exceptions.NewConnectionError: <urllib3.contrib.socks.SOCKSConnection object at 0x000001A19CC539B0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 445, in send
timeout=timeout
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: SOCKSHTTPConnectionPool(host='poll.pollcode.com', port=80): Max retries exceeded with url: /21673531 (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSConnection object at 0x000001A19CC539B0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\safeer\Desktop\pull.py", line 19, in
pollcode()
File "C:\Users\safeer\Desktop\pull.py", line 12, in pollcode
res = requests.post(url, proxies=Proxy, data=Post, timeout=100, verify=False)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "C:\Users\safeer\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: SOCKSHTTPConnectionPool(host='poll.pollcode.com', port=80): Max retries exceeded with url: /21673531 (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSConnection object at 0x000001A19CC539B0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

@laroi
Copy link

laroi commented Aug 10, 2018

@safeerk007 post the full code

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