1
Answer

Writing an ad blocker: Help needed!

Administrator

Administrator

22y
1.7k
1
i am planning to develop a rule-based ad & popup/-under blocking program as my degree level project. I am planning to use C#. I am thinking of having the program as a standalone application that work in the background to screen incoming web pages for ads (by looking for keywords like '/ads' etc), remove the ad displaying codes, then feed it to the browser. the goal here is to prevent ads from being downloaded, so i must intercept the incoming pages before the browser gets to display it. i have no prior knowlege in doing this kind of program. note that the development has not started yet. i am asking this question because i forsee the problems. i have quite a bit of experience in programming. My problem is: how do i intercept the page, removing the code lines, and then pass it to browser programatically. I am having a technical problem, so i really hope someone can shed some light and lead me to a technical solution. i know i can use regular expressions to do the filtering, but intercepting the page remains as my biggest prob. I know I can use a proxy server approach, but I wanna avoid using it. If possible, I hope I can get some samples in C# demo-ing the webpage interception in real-time. Also, someone mentioned that I should read up on IE event hookups like OnBeforeNavigate2, OnNewWindow2 and OnDocumentComplete. But then, if I exploit these events, wont my program be specific to IE only? Is there a more generic way of doing it? Anyone have any links to such resources? I am desperately in need of help. My program should also distingush the popup/under opened explicitly by the user and the real culprits - the ads. one idea i got from a friend is to scan window's title bar for specific words (like 'great deals' etc) but i know that's not the best way. so again, i hope someone can give me more ideas on how to implement this. Thanks in advance for all your help.
Answers (1)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

In this case you have to implement security logic, the .Net provides an entire API  System.Security, you can create a permission set that determines rule of messages transactions 
0
Riccardo
NA 5 0 16y
I mean every outgoing mail of a company (mail from a internal network to outside the network)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

What do you mean by outgoing mail, do you mean from example a spam?
0
Riccardo
NA 5 0 16y
Thank you very much for your answer!

Probably I should explain a little bit more about the functionality I would like to implement. Basicaly I would like to check every outgoing mail. Therefore I would like to
1. stop the smtp queue
2. wait for messages
3.check these messages (allowed or unallowed and probably remove some of them)
4. Start the smtp queue, so the messages can be send


0
Bechir Bejaoui
NA 20.1k 5.3m 16y

If I well understand your question you're using a Message queue object then you can do

MessageQueue mqueue = new MessageQueue();
            //This method will make the message queue in a standby state for any message
            IAsyncResult Async = mqueue.BeginReceive();

            //TO do perform you code here

            //This method
            Message Recived = mqueue.EndReceive(Async);
           
            //close the message queue
            mqueue.Close();
It's better to do that asynchormously