# Firewall : which language to use ?



## sinoop_joy (Dec 17, 2010)

I would like to do Firewall(the one like COMODO) as my final year project.

The thing is i have read that it is not possible using C#. Is that so ?
I cant use Java too ?
How about Visual C++ ?

Any other suitable languages ?


----------



## arpanmukherjee1 (Dec 19, 2010)

all 3 langs have the ability to do so.

java and .net framework have classes that provide high level control

u must know the algos of networking and socket programing.

built a packet filter in java once


----------



## sinoop_joy (Dec 20, 2010)

Can you provide me any details or  a link to a sample program ?

I read that we need to program in kernel mode so we cannot use C# for that..
So you are saying that there is no problem with dat rite ?
What will these classes do to program ? Will they make the program execute in kernel mode ?


----------



## arpanmukherjee1 (Dec 20, 2010)

elementary socket programming :: How to C# Socket programming



> we need to program in kernel mode so we cannot use C# for that.


now where did u read THAT ???

see :: C# does Shell, Part 1 - CodeProject

what i think u want to say is that u cannot access ring 0 

more info on rings :: Ring (computer security) - Wikipedia, the free encyclopedia

that is also not correct

see:: ProcessStartInfo Class

Process Class (System.Diagnostics)

*www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx

and yes u need to invoke the "net" dos command :: MS-DOS net command help

u may also be interested to look at Net Tools

i think now u realize the extent of .net and capability of C#

ask if u want to know more..


----------



## sinoop_joy (Dec 22, 2010)

firewall application - C#  says so


----------



## arpanmukherjee1 (Dec 23, 2010)

^^^ everything in that thread is correct.

you have to write unmanaged code in C# that is not governed by .net 

u must take help of WinPcap and libPcap. the former a sniffer and latter a dropper
nobody expects u to write device drivers, just use them

one thing, if u seriously want to do such projects a LOT of research on ur part is required


----------



## sinoop_joy (Dec 24, 2010)

I'm ready to do research. I actually want to do something like this to become better familiar with the language. But i'm doing this as part of my curriculum so i have to consider the mark part too. I will get approximately 3-4 months for doing this project.
Can you help me ?


----------



## Adam Cruge (Dec 25, 2010)

Nice post. I was wondering how to build such kind of software.
well one more doubt, after writing those code for that software how to transform it into .exe so that it looks like the software we use?


----------



## arpanmukherjee1 (Dec 25, 2010)

sinoop_joy said:


> I'm ready to do research. I actually want to do something like this to become better familiar with the language. But i'm doing this as part of my curriculum so i have to consider the mark part too. I will get approximately 3-4 months for doing this project.
> Can you help me ?



sure. i will post code fragments from my java project. u can convert it to C#

AFA u know what u r doing and can explain the algo be sure that u will be give above 90% marks

3-4 mths time is short, even if u know the lang. prefer doing it in the lang u know very well. if the lang is not known u will loose time coding functions that may already exist.

google up algos and look at the flow

i would highly recommend this book : Sybex CCNA Cisco Certified Network Associate Study Guide 2nd Edition 0782126472 download free

go through the index and find topics relevent to ur proj eg. 
IP address resolution
VLAN
packet filter
packet structure etc



Adam Cruge said:


> well one more doubt, after writing those code for that software how to transform it into .exe so that it looks like the software we use?



Visual Studio Professional edition supports Setup Projects that will create such setups.

also u can use Inno (free) at : *www.jrsoftware.org/isdl.php


----------



## Adam Cruge (Dec 25, 2010)

That is to do with software. Any other way to do it manually?


----------



## arpanmukherjee1 (Dec 25, 2010)

Adam Cruge said:


> That is to do with software. Any other way to do it manually?



of course u can...

but why not use something that is already out there and accepted as commercial standard ??


----------



## Adam Cruge (Dec 26, 2010)

The reason behind is that I want to learn this from scratch. So if you please tell me the way to do it.


----------



## sinoop_joy (Dec 26, 2010)

arpanmukherjee1 said:


> sure. i will post code fragments from my java project. u can convert it to C#
> 
> i would highly recommend this book : Sybex CCNA Cisco Certified Network Associate Study Guide 2nd Edition 0782126472 download free
> 
> ...



Thank u..
I'l be beginning soon.. Will let you know.
How can i contact you ?

BTW, how will VLAN b needed 4 my project ?
We had a Internetworking nd Computer networking theory n lab in the last semester. So i know the basics of networking.

And about the language, i did my mini project in c#. But it was a small one compared to this one. A sofware similar to Disclib. It was entirely different one.
I dont know the network monitoring part of any language,though i got the belief that i can catch up. And of course i got someone to help me now..

