{"id":3832,"date":"2024-03-11T16:56:22","date_gmt":"2024-03-11T08:56:22","guid":{"rendered":"https:\/\/dasmz.com\/?p=3832"},"modified":"2024-03-11T23:27:29","modified_gmt":"2024-03-11T15:27:29","slug":"%e5%9f%ba%e4%ba%8enetcat-nc%e5%91%bd%e4%bb%a4%ef%bc%8c%e6%a3%80%e6%b5%8b%e5%9c%b0%e5%9d%80%e7%ab%af%e5%8f%a3%e6%98%af%e5%90%a6%e9%80%9a-2024-03-11","status":"publish","type":"post","link":"https:\/\/dasmz.com\/?p=3832","title":{"rendered":"\u57fa\u4e8enetcat\/nc\u547d\u4ee4\uff0c\u68c0\u6d4b\u5730\u5740\u7aef\u53e3\u662f\u5426\u901a 2024-03-11"},"content":{"rendered":"\n<p><strong>\u524d\u7f00\u3001\u6587\u6863\u4fee\u6539\u8bb0\u5f55<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">20240311 \u521d\u59cb\u5316\u7f16\u8f91\u6b64\u6587\u7ae0\uff0c\u5b8c\u7a3f\n20240311 \u5728\u5f55\u5236\u89c6\u9891\u540e\uff0c\u4fee\u6b63\u90e8\u5206\u5185\u5bb9\u53ca\u63cf\u8ff0<\/pre>\n\n\n\n<p><strong>\u7ae0\u82821\u3001\u9700\u6c42\u63cf\u8ff0<\/strong><\/p>\n\n\n\n<p>\u4e1a\u52a1\u4fa7\uff0c\u7ecf\u5e38\u9700\u8981\u68c0\u6d4b\u4e1a\u52a1\u5730\u5740\uff0c\u4e1a\u52a1\u7aef\u53e3\u662f\u5426\u80fd\u901a\uff0c\u8fd9\u6837\u7684\u9700\u6c42\uff0c\u5c31\u9700\u8981\u914d\u5957\u7684\u5de5\u5177\u6765\u6392\u67e5\u3002<\/p>\n\n\n\n<p><strong>\u7ae0\u82822\u3001\u68c0\u67e5\u4e3b\u673a\u662f\u5426\u5b58\u6d3b<\/strong><\/p>\n\n\n\n<p>\u5e38\u89c4\u6765\u8bf4\uff0c\u68c0\u6d4b\u4e00\u4e2a\u4e1a\u52a1\uff0c\u662f\u5426\u53ef\u8fbe\uff0c\u5148\u68c0\u6d4b\u5176\u4e91\u4e3b\u673aECS\u662f\u5426\u5b58\u6d3b\uff0c\u5904\u4e8e\u5f00\u673a\u72b6\u6001\u3002\u4e00\u822c\u57fa\u4e8eping\u5176IP\u5730\u5740\u7684\u8def\u7531\u662f\u5426\u53ef\u901a\u7684\u65b9\u5f0f\u6765\u5224\u65ad\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4f18\u5148\u4f7f\u7528ICMP\u7684ping \u65b9\u5f0f\u8fdb\u884c\u68c0\u6d4b\u6392\u67e5\u95ee\u9898<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ping xxx.xxx.xxx.xxx    # \u5176\u4e2dxxx.xxx.xxx.xxx\u4e3a\u4e00\u4e2a\u6709\u6548IP\u5730\u5740<\/pre>\n\n\n\n<p>\u5982\u679cIP\u5730\u5740\u4e0d\u901a\uff0c\u53ef\u80fd\u4e3a\u7f51\u7edc\u771f\u5b9e\u4e0d\u901a\uff0c\u6216\u53ef\u80fd\u5b58\u5728\u5bf9\u7aef\u9632\u706b\u5899\u5c4f\u853dICMP\u7684\u5305<\/p>\n\n\n\n<p>\u4ea6\u53ef\u901a\u8fc7mtr \/ tracert \/ traceroute \u76f8\u5173\u547d\u4ee4\uff0c\u6d4b\u8bd5\u8def\u7531\u70b9\uff0c\u662f\u5426\u4e3a\u4e2d\u95f4\u67d0\u4e2a\u8def\u7531\u70b9\u6709\u8bef\u3002<\/p>\n\n\n\n<p><strong>\u7ae0\u82823\u3001\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u53ef\u901a<\/strong><\/p>\n\n\n\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5982\u679c\u4e0a\u4e00\u4e2a\u7ae0\u8282\u7684\u4e91\u4e3b\u673aIP\u5730\u5740\u90fd\u4e0d\u901a\uff0c\u4f18\u5148\u68c0\u67e5\u4e3b\u673a\u6545\u969c\/\u9632\u706b\u5899\u89c4\u5219\/IP\u5730\u5740\u7684\u8def\u7531\u95ee\u9898\u3002\u6216\u8005\uff0c\u5982\u679c\u8def\u7531\u6b63\u786e\u4e14\u660e\u786e\u77e5\u9053\u662f\u5bf9\u7aef\u5df2\u5173\u95edICMP\u5305\u54cd\u5e94\uff0c\u5219\u53ef\u8fdb\u884cTCP\/UDP\u7aef\u53e3\u68c0\u67e5\u3002<\/p>\n\n\n\n<p>\u672c\u6b21\u63a8\u8350\u4f7f\u7528netcat\/nc\u547d\u4ee4\uff0c\u8fdb\u884c\u7aef\u53e3TCP\/UDP\u662f\u5426\u53ef\u8fbe\u7684\u68c0\u67e5\u3002<\/p>\n\n\n\n<p><strong>3.1\u3001\u5b89\u88c5netcat<\/strong><\/p>\n\n\n\n<p>Debian\/Ubuntu \u5b89\u88c5netcat\/nc\u7684\u547d\u4ee4\uff0c\u4e14\u63a8\u8350\u4f18\u5148\u5b89\u88c5\u7684\u7248\u672c\u4e3a netcat-openbsd\uff0c\u800c\u975enetcat-traditional<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ OS: Debian 12\nroot@server:~# apt update\nroot@server:~# apt-get install netcat-openbsd     \nroot@server:~# <\/pre>\n\n\n\n<p><strong>3.2\u3001netcat\u53c2\u6570\u91ca\u4e49<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@server:~# nc -h\nOpenBSD netcat (Debian patchlevel 1.206-1ubuntu1)\nusage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]\n\t  [-m minttl] [-O length] [-P proxy_username] [-p source_port]\n\t  [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]\n\t  [-X proxy_protocol] [-x proxy_address[:port]] \t  [destination] \n\n\u53c2\u6570\u6e05\u5355\uff1a\n-4\t\tUse IPv4\/\u4ec5\u4f7f\u7528IPv4\n\n-6\t\tUse IPv6\/\u4ec5\u4f7f\u7528IPv6\n\n-b\t\tAllow broadcast\/\u5141\u8bb8\u5e7f\u64ad\n\n-C\t\tSend CRLF as line-ending\n\n-D\t\tEnable the debug socket option\/\u542f\u7528\u5bf9\u5957\u63a5\u5b57\u7684\u8c03\u8bd5\n\n-d\t\tDetach from stdin\/\u4e0d\u5c1d\u8bd5\u4ecestdin\u8fdb\u884c\u8bfb\u53d6\n\n-F\t\tPass socket fd\n\n-h\t\tThis help text\/\u5e2e\u52a9\u6587\u6863\n\n-I length\tTCP receive buffer length\n\n-i interval\tDelay interval for lines sent, ports scanned\/\u6307\u5b9a\u53d1\u9001\u548c\u63a5\u6536\u7684\u6587\u672c\u884c\u4e4b\u95f4\u7684\u5ef6\u8fdf\u65f6\u95f4interval\n\n-k\t\tKeep inbound sockets open for multiple connects\/nc\u5728\u63a5\u6536\u5b8c\u4e00\u4e2a\u8bf7\u6c42\u540e\u4e0d\u4f1a\u7acb\u5373\u9000\u51fa\uff0c\u800c\u662f\u4f1a\u7ee7\u7eed\u76d1\u542c\u5176\u4ed6\u8bf7\u6c42\n\n-l\t\tListen mode, for inbound connects\/\u76d1\u542c\u6a21\u5f0f\n\n-M ttl\t\tOutgoing TTL \/ Hop Limit\n\n-m minttl\tMinimum incoming TTL \/ Hop Limit\n\n-N\t\tShutdown the network socket after EOF on stdin\n\n-n\t\tSuppress name\/port resolutions\/\u4e0d\u4f7f\u7528\u57df\u540d\n\n-O length\tTCP send buffer length\n\n-P proxyuser\tUsername for proxy authentication\n\n-p port\t\tSpecify local port for remote connects\/\u4e3a\u8fdc\u7a0b\u8fde\u63a5\u5b9a\u4e49\u7684\u672c\u5730\u7aef\u53e3\u53f7\n\n-q secs\t\tquit after EOF on stdin and delay of secs\n\n-r\t\tRandomize remote ports\n\n-S\t\tEnable the TCP MD5 signature option\n\n-s source\tLocal source address\/\u6307\u5b9a\u7528\u4e8e\u53d1\u9001\u6570\u636e\u5305\u7684\u63a5\u53e3\u7684IP\u5730\u5740\n\n-T keyword\tTOS value\n\n-t\t\tAnswer TELNET negotiation\n\n-U\t\tUse UNIX domain socket\n\n-u\t\tUDP mode\/\u4f7f\u7528UDP\uff0c\u800c\u4e0d\u662f\u7f3a\u7701\u9009\u9879TCP\n\n-V rtable\tSpecify alternate routing table\n\n-v\t\tVerbose\/\u6307\u5b9a\u8be6\u7ec6\u8f93\u51fa\n\n-W recvlimit\tTerminate after receiving a number of packets\n\n-w timeout\tTimeout for connects and final net reads\/\u5982\u679c\u8fde\u63a5\u548cstdin\u7a7a\u95f2\u8d85\u8fc7\u4e86timeout\u79d2\uff0c\u5219\u65e0\u63d0\u793a\u5730\u5173\u95ed\u8fde\u63a5\n\n-X proto\tProxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\/\u4e0e\u4ee3\u7406\u670d\u52a1\u5668\u901a\u4fe1\u65f6\uff0c\u4f7f\u7528\u8be5\u6307\u5b9a\u534f\u8bae\u3002\u53d7\u652f\u6301\u7684\u534f\u8bae\u4e3a4(SOCKSv4)\u30015(SOCKSv5)\u548cconnect\uff08HTTP\u4ee3\u7406\uff09\u3002\u5982\u679c\u672a\u6307\u5b9a\u534f\u8bae\uff0c\u5219\u4f7f\u7528SOCKSv5\n\n-x addr[:port]\tSpecify proxy address and port\/\u4f7f\u7528proxy_address\u548cport\u4e0a\u7684\u4ee3\u7406\u8bf7\u6c42\u5230addr\u7684\u8fde\u63a5\u3002\u5982\u679c\u672a\u6307\u5b9aport\uff0c\u5219\u4f7f\u7528\u4ee3\u7406\u534f\u8bae\u7684\u5df2\u77e5\u7aef\u53e3\uff08SOCKS\u4e3a1080\uff0cHTTP\u4e3a3128\uff09\n\n-Z\t\tDCCP mode\n\n-z\t\tZero-I\/O mode [used for scanning]\/\u6267\u884c\u7aef\u53e3\u626b\u63cf\u3002\u5bf9\u4e8eTCP\u7aef\u53e3\uff08\u7f3a\u7701\uff09\uff0c\u5c1d\u8bd5\u5728\u4e0d\u53d1\u9001\u6570\u636e\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u8fde\u63a5\u626b\u63cf\uff08\u5b8c\u6574\u4e09\u8def\u4fe1\u53f7\u63e1\u624b\uff09\u3002\u5bf9\u4e8eUDP(\u2013u)\uff0c\u7f3a\u7701\u60c5\u51b5\u4e0b\u4f1a\u53d1\u9001\u7a7aUDP\u5305\n\nPort numbers can be individual or ranges: lo-hi [inclusive]\nroot@server:~# <\/pre>\n\n\n\n<p><strong>3.3\u3001\u7528netcat\u68c0\u6d4bTCP\u7aef\u53e3<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nc -nvz 93.150.241.210 8000-9999    \n<\/pre>\n\n\n\n<p><strong>3.4\u3001\u7528netcat\u68c0\u6d4bUDP\u7aef\u53e3<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nc -nvzu 93.150.241.210 123<\/pre>\n\n\n\n<p>\u7aef\u53e3\u5982\u679c\u662f\u901a\u7684\uff0c\u4f1a\u7c7b\u4f3c\u5982\u4e0b\u7684\u663e\u793a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@debian12:~# nc -nvz 10.11.11.200 22\nConnection to 10.11.11.200 22 port [tcp\/*] succeeded!\nroot@debian12:~# <\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img decoding=\"async\" loading=\"lazy\" width=\"498\" height=\"66\" src=\"https:\/\/dasmz.com\/wp-content\/uploads\/2024\/03\/Screenshot-from-2024-03-11-22-36-16.png\" alt=\"\" class=\"wp-image-3860\"\/><\/figure>\n\n\n\n<p><strong>3.5\u3001\u7528netcat\u4e34\u65f6\u542f\u52a8\u4e00\u4e2a\u670d\u52a1\u7aefTCP\/UDP\u76d1\u542c<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u662f\u4e3a\u4e86\u9a8c\u8bc1\u7aef\u53e3\uff0c\u9700\u8981\u81ea\u5df1\u5728\u670d\u52a1\u5668\u4e0a\u4e34\u65f6\u542f\u52a8\u4e00\u4e2a\u76d1\u542c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528netcat\u4e34\u65f6\u542f\u52a8\u4e00\u4e2a\u670d\u52a1\u7aef\u7684TCP\/UDP\u7aef\u53e3\u76d1\u542c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nc -n -l -k -u 123    # \u76d1\u542cUDP\/123\nnc -l -k 3389    # \u76d1\u542cTCP\/3389\n\n-l \u4ee3\u8868netcat \u5c06\u4ee5\u76d1\u542c\u6a21\u5f0f\u8fd0\u884c\uff1b\n-k \u8868\u793anetcat \u5728\u63a5\u6536\u5b8c\u4e00\u4e2a\u8bf7\u6c42\u540e\u4e0d\u4f1a\u7acb\u5373\u9000\u51fa\uff0c\u800c\u662f\u4f1a\u7ee7\u7eed\u76d1\u542c\u5176\u4ed6\u8bf7\u6c42\n-u \u4f7f\u7528UDP\uff0c\u800c\u4e0d\u662f\u7f3a\u7701\u9009\u9879TCP<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u9644\u5f551\u3001\u89c6\u9891\u64cd\u4f5c\u6f14\u793a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"000145  \u57fa\u4e8enetcatnc\u547d\u4ee4\uff0c\u68c0\u6d4b\u5730\u5740\u7aef\u53e3\u662f\u5426\u901a 2024-03-11\" width=\"625\" height=\"352\" src=\"https:\/\/www.youtube.com\/embed\/MQZFptrc86s?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><strong>\u9644\u5f552\u3001@Dasmz<\/strong><\/p>\n\n\n\n<p>\u535a\u5ba2\u5185\uff0c\u6240\u6709\u6559\u7a0b\u4e3a\u624b\u6253\u539f\u521b\u6559\u7a0b\uff0c\u5982\u679c\u6280\u672f\u6559\u7a0b\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u6b22\u8fce\u6253\u8d4f\u4f5c\u8005\u3002\u6280\u672f\u5c42\u9762\uff0c\u95fb\u9053\u6709\u5148\u540e\uff0c\u5982\u6709\u758f\u6f0f\u3001\u9519\u8bef\uff0c\u6b22\u8fce\u6307\u6b63\u3002\u6280\u672f\u535a\u5ba2\u7684\u5185\u5bb9\uff0c\u4e00\u822c\u5177\u6709\u4e00\u5b9a\u7684\u73af\u5883\u4f9d\u8d56\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u5e74\u4ee3\u4f9d\u8d56\uff0c\u914c\u60c5\u53c2\u8003\u5176\u4e2d\u7684\u5185\u5bb9\uff0c\u8bf7\u52ff\u5b8c\u5168\u7167\u642c\u7167\u6284\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u535a\u5ba2\u5185\u5df2\u63d0\u53ca\u7684\u4e13\u4e1a\u77e5\u8bc6\uff0c\u5982\u679c\u9700\u8981\u6280\u672f\u6307\u5bfc\uff0c\u6b22\u8fce\u8054\u7cfb\u6211\uff0c\u4ec5\u9700\u652f\u4ed8\u5de5\u65f6\u8d39<\/p>\n\n\n\n<p>Twitter: <a href=\"https:\/\/twitter.com\/fdmove\">Dasmz<\/a><\/p>\n\n\n\n<p>Youtube: <a href=\"https:\/\/www.youtube.com\/@DasmzStudio\" data-type=\"URL\" data-id=\"https:\/\/www.youtube.com\/@DasmzStudio\">@DasmzStudio<\/a><\/p>\n\n\n\n<p>Telegram: <a href=\"https:\/\/t.me\/fdmove\" data-type=\"URL\" data-id=\"https:\/\/t.me\/fdmove\">@Dasmz<\/a><\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"574\" height=\"446\" src=\"https:\/\/dasmz.com\/wp-content\/uploads\/2020\/12\/DONATE.jpg\" alt=\"Donate\" class=\"wp-image-18\"\/><figcaption class=\"wp-element-caption\">\u4e91\u4e5e\u8ba8<\/figcaption><\/figure><\/div>","protected":false},"excerpt":{"rendered":"<p>\u524d\u7f00\u3001\u6587\u6863\u4fee\u6539\u8bb0\u5f55 20240311 \u521d\u59cb\u5316\u7f16\u8f91\u6b64\u6587\u7ae0\uff0c\u5b8c\u7a3f 20240311 \u5728\u5f55\u5236\u89c6\u9891\u540e\uff0c\u4fee\u6b63\u90e8\u5206\u5185\u5bb9\u53ca\u63cf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[131,132],"_links":{"self":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/3832"}],"collection":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3832"}],"version-history":[{"count":22,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/3832\/revisions"}],"predecessor-version":[{"id":3873,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/3832\/revisions\/3873"}],"wp:attachment":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}