Piping Netcat output to files

  • For support and Advertisement ICQ: 481465 Jabber: verifiedcarder@xmpp.jp

Optex_Valid®

Extreme Hot Vendor
Verfied Vendor
Platinum Vendor
Top Rated Seller
Advance Vendor
Premium Seller
Jan 28, 2016
1,195
31
48
#1
<div class="bbWrapper"><span style="color: rgb(247, 218, 100)">First we will be piping the output from a simple netcat port scan to a file named output.txt. In general command line output can be outputted to a file by using the &gt; operator followed by a file name. For Netcat this won’t work because we need to direct both stderr and stdout into the file. We can do this by using the following command:<br /> nc -vv -z localhost 1-100 &gt; output.txt 2&gt;&amp;1<br /> <br /> <div class="lbContainer lbContainer--inline" data-xf-init="lightbox" data-lb-single-image="1" data-lb-container-zoom="1" data-lb-trigger=".js-lbImage-_xfUid-1-1542720484" data-lb-id="_xfUid-1-1542720484"> <div class="lbContainer-zoomer js-lbImage-_xfUid-1-1542720484" data-src="/proxy.php?image=https%3A%2F%2Fwww.hackingtutorials.org%2Fwp-content%2Fuploads%2F2017%2F03%2F1-Netcat-write-output-to-file.jpg&amp;hash=2f084c1147e940c2202a5dddc87be18f" aria-label="Zoom"></div> <img src="/proxy.php?image=https%3A%2F%2Fwww.hackingtutorials.org%2Fwp-content%2Fuploads%2F2017%2F03%2F1-Netcat-write-output-to-file.jpg&amp;hash=2f084c1147e940c2202a5dddc87be18f" data-url="https://www.hackingtutorials.org/wp-content/uploads/2017/03/1-Netcat-write-output-to-file.jpg" class="bbImage" data-zoom-target="1" alt="" /> </div> <br /> <br /> <br /> Output Netcat port scan to file.<br /> <br /> This command outputted all result from the port scan to the output.txt file. We can use the following command to filter the output for open ports using grep:<br /> <br /> nc -vv -z localhost 1-100 2&gt;&amp;1 | grep open &gt; output.txt<br /> <br /> <div class="lbContainer lbContainer--inline" data-xf-init="lightbox" data-lb-single-image="1" data-lb-container-zoom="1" data-lb-trigger=".js-lbImage-_xfUid-2-1542720484" data-lb-id="_xfUid-2-1542720484"> <div class="lbContainer-zoomer js-lbImage-_xfUid-2-1542720484" data-src="/proxy.php?image=https%3A%2F%2Fwww.hackingtutorials.org%2Fwp-content%2Fuploads%2F2017%2F03%2F2-Netcat-grep-output-to-file.jpg&amp;hash=96e6b84e487b7d5dd8fc94c9c76ee629" aria-label="Zoom"></div> <img src="/proxy.php?image=https%3A%2F%2Fwww.hackingtutorials.org%2Fwp-content%2Fuploads%2F2017%2F03%2F2-Netcat-grep-output-to-file.jpg&amp;hash=96e6b84e487b7d5dd8fc94c9c76ee629" data-url="https://www.hackingtutorials.org/wp-content/uploads/2017/03/2-Netcat-grep-output-to-file.jpg" class="bbImage" data-zoom-target="1" alt="" /> </div> <br /> <br /> <br /> Grep netcat output to file.<br /> This command only outputs the open ports to the text file. Let’s see how we can pipe netcat input and output to pivot network connections. </span></div>