Solved

Block internet access

Posted on 2001-08-30
22
221 Views
Last Modified: 2008-02-26
Hello everybody,
I need an example code to deny or allow the access to internet.

Thanks,
Diego Broos V.
0
Comment
Question by:dbroos
  • 6
  • 5
  • 4
  • +3
22 Comments
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Whole internet or some sites?
0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 200 total points
Comment Utility
One approach would be to simply program the approved URLs into the application...but that offcourse is an immediate weakness to the application...what would you do if the list of approved URLs changes?

Another method would be to publish the list of approved sites in a file that is then distributed to the users..possibly by email...Aside from the trouble of distributing the file there is always the possibility that some clever user will figure out how to edit the file and add unauthorized sites to the approved list.

Possibly the best approach is to maintain a single approved list on a server and have the program retrieve the list each time it starts. There is no chance of unauthorized tampering with the file and changes to the list can be easily made...

The format of the file doesn't really matter...as long as it works for you it's fine...

I hope this gives you the general idea...

Cheers,
Max.
0
 

Author Comment

by:dbroos
Comment Utility
whole internet
0
 
LVL 1

Expert Comment

by:george74
Comment Utility
hi,

the simplest thing you can do is calling ROUTE, and delete the gateway. This way the system still be able to access the LAN but will be unable to gain internet access.

To do this, you must do the following in your VB code, at the point you want to disable internet access:

....
Shell "ROUTE DELETE 0.0.0.0"
....

wherever you want to turn back internet access (because your program is exiting etc.), do the following:

...
Shell "ROUTE ADD 0.0.0.0 MASK 0.0.0.0 192.168.0.1"
                                      '^this is the GW address
....

Cheers ;)
0
 
LVL 1

Expert Comment

by:george74
Comment Utility
just a comment... the bloody fonts messed up (in the edit window it was fixed font)... the correction is: the gateway address in my example is 192.168.0.1, just the spaces shrunk and my marker shifted back...

enjoy!
0
 

Author Comment

by:dbroos
Comment Utility
george74, I forgot to said that i work with dinamic IP assignment (DHCP) therefore i dont know the gateway address.
There is another problem: anyone can type that command and gain access to the internet.
0
 
LVL 6

Expert Comment

by:pierrecampe
Comment Utility
ping
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
Take a look on my 'System wide Shell Hook dll' at http://www.freevbcode.com/ShowCode.Asp?ID=1308
Just add it to your project and at WindowCreated event check this window caption (or class name). If it contain "Internet Explorer" or "Netscape" words - use
PostMessage hWin, WM_CLOSE, 0&, 0&

Cheers
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
Slightly the same as Ark:

set a reference to Shdocvb.dll and add the following in the general section of a form:

Public WithEvents shIE As SHDocVw.ShellWindows

Now you've got events when IE windows are created or closed.

Maybe you can do something with this and Ark's PostMessage API.

D'Mzzl!
RoverM
0
 

Author Comment

by:dbroos
Comment Utility
The problem is that not only internet browsers like IE or netscape can access the internet, there are many other programs that use the internet.
0
 
LVL 19

Expert Comment

by:DreamMaster
Comment Utility
Well in that case...don't have the access to Internet open....pull out the plug...if you want to make sure noone uses it...make sure they can't use it....

I don't think it's doable to just stop all programs that make use of the Internet, to not use Internet at all...like you say there are too many programs that use it...

Max.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Expert Comment

by:george74
Comment Utility
hi dbroos,

if on dhcp, could call ipconfig (on NT) or winipcfg (on win9x) /release to drop the lease.

cheers,
george
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
george74:

Welcome to EE !

Since you are quite new here, please allow me to explain something about commenting or answering a question.

It is custom not to post an answer but to post a comment to a question, because then it remains open and more experts can take a look. This will result (in most cases) in a better answer for the question asker.

Please read this : http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp

and the text at the bottom of this page.

D'Mzzl!
RoverM
0
 
LVL 1

Expert Comment

by:george74
Comment Utility
RoverM,

thanks and sorry for all experts blocked.

Cheers.
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
george74: No problem and thanks!
0
 

Author Comment

by:dbroos
Comment Utility
george74, again, the problem is that anyone can type that command and gain access to the internet (/renew).
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
any progress here ?
0
 

Author Comment

by:dbroos
Comment Utility
no
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
Is your problem still active then ? What do you need ?
0
 

Author Comment

by:dbroos
Comment Utility
I was thinking the best solution is something like DreamMater said: "One approach would be to maintain a list of approved URLs on a server and have the program retrieve
the list each time it starts".  But i need a litle example code on how to allow or deny the access to a specific ip address.  Maybe this could be achieved using winsock or something like that?
0
 
LVL 19

Expert Comment

by:DreamMaster
Comment Utility
What you might do, and that would keep things to the minimum complexity, is use the Webbrowser control, you can give that a list of URLS that are viewable and block all others.

Should not be to hard to acchieve, if you want that kind of code let me know, because I will need to be at an other computer (allready build that code once...do not want to build it twice, says the lazy programmer :p)

Good luck,

Max.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
>>Ark:    Whole internet or some sites?
>>dbroos: whole internet
.....
>>dbroos: i need a litle example code on how to allow or deny the access to a specific ip address

????

If you tried to restrict some addresses, take a look on my code at http://www.freevbcode.com/ShowCode.Asp?ID=1606
>>This application provides control over all opened IE windows, as well as new windows opened while the application is running. You can receive and send events from every IE window. This allows you to calculate total surfing time, prohibit access to designated URLs, and more.

Note: This code is marked VB6 or higher because it uses Windows Common controls that are not backwards compatible. If you know how to edit .vbps and .frm files in a text editor to change the name and GUID of the Common Control Library, you can use this application in VB5 as well.<<

Cheers

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now