mirror of
https://github.com/minoplhy/filters-maker.git
synced 2024-12-22 18:18:13 +00:00
init
This commit is contained in:
commit
f723dc650d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.vscode
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 minoplhy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
74
crawler.py
Normal file
74
crawler.py
Normal file
@ -0,0 +1,74 @@
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
import re
|
||||
|
||||
input = sys.argv[1]
|
||||
|
||||
print('starting . . . ')
|
||||
|
||||
try:
|
||||
os.remove(input)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def download_filters(url):
|
||||
print("downloading: ",url)
|
||||
|
||||
get = requests.get(url)
|
||||
if get.status_code == requests.codes.ok:
|
||||
with open(input, 'ab') as f:
|
||||
for data in get:
|
||||
f.write(data)
|
||||
return url
|
||||
|
||||
def filtering(filters_welcome):
|
||||
print("filtering . . .")
|
||||
with open(filters_welcome, 'r') as f:
|
||||
lines = f.read().splitlines()
|
||||
with open(filters_welcome, 'w') as f:
|
||||
for line in lines:
|
||||
if not line.startswith(('#',';','@','$',' NS','@@||')) and line.strip():
|
||||
f.write('\n'.join([line + '\n']))
|
||||
print("++ successful!")
|
||||
f.close()
|
||||
|
||||
def filteringcon(filters_regex_one):
|
||||
print("filtering . . .")
|
||||
with open(filters_regex_one) as f:
|
||||
file = f.read().split('\n')
|
||||
for i in range(len(file)):
|
||||
file[i] = re.sub(';.*', '', file[i])
|
||||
file[i] = re.sub(' CNAME .$', '', file[i])
|
||||
file[i] = re.sub(' CNAME . $', '', file[i])
|
||||
with open(filters_regex_one, 'w') as f1:
|
||||
f1.writelines(["%s\n" % item for item in file])
|
||||
print("++ successful!")
|
||||
f.close()
|
||||
|
||||
def killingdup(duplicated_file):
|
||||
print('Getting rid of duplicated line')
|
||||
with open(duplicated_file, 'r') as f:
|
||||
lines = set(f.readlines())
|
||||
with open(duplicated_file, 'w') as f:
|
||||
f.writelines(set(lines))
|
||||
print("++ successful!")
|
||||
f.close()
|
||||
|
||||
download_filters("https://dbl.oisd.nl/")
|
||||
download_filters("https://hosts.netlify.app/Pro/rpz.txt")
|
||||
download_filters("https://filters.kylz.nl/RPZ/adguard/dns.txt")
|
||||
download_filters("https://filters.kylz.nl/RPZ/adguard/cname-tracker.txt")
|
||||
download_filters("https://filters.kylz.nl/RPZ/adguard/cname-original.txt")
|
||||
download_filters("https://filters.kylz.nl/RPZ/stevenblack/f-s.txt")
|
||||
download_filters("https://filters.kylz.nl/RPZ/someonewhocares/rpz.txt")
|
||||
download_filters("https://block.energized.pro/ultimate/formats/rpz.txt")
|
||||
download_filters("https://urlhaus.abuse.ch/downloads/rpz/")
|
||||
filtering(input)
|
||||
filteringcon(input)
|
||||
killingdup(input)
|
||||
|
||||
print('process completed.')
|
||||
print('Location of your file is ' + input)
|
||||
|
||||
exit()
|
46
maker-rpz.py
Normal file
46
maker-rpz.py
Normal file
@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
excluded = sys.argv[1]
|
||||
input = sys.argv[2]
|
||||
output = sys.argv[3]
|
||||
UTC = pytz.utc
|
||||
date = datetime.datetime.now(UTC)
|
||||
|
||||
def linecounter():
|
||||
with open(input) as f:
|
||||
for i, l in enumerate(f):
|
||||
pass
|
||||
return i + 1
|
||||
|
||||
def RPZbuilding():
|
||||
with open(excluded ,'r') as f:
|
||||
exclude = f.read().split()
|
||||
with open(input ,'r') as f:
|
||||
lines = f.read().splitlines() # read lines
|
||||
with open(output ,'w') as f:
|
||||
f.write('; Title : Minoplhy Personal Blocklist\n')
|
||||
f.write('; Description : My Very Personal DNS Blocklist plus crawling from the source\n')
|
||||
f.write('; Source : Source.txt\n')
|
||||
f.write('; Rule Counter : ' + str(linecounter()) +' Rules\n')
|
||||
f.write('; Format : RPZ\n')
|
||||
f.write('; Licenses : MIT\n')
|
||||
f.write('; Compiled Date : ' + str(date) +'\n\n')
|
||||
f.write('$TTL 12h\n')
|
||||
f.write('@ IN SOA localhost. root.localhost. (1 6h 1h 1w 2h)\n')
|
||||
f.write(' IN NS localhost.\n\n')
|
||||
for line in lines:
|
||||
if line.strip() and not line in exclude and not line.startswith(';'):
|
||||
f.write('\n'.join([line + ' CNAME .\n']))
|
||||
if line.startswith((';','$','@',' IN')):
|
||||
f.write('\n'.join([line + '\n']))
|
||||
if not line.strip():
|
||||
f.write('\n'.join([line + '\n']))
|
||||
f.close()
|
||||
os.remove(input)
|
||||
|
||||
RPZbuilding()
|
||||
exit()
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
requests==2.26.0
|
||||
pytz==2021.1
|
9
source.txt
Normal file
9
source.txt
Normal file
@ -0,0 +1,9 @@
|
||||
https://dbl.oisd.nl/
|
||||
https://hosts.netlify.app/Pro/rpz.txt
|
||||
https://filters.kylz.nl/RPZ/stevenblack/f-s.txt
|
||||
https://filters.kylz.nl/RPZ/adguard/dns.txt
|
||||
https://filters.kylz.nl/RPZ/adguard/cname-tracker.txt
|
||||
https://filters.kylz.nl/RPZ/adguard/cname-original.txt
|
||||
https://filters.kylz.nl/RPZ/stevenblack/f-s.txt
|
||||
https://filters.kylz.nl/RPZ/someonewhocares/rpz.txt
|
||||
https://block.energized.pro/ultimate/formats/rpz.txt
|
Loading…
Reference in New Issue
Block a user