-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonion_requests.py
More file actions
68 lines (53 loc) · 1.46 KB
/
onion_requests.py
File metadata and controls
68 lines (53 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests as rq
from bs4 import BeautifulSoup as bs
from stem import Signal
from stem.control import Controller
import time
def get_onions():
link = "https://ahmia.fi/onions/"
r = (rq.get(link)).content
html = bs(r,"html.parser")
onion = html.find("br").parent
l = (onion.text).replace(" ","").replace("\n\n","\n")
return l
def write_onions():
onions = get_onions()
print onions
file = open("onions.txt","a+")
file.write(onions)
links = file.readlines()
return links
def read_onions():
lines = write_onions()
proxies = {'http': 'socks5://127.0.0.1:9050','https': 'socks5://127.0.0.1:9050'}
try:
for line in lines:
send_requests(line,proxies)
except:
print "error"
#read_onions()
def send_requests(onion,proxies):
try:
r = rq.get(str(onion),proxies=proxies)
html = bs(r.content,"html.parser")
title = html.title.text
print "[+] %s \t %s"%(title, onion)
except:
print "[-] Error"
def change():
# Tor uses the 9050 port as the default socks port
proxies = {'http': 'socks5://127.0.0.1:9050','https': 'socks5://127.0.0.1:9050'}
link = "http://ipinfo.io/json"
r = rq.get(link,proxies=proxies)
print r
renew()
r = rq.get(link,proxies=proxies)
print r
# signal TOR for a new connection
def renew():
with Controller.from_port(port = 9051) as controller:
controller.authenticate(password="5w0rdf15h")
controller.signal(Signal.NEWNYM)
time.sleep(5)