Solved

Block internet access

Posted on 2001-08-30
22
225 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 28

Expert Comment

by:Ark
ID: 6443355
Whole internet or some sites?
0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 200 total points
ID: 6444010
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
ID: 6444921
whole internet
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Expert Comment

by:george74
ID: 6445741
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
ID: 6445748
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
ID: 6445970
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
ID: 6446855
ping
0
 
LVL 28

Expert Comment

by:Ark
ID: 6446926
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
ID: 6448966
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
ID: 6449178
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
ID: 6449946
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
 
LVL 1

Expert Comment

by:george74
ID: 6450257
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
ID: 6450337
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
ID: 6450356
RoverM,

thanks and sorry for all experts blocked.

Cheers.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6450394
george74: No problem and thanks!
0
 

Author Comment

by:dbroos
ID: 6450797
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
ID: 6483862
any progress here ?
0
 

Author Comment

by:dbroos
ID: 6488144
no
0
 
LVL 12

Expert Comment

by:roverm
ID: 6488274
Is your problem still active then ? What do you need ?
0
 

Author Comment

by:dbroos
ID: 6488907
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
ID: 6575915
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 28

Expert Comment

by:Ark
ID: 6575995
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 60
Set email body to html using vbscript 6 49
RUNRMTCMD from AS/400 12 68
VB6 - Scroll Mouse wheel on Picturebox 13 70
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

808 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