Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 45 guests online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Network Pen Testing
Netcat Relays on Windows
EH-Net
May 22, 2013, 11:05:32 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Ethical Hacking Discussions and Related Certifications
>
Network Pen Testing
(Moderator:
don
) >
Netcat Relays on Windows
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Netcat Relays on Windows (Read 13289 times)
0 Members and 1 Guest are viewing this topic.
SecMan
Newbie
Offline
Posts: 17
Netcat Relays on Windows
«
on:
May 30, 2010, 08:29:52 PM »
Hi,
I hope this is the right place in the forums for this question.
According to
http://www.sans.org/security-resources/sec560/netcat_cheat_sheet_v1.pdf
, you can create netcat relays on windows such as Listener-to-Client relays and other types of relays. However, even in simple scenarios, I find that the problem is that the 2nd nc command does not know how to pipe back the data it receives to the first netcat. A simple example will illustrate.
C:\> echo nc
www.google.com
80 > relay.bat
C:\> nc -l -p 4444 -e relay.bat
I then start up my web browser and wireshark to monitor the data. I point my web browser to 127.0.0.1:4444. No response is received. Looking at wireshark, I find that the connection was made to the
www.google.com
and data was received. However, it appears that the nc in relay.bat does not know how to return the data to the first nc.
Any ideas? Thanks.
PS. The above works fine on Linux, but not on Windows.
Logged
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #1 on:
June 01, 2010, 12:18:55 PM »
I tried a lot of methods to find answer to this question. Checked wireshark output and tried to come up with a reasonable explanation. Ultimately, I asked the person who loves netcat perhaps more than Hobbit himself--
Ed Skoudis
. I contacted him on twitter and he replied in minutes.
I'll just quote his response here:
Quote
@Equix3n Windows nc doesn't flush stuff through enough for your browser. Try doing it to a shell, and hit Enter a few times. You'll see.
«
Last Edit: June 01, 2010, 12:36:18 PM by Equix3n-
»
Logged
SecMan
Newbie
Offline
Posts: 17
Re: Netcat Relays on Windows
«
Reply #2 on:
June 01, 2010, 12:43:31 PM »
Thanks a lot Equix3n. It was one of those annoying things that kept nagging at me, especially since I didn't understand why it wasn't working. Thanks
Logged
SecMan
Newbie
Offline
Posts: 17
Re: Netcat Relays on Windows
«
Reply #3 on:
June 02, 2010, 04:51:26 AM »
By the way, has anyone successfully used this for anything other than something like HTTP? I tried using it to forward an SSH connection and netcat would die (but works perfectly on Linux). For example:
C:\> echo nc 192.168.1.1 22 > ssh.bat
C:\> nc -l -vv -p 44444 -e ssh.bat
When I then tried setting plink or any other ssh client to connect to localhost 44444, netcat would die and give me the following error:
connect to [127.0.0.1] from localhost [127.0.0.1] 44800
Failed to execute shell, error = 193: unknown socket error
Failed to execute shell: unknown socket error
Thanks.
Logged
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #4 on:
June 03, 2010, 02:11:48 PM »
Did you try this again? I've no problems connecting to netcat using plink. However, once connected plink just hangs there. But if I try making a raw connection using netcat I do get the banner info.
Read the following article, perhaps this could help you out.
http://www.governmentsecurity.org/forum/index.php?showtopic=5787
«
Last Edit: June 03, 2010, 02:55:59 PM by Equix3n-
»
Logged
SecMan
Newbie
Offline
Posts: 17
Re: Netcat Relays on Windows
«
Reply #5 on:
June 03, 2010, 02:49:21 PM »
Thanks Equix3n-. Didn't get very far. I get the impression that netcat on Windows is basically useless except for two things:
1. Uploading/downloading files
2. Giving you a cmd.exe and execution of other commands
For things such as port forwarding, I think it's miserable. Upload something like plink or socat or a meterpreter shell and use that instead.
I just thought that nc on Windows was better but that I was missing some option that would make it function the same as it does in Linux but that doesn't seem to be the case
Logged
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #6 on:
June 03, 2010, 02:57:31 PM »
Guess I've to disturb Weld Pond this time
Logged
Ketchup
Hero Member
Offline
Posts: 1021
Re: Netcat Relays on Windows
«
Reply #7 on:
June 03, 2010, 04:16:59 PM »
I got similar results to what you were seeing SecMan. The good news is that the source code is available and can be compared to the GNU netcat. That's obviously a bit of a project.
Logged
~~~~~~~~~~~~~~
Ketchup
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #8 on:
June 10, 2010, 07:32:05 AM »
I've been trying to find a solution ever since this was posted, and with ketchup replying that he's getting the same result as SecMan I'm getting a little confused.
Here are the steps I'm following. Check if I'm doing everything correctly.
a) Firstly I run a freeSSHd SSH server on port 22 of my machine.
b) Then I make a netcat batch file which invokes a netcat client to connect to the SSH server.
Code:
echo nc 127.0.0.1 22 > relayssh.bat
c) Then I start a netcat listener which executes the batch file whenever I connect to it.
Code:
nc -v -l -p 2222 -e relayssh.bat
d)Then if I connect to the netcat listener using a
netcat client
I get the banner information after pressing return 2-3 times, and the connection is terminated after hitting the return key again.
For netcat client:
Code:
nc -vv 127.0.0.1 22
After pressing return:
Code:
nc -vv 127.0.0.1 22
DNS fwd/rev mismatch: localhost != compaq-d
localhost [127.0.0.1] 22 (?) open
SSH-2.0-WeOnlyDo 2.1.3
too many output retries: CONNABORTED
sent 2, rcvd 24
The netcat listener window displays the following information when netcat client connect to it.
Code:
nc -v -l -p 2222 -e relayssh.bat
listening on [any] 2222 ...
DNS fwd/rev mismatch: localhost != compaq-d
connect to [127.0.0.1] from localhost [127.0.0.1] 3076
e) I start the netcat listener again and try to connect to it using plink.
Code:
plink -v -ssh 127.0.0.1 -P 2222
After hitting return the plink terminal displays the following information and hangs.
Code:
plink -v -ssh 127.0.0.1 -P 2222
Looking up host "127.0.0.1"
Connecting to 127.0.0.1 port 2222
The netcat listener window terminal displays the following result:
Code:
nc -v -l -p 2222 -e relayssh.bat
listening on [any] 2222 ...
DNS fwd/rev mismatch: localhost != compaq-d
connect to [127.0.0.1] from localhost [127.0.0.1] 3091
Furthermore, when I connect to the listener using either netcat client or plink the server message changes from
no user online
to
There is 1 user online
, which means that data is reaching the ssh server (as we can clearly see when we connect to the netcat listener using netcat) but not coming back to any other client except the netcat (Since we got the banner information using netcat client instead of plink). The same thing happened when we used a browser instead of a netcat client in the previous problem.
I did get the error you two are talking about, but only once and before I posted my previous reply. I then rebooted the system and tried again and haven't got the error since. That's why I asked you whether you're still getting that error. I have tried searching the net but my Googlefu isn't helping me much. So, in frustration, I've started reading the code and it is a bit of project
The code isn't large BTW, more than half of it is just comments.
«
Last Edit: June 10, 2010, 07:40:52 AM by Equix3n-
»
Logged
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #9 on:
June 16, 2010, 09:11:46 AM »
I'm just bumping this thread again so that it doesn't go into oblivion. Anyone else tried this?
Logged
yatz
Full Member
Offline
Posts: 222
Re: Netcat Relays on Windows
«
Reply #10 on:
June 16, 2010, 09:34:46 AM »
I just happened to be browsing the InGuardians website yesterday and found the netcat cheat sheet where this is mentioned. Maybe I'll give it a try...
Logged
"Live as though you would die tomorrow, learn as though you would live forever."
CCNA, MCSA, MCTS, Sec+, Net+, Linux+, CEH
yatz
Full Member
Offline
Posts: 222
Re: Netcat Relays on Windows
«
Reply #11 on:
June 16, 2010, 04:53:11 PM »
I played with this a bit during my lunch time and after work a bit, but I couldn't get much further that what has been stated.
Actually, I couldn't even get netcat to connect properly to telnet. I started the freesshd telnet server on a basic XP box, and then used
nc -vv 192.168.0.1 23
and got a bunch of random characters. After hitting enter I got a login prompt, but after that nothing seemed to take.
Actually I get the same problem with setting up the relay, so maybe the relay concept is working and there's just a basic problem with netcat connecting to a non-netcat client?? No idea. I may continue test later but no more time today.
BTW, I don't know your config Equix3n, but I took my test boxes off a domain environment and set static IP/DNS and I didn't get that DNS problem you were seeing so that was a plus.
Logged
"Live as though you would die tomorrow, learn as though you would live forever."
CCNA, MCSA, MCTS, Sec+, Net+, Linux+, CEH
yatz
Full Member
Offline
Posts: 222
Re: Netcat Relays on Windows
«
Reply #12 on:
June 17, 2010, 08:32:19 AM »
(Sorry to triple-post...)
I loaded up the source code this morning to see if I could find anything. All I have to say is
WOW
Some of the comments were funny, and variable names like GAPING_SECURITY_HOLE gave me a laugh.
And if I thought I could find out anything from this code, I was sorely mistaken.
Logged
"Live as though you would die tomorrow, learn as though you would live forever."
CCNA, MCSA, MCTS, Sec+, Net+, Linux+, CEH
Equix3n-
Sr. Member
Offline
Posts: 386
Re: Netcat Relays on Windows
«
Reply #13 on:
June 17, 2010, 08:36:36 AM »
Quote
Actually, I couldn't even get netcat to connect properly to telnet. I started the freesshd telnet server on a basic XP box, and then used
nc -vv 192.168.0.1 23
and got a bunch of random characters. After hitting enter I got a login prompt, but after that nothing seemed to take.
Try this:
nc -v -t <I.P> 23
Netcat doesn't handle telnet negotiation unless you use the -t flag. That being said even I couldn't connect to the freessd telnet server using netcat. I could get the login prompt but after that anything I type on the screen was just reflected back to me again. But I can connect to the telnet server on my router using netcat.
Logged
yatz
Full Member
Offline
Posts: 222
Re: Netcat Relays on Windows
«
Reply #14 on:
June 17, 2010, 08:57:38 AM »
Quote
Try this:
nc -v -t <I.P> 23
I did see the -t in the help listing but it gave the same error for freessd telnet server so I thought it didn't work... my mistake.
Anyway, yes this did work and the relay worked as well!
relay:
echo nc -t <telnet.server.ip.address> 23 > relaytelnet.bat
nc -v -l -p 4444 -e relaytelnet.bat
remote:
nc <relay.i.p.address> 4444
As Ed mentioned earlier, I had to hit enter 3 times after each command to get any response from the telnet server through the relay, which is still pretty lame.
Also, since this is Windows we can eliminate the need for the batch file by using the command in this way:
nc -v -l -p 4444 -e "nc -t <telnet.server.ip.address> 23"
The HTTP forwarding on port 80 still doesn't work, but again as Ed said it's probably because of the buffers.
Logged
"Live as though you would die tomorrow, learn as though you would live forever."
CCNA, MCSA, MCTS, Sec+, Net+, Linux+, CEH
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
SANSFIRE 2013
June 15 - 22
5% Off
w/ Code
:
EHN_5
SANS Deals 4 EH-Netters
5% OFF
Any
SANS Course
in Any Format!
Coupon Code:
EHN_5
Including
SANS Rocky Mountain 2013
&
SANS Boston 2013
Polls
Compared to this year, 2013 will be:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
Network Pen Testing
: AIX Vulnerability Assessments
(2) by
ras76
Tutorials
: Need guidance
(9) by
hanyhasan
Programming
: Finished Python Course in Codecademy now what?
(15) by
hanyhasan
Network Pen Testing
: Ruby on Rails Vulnerabilities / Attacks in BackTrack 5 r3
(0) by
SUdoctstudent
Network Pen Testing
: De-ICE 1.140 released!
(2) by
superkojiman
General Certification
: CPT Practical Submission
(1) by
UNIX
OSCP - Offensive Security Certified Professional
: Failed my first attempt at the OSCP exam
(94) by
azmatt
Tools
: Social-Engineer Toolkit (SET) Version 5.0 “The Wild West” Released
(2) by
m0wgli
Malware
: EICAR?
(3) by
UKSecurityGuy
Advisories
: HTB23154: Multiple Vulnerabilities in Exponent CMS
(0) by
AndyP
Advisories
: HTB23153: Multiple Vulnerabilities in Jojo CMS
(0) by
AndyP
Advisories
: HTB23151: Cross-Site Request Forgery (CSRF) in UMI.CMS
(0) by
AndyP
OSCP - Offensive Security Certified Professional
: Class Scheduled 6/8 - Linux n00b
(7) by
Taemyks
OSCP - Offensive Security Certified Professional
: OSCP exam scheduled
(6) by
gbhat
Incident Response
: LinkedIn Forensics
(0) by
AFENTIS_Forensics
General Certification
: Red Team/Blue Team
(1) by
ajohnson
Career Central
: Starter cert?
(3) by
Grendel
Network Pen Testing
: Beginner Ethical Hacker
(1) by
m0wgli
Web Applications
: Nessus and Nikto
(4) by
Seen
Network Pen Testing
: Cracking salted MD5 hash
(4) by
n37sh@rk
CEH - Certified Ethical Hacker
: Passed my C|EH
(3) by
n37sh@rk
Mass Media
: EC-council hacked, irony at his best?
(0) by
j0rDy
Web Applications
: SQL Injection into an INSERT statement.
(6) by
eyenit0
Network Pen Testing
: Solution for sipXtapi INVITE Message CSeq Field Header Remote Overflow
(1) by
m0wgli
Web Applications
: dns
(2) by
H1t M0nk3y
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.