I'm not 100% clear on what you want, but the way to think about this is that you run a program and it is assigned a port by the OS. You don't open a port then relate it to a program. It would help if we knew why you were opening the port. What is it supposed to do?

You need to study netcat. Then learn a little coding and you can assign a port to open in your program as long as there in no conflict. You cant just open a port with a windows command in the command prompt.

Ahhh... so you wish to know how to open a port on a remote system. Such as port 23 for telnet or whatnot. Well, if the port is closed, you're going to need to either run an exploit that drops a shell, or utilize what is open in an inginuitive way... such as is shown in this month's challenge. I'm of course assuming you want to open a port on a remote computer and not your own.

There needs to be a service or program on the other machine that is responding to your command on the remote machine. For instance, If I have managed to have installed a trojan on the remote box, I can have that respond back to me on a port of my choosing as long as there is not a conflict.

First off you should try scanning the ip with a port scanner. If the telnet port is closed than your best chance would be to nbtstat their computer... You can google it and find tutorials on how to do it. Note though nbtstat will only work if the victim has file sharing enabled...

Think of ports as being like phones. If a phone is unplugged, your call will not be recieved. So you can call all you want, and you'll continue to get no response. If the phone is plugged in, then it will recieve your call. What it does with that call (talk to someone, VM, call forwarding, fax, etc.) depends on what service it offers. If the phone is on, but there is a block on certain numbers calling in or it possibly only allows outbound calls and not incoming calls, that is like a firewall. I could go on with this analogy, but I think you get the point.

So being able to open a port would like asking someone to plug in the phone that uses the number you happen to be calling. Or in your case, if you manage to get a command prompt, then plug in the phone yourself... start a service. Either start one that the system already has on it but not running or upload one of your own like netcat in listening mode. Now your phone is on and ready to provide a service.

On the other hand, if there is a firewall in place, then you may have to contend with that, too.

Thanks you all of you guys whoever posted their views. However, which things do i have to get in order to connect or open port of the remote pc? Example: IP address and MAC address? I have my friend's static ip address and mac address and he is running windows XP with service pack 2. Now which program should i use in order to get established connection? Please help. My concept is clear about opening a post but not sure about programming. Also, even if i get the program, how would i send to him pc?

Unless you have permission from your friend to do this, it is illegal.

You already know that he is using Windows XP SP2. Use a program like Nmap to find out what else he might be running on his computer. If he is using a firewall, you will see that a lot of ports show up as "filtered". You have to find open ports, and try to exploit whatever he may be running (for example, if he is running an Apache server, find out what version he is running and search for known exploits for that version). If that doesn't work, try social engineering (to trick your friend into installing a service that will give you the desired exploit), or, if you have access to the computer itself, you can log on and install a program. If you don't know the password, you can use something like the "Offline NT Admin" disc to reset a password, such as the Administrator account. If he doesn't have antivirus software, you can easily install something like the backdoor "tini", or Abel.dll, either of which will give you a remote command prompt.

If you don't know where to find these tools, use Google.

This thread has given you all of the necessary steps to own a computer.

assuming you have permission to communicate with your friends computer then, as others have stated, you will need to install/enable a service to enable that communication. Taking it a bit further you could try looking at the likes of Remote Desktop or VNC.

However, as eth3real as stated, if you don't have permission then what you are attempting is illegal and you may be at the wrong forum. try unethicalhacker.net instead.

Hopefully you are in the right place and will be able to use all of the advice that has been supplied so far. Happy hunting