
{"id":18557,"date":"2009-12-31T12:21:49","date_gmt":"2009-12-31T06:51:49","guid":{"rendered":"http:\/\/froisa.com\/?p=192"},"modified":"2009-12-31T12:21:49","modified_gmt":"2009-12-31T06:51:49","slug":"nc-3","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2009\/12\/31\/nc-3\/","title":{"rendered":"nc &#8211; tcp\/ip  swiss army knife"},"content":{"rendered":"<p><u>ABOUT nc<\/u><\/p>\n<pre>\nNetcat (often abbreviated to nc) is a computer networking utility for reading from and writing to network connections using TCP or UDP. Netcat is designed to be a dependable back-end that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and investigation tool, since it can produce almost any kind of connection its user could need and has a number of built-in capabilities.\n<\/pre>\n<p><u>TYPICAL COMMANDLINE RELATED<\/u><br \/>\n[text]<br \/>\nWindow I Server<\/p>\n<p>$nc -l -p  3333<br \/>\nhello<br \/>\nhello<br \/>\nhow are you ?<br \/>\nfine<br \/>\nWindow II client<\/p>\n<p>$nc 127.0.0.1 3333<br \/>\nhello<br \/>\nhello<br \/>\nhow are you ?<br \/>\nfine<br \/>\n[\/text]<\/p>\n<p><u>Related Source Code Exposition<\/u><br \/>\n[text]<br \/>\ndoexec (fd)<br \/>\n  int fd;<br \/>\n{<br \/>\n  register char * p;<\/p>\n<p>  dup2 (fd, 0);                         \/* the precise order of fiddlage *\/<br \/>\n  close (fd);                           \/* is apparently crucial; this is *\/<br \/>\n  dup2 (0, 1);                          \/* swiped directly out of &quot;inetd&quot;. *\/<\/p>\n<p>  if (doexec_use_sh) {<br \/>\nDebug ((&quot;gonna exec &quot;%s&quot; using \/bin\/sh&#8230;&quot;, pr00gie))<br \/>\n    execl (&quot;\/bin\/sh&quot;, &quot;sh&quot;, &quot;-c&quot;, pr00gie, NULL);<br \/>\n    bail (&quot;exec %s failed&quot;, pr00gie);   \/* this gets sent out.  Hmm&#8230; *\/<br \/>\n  }<\/p>\n<p>  p = strrchr (pr00gie, &#8216;\/&#8217;);           \/* shorter argv[0] *\/<br \/>\n  if (p)<br \/>\n    p++;<br \/>\n  else<br \/>\n    p = pr00gie;<br \/>\nDebug ((&quot;gonna exec %s as %s&#8230;&quot;, pr00gie, p))<br \/>\n  execl (pr00gie, p, NULL);<br \/>\n  bail (&quot;exec %s failed&quot;, pr00gie);     \/* this gets sent out.  Hmm&#8230; *\/<br \/>\n} \/* doexec *\/<br \/>\n[\/text]<\/p>\n<p><u>Source Code Highlight<\/u><\/p>\n<pre>\nfiddle all  the file descriptors around, and  hand off to another prog.  Sort of like a one-off \"poor man's inetd\". This is the only section of code that would be security-critical, which  is\nwhy  it's ifdefed  out  by default.  Use at your own hairy risk; if you leave shells lying around\nbehind open listening ports  you deserve to lose!!\n<\/pre>\n<p><u>Related Knowledge<\/u><\/p>\n<pre>\nIt has been suggested  that the open() system call should get   a  flag   which  would   cause  it   to\nselect  a non-sequential   file   descriptor   from   the   outset, eliminating   the   need   for   a\nseparate   call   to nonseqfd(). There are, however,  a number of system calls which  create file\ndescriptors but  which have  no flags parameter and  which, thus, will never be  able to return\nnon-sequential  file descriptors;  socket() is  a classic example. So there will still  be a need for a\nsystem call which can duplicate a file descriptor into the new space.\n<\/pre>\n<p>LINKS<br \/>\n<a href=\"http:\/\/lwn.net\/Articles\/236843\/\">http:\/\/lwn.net\/Articles\/236843\/<\/a><br \/>\n<a href=\"http:\/\/www.g-loaded.eu\/2006\/11\/06\/netcat-a-couple-of-useful-examples\/\">http:\/\/www.g-loaded.eu\/2006\/11\/06\/netcat-a-couple-of-useful-examples\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ABOUT nc Netcat (often abbreviated to nc) is a computer networking utility for reading from and writing to network connections using TCP or UDP. Netcat is designed to be a dependable back-end that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2009\/12\/31\/nc-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;nc &#8211; tcp\/ip  swiss army knife&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":5243,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[1149,1153,1523],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18557"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=18557"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18557\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media\/5243"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=18557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=18557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=18557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}