473,573 Members | 4,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

port blocking

Does anyone know of a way, using C#, to programmaticall y block a
Windows port? I've looked into some low level solutions like NDIS, but
am hoping to find something that uses C#. Any help would be greatly
appreciated.

Feb 16 '06 #1
6 9233
Hi,

"JustinC" <ju***********@ gmail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Does anyone know of a way, using C#, to programmaticall y block a
Windows port? I've looked into some low level solutions like NDIS, but
am hoping to find something that uses C#. Any help would be greatly
appreciated.


No, there is nothing like that that I know of, I would suggest you check WMI
first , additionally see if the firewall that comes with SP2 has any API
you can use.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 17 '06 #2
Thanks Ignacio, I have been looking through WMI, it's just hard to know
where to even start. There is some stuff is SP2 and even more
planned/coming for the future. I was hoping to find something .NET
based b/c our app needs to work on XP as well as 2000.

I'll keep looking through WMI and I'll post an answer if I find one.

Feb 17 '06 #3

"JustinC" <ju***********@ gmail.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
| Thanks Ignacio, I have been looking through WMI, it's just hard to know
| where to even start. There is some stuff is SP2 and even more
| planned/coming for the future. I was hoping to find something .NET
| based b/c our app needs to work on XP as well as 2000.
|
| I'll keep looking through WMI and I'll post an answer if I find one.
|

The easiest is to shell-out (built-in) firewall configuration to the
netsh.exe command line utility.

For instance running:
netsh firewall show portopening
returns all ports open, while..

netsh firewall add portopening TCP 80 myport80

opens port 80 for TCP traffic

or:

add portopening protocol = TCP port = 135 name = DNS mode = ENABLE
scope = CUSTOM addresses =
192.168.0.1,192 .168.0.0/16,10.0.0.0/255.0.0.0,Local Subnet

for more info run - netsh firewall ?

Willy.


Feb 17 '06 #4
Willy,

I've been reading through the docs on netsh and it looks to be exactly
what I want, but I haven't been able to successfully block a port yet.

Specifically, I want to be able to turn on/off port 8080 to block
internet traffic. Does netsh allow you to completely block a port and
then later re-enable it? If so, what would be the syntax to do that?

Thanks again for your help.

Feb 17 '06 #5

"JustinC" <ju***********@ gmail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
| Willy,
|
| I've been reading through the docs on netsh and it looks to be exactly
| what I want, but I haven't been able to successfully block a port yet.
|
| Specifically, I want to be able to turn on/off port 8080 to block
| internet traffic. Does netsh allow you to completely block a port and
| then later re-enable it? If so, what would be the syntax to do that?
|
| Thanks again for your help.
|

Here are some examples:

Add an entry to all profiles, name = Web, default mode = DISABLE for port
tcp/8080
netsh firewall add portopening protocol = TCP port = 8080 name = Web mode =
DISABLE profile = all

Disable port
netsh firewall set portopening TCP 8080 Web DISABLE

Enable the port
netsh firewall set portopening TCP 8080 Web ENABLE

Show status of all profiles in verbose mode
netsh firewall show portopening ENABLE
Willy.
Feb 18 '06 #6
ok, that's what I was doing, it just wasn't doing what I was hoping it
would do. I'm trying to find a way to programmaticall y block all
internet traffic to a computer without blocking other network traffic.
I guess even with port 80 and 8080 blocked, outgoing traffic must
either produce an exception to allow incoming traffic, or another port
is being used. Thanks for all the help. Back to the drawing board!

Feb 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9948
by: lazydb2dba | last post by:
I would like to know if there is any reason that a connection port is not listening. I've found the following message in my db2diag.log DIA3003E Error encountered in "TCPIP" protocol support. Return code from "sqleGetAgent" was "-6036". Other findings are: 1. The result of "netstat -an|grep LISTEN" doesn't show the connection
3
5029
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0', '\0', '\1', 'Z', '0', '0',
3
3884
by: Bill | last post by:
I'm trying to use Enterprise Manager to manage my remote SQL database, but I can't seem to get a connection. I think my cable ISP Comcast may be blocking the port EM uses. What port does Enterprise Manager use to communicate with SQL? Thanks!
2
2383
by: Jim | last post by:
Tried a search, but didn't find quite what I was looking for. Situation: Have a VBA code process, tapping CDOSYS to send e-mail from Access, attaching an Excel spreadsheet, to a given list of e-mail addresses. Process used to work flawlessly. Now, corporate IT has upgraded the desktop anti-virus engines to McAfee 8.0i, which is blocking...
2
7101
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@gmail.com> Newsgroups: microsoft.public.in.csharp Subject: Multiple Clients, One port Date: Wed, 19 Apr 2006 09:36:02 -0700 I'm been working with sockets for a short while now using a server program a former coworker started. The program listens on a port for incomming connections. When a valid connection is...
2
6469
by: findyasir | last post by:
Hi all, I am having problem comunication with serial port in linux. I have tested the serial port with attaching a serial modem and dialing the numbers with wvdial. it works okie but when i connect HSM to the serial port it sends the message but i did not get a reply. mean it always being blocked in the read function. The same hsm is...
25
3607
by: bmearns | last post by:
Is it possible to specify which port to use as the outbound port on a connection? I have the IP address and port number for the computer I'm trying to connect to (not listening for), but it's expecting my connection on a certain port. Specifically, I'm trying to write an FTP host, and I'm trying to implement the PORT command. From...
1
3687
by: Andy Bates | last post by:
Hi - Can't see another newsgroup to post this in; so thought I'd post here. I have a C# application that relies on multicast UDP to detect how many PCs the application is executing on concurrently. This works okay providing the port is open but fails miserably if the port is blocked by a firewall. All applications provide a server...
0
3757
by: thesti | last post by:
hello, i'm trying to connect to SQL Server 2000 on my localhost through JDBC. i'm using the Microsoft SQL Server JDBC Driver 2.0 i couldnt make it, as i get the following error Unable to add connection. Cannot establish a connection to jdbc:sqlserver://localhost:1433;databaseName=Northwind using ...
0
7978
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8028
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5252
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3692
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2164
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1263
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.