Skip to content

Commit 3f6415f

Browse files
mashiro01rootzyazhb
authored
Fixed the problems with threads that cannot be stopped (#18)
* fixed threads; change iplist Co-authored-by: root <root@DESKTOP-FU09PBQ.localdomain> Co-authored-by: ZYA <zyazhb@yahoo.com>
1 parent 6b6ae7a commit 3f6415f

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python3
2-
from fake_useragent import UserAgent
32
import argparse
43
import myutils
54

multi.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ def __init__(self, ip, domain):
4242
self.domain = domain
4343

4444
def run(self):
45-
response = subprocess.check_output(
46-
"dig @{0} {1}".format(self.ip, self.domain), shell=True)
47-
if r";; connection timed out; no servers could be reached" not in str(response):
48-
iplist.append(self.ip)
45+
# response = subprocess.check_output(
46+
# "dig @{0} {1} +short".format(self.ip, self.domain), shell=True)
47+
48+
proc = subprocess.Popen(
49+
"dig @{0} {1} +short".format(self.ip, self.domain), shell=True, stdout=subprocess.PIPE)
50+
response = proc.stdout.read()
51+
proc.kill()
52+
if r";; connection timed out; no servers could be reached" not in str(response) and \
53+
response.decode() != '':
54+
ans = str(response).split("\\n")[1]
55+
if 'github.com.' not in ans:
56+
iplist.append(ans)
4957

5058

5159
def multi_local_dns(domain):
@@ -60,5 +68,7 @@ def multi_local_dns(domain):
6068
T_thread[i].start()
6169
time.sleep(3)
6270

63-
print("[+]Got domain! \n" + str(iplist))
64-
return domain, iplist
71+
# 去重
72+
iplist_change = list(set(iplist))
73+
print("[+]Got domain! \n" + str(iplist_change))
74+
return domain, iplist_change

myutils.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import multi
2+
from fake_useragent import UserAgent
13
import requests
24
import re
3-
from ping3 import ping
4-
import multi
55
from prettytable import PrettyTable
66

77

@@ -11,8 +11,18 @@ def run_core(domain, area):
1111
iplist = ['220.181.38.148', '39.156.69.79', '210.23.129.34', '210.23.129.34', '220.181.38.148', '39.156.69.79', '202.108.22.220', '220.181.33.31', '112.80.248.64', '14.215.178.80', '180.76.76.92', '210.23.129.34', '210.23.129.34', '39.156.69.79', '220.181.38.148', '203.12.160.35', '203.12.160.35', '39.156.69.79', '220.181.38.148',
1212
'202.108.22.220', '220.181.33.31', '112.80.248.64', '14.215.178.80', '180.76.76.92', '203.12.160.35', '203.12.160.35', '220.181.38.148', '39.156.69.79', '61.8.0.113', '61.8.0.113', '220.181.38.148', '39.156.69.79', '202.108.22.220', '220.181.33.31', '112.80.248.64', '14.215.178.80', '180.76.76.92', '61.8.0.113', '61.8.0.113']
1313
else:
14-
domain, ipll = multi.multi_local_dns(domain)
15-
return domain, ipll
14+
domain, iplist = multi.multi_local_dns(domain)
15+
return domain, iplist
16+
17+
18+
def run_remote_core(domain, area):
19+
ua = UserAgent()
20+
headers = {"User-Agent": ua.random, }
21+
r = requests.get("https://en.ipip.net/dns.php?a=dig&host=" +
22+
domain+"&area%5B%5D="+area, headers=headers)
23+
iplist = re.findall("\\d+\\.\\d+\\.\\d+\\.\\d+", r.text)
24+
print("[+]Got domain! \n" + str(iplist))
25+
return domain, iplist
1626

1727

1828
def clean(iplist):

0 commit comments

Comments
 (0)