Solved

Blocking ports

Posted on 2003-10-26
8
535 Views
Last Modified: 2007-12-19
How can i block ports using delphi and have the ability to turn them back on or off.

Also how can i monitor the connections on the computer like netstat

Thanks,
Hypoviax
0
Comment
Question by:Hypoviax
8 Comments
 
LVL 6

Expert Comment

by:swift99
Comment Utility
You are talking about either (a) writing a firewall program, or (b) writing a TCP Proxy program.

If (a), then you need to learn tier 0 and tier 1 Windows system programming.  Most of the books on this are written for C programmers, but if you're up to this particular task the programming language won't really matter to you.  A faster, cheaper, and more reliable alternative would be to pick up a linux installation and use the linux OS provided tools. Why re-invent something that is core functionality of a free (or at least really cheap) tool?

if (b), then I suggest picking up ICS at http://overbyte.delphicenter.com  .  The entire suite is written from the ground up in Delphi, and there are even examples of functional proxies on the "user built" page that you could use as a starting point.
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
Or (c) you just want to block the ports. The easiest way is to simply dump a TServerSocket or TTCPServer or equivalent on to your form, set the port number to the one you want to block, and then activate it. Only one application can listen on a port so the port must be free for you to attach to.

There is a netstat-like component on http://www.torry.net/networks.htm (second one down).

Geoff M.
0
 
LVL 2

Expert Comment

by:123456
Comment Utility
hi , i see a question as same as your question

see this link may be useful for you
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20751854.html#9493226

regards

0
 
LVL 5

Author Comment

by:Hypoviax
Comment Utility
Gmayo

I will have a look at your component. It is i think what i am looking for.

In regards to your other suggestion will this work if there already is a connection present on the port.

To Swift99

I am creating a security application that at the moment is very good at the desktop level, dealing with programs and files etc, however i need it so that it can control network flow in a way like a firewall but as gmayo said, all, at the moment that i want to do is block a specified port.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:gmayo
Comment Utility
You won't be able to take over the port if something else already has it. However, I think the netstat is independant of the ports and won't actually block anything, just monitor it. If something else has grabbed the port before your app starts then you probably need to start at a service level, ie when Windows starts.

Geoff M.
0
 
LVL 5

Author Comment

by:Hypoviax
Comment Utility
gmayo,

If this is so then i am satisfyed however, how will it be possible to apply a TServerSocket etc on more than one port. Is it possible to create a socket for each port? If so how is this done.

Also the component you are suggesting will not work for me. I am missing vcl30.bpl. It is not located in the delphi bin directory.

Thanks,

Hypoviax
0
 
LVL 8

Accepted Solution

by:
gmayo earned 250 total points
Comment Utility
You will need one TServerSocket per port to be blocked. Set the port number and Active flag.

I can't help with the vcl30.bpl - does the component you want come with source code so you can rebuild it? Basically, whatever you were trying to use was compiled under Delphi 3.

Geoff M.
0
 
LVL 5

Author Comment

by:Hypoviax
Comment Utility
Thanks for your help Geoff,

Hypoviax
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

9 Experts available now in Live!

Get 1:1 Help Now