Block specified URLs
I want to write an application in Delphi which filters requested URLs in the OS (not only web browsers) and if it matches - blocks it or changes the URL's content to blank. The problem is - I don't know where to start looking. Could you help me with some informations?
I think you're talking about a DNS service. usually, DNS services live outside, on your router, your ISP, or a 3rd-party like www.openDNS.org But you could write your own, run it on your PC, and set your internet settings to use that as your DNS server. I suspect that a lot of malware works like this....
Also, this sort of thing can be done with no programming at all - just edit your hosts file in C:\WINDOWS\system32\drivers\etc\hosts (it's a text file with no extension). Anything in there should trump.
Also, before you start writing an application to do this, have a look at OpenDNS. If it's an app for personal use, you may find that you don't need it. If it's going to be a commercial offering, this is the bar for usability and usefulness that you need to meet or beat.
http://www.mail-archive.com/delphi-talk@elists.org/msg01558.html - text by Francois PIETTE quoted bellow(in case link will become unavailable):
"There are several way to achieve your goal. The two main I see are: 1) Write a LSP (Layered Service Provider) 2) Write a proxy server
The first is not possible with Delphi (At least I think so. If anyone know how to write a LSP using Delphi, I would love to get the code).
The second - writing a proxy - is more or less easy with Delphi using ICS components. See "usermade" link at ICS website (http://www.overbyte.be). With this option, you have to configure IE to use the proxy: IE Menu / Tools / Internet options / Connections / Network parameters / Use a proxy and then enter the IP address (127.0.0.1 if proxy run on the same computer) and port number (pick anyone you like, for example 8080). Once IE is configured to use a proxy, it will send all requests to the proxy. Then the proxy will make the real request to the target server and return data back to IE. What is important there is that you get all URL entered in IE or indirectly use (clicking on links), and you can either really rely them to the target server or forge and answer your self to say the page access is denied.
At ICS website, on the usermade page, you'll even find a HTTP proxy component. If you need help with this component and/or the entire ICS, please use ICS support mailing list (same server as this list). See "support" link at ICS website for support details."
LE: it seems that this question is possible a duplicate Using delphi to block websites
use GetExtendedTcpTable api locate if there are any connexions to the remote server you want to block on port 80 if there is a connection use SetTcpEntry to terminate that connexion is pretty simple
精彩评论