You did firewall in Java ?


----------



## arpanmukherjee1 (Dec 26, 2010)

sinoop_joy said:


> Thank u..
> I'l be beginning soon.. Will let you know.
> How can i contact you ?



here on the forum itself. let others know of the progress and problem alike...



sinoop_joy said:


> BTW, how will VLAN b needed 4 my project ?.



it will be when u design a packet filter, which u will... eventually..



sinoop_joy said:


> We had a Internetworking nd Computer networking theory n lab in the last semester. So i know the basics of networking.



i know. i also know that programming structure provided by book is a big zero.



sinoop_joy said:


> And about the language, i did my mini project in c#. But it was a small one compared to this one. A sofware similar to Disclib. It was entirely different one.



thats good. but learning never stops.



sinoop_joy said:


> I dont know the network monitoring part of any language,though i got the belief that i can catch up. And of course i got someone to help me now..



there is always google to help u out and others and yes .. me 



sinoop_joy said:


> You did firewall in Java ?



no. i did "packet filtering" in java. firewall is a "configurable" packet filter and includes other algos/functions like heuristic search and support for encrytion like IPsec etc



Adam Cruge said:


> The reason behind is that I want to learn this from scratch. So if you please tell me the way to do it.



no need 4 me tell u its done before

please read the articles in a sequential fashion ::

1> Writing A Good Setup For Your Applications - CodeProject
2> dotNetInstaller - Setup Bootstrapper for .NET Application - CodeProject
3> Enhanced .NET Bootstrap Setup - CodeProject

also Wix tutorial ::

4> Creating an installer using Wix v3.0, Votive, and Visual Studio 2005/2008 - CodeProject
5> Creating an installer using Wix v3.0, Votive, and Visual Studio 2005/2008 - Part 2, the GUI - CodeProject


----------



## sinoop_joy (Feb 19, 2011)

Hey can you give me that code f your java project ?

How can i make my program start in kernel mode ?


----------



## funkysourav (Feb 19, 2011)

hey i have got a wild idea
How about you join the Comodo Forums
there are a bunch of crazy but very helpful guys there
tell them that you are a student and ask them to help you
maybe you'll get lucky(someone might help you with the tricks of the trade)

else there are many open source firewall projects at source forge
SourceForge.net: Open Source Firewall For Windows - Develop
Express Open Source Firewall Project » Download
align yourself with one and learn with the help of other developers

BTW
Great project
all the best


----------



## sinoop_joy (Feb 19, 2011)

@funkysourav : 
Thanks 4 d links and suggestions.
I sent a mail 2 comodo team asking about the language they use. Bt no reply 
Nyway wil check the forum...


----------



## funkysourav (Feb 19, 2011)

join the forum
and stay active there
you'll meet many helpful people there
heck even the COMODO CEO Melih sometimes talks and chats with end users on the forum
I think your best bet is there forum
don't ask for help not just yet
take your time, build reps and contacts
and present your problem as a hobby or student project
they will help you for sure

its not like they will be sharing Rocket Science Confidential secrets with you
but they will direct your path for sure
But it will take some time


----------



## sinoop_joy (Feb 19, 2011)

funkysourav said:


> join the forum
> its not like they will be sharing Rocket Science Confidential secrets with you


----------



## sinoop_joy (Mar 1, 2011)

Finally, i decided to modify the project a little bit.
I decided to do the controlling of Windows firewall to do the task. And started coding. Bt the problem is when i try to turn off the firewall using code , my program gets stopped and windows firewall is not turned off.. What could be the problem ?


I used this code...


```
Type NetFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false); 
INetFwMgr mgr = (INetFwMgr)Activator.CreateInstance(NetFwMgrType);
mgr.LocalPolicy.CurrentProfile.FirewallEnabled = false;
```



and i get this error.. I tried running the exe as administrator. Bt then too it is not happening. 

*img535.imageshack.us/img535/561/capturewc.jpg


----------



## funkysourav (Mar 1, 2011)

try running with admin privileges
maybe that will work
also lookup "iptables" the linux firewall


----------



## sinoop_joy (Mar 2, 2011)

funkysourav said:


> try running with admin privileges
> maybe that will work



i already tried that.. 


sinoop_joy said:


> I tried running the exe as administrator. Bt then too it is not happening.




---------- Post added 02-03-2011 at 10:17 AM ---------- Previous post was 01-03-2011 at 10:56 PM ----------

where can i get the C# code of these ?

Using Windows Firewall with Advanced Security (Windows)

All are C++ or VB codes... 


Can anyone convert this to C# code ?

Turning the Firewall Off (Windows)


----------

