Author Topic: Building Netcat with Powershell.  (Read 1406 times)

0 Members and 1 Guest are viewing this topic.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Building Netcat with Powershell.
« on: October 03, 2014, 08:34:03 pm »
One tool I’ve found particularly handy in Linux is Netcat. While Netcat is capable of performing a variety of tasks, in essence it takes data from STDIN, forwards it over a TCP connection to a nominated server and port, and writes any response from the server to STDOUT.

Netcat is useful for issuing requests to mail servers, web servers, software or hardware control ports, or almost any network-exposed service. For me however, Netcat is made most useful for two reasons: It is easily used within a script and it is installed-by-default in most Linux distributions I’ve used.

The tool most similar to Netcat to be included with Windows is the command-line Telnet Client, but it is not easily scriptable and in recent Windows versions it is an optional feature that needs to be intentionally installed.

With PowerShell’s tight integration with the full .NET Framework it is easy to quickly implement at least the basic behaviour of Netcat on Windows using the TcpClient and an Encoding. So easy, that I have written such a script, about 70 lines long (including formatting) in a little over an hour.

http://www.powershellmagazine.com/2014/10/03/building-netcat-with-powershell
[gist]jstangroome/9adaa87a845e5be906c8[/gist]
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline apexcr3d

  • /dev/null
  • *
  • Posts: 5
  • Cookies: 0
    • View Profile
Re: Building Netcat with Powershell.
« Reply #1 on: October 14, 2014, 12:20:49 am »
This is great... ! Thank you.

I was just searching the other day for any netcat executables for Windows that perhaps someone had written over the years...I did not find anything useable.

This is also nice because I am coincidentally knee-deep in a PowerShell boot-camp (self-structured), so reviewing this script will be a good exercise.