×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Website Blocker

Website Blocker

Website Blocker

(OP)
Was wanting to know if there was any source code for a starter program for a website blocker, what i need is it to read from a list of words if that given word is in the list it will not load the website


Thanks

RE: Website Blocker

MIB -

This is a pretty involved subject that comes up time and time again on the Winsock2 mailing list. The basics are that you have to write a LSP (Layered Service Provider) that intercepts both TCP and UDP packets (both, because of a bug in Microsoft's TCP/IP implmentation). If you want to support Win2K and Win98 as well as NT4 and Win95, you have to write things a bit differently as well.

Your LSP would have to do the following:
1) Determine if it's a TCP request
2) Determine if it's going to port 80
3) Determine if it's a HTTP request
4) Look at the URL to see if it's allowed, and if it's on the "badsite" list, return a HTTP response saying "You're a naughty boy!"

I would say that VB is not capable of writing a LSP because they load at boot time, and the runtime requirements for a VB program cannot be met. The reason behind using a LSP in the first place is the end users could install a 3rd-party browser (NetScape, Opera, etc) that could get around any filtering done by a VB app that uses the Internet Explorer OCX.

Chip H.

RE: Website Blocker

> That way all requests for pages could go through your VB app, not trivial though. <

That is one method I hadn't thought of. But like you said, non-trivial.

Plus, I haven't seen a TCP/IP OCX for VB that scaled to handle large numbers of users like using the Win32 I/O Completion Ports would.

MIB -- I think you ought to re-think this.

Chip H.

RE: Website Blocker

(OP)
ok thanks alot for the posts anyway it was an idea :))

RE: Website Blocker

Just a thought... if you can specify a list of URLs to block or simply want restrict the user to a list of "friendly" URLs you might be able to use the code at http://members.xoom.com/BadMunky/ (suggested by member netwalker1).

http://members.xoom.com/_XMCM/BadMunky/Source/ieaddr.zip retrieves the URL for the current page. Save that value and check to see if it is on a list of restricted pages (or fails to appear on a list of approved pages).

If it fails the test use the code in http://members.xoom.com/_XMCM/BadMunky/Source/VBURL.TXT to return the user to the previous page.

It isn't exactly what you were looking for but it might be a way to start.



temporary Vorpalcom home page
Send me suggestions or comments on my current software project.

RE: Website Blocker

Chip,

Interesting point about scaling a TCP ocx.

What do you call large numbers of connections? I have a 24x7 VB app that handles 200 ish TCP connections without trouble; uses MS Winsock.

Tell me more...

Mike

Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site

RE: Website Blocker

Well, while you guys were arguing bigger and better things, I wrote a little app to keep users from browsing beyond the straight-and-narrow. (Haven't tried it on NT.)
Corporate users waste a lot of time on the Internet and, sometimes, end up looking at something that doesn't improve the quality of their work.
Mike, I know you are an exception. Chiph, you were partially correct in your first post in this thread (but it really isn't that difficult). MIB, you might reconsider your approach (don't worry about the words, if a page disappears, the users can't read the words or look at the pictures).



temporary Vorpalcom home page
Send me suggestions or comments on my current software project.

RE: Website Blocker

Mike -

I don't have any hard numbers as to what the MS Winsock OCX can handle. Just looking at how a programmer would have to respond to it's events gives me a big clue that it doesn't scale.

And by scale, I mean large numbers of client connections (500 and up). You can always throw hardware at a scalability problem, but I think you & I both would prefer to solve it through more efficient algorithms (job security, you know!).

Have you worked with IOCP's before? They're not that bad, once you know a few tricks. The key is to use a couple of structures like this:

typedef enum LAST_IO_OPERATION_tag {
    ClientIoInit,
    ClientIoRead,
    ClientIoWrite
} LAST_IO_OPERATION, *PLAST_IO_OPERATION;

typedef struct CLIENT_CONTEXT_tag {
    SOCKET                        Socket;
    LAST_IO_OPERATION    LastClientIo;
    OVERLAPPED                Overlapped;
    BYTE                            byReadBuffer[READBUFFER_SIZE];
    WSABUF                        wsaBuf;
    //... Other app specific stuff ...//
} CLIENT_CONTEXT, *PCLIENT_CONTEXT;

to the CreateIoCompletionPort call.

    pClientContext->LastClientIo = ClientIoInit;
    // Associate the new socket with the existing Completion Port
    hCompletionPort = CreateIoCompletionPort((HANDLE)s, hCompletionPort, (DWORD) pClientContext, 0);

Then when your code returns from GetQueuedCompletionStatus (in your worker threads), the pClientContext structure gets passed along with all the info you need. You just look at the LastClientIo field to figure what kind of request it was (initialization, read, write), and handle it.


Alt255 -

Which part was I partially correct about? In writing a LSP, the fundamentals are easy. The hard part is all the border conditions -- what to do about UDP packets, how to handle installation, re-installation issues, etc.

The installation issues comes up pretty frequently too. Someone will write a LSP, then the user will install the latest whiz-bang internet software, and the LSP gets relocated in the call chain, and stops working.

Chip H.

RE: Website Blocker

MIB's original question asked for a simple way to get started on a blocker. It seemed, simple to use some ordinary API functions;
RasEnumConnections and RasGetConnectStatus to check the internet connection. EnumWindows, GetClassName, SendMessage and GetWindowsText to retrieve the URL. ShellExecute to return to the previous URL if the current one does not appear on a list of approved sites.

MIB could even check for "naughty" words on a page. This actually works, 'though I wouldn't recommend it because it's such a cheap and inefficient way of finding words on a page (Mike and ChipH will undoubtedly point out 39 good ways to copy the focus window to the clipboard).

OldClbd$=Clipboard.GetText    'save the contents of the clipboard
SendKeys "^a", True    'select all on the page with focus
SendKeys "^c", True    'put the text on the clipboard
SendKeys "{TAB}"    'deselect all
Clbd$=UCase$(Clipboard.GetText)    'put the upper case clipboard in a string
For Rep = 1 to UBound(NaughtyWordList)
'check for naughty words
    If InStr(Clbd$, NaughtyWordList(Rep)) Then
        MsgBox "Page contains naughty words"
    End If
Next
Clipboard.SetText OldClbd$    'restore the old clipboard contents

It just didn't seem necessary to use an OCX and, frankly, you guys are talking about things that are a little over my head. I'm sorry I opened my mouth.
With that, I respectfully bow out of this discussion.



temporary Vorpalcom home page
Send me suggestions or comments on my current software project.

RE: Website Blocker

> It just didn't seem necessary to use an OCX and, frankly, you guys are talking about things that are a little over my head. I'm sorry I opened my mouth. With that, I respectfully bow out of this discussion. <

Sorry -- got a little carried away. Besides, you know what they say -- "Thread drift happens"!

Looking over your code, it actually seems pretty simple -- snag the URL by copying it into the clipboard, check it, and if it's not on a "bad" list of any kind, send it on through. Maybe this was all MIB had in mind, back on 13Mar00.

And then I had to go and spoil it all by building it into a massive project that accounts for every possible condition. I'm such a geek. <sob>

Chip H.
<g>

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close