
{"id":5903,"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-2","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2009\/12\/31\/nc-2\/","title":{"rendered":"nc &#8211; TCP\/IP swiss army knife"},"content":{"rendered":"<h4><u> A UNIX Command <\/u><\/h4>\n<pre>\n<ul>\nWindow I Server <\/ul>\n$nc -l -p  3333\nhello\nhello\nhow are you ?\nfine\n\n<ul>\nWindow II client<\/ul>\n$nc 127.0.0.1 3333\nhello\nhello\nhow are you ?\nfine\n\n<\/pre>\n<h4><u> UNIX Explanation <\/u><\/h4>\n<pre>\nnetcat is a simple unix utility which reads and writes data\nacross network connections, using TCP or UDP protocol.\n<\/pre>\n<p><\/p>\n<h4><u>Related Source Code Exposition<\/u><\/h4>\n<pre>\ndoexec (fd)\n  int fd;\n{\n  register char * p;\n\n  dup2 (fd, 0);                         \/* the precise order of fiddlage *\/\n  close (fd);                           \/* is apparently crucial; this is *\/\n  dup2 (0, 1);                          \/* swiped directly out of \"inetd\". *\/\n\n  if (doexec_use_sh) {\nDebug ((\"gonna exec \\\"%s\\\" using \/bin\/sh...\", pr00gie))\n    execl (\"\/bin\/sh\", \"sh\", \"-c\", pr00gie, NULL);\n    bail (\"exec %s failed\", pr00gie);   \/* this gets sent out.  Hmm... *\/\n  }\n\n  p = strrchr (pr00gie, '\/');           \/* shorter argv[0] *\/\n  if (p)\n    p++;\n  else\n    p = pr00gie;\nDebug ((\"gonna exec %s as %s...\", pr00gie, p))\n  execl (pr00gie, p, NULL);\n  bail (\"exec %s failed\", pr00gie);     \/* this gets sent out.  Hmm... *\/\n} \/* doexec *\/\n\n<\/pre>\n<p><\/p>\n<h4><u> Source Code Highlight<\/u><\/h4>\n<pre>\nfiddle all  the file descriptors around, and  hand off to\nanother prog.  Sort of like a one-off \"poor man's inetd\".\nThis  is   the  only  section  of  code   that  would  be\nsecurity-critical,  which  is  why  it's ifdefed  out  by\ndefault.  Use at your own hairy risk; if you leave shells\nlying around  behind open listening ports  you deserve to\nlose!!\n\n<\/pre>\n<p><\/p>\n<h4><u> Featured Image <\/u><\/h4>\n<p><a href=\"http:\/\/www.trueangle.org\/wp-content\/uploads\/2011\/06\/330ab-netcat-june-4-2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.trueangle.org\/wp-content\/uploads\/2011\/06\/330ab-netcat-june-4-2.png\" alt=\"\" title=\"netcat-June.4\" width=\"406\" height=\"226\" class=\"alignnone size-full wp-image-5243\" srcset=\"https:\/\/www.trueangle.org\/wp-content\/uploads\/2011\/06\/330ab-netcat-june-4-2.png 406w, https:\/\/www.trueangle.org\/wp-content\/uploads\/2011\/06\/330ab-netcat-june-4-2-300x167.png 300w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><\/a><br \/>\n<\/p>\n<h4><u> Related Knowledge <\/u><\/h4>\n<pre>\nIt has been suggested  that the open() system call should\nget   a  flag   which  would   cause  it   to   select  a\nnon-sequential   file   descriptor   from   the   outset,\neliminating   the   need   for   a   separate   call   to\nnonseqfd(). There are, however,  a number of system calls\nwhich  create file  descriptors but  which have  no flags\nparameter and  which, thus, will never be  able to return\nnon-sequential  file descriptors;  socket() is  a classic\nexample. So there will still  be a need for a system call\nwhich can duplicate a file descriptor into the new space.\n\nsource : http:\/\/lwn.net\/Articles\/236843\/\n<\/pre>\n<p>\n<a href=\"http:\/\/www.g-loaded.eu\/2006\/11\/06\/netcat-a-couple-of-useful-examples\/\">netcat examples<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A UNIX Command Window I Server $nc -l -p 3333 hello hello how are you ? fine Window II client $nc 127.0.0.1 3333 hello hello how are you ? fine UNIX Explanation netcat is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol. Related Source Code Exposition &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2009\/12\/31\/nc-2\/\" 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":-1,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[1524],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/5903"}],"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=5903"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/5903\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=5903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=5903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=5903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}