PersianBlocker
PersianBlocker copied to clipboard
گفت و گو / Chit-Chat
عرض قدردانی
با توجه به پراکندگیهای موجود (و عدم maintanance نمودن لیستهای اقدامی پارسی در گذشته) متأسفانه امکان لحاظ کردن لیستهای زیر به طور مستقیم در uBlockOrigin برای هر شخص آسان نبود:
# uBlock Iran
https://raw.githubusercontent.com/mboveiri/ublock-iran/master/fa-ir-adblist.txt
# AdBlock Iran
https://raw.githubusercontent.com/farrokhi/adblock-iran/master/filter.txt
# AdBlock Farsi
https://raw.githubusercontent.com/SlashArash/adblockfa/master/adblockfa.txt
# AdBlock Persian
https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Adblock-Persian.txt
# AdBlock Persian from https://adblockplus.org/forum/viewtopic.php?f=2&t=7658
https://ideone.com/plain/K452p
# uBOPa filter list - may contain false positives
https://raw.githubusercontent.com/nimasaj/uBOPa/master/uBOPa.txt
در صورتی که به زحمت بسیار مفید maintain کردن لیست PersianBlocker ادامه دهید (و با توجه به include شدن در فهرست official افزونه uBlockOrigin( پس از نصب این افزونه، بهراحتی با چند کلیک میتوان این لیست را فعال نمود و بلافاصله از مزایای آن برخوردار شد.
با توجه به این مسئله، از زحمات شما قدردانی میکنم 👍🏻
درود بر شما. همونطور که عرض کردید یکی از اهداف این پروژه PersianBlocker از آغاز همین بود که فیلتر های مفیدِ 5 لیست کنونی رو در یک لیست تجمیع بکنیم و فیلتر های نامفید و به شدت عمومی و فیلتر های سایت هایی که دیگه بسته شدن رو بریزیم دور.
یکی دیگه از اهداف، همکاری کردن با بالادست(Upstream) هست که در صورت امکان یک سری فیلتر ها در بالادست ادغام بشه؛ مثلاً سایت های تبلیغاتی/ردیابی تو مایه های یکتانت یا کاپریلا که توی EasyList یا uBlock Filters یا EasyPrivacy یا uBlock Privacy نیستن رو پیشنهاد بکنم و اضافه بشن.
یک موضوع مهم دیگه هم که شوربختانه توی هیچکدوم از اون لیست هایی که فرستادید رعایت نشده بود، فیلتر های مربوط به ردیابی(Tracking) بود.
یعنی حتی یکی از اون لیست ها ندیدم فیلتری داشته باشن که tracker.digikala.com
یا analytics.digikala.com
رو مسدود کنه.
اما خوشبختانه توی PersianBlocker تا جایی که متوجه شدم ازون دست فیلتر ها هم لحاظ کردم.
در حال حاضر لیست Adblock-Iran به طور کامل بازنویسی شده و فیلتری ازش نمونده که نیاز به لحاظ کردن داشته باشه. لیست uBOPa هم تقریباً فیلتر های مفیدش به PersianBlocker افزوده شده. فقط میمونه اون چند تا لیست دیگه، که به مرور در این لیست ترکیب خواهند شد.
تنها مشکلی که وجود داره اینه که احساس میکنم اطلاع رسانی زیادی باید انجام بشه تا کاربران پارسی زبانِ uBlock Origin از وجود همچین لیستی آگاه بشن. چون مطمئنم خیلی کاربرای پارسی زبان uBlock Origin اصلاً نمیدونن که این افزونه لیست های Regional هم داره. لیست هایی مانند Adblock-Iran و Adblock Farsi هر کدوم 230 و 50 ستاره دارن اما نمیدونم چطور کاربران پارسی زبان اون لیست ها رو پیدا کردن و توشون مشارکت انجام دادن.
@MasterKia Great to see PersianBlocker included in https://github.com/gorhill/uBlock/commit/33b839fdd03f74689df3ee2b5c25a06435b350e0, but I'd like to ask to still track changes and updates to adblock-iran and include them in PersianBlocker when/if any new items are added (same with my maintained lists, e.g. additional-hosts/unwanted-iranian).
Maybe eventually the adblock-iran would point to PersianBlocker, in order to avoid forks and duplicate entries between lists.
track changes and updates to adblock-iran and include them in PersianBlocker when/if any new items are added
In a perfect world that's what I planned to do going forward; since my initial goal was to unite all Persian filterlists.
But seeing as farrokhi has blocked me from his Adblock-Iran repo, unfortunately I'll be unable to get notified of new changes/commits.
More details about that: https://github.com/uBlockOrigin/uAssets/discussions/13259#discussioncomment-2899326
my maintained lists, e.g. additional-hosts/unwanted-iranian
Sure thing, but are there any other list dedicated to Persian websites other than Unwanted-Iranian as you said "list_s_"?
Maybe eventually the adblock-iran would point to PersianBlocker, in order to avoid forks and duplicate entries between lists. I hope so, but I don't think that would happen unless farrokhi changes his mind.
Anyhow, I'm open to all your suggestions/changes:
ناسلامتی شما اسطوره من در زمینه مسدودسازی تبلیغات هستی؛ شاید 10 سال گذشته باشه اما با این حال من هیچوقت اسکریپت هوشمندانه و زیرکانه شما برای مسدود کردن تبلیغات بلاگفا/رزبلاگ رو یادم نمیره و نخواهد رفت ;-)
همینطوری میبندم که تو چشم نباشه :-)
مرسی بابت پاسخ extensive شما؛ و با کلیه موارد لحاظ شده بنده موافق هستم (به خصوص موارد مرتبط به Trackers و Duplicate/dead ها).
دو تا مسئله دیگه هم هست که می خواستم اشاره کنم:
- ادغام لیست های گذشته: من چندین لیست در گذسته به صورت private نگه داری کرده بودم، که قصد ادغام با لیست adblock-iran و حذف رول های تکراری و مرده را داشتم، با این حال با توجه به اینکه PersianBlocker به صورت لیست official ثبت شد فکر کنم بهتر این است که این فایل ها را برای شما ارسال کنم و درخواست داشته باشم موارد مورد نیازی که در این فایل ها مشاهده می فرمایید را به PersianBlocker اضافه نمایید، که در این صورت پیشاپیش از زحمات شما قدر دانی می کنم.
📦 CombinedIRFilterBlockList-DRS.txt
P.S. I'm sorry if this list is a bit exhaustive, as I haven't had time to maintain it yet. However, if you could go through it I would deeply appreciate your effort 😄
- ارائه در قالب Domains Only: با توجه به اینکه بنده (و بسیاری از دوستان) از سولوشن هایی مانند Pi-hole و DNScrypt-proxy جهت بلاک نمودن دامنه های تبلیغات و Tracker استفاده می کنند، متشکر می شوم که به گونه ای دامنه های جدید را اینکلود بفرمایید که parser هایی که لیست PersianBlocker را تبدیل به فرمت domains می کنند، بتوانند دامنه هایی که به طور کلی بایستی بلاک شوند را استخراج کنند (به عنوان مثال برخی از parser ها به رول های 3p در زمان استخراج توجه نمی کنند). شاید در نظر داشته باشید که مانند additional-hosts/unwanted-iranian یک لیست domains only نیز ارائه دهید، یا اینکه بنده changes لیست شما را track کنم و موارد جدید را به این قالب در لیست خودم اضافه کنم.
با سپاس و احترام فراوان از کلیه زحمات شما! 😄 👍🏻
1- لیست شما رو ذخیره کردم، بررسی میکنم و امیدوارم فیلتر ها یا سایت های خوبی از توش در بیاد. چون ما هم به فیلتر های خوب نیاز داریم و هم نیاز داریم سایت های پارسی زبان بیشتری رو بشناسیم. یکی از نقطه قوت اون 5 لیست پارسی زبان این بود که تونستم به کمکشون سایت های پارسی زبان رو شناسایی و پیدا بکنم.
2- شوربختانه آنچنان با سینتکس HOSTS File ها و یا فیلترلیست های Pi-Hole آشنا نیستم اما اگه توضیحی بتونید بدید مایلم باهاشون آشنایی پیدا کنم. آیا اگه یه لیست به این شکل وجود داشته باشه کفایت میکنه؟
sabavision.com
plus.sabavision.com
dsp.aparat.com
tracker.digikala.com
و ...
یا آیا باید اول همه این آدرس ها یه "0.0.0.0" هم گذاشته بشه تا لیست توی ابزار های شما درست کار کنه؟
و سوال بعدی این که آیا از ساب دامین پشتیبانی میکنن اصلاً؟ یعنی میشه plus.sabavision.com
رو لحاظ کرد؟
سوال بعدی این که آیا ازین مدل آدرس ها هم پشتیبانی میکنن؟ zoomit.ir/ads/banners
یا فقط آدرس کلی (zoomit.ir
) میشه بهشون داد؟
مثلاً فایل هاست StevenBlack اول همه آدرس هاش 0.0.0.0 هست اما فایل شما رو که دیدم فقط آدرس خالی داره
در ارتباط با مورد 1 تشکر ویژه می کنم.
در ارتباط با مورد دوم، به صورت کلی قاعده به این صورت هست:
(پیشاپیش از طولانی شدن متن پیام بنده عذرخواهی میکنم، ظاهراً طبق همیشه بنده در ارائه اطلاعات زیادهگویی میکنم)
1. تفاوت Domain Blocking با URL Blocking:
مقدمه: به طور کلی، درخواستهای HTTP هنگام ارسال نیاز به بهدست آوردن آدرس آیپی سرور مورد نظر را دارند؛ به عنوان مثال زمانی که دامنه doubleclick.net
را بخواهیم باز نماییم لازم است که ابتدا آدرس آیپی 142.250.185.206
توسط DNS Server بازگردانی شود.
زمانی که این درخواست HTTP توسط مرورگر ایجاد شده باشد (بهعنوان مثال توسط URL زیر)، این امکان وجود دارد که توسط افزونه uBlockOrigin اقدام کنیم به جلوگیری از ارتباط با دامنه و یا آدرس URL فراخوانی شده:
Example: http://doubleclick.net/foo/bar
˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ ˜˜˜˜˜˜˜
↑ ↑
Domain name ───────────┘ │
│
│
Path ─────────────────────────────┘
در صورتی که این درخواست از جایی بهجز مرورگر ایجاد شده باشد (بهعنوان مثال، اپلیکیشن موبایل، کنسول بازی، تلویزین هوشمند و...)، معمولاً امکان نصب افزونه uBlockOrigin و مشابه آن وجود ندارد -- در نتیجه، امکان بلاک نمودن دامنههای تبلیغاتی به این شکل نیز سلب میگردد.
در چنین شرایطی، میتوان از DNS سروری به غیر از سرور ارائه شده توسط ISP و یا 8.8.8.8 و 4.2.2.4 رایج استفاده کرد.
نرمافزار هایی مانند AdGuard Home، Pi-hole و DNScrypt-proxy ابن قابلیت را دارند که بهصورت local، از ارائه آیپی به درخواست دامنههای تبلیغاتی جلوگیری نمایند، و به اینصورت دامنههای Adware، Tracking، Malware و غیره، پیش از اینکه به افزونههای مرورگر برسند اگر بهصورت عامیانه بیان کنم، از بیخ بلاک شوند.
این متد بلاک نمودن، معمولاً هم جامعتر هستند، و هم effective تر. بنده شخصاً هر دو متد را با هم استفاده میکنم، زیرا بهاینصورت efficient ترین مکانیزم بلاک نمودن دامنههای مزخرف را استفاده میکنم و ضمناً دستگاههایی که فاقد قابلیت استفاده از uBlockOrigin هستند نیز میتوانند از دسترسی به این نوع دامنهها جلوگیری نمایند.
کمپانی هایی نظیر Cloudflare، بهغیر از ارائه سرور های DNS اصلی، آدرسهای فرعیای نیز ارائه میدهند که برخی از این دامنهها را بلاک نمودهاند (اما نه همه).
بهعنوان مثال، این DNS دامنههای Malware و یا Adult را بلاک میکنند -- اما متأسفانه این کار را این کمپانی بر روی Adware و Tracking انجام نمی دهد:
https://1.1.1.1/family/
من پیشنهاد میکنم که نگاهی نیز به نرمافزار بسیار کاربردی Pi-hole بیندازید، زیرا با توجه به مهارتهای شما و علاقهمندی شما ممکن است برایتان جالب باشد:
https://pi-hole.net/
بهطور کلی، اگر میدانیم که دامنهای مانند doubleclick.net
تبلیغاتی است و کاربردی به غیر این نیز ندارد، بهتر هست که دامنه به طور کلی بلاک گردد، حتی با اینکه افزونه uBlockOrigin از دسترسی به کل دامنه یا جزئی از آن جلوگیری نماید.
2. فرمت لیست دامنهها
در ارتباط با اینکه چه فرمتی جهت بلاک نمودن دامنهها لازم است؛ این مورد بستگی به مکانیزم بلاک نمودن دامنهها دارد.
نرمافزار هایی مانند Pi-hole و DNScrypt-proxy نیازی به اشاره 0.0.0.0
در ابتدای entry ندارند (و در حقیقت نبایستی اینکار انجام گردد، و تنها ارائه نام دامنه در هر خط کافی است.)
علت اینکه پیشوند 0.0.0.0
یا 127.0.0.1
را در ابتدای خطوط بعضی از فرمتها مشاهده میفرمایید این است که از فایل /etc/hosts
سیستمعامل، برخی بهجای نرمافزار های مناسب این کار (که در بالا بهآن اشاره شد) استفاده می کنند.
فایل hosts بر روی سیستمعامل، فایل خاصی میباشد که از آن پیش از ارتباط به DNS Server جهت دریافت آدرس آیپی سایت مورد نظر استفاده میشود و از این ترفند میتوان استفاده نمود تا بهجای نصب این دسته از نرمافزار ها، سیستمعامل مستقیماً آدرس آیپی مورد نظر را بازگردانی نماید.
به عنوان مثال در این مورد:
12.34.56.78 example.test
با قرار گیری این خط در فایل hosts سیستمعامل باعث میگردد که فرامینی نظیر ping example.test
و nslookup example.test
، آدرس آی پی 12.34.56.78
را برای این دامنه بازگردانی نمایند.
اکنون با استفاده از آدرس آیپی 0.0.0.0
(که یک آدرس غیر معتبر میباشد) میتوان از دسترسی به دامنهها جلوگیری کرد، زیر بهجای آدرس آیپی سرور مورد نظر، این آدرس توسط سیستمعامل بازگردانی میشود.
(در گذشته از آدرس 127.0.0.1
که آدرس localhost یا loopback بوده نیز استفاده میشده که بهدلایلی این کار درست نیست و استفاده از آدرس 0.0.0.0 برای این مضمون معمولاً توصیه میگردد.)
حال برخی از لیستها بر روی GitHub نسخه شامل این پیشوند را (جهت راحتی کاربر) ارائه میدهند که بدون نیاز به تغییرات دیگر، میتوان مستقیماً از آن استفاده نمود تا دامنههای مورد نظر بلاک گردد.
بنده به دو دلیل این کار را توصیه نمیکنم: 1- استفاده از نرمافزار هایی مانند Pi-hole و DNScrypt-proxy معمولاً بهتر است از استفاده از فایل hosts 2- در صورتی که شخصی نیاز و یا تمایل به استفاده از فایل hosts داشته باشد با برنامههایی نظیر Domains to Hosts converter میتوان بهراحتی این پیشوند را قرار داد.
ضمناً استفاده از فایل hosts ایراد دیگری دارد و آن این است که تنها دامنه اشاره شده بهصورت کامل بلاک میگردد، و هیچ ساب دامنهای از آن با این روش بلاک نمیگردد که قطعاً جهت بلاک نمودن بسیار از دامنههایی که مختص تبلیغات هستند، کار مناسبی نیست.
3. سطح بلاک نمودن توسط دامنه
در ارتباط با این مورد، دو نکته حائز اهمیت میباشد:
- نرمافزارهای نامبرده (Pihole, DNScrypt-proxy, AdGuard Home) و غیره این توانایی را دارند (و معمولاً بهصورت پیشفرض نیز اینطور تنظیم شده اند) که دامنه و تمامی ساب دامنههای آن را مسدود نمایند. بهطور مثال:
Domain: doubleclick.net
Blocks: *.doubleclick.net
example 1: foo.doubleclick.net
example 2: foo.bar.doubleclick.net
....
در نتیجه ارائه لیست برای این دسته از نرمافزار ها، لازم به ارائه سابدامنه نمیباشد و Top-level domain جهت بلاک نمودن تمامی ساب دامنههای مذکور کافی است.
همانطور که در بالا ذکر شد، استفاده از فایل hosts سیستمعامل فاقد قابلیت مسدود سازی این دسته از سابدامنهها است.
- بهطور کلی، استفاده از Hosts/Domain Blocking به منزله این است که از بازگردانی آیپی سرور مقصد جلوگیری میشود. این مسئله بهصورت باینری عمل میکند (یا دامنه بلاک است؛ یا خیر) و در نتیجه، کلیه آدرس URL های میزبانی شده بر روی دامنه مورد نظر یا همگی مسدود خواهند شد، یا قابل دسترس خواهند بود.
با توجه به اینکه مسیر URL مورد نظر بههیچعنوان به سرور DNS ارسال نمیگردند (چون نیازی به اینکار هم نیست) در نتیجه سرور DNS نمیتواند بر بلاک نمودن تنها بخشی از آن دامنه تأثیر گذار باشد. به عبارت دیگر:
doubleclick.net/some/path/tobe/blocked
در این مثال، در کلیه روشهای بلاک دامنه، نمیتوان some/path/tobe/blocked/
را تشخیص داد و آن را بلاک نمود.
در نتیجه این روش زمانی مفید واقع میشود که قصد بلاک کل دامنه را داشته باشیم، و در نتیجه برای بلاک نمودن یک مسیر استفاده نمیشود -- در نتیجه، مواردی که شامل مسیر URL هستند در لیستهای بلاک دامنه قرار نمیگیرند.
یک نکته جالب (Fun fact): ابزار های مرتبط به کرک و کیجن معمولاً لازم دارند که از دسترسی نرمافزار کرک شده به دامنهی سایت سازنده جلوگیری نمایند، تا از از کار افتادن برنامه جلوگیری شود. یک راه حل ساده و مؤثر که در این مورد رایج میباشد استفاده از فایل hosts سیستم عامل میباشد، زیرا این فایل بر روی همه سیستمعاملها موجود است، نیاز به تغییرات خاصی ندارد و اعمال آن نیز بسیار ساده میباشد.
بهطوری که چنانچه از سیستمعامل ویندوز استفاده مینمایید، میتوانید فایل hosts خود را باز نمایید و به احتمال قوی چندین خط را مشاهده خواهید نمود که مرتبط به همین مسئله activation نرمافزارهای پولی میباشد.
C:\Windows\System32\drivers\etc\hosts
در ارتباط با لیستهای maintain شده توسط بنده:
- با توجه به موارد اشاره شده، بنده تصمیم گرفتم که پیشوند
0.0.0.0
و127.0.0.1
را در لیست خود نگنجانم. - با توجه به پشتیبانی اکثر نرمافزارهای DNS server از قابلیت مسدود سازی ساب دامنه، من میتوانستم که سابدامینها را بهطور کلی از لیست خود حذف کنم، اما به دلیل اینکه میتوان از لیست بنده در فایل hosts نیز استفاده برد (پس از انجام تغییرات ذکر شده) تصمیمگرفتم که سابدامنههای مهم را علیرغم redundent بودن، لحاظ کنم.
- یکی از لیستهای بنده additional-hosts/activation است که مانند کاری که برنامههای کرک و کیجن میکنند جهت جلوگیری از از کار افتادن کرک برنامههای پولی طرح شده، و بخشی از آن نیز بر مبنای فایلهای hosts رایج جمع آوری شده است.
مجدداً بابت طولانی شدن متن پیام پوزش میطلبم، و امیدوارم که موارد بیان شده در این زمینه مفید واقع شده باشد.
با سپاس فراوان از توجه وقت شما!
پس با این تفاسیر امکان لحاظ کردن همچین فیلتر هایی برای Pi-Hole و دیگر نرم افزار های مشابه وجود نداره (مثلاً تبلیغات بلاگفا/رزبلاگ رو نمیتونیم مسدود کنیم):
analytics-*.aasaam.com
blogfa.com/a/
parsiblog.com/ga.js
rozblog.com/include/rozblog_ads_js
نسخه اولیه لیست آماده شد: https://raw.githubusercontent.com/MasterKia/PersianBlocker/main/PersianPiHole.txt
درباره فیلتر های برای هر سایت (Site-Specific) اندکی مردد هستم، چون Pi-Hole به دلیل مسدودسازی در سطح DNS، نمیتونه از فیلتر کردن بخشی از دامنه پشتیبانی بکنه، یعنی نمیشه zoomit.ir/images/ads
رو مسدود کرد؛ و هم از فیلتر های Cosmetic پشتیبانی نمیکنه، یعنی نمیشه zoomit.ir##.ads
رو مسدود کرد.
بنابراین همونطور که گفتید اگه کاربر هم از افزونه uBlock Origin و هم از ابزار هایی مانند Pi-Hole بهره ببره، بهتر هست.
متأسفانه Cloudflare مسدودسازی بر روی Adware و Tracking انجام نمی دهد
گمون میکنم AdGuard Public DNS و NextDNS دامنه های تبلیغاتی و ردیابی رو هم مسدود میکنن، البته اینکه سرعتشون به اندازه امثالِ Cloudflare باشه رو باید سنجید و بررسی کرد.
This "analytics-*.aasaam.com
" need use regex in Pi-Hole, so as "supplement" list better install with Python script as Pi-Hole team it will not facilitate the import of regular expressions form file (sic!).
(^|\.)analytics-.*\.aasaam\.com$
- may works: https://docs.pi-hole.net/regex/tutorial/
- https://github.com/mmotti/pihole-regex and Hawkeye form FiltersHeroes made:
RLI_for_Pi-hole.py
- https://github.com/radoslawkierznowski/regex-importer-for-pi-hole - another Toutorial.
Other three may works only in Privoxy? I suppose AdGuard Home (Alternative for Pi-Hole) no implemented detect path filtering.
Also I think that AdGuard DNS and NextDNS after configuration (AdGuard have services at beta stage, NextDNS on free acconut may still filter first 300'000 network requests per month and 300'001+ send without filtering) can block domains based on hosts lists.
Not configurable versions maybe have documentation do they filter something.
I was very interested at the paragraph about blocking IP addresses with the help of Pi-Hole, once it was impossible or I mistakenly asked MajkiIT if the regex mechanism distinguishes it instead use simple filtering. Optionally, the translator damaged the sentence and I should check the English description and then only in my native language.
Welcome @krystian3w Me and @DRSDavidSoft mostly chat in English but just this recently I switched to Persian out of mere convivence. I try to speak English here from now on going forward :D
Thanks for the fast response, @krystian3w!
Just for the sake of completeness, I'd like to point out a couple of things that @MasterKia asked about. (beforehand, I'd like to once again apologize for the long post)
1. Site-specific/Cosmetic filtering
Since the DNS blocking mechanism cannot facilitate modifying the content on the page, it cannot be used to remove or filter ads and other content on the page.
However, this is not what it's designed to do so, so it's actually a good thing. This mechanism should only be used for the websites that are ad-centric, tracking-centric, etc as a whole, not to filter specific parts of the webpage (like what uBlock Origin is designed to do).
Sadly, this means that DNS blocking is not by itself enough to say, remove Youtube, Spotify, Aparat, Blogfa ads, and if we try to do so, the whole website might get bricked.
However, it's a perfectly fine method to block Pop up domains, Tracking (such as Webgozar) websites, and affiliate domains as well.
Don't worry about the cosmetic/path-based blocking not being suitable for this usage, as I mentioned before when possible uBo and other alternatives cover this kind of blocking.
2. Path filtering
There are software like Privoxy, and maybe AdGuard Home to facilitate path blocking. There are however two downsides to using such mechanisms:
-
The traffic must go through it, as otherwise, it cannot apply the block; which could result in increased bandwidth usage if the software isn't hosted locally
-
In order to filter traffic, it must be able to actually see what is going through; this is fine for plain HTTP connections, however encrypted HTTPS connections must be decrypted first, and then re-encrypted with a different private/public key certificate for each connection going through it, and the client must be configured as well in order to allow the MITM (man in the middle) modifications to the response.
I set up Privoxy/Squid in addition to DNSCrypt-proxy and Unbound for personal use back in 2014 when HTTPS wasn't a common thing to see in all websites, and it worked wonderfully to filter ads in domains such as blogfa/persiangig/etc.
Now that HTTPS is more commonplace (which I'm very grateful for it), the old mechanisms of filtering paths don't work anymore in software such as Privoxy. They have recently introduced an experimental HTTPS filtering capability, but since then I haven't set it up for my personal usage, since I preferred not to decrypt HTTPS content that is passing through the server.
Sidenote: Personally, I am still using Privoxy/Squid due to some other reasons (related to the regional limitations, such as sanctions and censorship); but the main bulk of domain blocking is done at the DNS level, for me.
3. Wildcard/Regex blocking
Most of the DNS blocker software, to my knowledge, doesn't support regex or wildcard blocking. Pi-hole is great because it can block regex entries, however, this might not be supported everywhere.
AdGuard I think supports both, but I might be mistaken.
Personally, I use another great project named DNScrypt-proxy, since only it has DNS filtering, it has other super useful features such as encrypted forwarding, cloaking, load balancing, anonymization, and some other features as well!
Thank you for @krystian3w for providing more info on the regex blocking. It's extremely efficient and useful, and I'd like to suggest reading more about and learning Regular Expressions if you haven't yet used them in some capacity.
What I personally do for additional-hosts lists is to provide a separate wildcard/regex list, in addition to the plain domains-only list. This way, supported software can pull in the list, apply conversions if required, and use them.
Back when I set it up in 2015, Pi-hole wasn't mature enough to use as a general DNS server, and it was only available on Rasberry Pi, so I stuck to DNScrypt-proxy for the time being. You can read more about my setup, which I use to this day, here:
https://github.com/DRSDavidSoft/additional-hosts#set-up--configuration
Sidenote: In my opinion, DNS encryption by itself is a very important topic, especially with the regional blocks that we face, e.g. dig youtube.com
should return Youtube's IP address, such as 142.250.179.78
. However, due to regional regulations here, all ISPs must return the bogus IP address of 10.10.34.36
, which is a censorship, locally hosted server.
I find the behavior annoying that the ISPs can spoof the returned IP address of an unencrypted DNS request to whatever they want, so I strongly advocate for DNS encryption solutions, such as the recent DNS-over-HTTPS and DNS-over-TLS, or the DNSCrypt v2 protocol that I use, as mentioned above.
This way, besides preventing the unwanted tracking of visited domains by the government, the correct IP address of the server is returned instead of the spoofed one, with the additional block of unwanted domains on top of that.
Sorry for the long sidenote BTW
4. AdGuard Public DNS / NextDNS
Both of these services are great, and IMO fine for personal use. NextDNS specifically can be analogized to running Pi-hole in the cloud, meaning you can include what filter lists to include, and I believe it can be set up to use 1.1.1.1 as the upstream. There are other publicly available, ads blocking DNS servers out there as well, some of them running open-source software with public lists as well.
Personally, I prefer running my own services for personal and/or commercial usage due to a couple of reasons (such as having more control).
Whatever the usage may be (local or remote), it is super useful to provide such lists, so it can be incorporated into other blocking technologies as well. Especially, on mobile devices with the help of apps such as Blokada, AdAway, AdGuard, DNS66, and more.
One of the aggregated Pi-hole lists out there (one of the best) is Oisd.nl, it collects all the best Pi-hole lists, merges and de-duplicates them into a single efficient one. At the time of writing, the maintainer hasn't included PersianBlocker in there, but I'm sure with a little time he will catch on and include it as well.
Oisd.nl list can be used with NextDNS.
Sidenote, again: I use a dozen of domain lists, that amount to a total of about ~1 million blocked domains. I've applied about ~2.4K whitelisted domains, and the result is being used for all devices in my home and workplace, my friend, family, and colleagues' devices, and also among all of the servers that I use, or maintain.
5. IP filtering
To the best of my knowledge, it is impossible to block outgoing connections to an IP address, unless a firewall is involved.
However, software like Pi-hole and DNSCrypt-proxy has a neat feature where they can filter the response of a DNS query request if the returned IP address matches the one being blocked.
This can have the same outcome of actually blocking the IP address itself, however, it's not the same.
For example, if the IP address of a domain like example.com
is 1.1.1.1
and then we configure the server to block the IP address 1.1.1.1
, then whenever the domain name example.com
is being queried since the IP address matches the one being blocked, then the DNS server refuses to resolve the query.
Cool feature, but I haven't found a use case for it personally. I prefer actually blocking the IP address, both the incoming and outgoing traffic for increased security and privacy.
One example is the bogus IP of 10.10.34.36
, which is used for nonsensical regional censorships here.
Using Pi-hole, it's not possible to block the IP address, since it's referenced by the browsers directly, and not as the result of resolving a known DNS query.
In these situations, I have blocked the entire 10.10.34.0/24
IP range within the firewall, which is as useless traffic as the unwanted ads that I block.
I have seen people mistakenly add something like this to their HOSTS file (sometimes the pirated software does the same, too):
0.0.0.0 10.10.34.34
0.0.0.0 http://blockeddomain.com
0.0.0.0 somedomain/foo/bar
All of the entries above are invalid, and usually ignored by the operating system. The only allowed (and possible, really) syntax for the HOSTS file is just the domain name, and the IP we want for that domain to resolve to.
This means that using the 0.0.0.0 xxxx.com
syntax, only domains can be blocked, nothing more or less.
Just an interesting fact I have seen on people's machines, that I thought to share.
One key question: Is there any point for using a DNS based solution (like Pi-Hole) when uBlock Origin can cancel network requests early within the browser? In this situation the network request wouldn't even reach the Pi-Hole to being with.
You mentioned "mobile applications, game consoles, Smart TVs, etc". I'd argue that on mobile, users could install uBlock Origin on Firefox. But mobile application advertising is annoying, and I have no solution to offer for that (other than disconnecting from the internet when using those apps). Is there really ads on game consoles and smart TVs? do owners browse the web on those things?
One key question: Is there any point for using a DNS based solution (like Pi-Hole) when uBlock Origin can cancel network requests early within the browser? In this situation the network request wouldn't even reach the Pi-Hole to being with.
Considering a situation where the user is only using a web-browser where uBlockOrigin is installed, and the filter lists used by uBlockOrigin and Pi-Hole are the same one to one, then the answer is no.
There might only be the issue of efficiency, since it's advised against loading huge amounts of domains into the uBlock Origin memory, as it's a waste of system RAM since the user is not going to visit each and every one of those domains.
However, in many cases, the requests are not coming all from the browser, or a browser with uBlock Origin enabled (such as embedded/built-in ones uses by Skyper, Discord, etc)... and also, many programs and apps may include trackers, which can't be blocked using uBo. That's the primary reason I suggest using Pi-Hole in addition to uBlock Origin, for the sake of completeness.
I'd argue that on mobile, users could install uBlock Origin on Firefox.
Correct, but even though popular browsers such as Samsung Internet support content blockers such as AdGuard, many like Google Chrome (and some other browsers on iOS) don't support either content blockers nor browser extensions.
If the browser of choice supports extensions, then uBlock Origin would suffice the same as using it on desktop, but on other cases, DNS blocking is what usually required
But mobile application advertising is annoying, and I have no solution to offer for that (other than disconnecting from the internet when using those apps).
I'd like to strongly suggest visiting filters like EnergizedProtection, 1Hosts, and projects such as AdAway, AdGuard Android, DNS66, and Blokada if you're on android. Many of them are open-source, and available on F-Droid repository.
Many mobile games contain useless video ads, text ads, and many trackers, and even Xiaomi devices have the audacity to display ads within the system installer! 🤯
If you can use a Pi-hole or NextDNS solution, you don't need to run these android apps. As I said, all of my traffic goes through my encrypted and ad-blocked DNS traffic, so I only need to include the Pi-hole lists.
If you're somehow doubtful, I'd like to invite you to run the Fiddler tool on your machine, setting it up so your Android traffic goes through it, and just have a look when you open general apps like Reddit, Twitter, some games, etc.
I guarantee you it'll blow your mind, how much tracking and ad junk traffic is generated, sometimes by the manufacturer and pre-installed apps themselves.
It's even better if you could root your device and install custom ROMs that don't include this junk traffic, but for most people using a DNS blocker would suffice.
Don't disconnect your internet, combat the ads! 🙏🏻
Is there really ads on game consoles and smart TVs? do owners browse the web on those things?
Yes, but it's not limited just to web browsing. The ads are fetched from the TV manufacturer and shown on the user interface, in addition to the web browser.
If you visit the /assholedesign on reddit and sort for the top of all time, you'll see results like these:
- https://www.reddit.com/r/assholedesign/comments/ex8e5z/i_love_ads_on_my_250_console_that_i_continue_to/
- https://www.reddit.com/r/assholedesign/comments/co5aw4/unremovable_ads_on_my_2500_samsung_smart_tv/
- https://www.reddit.com/r/assholedesign/comments/d1l14i/appstore_for_you/
- https://www.reddit.com/r/assholedesign/comments/c575w1/2k19_is_a_retail_60_game_they_put_non_skippable/
- https://www.reddit.com/r/assholedesign/comments/j2xrts/apparently_spending_2500_on_a_samsung_tv_doesnt/
- https://www.reddit.com/r/YouShouldKnow/comments/gn7fw5/ysk_if_you_own_a_samsung_smart_tv_that_has_ads/
- https://www.reddit.com/r/assholedesign/comments/muf1xx/i_love_this_device_but_ads_on_a_1500_premium/
- https://www.reddit.com/r/assholedesign/comments/nki4hl/xiaomi_putting_ads_everywhere_even_in_folders/
I have the same Samsung Smart TV as mentioned in the second link above.
These are the lists I include to combat ads:
- https://v.firebog.net/hosts/static/SamsungSmart.txt
- https://raw.githubusercontent.com/d43m0nhLInt3r/socialblocklists/master/SmartTV/smarttvblocklist.txt
- https://raw.githubusercontent.com/ftpmorph/ftprivacy/master/blocklists/smart-tv-ads-tracking.txt
- https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt
the bogus IP address of
10.10.34.36
, which is a censorship, locally hosted server.
Good thing I blocked 10.10.34.35
, I didn't know about 10.10.34.36
though; are you sure it's in use?
Edit:
I have blocked the entire 10.10.34.0/24 IP range within the firewall
Should I include 10.10.34.*
?
Are we sure that no legitimate site uses IP from that range (0 to 24)?
ISPs can spoof the returned IP address of an unencrypted DNS request to whatever they want, so I strongly advocate for DNS encryption solutions, such as the recent DNS-over-HTTPS
So far in my tests, current major ISPs (HamraheAval and Irancell) support unencrypted custom DNS. But SamanTel (a subset of RighTel) doesn't even allow unencrypted custom DNS (so I'd assume RighTel doesn't allow it as well).
I tried DoH encrypted custom DNS on Windows 11 using Irancell but it didn't work, I don't know why. But the DoH in Firefox works.
I'd like to strongly suggest visiting filters like EnergizedProtection, 1Hosts, and projects such as AdAway, AdGuard Android, DNS66, and Blokada if you're on android. Many of them are open-source, and available on F-Droid repository.
I've been using NetGuard in the last months; all apps are blocked from connecting to the internet, except apps that I whitelist and domains that I allow those apps to connect to.
Should I include
10.10.34.*
? Are we sure that no legitimate site uses IP from that range (0 to 24)?
In my tests and from past experience, all of the 10.10.34.0-255 range was only assigned for the bogus censorship servers. I haven't found any case where it was used for anything else than this.
Note: the /24
subnet range refers to the last part of the IP being from 0
to 255
.
So, x.x.x.0/24
is basically the same as x.x.x.0
to x.x.x.255
current major ISPs (HamraheAval and Irancell) support unencrypted custom DNS. But SamanTel (a subset of RighTel) doesn't even allow unencrypted custom DNS
I personally refrain from using the DNS servers provided by the ISP itself, as they can see the individual requests being made, which implies reduced privacy and a security risk.
If they have blocked access to the encrypted DNS servers, it seems a good time to invest in setting up your personal network for increased security, privacy, and reduced ads, trackers and malware in general.
I tried DoH encrypted custom DNS on Windows 11 using Irancell but it didn't work, I don't know why. But the DoH in Firefox works.
Sure, that's one of the reasons that I suggest using DNScrypt-proxy. It includes its own encrypted protocol for transmitting DNS packets, is fast and reliable.
I've been using NetGuard in the last months; all apps are blocked from connecting to the internet, except apps that I whitelist and domains that I allow those apps to connect to.
Equally a good idea to use!
I'm really happy to see that you've adopted the PersianPihole format as well, as it can be used in all of the places discussed above -- on servers, routers, as hosts file or directly in the mobile phone.
I'd like to ask you to monitor your mobile traffic as well, and add any domains that need to be blocked in your lists, in order to increase the number of domains that it covers.
Cheers! 😄 👍🏻
یک مورد off-topic دیگر... جهت نمایش، اینجا را کلیک کنید
Sorry for my delayed response on that part, but I just came to say that it seems that the filtering game has become deeper and a lot of Telegram proxies are getting slaughtered unfortunately.
@MasterKia No problems at all, I'd still like to discuss more about this, if you are interested. I'm available on Discord and Telegram, if either one works for you.
You can also contact me via email for a preliminary proxy setup, as to use Telegram for continued discussions.
In a few weeks, I'll be in touch.
Also in a few weeks I'll make the PersianPiHole list on par with PersianBlocker (by bringing entries from your unwanted-iranian list).
BTW, Do all major DNS blocking tools, treat "#" as comment (e.g. "# Trackers")?
@MasterKia Mostly yes, I haven't seen one where the #
character isn't treated as start of a comment.
List with regex no like comments or need cleaing in Python on import.
https://github.com/AdguardTeam/FiltersRegistry/pull/623/commits/4697b7594fd05ee45b2f344aeaea9c720f938621
PersianBlocker has been added to AdGuard, they decided to call it "Persian Blocker" though :P
I'm glad it got the "high" trust level, since PersianBlocker depends on scriptlets (##+js
rules) to defuse ads/trackers/annoyances in some sites (zoomit.ir
ads, khanoumi.com
click tracking and takmili.com
annoyance to name a few).
@DRSDavidSoft I found these filters in AdGuard Base Ads filterlist, but the filters should be broken by now; considering your expertise with s0ft9-8, do you think there is any way to write AdGuard filters for this site?
s0ft9-8.ir#$#[id^="sidebar"][id*="stick"] > section { opacity: 0 !important; pointer-events: none !important; }
@@||s0ft9-8.ir^$generichide
||s0ft9-8.ir/templates/s0ft9-8_default/js/jquery.js$replace=/(\|download\|hcrack\|)[\s\S]*?(\|\|collapsing\|)/\$1body\$2/
! s0ft9-8.ir/templates/s0ft9-8_default/js/jquery$replace=/\|antibot\|(\|)?[\s\S]*\|main\|/\|antibot\|\$1body\|main\|/
! ||s0ft9-8.ir/templates/s0ft9-8_default/js/jquery$replace=/\|antibot\|(size\|)?(\|)?[\s\S]*?\|main\|/\|antibot\|\$1\$2body\|main\|/
Edit: Never mind, I figured it out.
Replace can't be read from 3-rd party projects even have high level, so these still live in AdGuard Base if can works after boost.
You only can try disable by ,badfilter
/ $badfilter
if filter compiler don't touch rule. If delete then can be reported as bug and asap ask AdGuard team to rewrite or disable to minimize breakge.
Ghide is fast way to disable bugs from e.g. EasyList when no works scriptlets/css/thousands cosmetic exceptions. But also disable good generic cosmetic filters (exist and new from future).
hack with opacity on "ad" may work in the past if page added detect:
-
position: absolute/relative
-
visibility: hidden
- css transformations (e.g. width/height no longer match to range)
- remove node by
:remove()
/ html filtering / pure js rule with long delay (e.g. 3 second after "domContentLoaded").
selector is limited to have part of text in ID and Class (maybe page added randomized numbers after text).
Replace can't be read from 3-rd party projects even have high level, so these still live in AdGuard Base if can works after boost.
it can be reported as bug and asap ask AdGuard team to rewrite or disable to minimize breakge.
Then I guess we could ask AdGuard to rewrite new filters. Looks like some people have reported this site in the last month:
https://github.com/AdguardTeam/AdguardFilters/issues/120851
https://github.com/AdguardTeam/AdguardFilters/issues/119805
https://github.com/AdguardTeam/AdGuardExtra/issues/320
But it seems the AdGuard team didn't write any fix for it.
hack with opacity on "ad" may work in the past if page added detect:
Thanks for the explanation, it helped me to deal with this.
@MasterKia تشکر خیلی فراوان به خاطر زحماتی که برای این لیست میکشی ، کار تون خیلی ارزشمنده.
@chromer030 سپاس از پیام محبت آمیز شما و اینکه مشارکت میکنید.
امیدوارم در صورت امکان این لیست رو به دیگران هم معرفی کنید تا فعّالش کنن.
حتی کسایی که رو گوشی هستن هم میتونن فایرفاکس اندروید رو نصب کنن و بعد افزونه uBlock Origin رو بریزن و از لیست بهره ببرن. لیست PersianBlocker به لیست های پیشفرض uBO افزوده شده و راحت میتونن فعالش کنن (دیگه نیازی به کپی آدرس لیست و ... نیست)
به زودی قراره به لیست های AdGuard هم افزوده بشه. لیست رو Approve کردن ولی نمیدونم چرا هنوز Merge نکردنش.
امیدوارم لیست گستردگی و پوشش خوبی براتون داشته باشه که نیازی به گزارش دادن پیش نیاد اما اگه سایتی رو دیدید که تبلیغ یا ردیاب(Tracker) یا حتی کارای رو مخ (بستن کپی، راست کلیک، انتخاب متن و ...) داشت، فقط کافیه آدرسش رو اینجا برام بفرستید تا فیلتر های مربوط بهش رو اضافه کنم.
@MasterKia
بله حتما ، من به هر کسی که میتونم این لیست رو معرفی میکنم ، مسدود شدن تبلیغات کلی در مصرف اینترنتشون هم صرفه جویی میکنه.
برای اندروید به جز فایرفاکس ، مرورگر Kiwi هم که بر پایه Chromium هستش و اوپن سورس هم شده ، تقریبا اکثر افزونه ها رو پشتیبانی میکنه و پشتیبانی اش از Ublock Origin هم عالیه.
بازم ممنونم از تلاش ها و زحماتی که میکشید.