How To: Netcat – Check for open ports with the command line

NetCat PortKitty Port-checking

When troubleshooting a network integration or any other connection issue in Linux, step one is usually a matter of checking to see if the network port on the other side is even responding.

Netcat -The network Swiss Army knife (Hobbit, not nmap)- is the right tool for the job.

Before we begin, NetCat needs to be installed.

# RHEL / CentOS
~$ yum install nc

# Debian / Ubuntu
~$ apt-get install nc

Once installed, you can invoke Netcat like so:
~$ nc [REMOTE_SERVER] [PORT]

Syntax:
[REMOTE_SERVER] – The server to be checked
[PORT] – The service/port to be checked

 

 


Connection to google.com 443 port [tcp/https] succeeded!

Confessions of a SysOP – Linux Enthusiasm in the Enterprise Environment

Dell RHEL 6

I used to be highly enthusiastic about open and free information technology, and I still am to some extent, but the workplace made me think critically in a new way.

Ever since my first introduction to Linux a couple of years ago, running as a Knoppix Live DVD on my parents old HP 3GHz Pentium 4, I’ve had a constant buzz from all the quirky and cool features. It didn’t take long until I discovered and familiarized myself with the shell, and learned about it’s place in the operating system. How could I have missed this?

Soon thereafter, I gathered the courage to install it for the first time. This time on an old Packard Bell laptop. Ubuntu 6.04 was my system of choice at the time, and to this day I don’t regret it. I’ve always felt that Debian has a more Human touch.

Fast-forward a couple of years and I’m studying this marvelous OS, for two years, full time. My initial experience was nothing short of a technological enlightenment. Linux or not, *Nix systems have a very colorful history, and has always had ha place in IT infrastructure. Here, I was taught what Linux does best, in the elusive Enterprise Environment (that phrase still gives me chills).

Business critical server services such as DNS, SMTP, SQL, HTTP, NFS, FTP, Certificate signing and various applications hosted -on none other than- Linux. What else? Who wouldn’t?

Then came, the work environment. There I learned, the hard way, that not everyone is so understanding.

Why, for example, would the web-developer ask me to “chmod 777” every file in the application directory and “./start-crappyenterpriseapp.sh”, while running and owned by user root (!!!).

Or, perhaps, order a publicly accessible file server and emphasize on security. Noting that user directories should be chrooted and not be able to access each other, Challenge Accepted. Two weeks later: “Could we make it so that user A can read/write in the home-directories of users C, D and E? Also, could we use FTP instead of that pesky sFTP? It’s time-consuming emailing keys” (…).

How about, receiving the request: “Could we add the zone company.local to your public authoritative name server?  All our servers, internal and public, already use it as their primary DNS server. Adding a couple company.local sub-domains there would be a quick fix. Right?” (… no).

Never let them see you bleed.

How To: Send and receive files with Ncat (formerly NetCat)

As with any application in Linux, piping the output from an application to a logfile or perhaps another application. Can sometimes clarify what is going on. It would be even better if you could “cat” any output over the Network (Ncat, get it?) to another computer. That is where Ncat comes in.

First, some basics

  • ncat The command in question
  • -v Verbose output, recommended for testing
  • -l Tells ncat to listen
  • -k Tells ncat to keep the connection up (ncat exits on client disconnect by default)
  • -n Tells ncat to skip DNS resolution (not necessary when connecting/listening on plain IP’s)
  • –ssl Tells ncat to send data encrypted with ssl (optional)
  • –send-only Tells ncat to only send data (optional)
  • –recv-only Tells ncat to only receive data (optional)

Now, some examples

  • [Server] $ncat -l 1025 > file.txt [Client] $cat file.txt | ncat [IP of Server] 1025 – Sends “file.txt” to the server over port 1025
  • [Server] $ncat -lkv 12345 > file.txt [Client] $cat file.txt | ncat [IP of Server] 12345 – Sends “file.txt” to the server over port 12345. The server will verbosely print what is going on, and keep the connection open when the client disconnects
  • [Server] $ncat -lkvn –recv-only 1337 > supersecretfile.txt [Client] $cat supersecretfile.txt | ncat –send-only –ssl [IP of Server] 1337 – Sends “supersecretfile.txt” to the server over port 1337. The server will verbosely print output, keep the connection open and skip resolving DNS. While the client sends the data encrypted over ssl

Netcat Tutorial: Connect Through Proxy

If you are performing a pentest, you have to stay as anonymous as you can, even ifyou are performing such a simple task as a banner grab. Anonymity is specially important when performing a bind shell to a remote computer, and you don’t want your computer savvy victim to take notice, or at least, be able to track you.

Continue reading Netcat Tutorial: Connect Through Proxy

Setup OpenDNS In Mac OS X

There are several reasons you might want to use OpenDNS, the biggest two I use it is for speed and security, here I will show you how you can set it up on your Mac:

  1. Open system preferences and click “Network”
  2. Select your network interface and then click on “Advanced”. If you don’t know what network interface you are using, then it’s the one with a green circle next to it, in my case “AirPort”
  3. Once in advanced click the “DNS” tab
  4. Finally, add the following IP,s: 208.67.222.222, 208.67.220.220