{"id":177,"date":"2022-05-25T18:10:26","date_gmt":"2022-05-25T10:10:26","guid":{"rendered":"http:\/\/www.aqwu.net\/wp\/?p=177"},"modified":"2022-05-25T18:10:26","modified_gmt":"2022-05-25T10:10:26","slug":"offensive-windows-ipc-internals-1-named-pipes","status":"publish","type":"post","link":"https:\/\/www.aqwu.net\/wp\/?p=177","title":{"rendered":"Offensive Windows IPC Internals 1: Named Pipes"},"content":{"rendered":"\n<p>\u539f\u6587\u94fe\u63a5\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html\">https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\">\u4ecb\u7ecd<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#introduction\"><\/a><\/h2>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u6807\u5fd7\u7740\u4e00\u7cfb\u5217\u5173\u4e8e\u5404\u79cd\u57fa\u4e8eWindows\u7684<strong>I<\/strong>nter-P rocess-C ommunication\uff08IPC\uff09\u6280\u672f\u7ec4\u4ef6\u7684\u5185\u90e8\u548c<strong><\/strong>\u6709\u8da3\u90e8\u5206\u7684\u5e16\u5b50\u7684\u5f00\u59cb\u3002<strong><\/strong>\u6700\u521d\uff0c\u672c\u7cfb\u5217\u5c06\u6db5\u76d6\u4ee5\u4e0b\u4e3b\u9898\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u547d\u540d\u7ba1\u9053<\/li><li>\u65ad\u7eed\u5668<\/li><li>\u963f\u5c14\u5e15\u514b<\/li><li>\u65ad\u7eed\u5668<\/li><\/ul>\n\n\n\n<p>\u56e0\u6b64\uff0c\u4e00\u4e9bIPC\u6280\u672f\u7ec4\u4ef6\u88ab\u9057\u6f0f\u4e86\uff0c\u4f46\u6211\u53ef\u80fd\u4f1a\u5728\u67d0\u4e2a\u65f6\u5019\u9644\u52a0\u672c\u7cfb\u5217\uff0c\u4f8b\u5982\u5305\u62ec\u5176\u4e2d\u4e00\u4e9b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7a97\u53e3\u6d88\u606f<\/li><li>DDE\uff08\u57fa\u4e8e\u7a97\u53e3\u6d88\u606f\uff09<\/li><li>\u89c6\u7a97\u63d2\u5ea7<\/li><li>\u90ae\u4ef6\u63d2\u69fd<\/li><\/ul>\n\n\n\n<p>\u597d\u5427\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u5427\uff0c\u547d\u540d\u7ba1\u9053&#8230;<\/p>\n\n\n\n<p>\u867d\u7136\u540d\u79f0\u542c\u8d77\u6765\u6709\u70b9\u5947\u602a\uff0c\u4f46\u7ba1\u9053\u662f\u4e00\u79cd\u975e\u5e38\u57fa\u672c\u548c\u7b80\u5355\u7684\u6280\u672f\uff0c\u7528\u4e8e\u5728\u4e24\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\u548c\u5171\u4eab\u6570\u636e\uff0c\u5176\u4e2d\u672f\u8bed<strong>\u7ba1\u9053<\/strong>\u4ec5\u63cf\u8ff0\u4e86\u8fd9\u4e24\u4e2a\u8fdb\u7a0b\u4f7f\u7528\u7684\u5171\u4eab\u5185\u5b58\u7684\u4e00\u90e8\u5206\u3002<br>\u4e3a\u4e86\u4ece\u4e00\u5f00\u59cb\u5c31\u6b63\u786e\u5730\u63cf\u8ff0\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u6b63\u5728\u8c08\u8bba\u7684IPC\u6280\u672f\u88ab\u79f0\u4e3a\u201c\u7ba1\u9053\u201d\uff0c\u6709\u4e24\u79cd\u7c7b\u578b\u7684\u7ba1\u9053\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u547d\u540d\u7ba1\u9053<\/li><li>\u533f\u540d\u7ba1\u9053<\/li><\/ul>\n\n\n\n<p>\u5927\u591a\u6570\u65f6\u5019\uff0c\u5728\u8c08\u8bba\u7ba1\u9053\u65f6\uff0c\u60a8\u53ef\u80fd\u6307\u7684\u662f\u547d\u540d\u7ba1\u9053\uff0c\u56e0\u4e3a\u5b83\u4eec\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u529f\u80fd\u96c6\uff0c\u5176\u4e2d\u533f\u540d\u7ba1\u9053\u4e3b\u8981\u7528\u4e8e\u5b50\u7236\u901a\u4fe1\u3002\u8fd9\u4e5f\u610f\u5473\u7740\uff1a\u7ba1\u9053\u901a\u4fe1\u53ef\u4ee5\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u7684\u4e24\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\uff08\u4f7f\u7528\u547d\u540d\u7ba1\u9053\u548c\u533f\u540d\u7ba1\u9053\uff09\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8de8\u8ba1\u7b97\u673a\u8fb9\u754c\u8fdb\u884c\uff08\u53ea\u6709\u547d\u540d\u7ba1\u9053\u624d\u80fd\u8de8\u8ba1\u7b97\u673a\u8fb9\u754c\u8fdb\u884c\u901a\u4fe1\uff09\u3002\u7531\u4e8e\u547d\u540d\u7ba1\u9053\u6700\u76f8\u5173\u5e76\u652f\u6301\u5b8c\u6574\u7684\u529f\u80fd\u96c6\uff0c\u56e0\u6b64\u672c\u6587\u5c06\u4ec5\u91cd\u70b9\u4ecb\u7ecd\u547d\u540d\u7ba1\u9053\u3002<\/p>\n\n\n\n<p>\u8981\u4e3a\u547d\u540d\u7ba1\u9053\u6dfb\u52a0\u4e00\u4e9b\u5386\u53f2\u80cc\u666f\uff1a\u547d\u540d\u7ba1\u9053\u8d77\u6e90\u4e8e OS\/2 \u6b21\u3002\u786e\u5b9a\u547d\u540d\u7ba1\u9053\u88ab\u5f15\u5165Windows\u7684\u786e\u5207\u53d1\u5e03\u65e5\u671f\u662f\u5f88\u56f0\u96be\u7684\uff0c\u4f46\u81f3\u5c11\u53ef\u4ee5\u8bf4\u5b83\u4e00\u5b9a\u662f\u57281992\u5e74\u7684Windows 3.1\u4e2d\u652f\u6301\u7684 &#8211; \u6b63\u5982<a href=\"https:\/\/archive.org\/details\/win_dos_dev_jrnl_v4n4_apr_93\/page\/n23\/mode\/2up?q=Pipes\">Windows \/ DOS Developer&#8217;s Journal Volume 4<\/a>\u4e2d\u6240\u8ff0\uff0c\u56e0\u6b64\u53ef\u4ee5\u516c\u5e73\u5730\u5047\u8bbe\u547d\u540d\u7ba1\u9053\u5df2\u57281990\u5e74\u4ee3\u521d\u6dfb\u52a0\u5230Windows\u4e2d\u3002<\/p>\n\n\n\n<p>\u5728\u6211\u4eec\u6df1\u5165\u7814\u7a76\u547d\u540d\u7ba1\u9053\u5185\u90e8\u4e4b\u524d\uff0c\u8bf7\u6ce8\u610f\uff0c\u540e\u9762\u5c06\u6709\u4e00\u4e9b\u4ee3\u7801\u7247\u6bb5\u53d6\u81ea\u6211\u7684\u516c\u5171<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/tree\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\">\u547d\u540d\u7ba1\u9053\u793a\u4f8b\u5b9e\u73b0<\/a>\u3002\u6bcf\u5f53\u60a8\u89c9\u5f97\u9700\u8981\u56f4\u7ed5\u4ee3\u7801\u6bb5\u7684\u66f4\u591a\u4e0a\u4e0b\u6587\u65f6\uff0c\u8bf7\u524d\u5f80\u4ee3\u7801\u5b58\u50a8\u5e93\u5e76\u67e5\u770b\u66f4\u5927\u7684\u56fe\u666f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"named-pipe-messaging\">\u547d\u540d\u7ba1\u9053\u6d88\u606f\u4f20\u9012<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#named-pipe-messaging\"><\/a><\/h2>\n\n\n\n<p>\u597d\u5427\uff0c\u8ba9\u6211\u4eec\u5206\u89e3\u4e00\u4e0b\uff0c\u4ee5\u83b7\u5f97\u547d\u540d\u7ba1\u9053\u5185\u90e8\u3002\u5f53\u4f60\u4ece\u672a\u542c\u8bf4\u8fc7\u547d\u540d\u7ba1\u9053\u4e4b\u524d\uff0c\u5c06\u8fd9\u79cd\u901a\u4fe1\u6280\u672f\u60f3\u8c61\u6210\u4e00\u4e2a\u771f\u6b63\u7684\u94a2\u7ba1 &#8211; \u4f60\u6709\u4e00\u4e2a\u4e24\u7aef\u7684\u7a7a\u5fc3\u6761\uff0c\u5982\u679c\u4f60\u5728\u4e00\u7aef\u558a\u51fa\u4ec0\u4e48\u4e1c\u897f\uff0c\u542c\u4f17\u5c31\u4f1a\u5728\u53e6\u4e00\u7aef\u542c\u5230\u4f60\u7684\u8bdd\u3002\u8fd9\u5c31\u662f\u547d\u540d\u7ba1\u9053\u6240\u505a\u7684\u4e00\u5207\uff0c\u5b83\u5c06\u4fe1\u606f\u4ece\u4e00\u7aef\u4f20\u8f93\u5230\u53e6\u4e00\u7aef\u3002<br>\u5982\u679c\u4f60\u662fUnix\u7528\u6237\uff0c\u4f60\u80af\u5b9a\u4ee5\u524d\u4f7f\u7528\u8fc7\u7ba1\u9053\uff08\u56e0\u4e3a\u8fd9\u4e0d\u662f\u4e00\u79cd\u7eaf\u7cb9\u7684Windows\u6280\u672f\uff09\uff0c\u5982\u4e0b\u6240\u793a\uff1a.\u8f93\u51fa \u7684\u5185\u5bb9\u7684\u547d\u4ee4\uff0c\u4f46\u4e0d\u662f\u5c06\u8f93\u51fa\u663e\u793a\u5230 STDOUT\uff08\u53ef\u80fd\u662f\u60a8\u7684\u7ec8\u7aef\u7a97\u53e3\uff09\uff0c\u800c\u662f\u5c06\u8f93\u51fa\u91cd\u5b9a\u5411\uff08\u201c\u7ba1\u9053\u5316\u201d\uff09\u5230\u7b2c\u4e8c\u4e2a\u547d\u4ee4\u7684\u8f93\u5165\uff0c\u4ece\u800c\u8ba1\u7b97\u6587\u4ef6\u7684\u884c\u6570\u3002\u8fd9\u662f\u4e00\u4e2a\u533f\u540d\u7ba1\u9053\u7684\u4f8b\u5b50\u3002<code>cat file.txt | wc -l<\/code><code>file.txt<\/code><code>wc -l<\/code><\/p>\n\n\n\n<p>\u57fa\u4e8e Windows \u7684\u547d\u540d\u7ba1\u9053\u4e0e\u4e0a\u8ff0\u793a\u4f8b\u4e00\u6837\u6613\u4e8e\u7406\u89e3\u3002\u4e3a\u4e86\u4f7f\u6211\u4eec\u80fd\u591f\u4f7f\u7528\u7ba1\u9053\u7684\u5b8c\u6574\u529f\u80fd\u96c6\uff0c\u6211\u4eec\u5c06\u6446\u8131\u533f\u540d\u7ba1\u9053\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u76f8\u4e92\u901a\u4fe1\u7684\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u3002<br>\u547d\u540d\u7ba1\u9053\u53ea\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u66f4\u5177\u4f53\u5730\u8bf4\u662f<strong>\u4e00\u4e2aFILE_OBJECT<\/strong>\uff0c\u5b83\u7531\u4e00\u4e2a\u7279\u6b8a\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c<strong>\u547d\u540d\u7ba1\u9053\u6587\u4ef6\u7cfb\u7edf \uff08NPFS\uff09 \u7ba1\u7406<\/strong>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/NamedPipe_KernelObject.png\" alt=\"\u547d\u540d\u7ba1\u9053\u5185\u6838\u5bf9\u8c61\"\/><\/figure>\n\n\n\n<p>\u5f53\u60a8\u521b\u5efa\u547d\u540d\u7ba1\u9053\u65f6\uff0c\u5047\u8bbe\u6211\u4eec\u5c06\u5176\u79f0\u4e3a\u201cfpipe\u201d\uff0c\u5728\u5f15\u64ce\u76d6\u4e0b\uff0c\u60a8\u6b63\u5728\u4e00\u4e2a\u540d\u4e3a\u201cfpipe\u201d\uff08\u56e0\u6b64\uff1a\u547d\u540d\u7ba1\u9053\uff09\u7684\u7279\u6b8a\u8bbe\u5907\u9a71\u52a8\u5668\u4e0a\u521b\u5efa\u4e00\u4e2aFILE_OBJECT\uff0c\u8be5\u9a71\u52a8\u5668\u540d\u4e3a\u201c\u7ba1\u9053\u201d\u3002<br>\u8ba9\u6211\u4eec\u628a\u5b83\u5305\u88c5\u6210\u4e00\u4e2a\u5b9e\u7528\u7684\u4e1c\u897f\u3002\u547d\u540d\u7ba1\u9053\u662f\u901a\u8fc7\u8c03\u7528 WinAPI \u51fd\u6570&nbsp;<strong>CreateNamedPipe \u521b\u5efa\u7684<\/strong>\uff0c\u4f8b\u5982\u4f7f\u7528\u4ee5\u4e0b [<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeServer\/CPP-Basic-PipeServer.cpp#L88\">Source<\/a>]\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HANDLE serverPipe = CreateNamedPipe(\n    L\"\\\\\\\\.\\\\pipe\\\\fpipe\",\t\/\/ name of our pipe, must be in the form of \\\\.\\pipe\\&lt;NAME&gt;\n    PIPE_ACCESS_DUPLEX, \/\/ open mode, specifying a duplex pipe so server and client can send and receive data\n    PIPE_TYPE_MESSAGE,\t\/\/ MESSAGE mode to send\/receive messages in discrete units (instead of a byte stream)\n    1,\t\t\t\/\/ number of instanced for this pipe, 1 is enough for our use case\n    2048,\t\t\/\/ output buffer size\n    2048,\t\t\/\/ input buffer size\n    0,\t\t\t\/\/ default timeout value, equal to 50 milliseconds\n    NULL\t\t\/\/ use default security attributes\n);\n<\/code><\/pre>\n\n\n\n<p>\u76ee\u524d\uff0c\u6b64\u8c03\u7528\u4e2d\u6700\u6709\u8da3\u7684\u90e8\u5206\u662f .<br>C++\u9700\u8981\u8f6c\u4e49\u659c\u6760\uff0c\u56e0\u6b64\u4e0e\u8bed\u8a00\u65e0\u5173\uff0c\u8fd9\u7b49\u4e8e \u3002\u524d\u5bfc\u7684\u201c\\.\u201d\u662f\u6307\u8ba1\u7b97\u673a\u7684\u5168\u5c40\u6839\u76ee\u5f55\uff0c\u5176\u4e2d\u672f\u8bed\u201c\u7ba1\u9053\u201d\u662f\u6307\u5411 NamedPipe \u8bbe\u5907\u7684\u7b26\u53f7\u94fe\u63a5\u3002<code>\\\\\\\\.\\\\pipe\\\\fpipe<\/code><code>\\\\.\\pipe\\fpipe<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/NamedPipe_SymbolicLink.png\" alt=\"NamedPipe SymbolicLink\"\/><\/figure>\n\n\n\n<p>\u7531\u4e8e\u547d\u540d\u7ba1\u9053\u5bf9\u8c61\u662fFILE_OBJECT\uff0c\u56e0\u6b64\u8bbf\u95ee\u6211\u4eec\u521a\u521a\u521b\u5efa\u7684\u547d\u540d\u7ba1\u9053\u7b49\u4e8e\u8bbf\u95ee\u201c\u666e\u901a\u201d\u6587\u4ef6\u3002<br>\u56e0\u6b64\uff0c\u4ece\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u547d\u540d\u7ba1\u9053\u5c31\u50cf\u8c03\u7528 [<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeClient\/CPP-Basic-PipeClient.cpp#L58\">Source<\/a>] \u4e00\u6837\u7b80\u5355\uff1a<code>CreateFile<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HANDLE hPipeFile = CreateFile(L\"\\\\\\\\127.0.0.1\\\\pipe\\\\fpipe\", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u8fde\u63a5\u540e\uff0c\u53ea\u9700\u8c03\u7528 [<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeClient\/CPP-Basic-PipeClient.cpp#L65\">Source<\/a>] \u5373\u53ef\u4ece\u7ba1\u9053\u8bfb\u53d6\uff1a<code>ReadFile<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ReadFile(hPipeFile, pReadBuf, MESSAGE_SIZE, pdwBytesRead, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u5728\u4ece\u7ba1\u9053\u4e2d\u8bfb\u53d6\u4e00\u4e9b\u6570\u636e\u4e4b\u524d\uff0c\u60a8\u5e0c\u671b\u670d\u52a1\u5668\u5411\u5176\u5199\u5165\u4e00\u4e9b\u6570\u636e\uff08\u60a8\u53ef\u4ee5\u8bfb\u53d6\uff09\u3002\u8fd9\u662f\u901a\u8fc7\u6253\u7535\u8bdd &#8211; \u8c01\u4f1a\u731c\u5230\u5b83 &#8211; [<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeServer\/CPP-Basic-PipeServer.cpp#L110\">\u6765\u6e90<\/a>]\u6765\u5b8c\u6210\u7684\uff1a<code>WriteFile<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WriteFile(serverPipe, message, messageLenght, &amp;bytesWritten, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u4f46\u662f\uff0c\u5f53\u60a8\u201c\u5199\u5165\u201d\u7ba1\u9053\u65f6\uff0c\u5b9e\u9645\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f<br>\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7ba1\u9053\u540e\uff0c\u60a8\u521b\u5efa\u7684\u7ba1\u9053\u5c06\u4e0d\u518d\u5904\u4e8e\u4fa6\u542c\u72b6\u6001\uff0c\u5e76\u4e14\u53ef\u4ee5\u5411\u5176\u5199\u5165\u6570\u636e\u3002\u7528\u6237 land \u8c03\u7528\u88ab\u8c03\u5ea6\u5230\u5185\u6838 land\uff0c\u5728\u8c03\u7528\u4f4d\u7f6e\uff0c\u5b83\u786e\u5b9a\u6709\u5173\u5199\u5165\u64cd\u4f5c\u7684\u6240\u6709\u4f4d\u548c\u7247\u6bb5\uff0c\u4f8b\u5982\uff0c\u54ea\u4e2a\u8bbe\u5907\u5bf9\u8c61\u4e0e\u7ed9\u5b9a\u6587\u4ef6\u5173\u8054\uff0c\u5199\u5165\u64cd\u4f5c\u662f\u5426\u5e94\u540c\u6b65\uff08\u8bf7\u53c2\u9605<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#overlapping-pipe-io-blocking-mode--in-out-buffers\">\u91cd\u53e0\u7ba1\u9053 I\/O\u3001\u963b\u585e\u6a21\u5f0f\u548c\u4f20\u5165\/\u8f93\u51fa\u7f13\u51b2\u533a<\/a>\u4e00\u8282\uff09\uff0c\u8bbe\u7f6e I\/O \u8bf7\u6c42\u6570\u636e\u5305 \uff08IRP\uff09 \u5e76\u6700\u7ec8\u5b9e\u73b0&nbsp;<em>NtWriteFile<\/em>&nbsp;\u6ce8\u610f\u60a8\u7684\u6570\u636e\u5df2\u5199\u5165\u6587\u4ef6\u3002\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u6307\u5b9a\u7684\u6570\u636e\u4e0d\u4f1a\u5199\u5165\u78c1\u76d8\u4e0a\u7684\u5b9e\u9645\u6587\u4ef6\uff0c\u800c\u662f\u5199\u5165\u7531\u6587\u4ef6\u53e5\u67c4\u5f15\u7528\u7684\u5171\u4eab\u5185\u5b58\u90e8\u5206\u3002<code>WriteFile<\/code><code>NtWriteFile<\/code><code>CreateNamedPipe<\/code><\/p>\n\n\n\n<p>\u6700\u540e &#8211; \u5982\u7b80\u4ecb\u4e2d\u6240\u8ff0 &#8211; \u547d\u540d\u7ba1\u9053\u4e5f\u53ef\u4ee5\u8de8\u7cfb\u7edf\u8fb9\u754c\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u4f7f\u7528\u3002<br>\u8c03\u7528\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u4e0d\u9700\u8981\u5176\u4ed6\u5b9e\u73b0\uff0c\u53ea\u9700\u786e\u4fdd\u5bf9&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>&nbsp;\u7684\u8c03\u7528\u6307\u5b9a\u4e86 IP \u6216\u4e3b\u673a\u540d\uff08\u5982\u4e0a\u9762\u7684\u793a\u4f8b\u6240\u793a\uff09\u3002<br>\u8ba9\u6211\u4eec\u731c\u731c\u4e00\u731c\uff1a\u8c03\u7528\u8fdc\u7a0b\u7ba1\u9053\u670d\u52a1\u5668\u65f6\u5c06\u4f7f\u7528\u4ec0\u4e48\u7f51\u7edc\u534f\u8bae\uff1f&#8230;.\u9f13\u6eda&#8230;\u7edd\u5bf9\u4e0d\u8db3\u4e3a\u5947\u7684\u662f\uff0c\u5b83\u662f<strong>SMB<\/strong>\u3002<br>\u4e0e\u8fdc\u7a0b\u670d\u52a1\u5668\u5efa\u7acb SMB \u8fde\u63a5\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fdc\u7a0b\u670d\u52a1\u5668\u7531\u534f\u5546\u8bf7\u6c42\u521d\u59cb\u5316\uff0c\u4ee5\u786e\u5b9a\u7f51\u7edc\u8eab\u4efd\u9a8c\u8bc1\u534f\u8bae\u3002\u4e0e\u5176\u4ed6IPC\u673a\u5236\uff08\u4f8b\u5982RPC\uff09\u4e0d\u540c\uff0c\u60a8\u4f5c\u4e3a\u670d\u52a1\u5668\u5f00\u53d1\u4eba\u5458\u65e0\u6cd5\u63a7\u5236\u7f51\u7edc\u8eab\u4efd\u9a8c\u8bc1\u534f\u8bae\uff0c\u56e0\u4e3a\u8fd9\u59cb\u7ec8\u662f\u901a\u8fc7SMB\u534f\u5546\u7684\u3002\u7531\u4e8e Kerberos \u662f\u81ea Windows 2000 \u4ee5\u6765\u7684\u9996\u9009\u8eab\u4efd\u9a8c\u8bc1\u65b9\u6848\uff0c\u56e0\u6b64\u5982\u679c\u53ef\u80fd\u7684\u8bdd\uff0c\u5c06\u534f\u5546 Kerberos\u3002<br><strong>\u6ce8\uff1a<\/strong>&nbsp;\u4ece\u5ba2\u6237\u7aef\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9\u8fde\u63a5\u5230\u4e3b\u673a\u540d\u6216 IP \u6765\u6709\u6548\u5730\u9009\u62e9\u8eab\u4efd\u9a8c\u8bc1\u534f\u8bae\u3002\u7531\u4e8e Kerberos \u7684\u8bbe\u8ba1\uff0c\u5b83\u4e0d\u80fd\u5f88\u597d\u5730\u5904\u7406 IP\uff0c\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u9009\u62e9\u8fde\u63a5\u5230 IP \u5730\u5740\uff0c\u534f\u5546\u7684\u7ed3\u679c\u5c06\u59cb\u7ec8\u4e3a NTLM\uff08v2\uff09\u3002\u7136\u800c\uff0c\u5f53\u60a8\u8fde\u63a5\u5230\u4e3b\u673a\u540d\u65f6\uff0c\u60a8\u5f88\u53ef\u80fd\u6700\u7ec8\u603b\u662f\u4f7f\u7528Kerberos\u3002<\/p>\n\n\n\n<p>\u786e\u5b9a\u8eab\u4efd\u9a8c\u8bc1\u540e\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u8981\u6267\u884c\u7684\u64cd\u4f5c\u518d\u6b21\u53ea\u662f\u7ecf\u5178\u6587\u4ef6\u64cd\u4f5c\uff0c\u7531 SMB \u5904\u7406\uff0c\u5c31\u50cf\u4efb\u4f55\u5176\u4ed6\u6587\u4ef6\u64cd\u4f5c\u4e00\u6837\uff0c\u4f8b\u5982\uff0c\u901a\u8fc7\u542f\u52a8\u201c\u521b\u5efa\u8bf7\u6c42\u6587\u4ef6\u201d\u8bf7\u6c42\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/NamedPipe_RemoteRead.png\" alt=\"NamedPipe RemoteRead\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"data-transfer-modes\">\u6570\u636e\u4f20\u8f93\u6a21\u5f0f<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#data-transfer-modes\"><\/a><\/h3>\n\n\n\n<p>\u547d\u540d\u7ba1\u9053\u63d0\u4f9b\u4e24\u79cd\u57fa\u672c\u901a\u4fe1\u6a21\u5f0f\uff1a\u5b57\u8282\u6a21\u5f0f\u548c\u6d88\u606f\u6a21\u5f0f\u3002<\/p>\n\n\n\n<p>\u5728<strong>\u5b57\u8282\u6a21\u5f0f\u4e0b<\/strong>\uff0c\u6d88\u606f\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u4f5c\u4e3a\u8fde\u7eed\u7684\u5b57\u8282\u6d41\u4f20\u8f93\u3002\u8fd9\u610f\u5473\u7740\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u5668\u5e94\u7528\u7a0b\u5e8f\u4e0d\u786e\u5207\u77e5\u9053\u5728\u4efb\u4f55\u7ed9\u5b9a\u65f6\u523b\u4ece\u7ba1\u9053\u8bfb\u53d6\u6216\u5199\u5165\u591a\u5c11\u5b57\u8282\u3002\u56e0\u6b64\uff0c\u4e00\u7aef\u7684\u5199\u5165\u5e76\u4e0d\u603b\u662f\u5bfc\u81f4\u53e6\u4e00\u4fa7\u7684\u76f8\u540c\u5927\u5c0f\u7684\u8bfb\u53d6\u3002\u8fd9\u5141\u8bb8\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u5728\u4e0d\u5173\u5fc3\u6570\u636e\u5927\u5c0f\u7684\u60c5\u51b5\u4e0b\u4f20\u8f93\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u5728<strong>\u6d88\u606f\u6a21\u5f0f\u4e0b<\/strong>\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4ee5\u79bb\u6563\u5355\u5143\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u3002\u6bcf\u6b21\u5728\u7ba1\u9053\u4e0a\u53d1\u9001\u6d88\u606f\u65f6\uff0c\u90fd\u5fc5\u987b\u5c06\u5176\u4f5c\u4e3a\u5b8c\u6574\u6d88\u606f\u8bfb\u53d6\u3002\u5982\u679c\u5728\u6d88\u606f\u6a21\u5f0f\u4e0b\u4ece\u670d\u52a1\u5668\u7ba1\u9053\u8bfb\u53d6\uff0c\u4f46\u8bfb\u53d6\u7f13\u51b2\u533a\u592a\u5c0f\u800c\u65e0\u6cd5\u5bb9\u7eb3\u6240\u6709\u6570\u636e\uff0c\u5219\u7f13\u51b2\u533a\u4e2d\u9002\u5408\u7684\u6570\u636e\u90e8\u5206\u5c06\u88ab\u590d\u5236\u5230\u8be5\u7f13\u51b2\u533a\uff0c\u5176\u4f59\u6570\u636e\u4fdd\u7559\u5728\u670d\u52a1\u5668\u7684\u5171\u4eab\u5185\u5b58\u90e8\u5206\u4e2d\uff0c\u60a8\u5c06\u6536\u5230\u9519\u8bef 234\uff080xEA\uff0c ERROR_MORE_DATA\uff09 \u8868\u793a\u6709\u66f4\u591a\u6570\u636e\u8981\u83b7\u53d6\u3002<\/p>\n\n\n\n<p>\u6d88\u606f\u6a21\u5f0f\u7684\u76f4\u89c2\u6bd4\u8f83\u5982\u4e0b\u6240\u793a\uff0c\u53d6\u81ea\u201cMicrosoft Windows\u7684\u7f51\u7edc\u7f16\u7a0b\u201d\uff081999\uff09\uff1a<img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/NamedPipe_MessageModes.png\" alt=\"\u547d\u540d\u7ba1\u9053\u6d88\u606f\u6a21\u5f0f\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"overlapping-pipe-io-blocking-mode--in-out-buffers\">\u91cd\u53e0\u7ba1\u9053 I\/O\u3001\u963b\u585e\u6a21\u5f0f\u548c\u8fdb\u51fa\u7f13\u51b2\u5668<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#overlapping-pipe-io-blocking-mode--in-out-buffers\"><\/a><\/h3>\n\n\n\n<p>\u4ece\u5b89\u5168\u89d2\u5ea6\u6765\u770b\uff0c\u91cd\u53e0\u7684 I\/O\u3001\u963b\u585e\u6a21\u5f0f\u548c\u5165\/\u51fa\u7f13\u51b2\u533a\u5e76\u4e0d\u662f\u7279\u522b\u91cd\u8981\uff0c\u4f46\u8981\u610f\u8bc6\u5230\u8fd9\u4e9b\u7f13\u51b2\u533a\u7684\u5b58\u5728\u4ee5\u53ca\u5b83\u4eec\u7684\u542b\u4e49\uff0c\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u3001\u901a\u4fe1\u3001\u6784\u5efa\u548c\u8c03\u8bd5\u547d\u540d\u7ba1\u9053\u3002\u56e0\u6b64\uff0c\u6211\u5c06\u5728\u8fd9\u91cc\u7b80\u8981\u6dfb\u52a0\u8fd9\u4e9b\u6982\u5ff5\u3002<\/p>\n\n\n\n<p><strong>\u91cd\u53e0 I\/O<\/strong><br>\u591a\u4e2a\u4e0e\u547d\u540d\u7ba1\u9053\u76f8\u5173\u7684\u51fd\u6570\uff08\u5982&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile<\/a>\u3001<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-writefile\">WriteFile<\/a>\u3001<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/namedpipeapi\/nf-namedpipeapi-transactnamedpipe\">TransactNamedPipe<\/a>&nbsp;\u548c&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/namedpipeapi\/nf-namedpipeapi-connectnamedpipe\">ConnectNamedPipe<\/a>\uff09\u53ef\u4ee5<strong>\u540c\u6b65<\/strong>\u6267\u884c\u7ba1\u9053\u64cd\u4f5c\uff0c\u8fd9\u610f\u5473\u7740\u6267\u884c\u7ebf\u7a0b\u5728\u7ee7\u7eed\u4e4b\u524d\u7b49\u5f85\u64cd\u4f5c\u5b8c\u6210\uff0c\u6216\u8005<strong>\u5f02\u6b65<\/strong>\u6267\u884c\uff0c\u8fd9\u610f\u5473\u7740\u6267\u884c\u7ebf\u7a0b\u5c06\u89e6\u53d1\u64cd\u4f5c\u5e76\u7ee7\u7eed\u800c\u4e0d\u7b49\u5f85\u5176\u5b8c\u6210\u3002<br>\u8bf7\u52a1\u5fc5\u6ce8\u610f\uff0c\u901a\u8fc7\u5728&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u8c03\u7528\u4e2d\u8bbe\u7f6eFILE_FLAG_OVERLAPPED\uff0c\u53ea\u80fd\u5728\u5141\u8bb8\u91cd\u53e0 I\/O \u7684\u7ba1\u9053\uff08\u670d\u52a1\u5668\uff09\u4e0a\u8fdb\u884c\u5f02\u6b65\u7ba1\u9053\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/minwinbase\/ns-minwinbase-overlapped\">\u91cd\u53e0<\/a>\u7ed3\u6784\u4f5c\u4e3a\u4e0a\u8ff0\u6bcf\u4e2a\u201c\u6807\u51c6\u201d\u7ba1\u9053\u64cd\u4f5c\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u6765\u8fdb\u884c\u5f02\u6b65\u8c03\u7528\u3002\u5982&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile<\/a>\uff0c\u6216\u901a\u8fc7\u5c06<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/minwinbase\/nc-minwinbase-lpoverlapped_completion_routine\">COMPLETION_ROUTINE<\/a>\u6307\u5b9a\u4e3a\u201c\u6269\u5c55\u201d\u7ba1\u9053\u64cd\u4f5c\uff08\u5982&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfileex\">ReadFileEx\uff09<\/a>\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u3002\u524d\u8005\u662f\u91cd\u53e0\u7ed3\u6784\uff0c\u65b9\u6cd5\u662f\u57fa\u4e8e\u4e8b\u4ef6\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5fc5\u987b\u521b\u5efa\u4e00\u4e2a\u4e8b\u4ef6\u5bf9\u8c61\uff0c\u5e76\u5728\u64cd\u4f5c\u5b8c\u6210\u540e\u53d1\u51fa\u4fe1\u53f7\uff0c\u800cCOMPLETION_ROUTINE\u65b9\u6cd5\u662f\u57fa\u4e8e\u56de\u8c03\u7684\uff0c\u8fd9\u610f\u5473\u7740\u56de\u8c03\u4f8b\u7a0b\u88ab\u4f20\u9012\u7ed9\u6267\u884c\u7ebf\u7a0b\uff0c\u8be5\u7ebf\u7a0b\u5728\u53d1\u51fa\u4fe1\u53f7\u540e\u6392\u961f\u5e76\u6267\u884c\u3002\u6709\u5173\u6b64\u5185\u5bb9\u7684\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605<a href=\"https:\/\/docs.microsoft.com\/en-gb\/windows\/win32\/ipc\/synchronous-and-overlapped-input-and-output\">\u6b64\u5904<\/a>\uff0c<a href=\"https:\/\/docs.microsoft.com\/en-gb\/windows\/win32\/ipc\/named-pipe-server-using-overlapped-i-o\">\u5176\u4e2d\u5305\u542b Microsoft \u5728\u6b64\u5904<\/a>\u7684\u793a\u4f8b\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p><strong>\u963b\u585e\u6a21\u5f0f<\/strong><\/p>\n\n\n\n<p>\u5728\u4f7f\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u8bbe\u7f6e\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u65f6\uff0c\u901a\u8fc7\u5728&nbsp;<em>dwPipeMode<\/em>&nbsp;\u53c2\u6570\u4e2d\u4f7f\u7528\uff08\u6216\u7701\u7565\uff09\u6807\u5fd7\u6765\u5b9a\u4e49\u963b\u585e\u6a21\u5f0f\u884c\u4e3a\u3002\u4ee5\u4e0b\u4e24<em>\u4e2a dwPipeMode<\/em>&nbsp;\u6807\u5fd7\u5b9a\u4e49\u4e86\u670d\u52a1\u5668\u7684\u963b\u585e\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>PIPE_WAIT\uff08\u9ed8\u8ba4\uff09\uff1a\u5df2\u542f\u7528\u963b\u6b62\u6a21\u5f0f\u3002\u4f7f\u7528\u547d\u540d\u7ba1\u9053\u64cd\u4f5c\uff08\u5982\u5728\u542f\u7528\u4e86\u963b\u585e\u6a21\u5f0f\u7684\u7ba1\u9053\u4e0a\u7684&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile\uff09<\/a>\u65f6\uff0c\u8be5\u64cd\u4f5c\u5c06\u7b49\u5f85\u5b8c\u6210\u3002\u8fd9\u610f\u5473\u7740\u5728\u8fd9\u6837\u7684\u7ba1\u9053\u4e0a\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u5c06\u7b49\u5230\u6709\u6570\u636e\u8981\u8bfb\u53d6\uff0c\u5199\u5165\u64cd\u4f5c\u5c06\u7b49\u5230\u6240\u6709\u6570\u636e\u90fd\u5199\u5165\u3002\u8fd9\u5f53\u7136\u4f1a\u5bfc\u81f4\u64cd\u4f5c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u65e0\u9650\u671f\u7b49\u5f85\u3002<\/li><li>PIPE_NOWAIT\uff1a\u7981\u7528\u963b\u6b62\u6a21\u5f0f\u3002\u547d\u540d\u7ba1\u9053\u64cd\u4f5c\uff08\u5982&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile\uff09<\/a>\u4f1a\u7acb\u5373\u8fd4\u56de\u3002\u60a8\u9700\u8981\u4f8b\u7a0b\uff08\u5982\u91cd\u53e0 I\/O\uff09\u6765\u786e\u4fdd\u8bfb\u53d6\u6216\u5199\u5165\u6240\u6709\u6570\u636e\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u8f93\u5165\/\u8f93\u51fa\u7f13\u51b2\u5668<\/strong><\/p>\n\n\n\n<p>\u901a\u8fc7\u8f93\u5165\/\u8f93\u51fa\u7f13\u51b2\u533a\uff0c\u6211\u6307\u7684\u662f\u60a8\u5728\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u65f6\u521b\u5efa\u7684\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u7684\u8f93\u5165\u548c\u8f93\u51fa\u7f13\u51b2\u533a\uff0c\u66f4\u51c6\u786e\u5730\u8bf4\u662f\u6307&nbsp;<em>nInBufferSize<\/em>&nbsp;\u548c&nbsp;<em>nOutBufferSize<\/em>&nbsp;\u53c2\u6570\u4e2d\u8fd9\u4e9b\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u3002<br>\u6267\u884c\u8bfb\u53d6\u548c\u5199\u5165\u64cd\u4f5c\u65f6\uff0c\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u4f7f\u7528\u975e\u5206\u9875\u5185\u5b58\uff08\u5373\u7269\u7406\u5185\u5b58\uff09\u4e34\u65f6\u5b58\u50a8\u8981\u8bfb\u53d6\u6216\u5199\u5165\u7684\u6570\u636e\u3002\u5141\u8bb8\u5f71\u54cd\u6240\u521b\u5efa\u670d\u52a1\u5668\u7684\u8fd9\u4e9b\u503c\u7684\u653b\u51fb\u8005\u53ef\u4ee5\u6ee5\u7528\u8fd9\u4e9b\u503c\uff0c\u901a\u8fc7\u9009\u62e9\u5927\u578b\u7f13\u51b2\u533a\u6765\u53ef\u80fd\u5bfc\u81f4\u7cfb\u7edf\u5d29\u6e83\uff0c\u6216\u8005\u901a\u8fc7\u9009\u62e9\u5c0f\u7f13\u51b2\u533a\u6765\u5ef6\u8fdf\u7ba1\u9053\u64cd\u4f5c\uff08\u4f8b\u5982 0\uff09\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u5927\u7f13\u51b2\u533a<\/strong>\uff1a\u7531\u4e8e\u8f93\u5165\/\u8f93\u51fa\u7f13\u51b2\u533a\u672a\u5206\u9875\uff0c\u5982\u679c\u9009\u62e9\u592a\u5927\uff0c\u670d\u52a1\u5668\u5c06\u8017\u5c3d\u5185\u5b58\u3002\u4f46\u662f\uff0c<em>nInBufferSize<\/em>&nbsp;\u548c&nbsp;<em>nOutBufferSize<\/em>&nbsp;\u53c2\u6570\u4e0d\u4f1a\u88ab\u7cfb\u7edf\u201c\u76f2\u76ee\u201d\u63a5\u53d7\u3002\u4e0a\u9650\u7531\u7cfb\u7edf\u4f9d\u8d56\u5e38\u6570\u5b9a\u4e49;\u6211\u627e\u4e0d\u5230\u6709\u5173\u6b64\u5e38\u91cf\u7684\u8d85\u7ea7\u51c6\u786e\u4fe1\u606f\uff08\u5e76\u4e14\u6ca1\u6709\u6316\u6398\u6807\u9898\uff09;<a href=\"https:\/\/blog.stephencleary.com\/2010\/03\/io-limitation-in-windows.html\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u8868\u660e\uff0c\u5bf9\u4e8ex64 Windows7\u7cfb\u7edf\u6765\u8bf4\uff0c\u5b83\u5927\u7ea6\u662f4GB\u3002<br><\/li><li><strong>\u5c0f\u7f13\u51b2\u533a<\/strong>\uff1a\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a 0 \u5bf9\u4e8e&nbsp;<em>nInBufferSize<\/em>&nbsp;\u548c&nbsp;<em>nOutBufferSize<\/em>&nbsp;\u7edd\u5bf9\u6709\u6548\u3002\u5982\u679c\u7cfb\u7edf\u4e25\u683c\u6267\u884c\u5b83\u88ab\u544a\u77e5\u7684\u5185\u5bb9\uff0c\u60a8\u5c06\u65e0\u6cd5\u5c06\u4efb\u4f55\u5185\u5bb9\u5199\u5165\u7ba1\u9053\uff0c\u5219\u5bfc\u81f4\u5927\u5c0f\u4e3a0\u7684\u7f13\u51b2\u533a\u662f&#8230;\u597d\u5427\uff0c\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u7f13\u51b2\u533a\u3002\u5f88\u9ad8\u5174\u7cfb\u7edf\u8db3\u591f\u667a\u80fd\uff0c\u53ef\u4ee5\u7406\u89e3\u60a8\u8981\u6c42\u6700\u5c0f\u7f13\u51b2\u533a\uff0c\u56e0\u6b64\u4f1a\u5c06\u5b9e\u9645\u5206\u914d\u7684\u7f13\u51b2\u533a\u6269\u5c55\u5230\u5b83\u63a5\u6536\u7684\u5927\u5c0f\uff0c\u4f46\u8fd9\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u5f71\u54cd\u3002\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a 0 \u8868\u793a\u5728\u5c06\u65b0\u6570\u636e\u5199\u5165\u7f13\u51b2\u533a\u4e4b\u524d\uff0c\u7ba1\u9053\u53e6\u4e00\u7aef\u7684\u8fdb\u7a0b\u5fc5\u987b\u8bfb\u53d6\u6bcf\u4e2a\u5b57\u8282\uff08\u4ece\u800c\u6e05\u9664\u7f13\u51b2\u533a\uff09\u3002\u5bf9\u4e8e&nbsp;<em>nInBufferSize<\/em>&nbsp;\u548c&nbsp;<em>nOutBufferSize<\/em>&nbsp;\u6765\u8bf4\uff0c\u60c5\u51b5\u90fd\u662f\u5982\u6b64\u3002\u56e0\u6b64\uff0c\u5927\u5c0f\u4e3a 0 \u7684\u7f13\u51b2\u533a\u53ef\u80fd\u4f1a\u5bfc\u81f4\u670d\u52a1\u5668\u5ef6\u8fdf\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"named-pipe-security\">\u547d\u540d\u7ba1\u9053\u5b89\u5168\u6027<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#named-pipe-security\"><\/a><\/h2>\n\n\n\n<p>\u518d\u4e00\u6b21\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u5173\u4e8e\u5982\u4f55\u8bbe\u7f6e\u548c\u63a7\u5236\u547d\u540d\u7ba1\u9053\u5b89\u5168\u6027\u7684\u672c\u7ae0\u53d8\u5f97\u76f8\u5f53\u77ed\uff0c\u4f46\u91cd\u8981\u7684\u662f\u8981\u77e5\u9053\u8fd9\u662f\u5982\u4f55\u5b8c\u6210\u7684\u3002<\/p>\n\n\n\n<p>\u5f53\u60a8\u60f3\u8981\u4fdd\u62a4\u547d\u540d\u7ba1\u9053\u8bbe\u7f6e\u65f6\uff0c\u552f\u4e00\u53ef\u4ee5\u8f6c\u52a8\u7684\u9f7f\u8f6e\u662f\u5c06\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668<strong>\u7684\u5b89\u5168\u63cf\u8ff0\u7b26<\/strong>\u8bbe\u7f6e\u4e3a&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u8c03\u7528\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570 \uff08<em>lpSecurityAttributes<\/em>\uff09\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u60f3\u4e86\u89e3\u5b89\u5168\u63cf\u8ff0\u7b26\u662f\u4ec0\u4e48\uff0c\u5982\u4f55\u4f7f\u7528\u5b83\u4ee5\u53ca\u5b83\u7684\u5916\u89c2\uff0c\u60a8\u53ef\u4ee5\u5728\u6211\u7684\u5e16\u5b50\u4e2d\u627e\u5230\u7b54\u6848&nbsp;<a href=\"https:\/\/csandker.io\/2018\/06\/14\/AWindowsAuthorizationGuide.html#the-security-descriptor-dacl--sacl\">Windows\u6388\u6743\u6307\u5357<\/a>\u3002<\/p>\n\n\n\n<p>\u8bbe\u7f6e\u6b64\u5b89\u5168\u63cf\u8ff0\u7b26\u662f\u53ef\u9009\u7684;\u53ef\u4ee5\u901a\u8fc7\u4e3a&nbsp;<em>lpSecurityAttributes<\/em>&nbsp;\u53c2\u6570\u6307\u5b9a&nbsp;<em>NULL<\/em>&nbsp;\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u5b89\u5168\u63cf\u8ff0\u7b26\u3002<br>Windows \u6587\u6863\u5b9a\u4e49\u4e86\u9ed8\u8ba4\u5b89\u5168\u63cf\u8ff0\u7b26\u5bf9\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u7684\u4f5c\u7528\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u547d\u540d\u7ba1\u9053\u7684\u9ed8\u8ba4\u5b89\u5168\u63cf\u8ff0\u7b26\u4e2d\u7684 ACL \u5411 LocalSystem \u5e10\u6237\u3001\u7ba1\u7406\u5458\u548c\u521b\u5efa\u8005\u6240\u6709\u8005\u6388\u4e88\u5b8c\u5168\u63a7\u5236\u6743\u9650\u3002\u5b83\u4eec\u8fd8\u5411 Everyone \u7ec4\u7684\u6210\u5458\u548c\u533f\u540d\u5e10\u6237\u6388\u4e88\u8bfb\u53d6\u8bbf\u95ee\u6743\u9650\u3002<br>\u6765\u6e90\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea#parameters\">CreateNamedPipe &gt; Paremter &gt; lpSecurityAttributes<\/a><\/p><\/blockquote>\n\n\n\n<p>\u56e0\u6b64\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u672a\u6307\u5b9a\u5b89\u5168\u63cf\u8ff0\u7b26\uff0c\u5219\u65e0\u8bba\u8bfb\u53d6\u5ba2\u6237\u7aef\u662f\u5426\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\uff0c<em>\u201c\u6bcf\u4e2a\u4eba\u90fd<\/em>\u53ef\u4ee5\u4ece\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u8bfb\u53d6\u201d\u3002<br>\u5982\u679c\u5728\u672a\u8bbe\u7f6e\u5b89\u5168\u63cf\u8ff0\u7b26\u7684\u60c5\u51b5\u4e0b\u8fde\u63a5\u5230\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\uff0c\u4f46\u4ecd\u6536\u5230\u201c\u62d2\u7edd\u8bbf\u95ee\u9519\u8bef\u201d\uff08\u9519\u8bef\u4ee3\u7801\uff1a5\uff09\uff0c\u8bf7\u786e\u4fdd\u4ec5\u6307\u5b9a\u4e86\u8bfb\u53d6\u8bbf\u95ee\u6743\u9650\uff08\u8bf7\u6ce8\u610f\uff0c\u4e0a\u9762\u7684\u793a\u4f8b\u6307\u5b9a\u4e86\u201c\u8bfb\u53d6\u201d\u548c\u201c\u5199\u5165\u201d\u8bbf\u95ee\u6743\u9650\uff09\u3002<code>GENERIC_READ | GENERIC_WRITE<\/code><\/p>\n\n\n\n<p>\u5bf9\u4e8e\u8fdc\u7a0b\u8fde\u63a5\uff0c\u8bf7\u518d\u6b21\u6ce8\u610f\uff08\u5982<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#named-pipe-messaging\">\u547d\u540d\u7ba1\u9053\u6d88\u606f\u4f20\u9012<\/a>\u4e00\u7ae0\u672b\u5c3e\u6240\u8ff0\uff09\uff0c<strong>\u7f51\u7edc\u8eab\u4efd\u9a8c\u8bc1\u534f\u8bae\u662f\u901a\u8fc7 SMB \u534f\u8bae\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u534f\u5546\u7684<\/strong>\u3002\u65e0\u6cd5\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u5f3a\u5236\u4f7f\u7528\u66f4\u5f3a\u7684 Kerberos \u534f\u8bae\uff08\u53ea\u80fd\u5728\u670d\u52a1\u5668\u4e3b\u673a\u4e0a\u7981\u7528 NTLM\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"impersonation\">\u6a21\u4eff<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#impersonation\"><\/a><\/h3>\n\n\n\n<p>\u6a21\u62df\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6982\u5ff5\uff0c\u6211\u4eec\u5c06\u5728\u4e0b\u4e00\u8282\u4e2d\u8ba8\u8bba\u5177\u6709\u547d\u540d\u7ba1\u9053\u7684\u653b\u51fb\u5411\u91cf\u3002<br>\u5982\u679c\u60a8\u719f\u6089\u6a21\u62df\uff0c\u8bf7\u968f\u65f6\u8df3\u8fc7\u672c\u8282;<strong>\u6a21\u62df\u5e76\u975e\u7279\u5b9a\u4e8e\u547d\u540d\u7ba1\u9053<\/strong>\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u8fd8\u6ca1\u6709\u5728 Windows \u73af\u5883\u4e2d\u9047\u5230\u6a21\u62df\uff0c\u8ba9\u6211\u4e3a\u60a8\u5feb\u901f\u603b\u7ed3\u4e00\u4e0b\u8fd9\u4e2a\u6982\u5ff5\uff1a<\/p>\n\n\n\n<p><strong>\u6a21\u62df<\/strong>\u662f\u7ebf\u7a0b\u5728\u4e0e\u62e5\u6709\u7ebf\u7a0b\u7684\u8fdb\u7a0b\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u4e0d\u540c\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u4e2d\u6267\u884c\u7684\u80fd\u529b\u3002\u6a21\u62df\u901a\u5e38\u9002\u7528\u4e8e\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u4f53\u7cfb\u7ed3\u6784\uff0c\u5176\u4e2d\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668\uff0c\u670d\u52a1\u5668\u53ef\u4ee5\uff08\u5982\u679c\u9700\u8981\uff09\u6a21\u62df\u5ba2\u6237\u7aef\u3002\u6a21\u62df\u4f7f\u670d\u52a1\u5668\uff08\u7ebf\u7a0b\uff09\u80fd\u591f\u4ee3\u8868\u5ba2\u6237\u7aef\u6267\u884c\u64cd\u4f5c\uff0c\u4f46\u5728\u5ba2\u6237\u7aef\u8bbf\u95ee\u6743\u9650\u7684\u9650\u5236\u5185\u3002<br>\u4e00\u4e2a\u5178\u578b\u7684\u573a\u666f\u662f\u670d\u52a1\u5668\u5e0c\u671b\u8bbf\u95ee\u67d0\u4e9b\u8bb0\u5f55\uff08\u4f8b\u5982\u5728\u6570\u636e\u5e93\u4e2d\uff09\uff0c\u4f46\u53ea\u5141\u8bb8\u5ba2\u6237\u7aef\u8bbf\u95ee\u81ea\u5df1\u7684\u8bb0\u5f55\u3002\u670d\u52a1\u5668\u73b0\u5728\u53ef\u4ee5\u56de\u590d\u5ba2\u6237\u7aef\uff0c\u8981\u6c42\u83b7\u53d6\u8bb0\u5f55\u672c\u8eab\u5e76\u5c06\u5176\u53d1\u9001\u5230\u670d\u52a1\u5668\uff0c\u6216\u8005\u670d\u52a1\u5668\u53ef\u4ee5\u4f7f\u7528\u6388\u6743\u534f\u8bae\u6765\u8bc1\u660e\u5ba2\u6237\u7aef\u5141\u8bb8\u670d\u52a1\u5668\u8bbf\u95ee\u8bb0\u5f55\uff0c\u6216\u8005 &#8211; \u8fd9\u5c31\u662f\u6a21\u62df &#8211;&nbsp;<strong>\u5ba2\u6237\u7aef\u5411\u670d\u52a1\u5668\u53d1\u9001\u4e00\u4e9b\u6807\u8bc6\u4fe1\u606f\u5e76\u5141\u8bb8\u670d\u52a1\u5668\u5207\u6362\u5230\u5ba2\u6237\u7aef\u7684\u89d2\u8272<\/strong>.\u6709\u70b9\u50cf\u5ba2\u6237\u7aef\u5c06\u5176\u9a7e\u9a76\u6267\u7167\u6388\u4e88\u670d\u52a1\u5668\uff0c\u5e76\u5141\u8bb8\u4f7f\u7528\u8be5\u8bb8\u53ef\u8bc1\u6765\u8bc6\u522b\u5176\u4ed6\u65b9\uff0c\u4f8b\u5982\u7f51\u5173\u5b88\u536b\uff08\u6216\u66f4\u6280\u672f\u6027\u7684\u6570\u636e\u5e93\u670d\u52a1\u5668\uff09\u3002<\/p>\n\n\n\n<p>\u6807\u8bc6\u4fe1\u606f\uff08\u5982\u6307\u5b9a\u5ba2\u6237\u7aef\u662f\u8c01\u7684\u4fe1\u606f\uff08\u5982&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/troubleshoot\/windows-server\/identity\/security-identifiers-in-windows\">SID<\/a>\uff09\uff09\u6253\u5305\u5728\u79f0\u4e3a<strong>\u5b89\u5168\u4e0a\u4e0b\u6587\u7684\u7ed3\u6784\u4e2d<\/strong>\u3002\u6b64\u7ed3\u6784\u6df1\u6df1\u5730\u5d4c\u5165\u5230\u64cd\u4f5c\u7cfb\u7edf\u7684\u5185\u90e8\uff0c\u662f\u8fdb\u7a0b\u95f4\u901a\u4fe1\u6240\u9700\u7684\u4fe1\u606f\u3002\u56e0\u6b64\uff0c\u5ba2\u6237\u7aef\u65e0\u6cd5\u5728\u6ca1\u6709\u5b89\u5168\u4e0a\u4e0b\u6587\u7684\u60c5\u51b5\u4e0b\u8fdb\u884cIPC\u8c03\u7528\uff0c\u4f46\u5b83\u9700\u8981\u4e00\u79cd\u65b9\u6cd5\u6765\u6307\u5b9a\u5b83\u5141\u8bb8\u670d\u52a1\u5668\u4e86\u89e3\u7684\u5185\u5bb9\u4ee5\u53ca\u5982\u4f55\u5904\u7406\u5176\u6807\u8bc6\u3002\u63a7\u5236\u5fae\u8f6f\u521b\u5efa\u4e86\u6240\u8c13\u7684<strong>\u6a21\u62df\u7ea7\u522b<\/strong>\u3002<br>SECURITY_IMPERSONATION_LEVEL\u679a\u4e3e\u7ed3\u6784\u5b9a\u4e49\u4e86\u56db\u4e2a\u6a21\u62df\u7ea7\u522b\uff0c\u8fd9\u4e9b\u7ea7\u522b\u786e\u5b9a\u670d\u52a1\u5668\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u4e0a\u4e0b\u6587\u4e2d\u6267\u884c\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>SECURITY_IMPERSONATION_LEVEL<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td>\u5b89\u5168\u6027\u533f\u540d<\/td><td>\u670d\u52a1\u5668\u65e0\u6cd5\u6a21\u62df\u6216\u6807\u8bc6\u5ba2\u6237\u7aef\u3002<\/td><\/tr><tr><td>\u5b89\u5168\u6027\u8bc6\u522b<\/td><td>\u670d\u52a1\u5668\u53ef\u4ee5\u83b7\u53d6\u5ba2\u6237\u7aef\u7684\u6807\u8bc6\u548c\u6743\u9650\uff0c\u4f46\u4e0d\u80fd\u6a21\u62df\u5ba2\u6237\u7aef\u3002<\/td><\/tr><tr><td>\u5b89\u5168\u6027\u4e2a\u6027\u5316<\/td><td>\u670d\u52a1\u5668\u53ef\u4ee5\u5728\u672c\u5730\u7cfb\u7edf\u4e0a\u6a21\u62df\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u3002<\/td><\/tr><tr><td>\u5b89\u5168\u59d4\u6d3e<\/td><td>\u670d\u52a1\u5668\u53ef\u4ee5\u5728\u8fdc\u7a0b\u7cfb\u7edf\u4e0a\u6a21\u62df\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u6709\u5173\u6a21\u62df\u7684\u66f4\u591a\u80cc\u666f\u4fe1\u606f\uff0c\u8bf7\u9605\u8bfb Microsoft \u7684<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/client-impersonation\">\u5ba2\u6237\u7aef\u6a21\u62df<\/a>\u6587\u6863\u3002<br>\u6709\u5173\u6a21\u62df\u7684\u4e00\u4e9b\u4e0a\u4e0b\u6587\uff0c\u8bf7\u67e5\u770b\u8bbf\u95ee<a href=\"https:\/\/csandker.io\/2018\/06\/14\/AWindowsAuthorizationGuide.html#access-tokens\">\u4ee4\u724c<\/a>\u548c\u6211\u5173\u4e8e&nbsp;<a href=\"https:\/\/csandker.io\/2018\/06\/14\/AWindowsAuthorizationGuide.html\">Windows \u6388\u6743<\/a>\u7684\u5e16\u5b50\u4e2d\u7684\u4ee5\u4e0b<a href=\"https:\/\/csandker.io\/2018\/06\/14\/AWindowsAuthorizationGuide.html#impersonation\">\u6a21\u62df<\/a>\u90e8\u5206\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"impersonating-a-named-pipe-client\">\u6a21\u62df\u547d\u540d\u7ba1\u9053\u5ba2\u6237\u7aef<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#impersonating-a-named-pipe-client\"><\/a><\/h3>\n\n\n\n<p>\u597d\u5427\uff0c\u5f53\u6211\u4eec\u8c08\u8bba\u8fd9\u4e2a\u8bdd\u9898\u65f6\uff0c\u4ee5\u9632\u60a8\u8fd8\u6ca1\u6709\u5b8c\u5168\u65e0\u804a\u3002\u8ba9\u6211\u4eec\u5feb\u901f\u4e86\u89e3\u4e00\u4e0b\u5982\u679c\u670d\u52a1\u5668\u6a21\u62df\u5ba2\u6237\u7aef\uff0c\u540e\u53f0\u5b9e\u9645\u53d1\u751f\u7684\u60c5\u51b5\u3002<br>\u5982\u679c\u60a8\u5bf9\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u70b9\u66f4\u611f\u5174\u8da3\uff0c\u53ef\u4ee5<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeServer\/CPP-Basic-PipeServer.cpp#L21\">\u5728\u6b64\u5904<\/a>\u7684\u793a\u4f8b\u5b9e\u73b0\u4e2d\u627e\u5230\u7b54\u6848\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u6b65\u9aa4 1<\/strong>\uff1a\u670d\u52a1\u5668\u7b49\u5f85\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u4f20\u5165\u8fde\u63a5\uff0c\u7136\u540e\u8c03\u7528<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/namedpipeapi\/nf-namedpipeapi-impersonatenamedpipeclient\">\u6a21\u62df\u547d\u540d\u7ba1\u9053\u5ba2\u6237\u7aef<\/a>\u51fd\u6570\u3002<\/li><li><strong>\u6b65\u9aa4 2<\/strong>\uff1a\u6b64\u8c03\u7528\u4f1a\u5bfc\u81f4\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-zwcreateevent\">NtCreateEvent<\/a>\uff08\u4ee5\u521b\u5efa\u56de\u8c03\u4e8b\u4ef6\uff09\u548c&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-ntfscontrolfile\">NtFsControlFile<\/a>\uff08\u6267\u884c\u6a21\u62df\u7684\u51fd\u6570\uff09\u3002<\/li><li><strong>\u6b65\u9aa4 3<\/strong>\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-ntfscontrolfile\">NtFsControlFile<\/a>&nbsp;\u662f\u4e00\u4e2a\u901a\u7528\u51fd\u6570\uff0c\u5176\u64cd\u4f5c\u7531\u53c2\u6570\u6307\u5b9a\uff0c\u5728\u672c\u4f8b\u4e2d<strong>\uff0c\u53c2\u6570FSCTL_PIPE_Impersonate<\/strong>\u3002<br><br><em>\u4ee5\u4e0b\u5185\u5bb9\u57fa\u4e8e<a href=\"https:\/\/reactos.org\/\">ReactOS<\/a>\u7684\u5f00\u6e90\u4ee3\u7801\uff0c\u4f46\u6211\u8ba4\u4e3a\u5047\u8bbeWindows\u5185\u6838\u56e2\u961f\u4ee5\u7c7b\u4f3c\u7684\u65b9\u5f0f\u5b9e\u73b0\u5b83\u662f\u516c\u5e73\u7684\u3002<\/em><\/li><li><strong>\u6b65\u9aa4 4<\/strong>\uff1a\u8fdb\u4e00\u6b65\u8c03\u7528\u5806\u6808&nbsp;<a href=\"https:\/\/doxygen.reactos.org\/d4\/de2\/npfs_2fsctrl_8c_source.html#l00755\">NpCommonFileSystemControl<\/a>\uff0c\u5176\u4e2d&nbsp;<em>FSCTL_PIPE_IMPERSONATE<\/em>&nbsp;\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\uff0c\u5e76\u5728\u5f00\u5173\u5927\u5c0f\u5199\u6307\u4ee4\u4e2d\u4f7f\u7528\u4ee5\u786e\u5b9a\u8981\u6267\u884c\u7684\u64cd\u4f5c\u3002<\/li><li><strong>\u6b65\u9aa4 5<\/strong>\uff1a<a href=\"https:\/\/doxygen.reactos.org\/d4\/de2\/npfs_2fsctrl_8c_source.html#l00755\">NpCommonFileSystemControl<\/a>&nbsp;\u8c03\u7528&nbsp;<a href=\"https:\/\/doxygen.reactos.org\/d4\/d30\/drivers_2filesystems_2npfs_2npfs_8h.html#a16f8a0a170b7db81958977197c32d2a7\">NbAcquireExeclusiveVcb<\/a>&nbsp;\u6765\u9501\u5b9a\u5bf9\u8c61\uff0c\u5e76\u5728\u7ed9\u5b9a\u670d\u52a1\u5668\u7684\u7ba1\u9053\u5bf9\u8c61\u548c\u5ba2\u6237\u7aef\u53d1\u51fa\u7684 IRP\uff08I\/O \u8bf7\u6c42\u5bf9\u8c61\uff09\u7684\u60c5\u51b5\u4e0b\u8c03\u7528&nbsp;<a href=\"https:\/\/doxygen.reactos.org\/d4\/de2\/npfs_2fsctrl_8c.html#a0509b29312815e37ad722b9e3966b086\">NpImpersonate<\/a>\u3002<\/li><li><strong>\u6b65\u9aa4 6<\/strong>\uff1a<a href=\"https:\/\/doxygen.reactos.org\/d4\/de2\/npfs_2fsctrl_8c.html#a0509b29312815e37ad722b9e3966b086\">NpImpersonate<\/a>&nbsp;\u7136\u540e\u53cd\u8fc7\u6765\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-seimpersonateclientex\">SeImpersonateClientEx<\/a>\uff0c\u5e76\u5c06\u5ba2\u6237\u7aef<strong>\u7684\u5b89\u5168\u4e0a\u4e0b\u6587<\/strong>\uff08\u5df2\u4ece\u5ba2\u6237\u7aef\u7684 IRP \u83b7\u53d6\uff09\u4f5c\u4e3a\u53c2\u6570\u3002<\/li><li><strong>\u6b65\u9aa4 7<\/strong>\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-seimpersonateclientex\">SeImpersonateClientEx<\/a>&nbsp;\u4f9d\u6b21\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/ntifs\/nf-ntifs-psimpersonateclient\">PsImpersonateClient<\/a>\uff0c\u5176\u4e2d\u5305\u542b\u670d\u52a1\u5668\u7684\u7ebf\u7a0b\u5bf9\u8c61\u548c\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4ee4\u724c\uff0c\u540e\u8005\u662f\u4ece\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u4e2d\u63d0\u53d6\u7684<\/li><li><strong>\u6b65\u9aa4 8<\/strong>\uff1a\u7136\u540e\u5c06\u670d\u52a1\u5668\u7684\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u66f4\u6539\u4e3a\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u3002<\/li><li><strong>\u6b65\u9aa4 9<\/strong>\uff1a\u5728\u5ba2\u6237\u7aef\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u4e2d\uff0c\u670d\u52a1\u5668\u6267\u884c\u7684\u4efb\u4f55\u64cd\u4f5c\u548c\u670d\u52a1\u5668\u8c03\u7528\u7684\u4efb\u4f55\u529f\u80fd\u90fd\u662f\u4f7f\u7528\u5ba2\u6237\u7aef\u7684\u6807\u8bc6\u8fdb\u884c\u7684\uff0c<strong>\u4ece\u800c\u6a21\u62df\u5ba2\u6237\u7aef<\/strong>\u3002<\/li><li><strong>\u6b65\u9aa4 10<\/strong>\uff1a\u5982\u679c\u670d\u52a1\u5668\u5728\u6210\u4e3a\u5ba2\u6237\u7aef\u65f6\u5b8c\u6210\u4e86\u5b83\u6253\u7b97\u6267\u884c\u7684\u64cd\u4f5c\uff0c\u5219\u670d\u52a1\u5668\u5c06\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/securitybaseapi\/nf-securitybaseapi-reverttoself\">RevertToSelf<\/a>&nbsp;\u4ee5\u5207\u6362\u56de\u5176\u81ea\u5df1\u7684\u539f\u59cb\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"attack-surface\">\u653b\u51fb\u9762<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#attack-surface\"><\/a><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"client-impersonation\">\u5ba2\u6237\u7aef\u6a21\u62df<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#client-impersonation\"><\/a><\/h3>\n\n\n\n<p>\u6240\u4ee5\u6700\u540e\u6211\u4eec\u8c08\u8bba\u7684\u662f\u653b\u51fb\u9762\u3002\u57fa\u4e8e\u547d\u540d\u7ba1\u9053\u7684\u6700\u91cd\u8981\u7684\u653b\u51fb\u5a92\u4ecb\u662f\u6a21\u62df\u3002<br>\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u5df2\u7ecf<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#impersonation\">\u5728\u4e0a\u9762\u7684\u90e8\u5206\u4e2d<\/a>\u4ecb\u7ecd\u5e76\u7406\u89e3\u4e86\u6a21\u62df\u7684\u6982\u5ff5\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u6df1\u5165\u7814\u7a76\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"attack-scenario\">\u653b\u51fb\u573a\u666f<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#attack-scenario\"><\/a><\/h4>\n\n\n\n<p>\u5f53\u60a8\u83b7\u5f97\u5141\u8bb8\u60a8\u6307\u5b9a\u6216\u63a7\u5236\u8bbf\u95ee\u6587\u4ef6\u7684\u670d\u52a1\uff0c\u7a0b\u5e8f\u6216\u4f8b\u7a0b\u65f6\uff0c\u6700\u597d\u6ee5\u7528\u547d\u540d\u7ba1\u9053\u7684\u6a21\u62df\uff08\u65e0\u8bba\u5b83\u662f\u5426\u5141\u8bb8\u60a8\u8bfb\u53d6\u6216\u5199\u5165\u8bbf\u95ee\u6216\u4e24\u8005\u517c\u800c\u6709\u4e4b\uff09\u3002\u7531\u4e8e\u547d\u540d\u7ba1\u9053\u57fa\u672c\u4e0a\u662fFILE_OBJECTs\uff0c\u5e76\u4e14\u5bf9\u4e0e\u5e38\u89c4\u6587\u4ef6\uff08<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile<\/a>\uff0c<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-writefile\">WriteFile<\/a>\uff0c<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>\u7b49\uff09\u76f8\u540c\u7684\u8bbf\u95ee\u529f\u80fd\u8fdb\u884c\u64cd\u4f5c\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u6307\u5b9a\u547d\u540d\u7ba1\u9053\u800c\u4e0d\u662f\u5e38\u89c4\u6587\u4ef6\u540d\uff0c\u5e76\u4f7f\u53d7\u5bb3\u8005\u8fdb\u7a0b\u8fde\u63a5\u5230\u60a8\u63a7\u5236\u4e0b\u7684\u547d\u540d\u7ba1\u9053\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"prerequisites\">\u5148\u51b3\u6761\u4ef6<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#prerequisites\"><\/a><\/h4>\n\n\n\n<p>\u5c1d\u8bd5\u6a21\u62df\u5ba2\u6237\u7aef\u65f6\uff0c\u9700\u8981\u68c0\u67e5\u4e24\u4e2a\u91cd\u8981\u65b9\u9762\u3002<br>\u7b2c\u4e00\u79cd\u662f\u68c0\u67e5\u5ba2\u6237\u7aef\u5982\u4f55\u5b9e\u73b0\u6587\u4ef6\u8bbf\u95ee\uff0c\u66f4\u5177\u4f53\u5730\u8bf4\uff0c\u5ba2\u6237\u7aef\u5728\u8c03\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>&nbsp;\u65f6\u662f\u5426\u6307\u5b9a\u4e86 SECURITY_SQOS_PRESENT \u6807\u5fd7\uff1f<\/p>\n\n\n\n<p>\u5bf9&nbsp;<em>CreateFile<\/em>&nbsp;<strong>\u7684\u6613\u53d7\u653b\u51fb\u8c03\u7528<\/strong>\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hFile = CreateFile(pipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u800c\u5bf9&nbsp;<em>CreateFile<\/em>&nbsp;<strong>\u7684\u5b89\u5168\u8c03\u7528<\/strong>\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ calling with explicit SECURITY_IMPERSONATION_LEVEL\nhFile = CreateFile(pipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION , NULL);\n\/\/ calling without explicit SECURITY_IMPERSONATION_LEVEL\nhFile = CreateFile(pipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0d\u663e\u5f0f\u6307\u5b9aSECURITY_IMPERSONATION_LEVEL\u7684\u8c03\u7528\uff08\u5982\u4e0a\u9762\u7684\u540e\u9762\u793a\u4f8b\u6240\u793a\uff09\u662f\u4f7f\u7528\u533f\u540d\u7684\u5b89\u5168\u7ea7\u522b\u6a21\u62df\u8fdb\u884c\u7684\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>\u5982\u679c\u8bbe\u7f6eSECURITY_SQOS_PRESENT\u6807\u5fd7\u65f6\u672a\u8bbe\u7f6e\u4efb\u4f55\u5176\u4ed6\u6a21\u62df\u7ea7\u522b \uff08IL\uff09\uff0c\u6216\u8005\u5c06 IL \u8bbe\u7f6e\u4e3aSECURITY_IDENTIFICATION\u6216SECURITY_ANONYMOUS<u>\u5219\u65e0\u6cd5<\/u>\u6a21\u62df\u5ba2\u6237\u7aef\u3002<\/strong><\/p><\/blockquote>\n\n\n\n<p><strong>\u8981\u68c0\u67e5\u7684\u7b2c\u4e8c\u4e2a\u91cd\u8981\u65b9\u9762<\/strong>\u662f\u6587\u4ef6\u540d\uff0c\u53c8\u540d\u3002<em>lpFileName<\/em>&nbsp;\u53c2\u6570\uff0c\u63d0\u4f9b\u7ed9&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>\u3002\u5728\u8c03\u7528\u672c\u5730\u547d\u540d\u7ba1\u9053\u6216\u8c03\u7528\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u4e4b\u95f4\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u533a\u522b\u3002<\/p>\n\n\n\n<p>\u5bf9\u672c\u5730\u547d\u540d\u7ba1\u9053\u7684\u8c03\u7528\u7531\u6587\u4ef6\u4f4d\u7f6e \u5b9a\u4e49\u3002<br>\u4ec5\u5f53\u4f7f\u7528\u9ad8\u4e8e&nbsp;SECURITY_IDENTIFICATION \u7684\u6a21\u62df\u7ea7\u522b\u663e\u5f0f\u8bbe\u7f6eSECURITY_SQOS_PRESENT\u6807\u5fd7\u65f6\uff0c\u624d\u80fd\u6a21\u62df\u5bf9\u672c\u5730\u7ba1\u9053\u7684\u8c03\u7528\u3002\u56e0\u6b64<strong>\uff0c\u6613\u53d7\u653b\u51fb\u7684\u8c03\u7528<\/strong>\u5982\u4e0b\u6240\u793a\uff1a<code>\\\\.\\pipe\\&lt;SomeName&gt;<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hFile = CreateFile(L\"\\\\.\\pipe\\fpipe\", GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT | SECURITY_IMPERSONATION, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u9700\u8981\u660e\u786e\u7684\u662f\u3002\u5bf9\u672c\u5730\u7ba1\u9053<strong>\u7684\u5b89\u5168\u8c03\u7528<\/strong>\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hFile = CreateFile(L\"\\\\.\\pipe\\fpipe\", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);\n<\/code><\/pre>\n\n\n\n<p>\u5373\u4f7f\u6ca1\u6709SECURITY_SQOS_PRESENT\uff0c\u6b64\u7a0d\u540e\u8c03\u7528\u4e5f\u662f\u5b89\u5168\u7684\uff0c\u56e0\u4e3a\u8c03\u7528\u7684\u662f\u672c\u5730\u7ba1\u9053\u3002<\/p>\n\n\n\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u7531\u4ee5\u4e3b\u673a\u540d\u6216 IP \u5f00\u5934\u7684&nbsp;<em>lpFileName<\/em>&nbsp;\u5b9a\u4e49\uff0c\u4f8b\u5982\uff1a\u3002<br>\u73b0\u5728\u662f\u91cd\u8981\u7684\u4e00\u70b9\uff1a<code>\\\\ServerA.domain.local\\pipe\\&lt;SomeName&gt;<\/code><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>\u5982\u679cSECURITY_SQOS_PRESENT\u6807\u5fd7<u>\u4e0d\u5b58\u5728<\/u>\u5e76\u4e14\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u79f0\u4e3a\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\uff0c\u5219\u6a21\u62df\u7ea7\u522b\u7531\u8fd0\u884c\u540d\u79f0\u7ba1\u9053\u670d\u52a1\u5668\u7684\u7528\u6237\u6743\u9650\u5b9a\u4e49\u3002<\/strong><\/p><\/blockquote>\n\n\n\n<p>\u8fd9\u610f\u5473\u7740\uff0c\u5f53\u60a8\u8c03\u7528\u6ca1\u6709SECURITY_SQOS_PRESENT\u6807\u5fd7\u7684\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u65f6\uff0c\u8fd0\u884c\u8be5\u7ba1\u9053\u7684\u653b\u51fb\u8005\u7528\u6237\u5fc5\u987b\u6301\u6709&nbsp;<strong>SeImpersonatePrivilege<\/strong>&nbsp;\uff08<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/privilege-constants\">SE_IMPERSONATE_NAME<\/a>\uff09 \u624d\u80fd\u6a21\u62df\u5ba2\u6237\u7aef\u3002<br>\u5982\u679c\u60a8\u7684\u7528\u6237\u4e0d\u5177\u6709\u6b64\u6743\u9650\uff0c\u5219\u6a21\u62df\u7ea7\u522b\u5c06\u8bbe\u7f6e\u4e3a\u201c\u5b89\u5168\u8bc6\u522b\u201d\uff08\u5141\u8bb8\u60a8\u8bc6\u522b\u7528\u6237\uff0c\u4f46\u4e0d\u80fd\u6a21\u62df\u7528\u6237\uff09\u3002<br>\u4f46\u8fd9\u4e5f\u610f\u5473\u7740\uff0c\u5982\u679c\u60a8\u7684\u7528\u6237\u6301\u6709&nbsp;<strong>SeEnableDelegationPrivilege<\/strong>&nbsp;\uff08<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/privilege-constants\">SE_ENABLE_DELEGATION_NAME<\/a>\uff09\uff0c\u5219\u6a21\u62df\u7ea7\u522b\u5c06\u8bbe\u7f6e\u4e3a SecurityDelete\uff0c\u60a8\u751a\u81f3\u53ef\u4ee5\u9488\u5bf9\u5176\u4ed6\u7f51\u7edc\u670d\u52a1\u5bf9\u53d7\u5bb3\u7528\u6237\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6709<strong>\u4e00\u4e2a\u91cd\u8981\u7684\u6536\u83b7<\/strong>\u662f\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a&nbsp;<code>\\\\127.0.0.1\\pipe\\&lt;SomeName&gt;<\/code>\u5bf9\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u7684\u547d\u540d\u7ba1\u9053\u8fdb\u884c\u8fdc\u7a0b\u7ba1\u9053\u8c03\u7528&gt;<\/strong><\/p><\/blockquote>\n\n\n\n<p>\u8981\u6700\u7ec8\u5c06\u5404\u4e2a\u90e8\u5206\u7ec4\u5408\u5728\u4e00\u8d77\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u672a\u8bbe\u7f6eSECURITY_SQOS_PRESENT\uff0c\u5219\u53ef\u4ee5\u5728\u7528\u6237\u81f3\u5c11\u5177\u6709SE_IMPERSONATE_NAME\u6743\u9650\u65f6\u6a21\u62df\u5ba2\u6237\u7aef\uff0c\u4f46\u5bf9\u4e8e\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u7684\u547d\u540d\u7ba1\u9053\uff0c\u60a8\u9700\u8981\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8c03\u7528\u5b83\u4eec<code>\\\\127.0.0.1\\pipe\\...<\/code><\/li><li>\u5982\u679c\u8bbe\u7f6e\u4e86SECURITY_SQOS_PRESENT\uff0c\u5219\u53ea\u6709\u5728\u540c\u65f6\u8bbe\u7f6e\u4e86\u9ad8\u4e8e&nbsp;SECURITY_IDENTIFICATION \u7684\u6a21\u62df\u7ea7\u522b\u65f6\uff0c\u624d\u80fd\u6a21\u62df\u5ba2\u6237\u7aef\uff08\u65e0\u8bba\u662f\u5728\u672c\u5730\u8fd8\u662f\u8fdc\u7a0b\u8c03\u7528\u547d\u540d\u7ba1\u9053\uff09\u3002<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"misleading-documentation\">\u8bef\u5bfc\u6027\u6587\u6863<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#misleading-documentation\"><\/a><\/h4>\n\n\n\n<p>Microsoft \u6709\u5173<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/impersonation-levels\">\u6a21\u62df\u7ea7\u522b\uff08\u6388\u6743\uff09\u7684\u6587\u6863<\/a>\u58f0\u660e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5f53\u547d\u540d\u7ba1\u9053\u3001RPC \u6216 DDE&nbsp;<strong>\u8fde\u63a5\u662f\u8fdc\u7a0b\u8fde\u63a5\u65f6<\/strong>\uff0c\u5c06\u5ffd\u7565\u4f20\u9012\u7ed9 CreateFile \u4ee5\u8bbe\u7f6e<strong>\u6a21\u62df\u7ea7\u522b<\/strong>\u7684\u6807\u5fd7\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5ba2\u6237\u7aef\u7684\u6a21\u62df\u7ea7\u522b\u7531\u670d\u52a1\u5668\u542f\u7528\u7684\u6a21\u62df\u7ea7\u522b\u786e\u5b9a\uff0c\u8be5\u6a21\u62df\u7ea7\u522b\u7531\u76ee\u5f55\u670d\u52a1\u4e2d\u670d\u52a1\u5668\u5e10\u6237\u4e0a\u7684\u6807\u5fd7\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e3a\u670d\u52a1\u5668\u542f\u7528\u4e86\u59d4\u6d3e\uff0c\u5219\u5ba2\u6237\u7aef\u7684\u6a21\u62df\u7ea7\u522b\u4e5f\u5c06\u8bbe\u7f6e\u4e3a\u59d4\u6d3e\uff0c\u5373\u4f7f\u4f20\u9012\u7ed9 CreateFile \u7684\u6807\u5fd7\u6307\u5b9a\u4e86\u6807\u8bc6\u6a21\u62df\u7ea7\u522b\u4e5f\u662f\u5982\u6b64\u3002<br>\u6765\u6e90\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/impersonation-levels\">Windows \u6587\u6863\uff1a\u6a21\u62df\u7ea7\u522b\uff08\u6388\u6743\uff09<\/a><\/p><\/blockquote>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0c\u8fd9\u5728\u6280\u672f\u4e0a\u662f\u6b63\u786e\u7684\uff0c\u4f46\u5b83\u6709\u70b9\u8bef\u5bfc&#8230;&#8230;<br>\u51c6\u786e\u7684\u7248\u672c\u662f\uff1a\u8c03\u7528\u8fdc\u7a0b\u547d\u540d\u7ba1\u9053\u65f6\uff0c\u60a8\u53ea\u5c06\u6a21\u62df\u7ea7\u522b\u6807\u5fd7\uff08\u800c\u4e0d\u662f\u5176\u4ed6\u4efb\u4f55\u540d\u79f0\uff09\u6307\u5b9a\u7ed9&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>\uff0c\u90a3\u4e48\u8fd9\u4e9b\u6807\u5fd7\u5c06\u88ab\u5ffd\u7565\uff0c\u4f46\u662f\u5982\u679c\u60a8\u5c06\u6a21\u62df\u6807\u5fd7\u4e0eSECURITY_SQOS_PRESENT\u6807\u5fd7\u4e00\u8d77\u6307\u5b9a\uff0c\u5219\u5c06\u9075\u5faa\u8fd9\u4e9b\u6807\u5fd7\u3002<\/p>\n\n\n\n<p>\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ In the below call the SECURITY_IDENTIFICATION flag will be respected by the remote server\nhFile = CreateFile(L\"\\\\ServerA.domain.local\", GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION, NULL);\n<em>\/* --&gt; The server will obtain a SECURITY_IDENTIFICATION token *\/<\/em>\n\n\/\/ In this call the SECURITY_IDENTIFICATION flag will be ignored\nhFile = CreateFile(L\"\\\\ServerA.domain.local\", GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_IDENTIFICATION, NULL);\n<em>\/* --&gt; The server will obtain a token based on the privileges of the user running the server. \n        A user holding SeImpersonatePrivilege will get an SECURITY_IMPERSONATION token *\/<\/em>\n\n\/\/ In this call the Impersonation Level will default to SECURITY_ANONYMOUS and will be respected\nhFile = CreateFile(L\"\\\\ServerA.domain.local\", GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT, NULL);\n<em>\/* --&gt; The server will obtain a SECURITY_ANONYMOUS token. A call to  OpenThreadToken will result in error 1347 (0x543, ERROR_CANT_OPEN_ANONYMOUS)*\/<\/em>\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"implementation\">\u5b9e\u73b0<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#implementation\"><\/a><\/h4>\n\n\n\n<p>\u4f60\u53ef\u4ee5<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeServer\/CPP-Basic-PipeServer.cpp\">\u5728\u6211\u7684<\/a>\u793a\u4f8b\u4ee3\u7801\u4e2d\u627e\u5230\u4e00\u4e2a\u5b8c\u6574\u7684\u5b9e\u73b0\u3002\u5b9e\u73b0\u7684\u5feb\u901f\u8fd0\u884c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create a server named pipe\nserverPipe = CreateNamedPipe(\n    pipeName,           \/\/ name of our pipe, must be in the form of \\\\.\\pipe\\&lt;NAME&gt;\n    PIPE_ACCESS_DUPLEX, \/\/ The rest of the parameters don't really matter\n    PIPE_TYPE_MESSAGE,\t\/\/ as all you want is impersonate the client...\n    1,\t\t\/\/ \n    2048,\t\/\/ \n    2048,\t\/\/ \n    0,\t\t\/\/ \n    NULL\t\/\/ This should ne NULL so every client can connect\n);\n\/\/ wait for pipe connections\nBOOL bPipeConnected = ConnectNamedPipe(serverPipe, NULL);\n\/\/ Impersonate client\nBOOL bImpersonated = ImpersonateNamedPipeClient(serverPipe);\n\/\/ if successful open Thread token - your current thread token is now the client's token\nBOOL bSuccess = OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, FALSE, &amp;hToken);\n\/\/ now you got the client token saved in hToken and you can safeyl revert back to self\nbSuccess = RevertToSelf();\n\/\/ Now duplicate the client's token to get a Primary token\nbSuccess = DuplicateTokenEx(hToken,\n    TOKEN_ALL_ACCESS,\n    NULL,\n    SecurityImpersonation,\n    TokenPrimary,\n    &amp;hDuppedToken\n);\n\/\/ If that succeeds you got a Primary token as hDuppedToken and you can create a proccess with that token\nCreateProcessWithTokenW(hDuppedToken, LOGON_WITH_PROFILE, command, NULL, CREATE_NEW_CONSOLE, NULL, NULL, &amp;si, &amp;pi);\n<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u53ef\u4ee5\u5728\u4e0b\u9762\u770b\u5230\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/NamedPipe_Impersonation.png\" alt=\"\u547d\u540d\u7ba1\u9053\u6a21\u62df\"\/><\/figure>\n\n\n\n<p>\u5f53\u60a8\u81ea\u5df1\u5b9e\u73b0\u6b64\u529f\u80fd\u65f6\uff0c\u6709\u4e00\u4e9b\u9677\u9631\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f53\u60a8\u4f7f\u7528<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createprocesswithtokenw\">CreateProcessWithTokenW<\/a>\u521b\u5efa\u8fdb\u7a0b\u65f6\uff0c\u60a8\u9700\u8981\u5728\u8c03\u7528<em>CreateProcessWithTokenW<\/em>\u4e4b\u524d<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/securitybaseapi\/nf-securitybaseapi-reverttoself\">\u6062\u590d\u5230\u81ea\u5df1<\/a>\uff0c\u5426\u5219\u60a8\u5c06\u6536\u5230\u9519\u8bef\u3002<\/li><li>\u5f53\u60a8\u60f3\u8981\u521b\u5efa\u57fa\u4e8e\u7a97\u53e3\u7684\u8fdb\u7a0b\uff08\u5e26\u6709\u5f39\u51fa\u7a97\u53e3\u7684\u8fdb\u7a0b\uff0c\u4f8b\u5982calc.exe\u6216cmd.exe\uff09\u65f6\uff0c\u60a8\u9700\u8981\u6388\u4e88\u5ba2\u6237\u7aef\u5bf9\u7a97\u53e3\u548c\u684c\u9762\u7684\u8bbf\u95ee\u6743\u9650\u3002\u53ef\u4ee5<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Util\/Access.cpp\">\u5728\u6b64\u5904<\/a>\u627e\u5230\u5141\u8bb8\u6240\u6709\u7528\u6237\u8bbf\u95ee\u60a8\u7684\u7a97\u53e3\u548c\u684c\u9762\u7684\u793a\u4f8b\u5b9e\u73b0\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"instance-creation-race-condition\">\u5b9e\u4f8b\u521b\u5efa\u4e89\u7528\u6761\u4ef6<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#instance-creation-race-condition\"><\/a><\/h3>\n\n\n\n<p>\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u662f\u5728\u540d\u79f0\u7ba1\u9053\u6587\u4ef6\u7cfb\u7edf \uff08NPFS\uff09 \u8bbe\u5907\u9a71\u52a8\u5668\u4e2d\u7684\u5168\u5c40\u201c\u547d\u540d\u7a7a\u95f4\u201d\u4e2d\u521b\u5efa\u5e76\u5b58\u5728\u7684\uff08\u5b9e\u9645\u4e0a\u6280\u672f\u4e0a\u6ca1\u6709\u547d\u540d\u7a7a\u95f4\uff0c\u4f46\u8fd9\u6709\u52a9\u4e8e\u7406\u89e3\u6240\u6709\u547d\u540d\u7ba1\u9053\u90fd\u4f4d\u4e8e\u540c\u4e00\u5c4b\u6a90\u4e0b\uff09\u3002\u6b64\u5916\uff0c\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u591a\u4e2a\u547d\u540d\u7ba1\u9053\u53ef\u4ee5\u5b58\u5728\u4e8e\u8fd9\u4e2a\u5c4b\u6a90\u4e0b\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\uff0c\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u521b\u5efa\u4e86\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u547d\u540d\u7ba1\u9053\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\u60c5\u51b5\u5462\uff1f\u597d\u5427\uff0c\u5982\u679c\u60a8\u6ca1\u6709\u8bbe\u7f6e\u6b63\u786e\u7684\u6807\u5fd7\uff0c\u5219\u4e0d\u4f1a\u53d1\u751f\u4efb\u4f55\u4e8b\u60c5\uff0c\u8fd9\u610f\u5473\u7740\u60a8\u4e0d\u4f1a\u6536\u5230\u9519\u8bef\uff0c\u66f4\u7cdf\u7cd5\u7684\u662f\uff0c\u7531\u4e8e\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u7ec4\u7ec7\u5728FIFO\uff08\u5148\u8fdb\u5148\u51fa\uff09\u5806\u6808\u4e2d\uff0c\u56e0\u6b64\u60a8\u5c06\u65e0\u6cd5\u83b7\u5f97\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<br>\u6b64\u8bbe\u8ba1\u4f7f\u547d\u540d\u7ba1\u9053\u5bb9\u6613\u53d7\u5230\u5b9e\u4f8b\u521b\u5efa\u4e89\u7528\u6761\u4ef6\u6f0f\u6d1e\u7684\u653b\u51fb\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"attack-scenario-1\">\u653b\u51fb\u573a\u666f<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#attack-scenario-1\"><\/a><\/h4>\n\n\n\n<p>\u5229\u7528\u6b64\u7c7b\u4e89\u7528\u6761\u4ef6\u7684\u653b\u51fb\u60c5\u5f62\u5982\u4e0b\uff1a\u60a8\u5df2\u7ecf\u786e\u5b9a\u4e86\u4e00\u4e2a\u670d\u52a1\u3001\u7a0b\u5e8f\u6216\u4f8b\u7a0b\uff0c\u8be5\u670d\u52a1\u3001\u7a0b\u5e8f\u6216\u4f8b\u7a0b\u521b\u5efa\u4e86\u4e00\u4e2a\u547d\u540d\u7ba1\u9053\uff0c\u8be5\u7ba1\u9053\u7531\u5728\u4e0d\u540c\u5b89\u5168\u4e0a\u4e0b\u6587\u4e2d\u8fd0\u884c\u7684\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\uff08\u5047\u8bbe\u5b83\u4eec\u5728 NT \u670d\u52a1\u7528\u6237\u4e0b\u8fd0\u884c\uff09\u3002\u670d\u52a1\u5668\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u7ba1\u9053\uff0c\u7528\u4e8e\u4e0e\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u901a\u4fe1\u3002\u5076\u5c14\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\u547d\u540d\u7ba1\u9053 &#8211; \u5982\u679c\u670d\u52a1\u5668\u5e94\u7528\u7a0b\u5e8f\u5728\u521b\u5efa\u670d\u52a1\u5668\u7ba1\u9053\u540e\u89e6\u53d1\u5ba2\u6237\u7aef\u8fde\u63a5\uff0c\u8fd9\u79cd\u60c5\u51b5\u5e76\u4e0d\u5c11\u89c1\u3002\u60a8\u53ef\u4ee5\u786e\u5b9a\u670d\u52a1\u5668\u7684\u542f\u52a8\u65f6\u95f4\u548c\u65b9\u5f0f\u4ee5\u53ca\u5b83\u521b\u5efa\u7684\u7ba1\u9053\u7684\u540d\u79f0\u3002<br>\u73b0\u5728\uff0c\u60a8\u6b63\u5728\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8be5\u7a0b\u5e8f\u5728\u76ee\u6807\u670d\u52a1\u5668\u7684\u547d\u540d\u7ba1\u9053\u4e4b\u524d\u521b\u5efa\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u7684\u65b9\u6848\u4e2d\u521b\u5efa\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u547d\u540d\u7ba1\u9053\u3002\u5982\u679c\u670d\u52a1\u5668\u7684\u547d\u540d\u7ba1\u9053\u521b\u5efa\u4e0d\u5b89\u5168\uff0c\u5219\u4e0d\u4f1a\u6ce8\u610f\u5230\u5df2\u5b58\u5728\u540c\u540d\u7684\u547d\u540d\u7ba1\u9053\uff0c\u5e76\u5c06\u89e6\u53d1\u5ba2\u6237\u7aef\u8fdb\u884c\u8fde\u63a5\u3002\u7531\u4e8eFIFO\u5806\u6808\uff0c\u5ba2\u6237\u7aef\u5c06\u8fde\u63a5\u5230\u60a8\uff0c\u60a8\u53ef\u4ee5\u8bfb\u53d6\u6216\u5199\u5165\u5176\u6570\u636e\u6216\u5c1d\u8bd5\u6a21\u62df\u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"prerequisites-1\">\u5148\u51b3\u6761\u4ef6<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#prerequisites-1\"><\/a><\/h4>\n\n\n\n<p>\u8981\u4f7f\u6b64\u653b\u51fb\u8d77\u4f5c\u7528\uff0c\u60a8\u9700\u8981\u4e00\u4e2a\u76ee\u6807\u670d\u52a1\u5668\uff0c\u8be5\u670d\u52a1\u5668\u4e0d\u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u540c\u540d\u7684\u547d\u540d\u7ba1\u9053\u3002\u901a\u5e38\uff0c\u670d\u52a1\u5668\u6ca1\u6709\u989d\u5916\u7684\u4ee3\u7801\u6765\u624b\u52a8\u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u540c\u540d\u7684\u7ba1\u9053 &#8211; \u4ed4\u7ec6\u60f3\u60f3\uff0c\u5982\u679c\u60a8\u7684\u7ba1\u9053\u540d\u79f0\u5df2\u7ecf\u5b58\u5728\uff0c\u60a8\u4f1a\u671f\u671b\u6536\u5230\u9519\u8bef\u5417\uff1f\u4f46\u8fd9\u4e0d\u4f1a\u53d1\u751f\uff0c\u56e0\u4e3a\u4e24\u4e2a\u540c\u540d\u7684\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u662f\u7edd\u5bf9\u6709\u6548\u7684&#8230;&#8230;\u65e0\u8bba\u51fa\u4e8e\u4f55\u79cd\u539f\u56e0\u3002<br>\u4f46\u4e3a\u4e86\u53cd\u51fb\u8fd9\u79cd\u653b\u51fb\uff0cMicrosoft \u6dfb\u52a0\u4e86<strong>FILE_FLAG_FIRST_PIPE_INSTANCE<\/strong>\u6807\u5fd7\uff0c\u53ef\u4ee5\u5728\u901a\u8fc7&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u521b\u5efa\u547d\u540d\u7ba1\u9053\u65f6\u6307\u5b9a\u8be5\u6807\u5fd7\u3002\u8bbe\u7f6e\u6b64\u6807\u5fd7\u540e\uff0c\u60a8\u7684\u521b\u5efa\u8c03\u7528\u5c06\u8fd4\u56deINVALID_HANDLE_VALUE\uff0c\u8fd9\u5c06\u5bfc\u81f4\u5728\u5bf9&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/namedpipeapi\/nf-namedpipeapi-connectnamedpipe\">ConnectNamedPipe \u7684<\/a>\u540e\u7eed\u8c03\u7528\u4e2d\u51fa\u73b0\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u7684\u76ee\u6807\u670d\u52a1\u5668\u672a\u6307\u5b9aFILE_FLAG_FIRST_PIPE_INSTANCE\u6807\u5fd7\uff0c\u5219\u53ef\u80fd\u5bb9\u6613\u53d7\u5230\u653b\u51fb\uff0c\u4f46\u662f\u653b\u51fb\u8005\u8fd8\u9700\u8981\u6ce8\u610f\u4e00\u4ef6\u4e8b\u3002\u901a\u8fc7&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u521b\u5efa\u547d\u540d\u7ba1\u9053\u65f6\uff0c\u6709\u4e00\u4e2a&nbsp;<em>nMaxInstances<\/em>&nbsp;\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u6307\u5b9a&#8230;\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u53ef\u4ee5\u4e3a\u6b64\u7ba1\u9053\u521b\u5efa\u7684\u6700\u5927\u5b9e\u4f8b\u6570\u3002\u7ba1\u9053\u7684\u7b2c\u4e00\u4e2a\u5b9e\u4f8b\u53ef\u4ee5\u6307\u5b9a\u6b64\u503c;<br>\u6765\u6e90\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a><\/p><\/blockquote>\n\n\n\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u5c06\u5176\u8bbe\u7f6e\u4e3a\u201c1\u201d\uff08\u5982\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u6240\u793a\uff09\uff0c\u5219\u4f1a\u6740\u6b7b\u81ea\u5df1\u7684\u653b\u51fb\u5a92\u4ecb\u3002\u8981\u5229\u7528\u5b9e\u4f8b\u521b\u5efa\u4e89\u7528\u6761\u4ef6\u6f0f\u6d1e<strong>\uff0c\u8bf7\u5c06\u6b64\u6f0f\u6d1e\u8bbe\u7f6e\u4e3aPIPE_UNLIMITED_INSTANCES<\/strong>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"implementation-1\">\u5b9e\u73b0<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#implementation-1\"><\/a><\/h4>\n\n\n\n<p>\u5229\u7528\u6b64\u6f0f\u6d1e\u6240\u9700\u8981\u505a\u7684\u5c31\u662f\u5728\u6b63\u786e\u7684\u65f6\u95f4\u521b\u5efa\u5177\u6709\u6b63\u786e\u540d\u79f0\u7684\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u3002<br><a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/blob\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\/CPP-Basic-PipeServer\/CPP-Basic-PipeServer.cpp\">\u6211\u5728\u8fd9\u91cc<\/a>\u7684\u793a\u4f8b\u5b9e\u73b0\u53ef\u4ee5\u7528\u4f5c\u5b9e\u73b0\u6a21\u677f\u3002\u5c06\u5b83\u653e\u5728\u60a8\u559c\u6b22\u7684IDE\u4e2d\uff0c\u8bbe\u7f6e\u5728\u60a8\u7684\u7ba1\u9053\u540d\u79f0\u4e2d\uff0c\u786e\u4fdd\u4f7f\u7528PIPE_UNLIMITED_INSTANCES\u6807\u5fd7\u521b\u5efa\u547d\u540d\u7ba1\u9053\u5e76\u5f00\u706b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"instance-creation-special-flavors\">\u5b9e\u4f8b\u521b\u5efa\u7279\u6b8a\u98ce\u683c<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#instance-creation-special-flavors\"><\/a><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"unanswered-pipe-connections\">\u672a\u5e94\u7b54\u7684\u7ba1\u9053\u8fde\u63a5<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#unanswered-pipe-connections\"><\/a><\/h4>\n\n\n\n<p>\u672a\u5e94\u7b54\u7684\u7ba1\u9053\u8fde\u63a5\u662f\u7531\u5ba2\u6237\u7aef\u53d1\u51fa\u7684\u90a3\u4e9b\u8fde\u63a5\u5c1d\u8bd5\uff08\u8c01\u4f1a\u731c\u5230\u5b83\uff09\u4e0d\u6210\u529f\uff0c\u56e0\u6b64\u672a\u5e94\u7b54\uff0c\u56e0\u4e3a\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u7ba1\u9053\u4e0d\u5b58\u5728\u3002<br>\u8fd9\u91cc\u7684\u6f0f\u6d1e\u5229\u7528\u6f5c\u529b\u975e\u5e38\u6e05\u695a\u548c\u7b80\u5355\uff1a\u5982\u679c\u5ba2\u6237\u7aef\u60f3\u8981\u8fde\u63a5\u5230\u4e0d\u5b58\u5728\u7684\u7ba1\u9053\uff0c\u6211\u4eec\u4f1a\u521b\u5efa\u4e00\u4e2a\u5ba2\u6237\u7aef\u53ef\u4ee5\u8fde\u63a5\u5230\u7684\u7ba1\u9053\uff0c\u5e76\u5c1d\u8bd5\u901a\u8fc7\u6076\u610f\u901a\u4fe1\u64cd\u7eb5\u5ba2\u6237\u7aef\u6216\u6a21\u62df\u5ba2\u6237\u7aef\u4ee5\u83b7\u53d6\u5176\u4ed6\u6743\u9650\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u6f0f\u6d1e\u6709\u65f6\u4e5f\u88ab\u79f0\u4e3a<em>\u591a\u4f59\u7684\u7ba1\u9053\u8fde\u63a5<\/em>\uff08\u4f46\u5728\u6211\u770b\u6765\uff0c\u8fd9\u4e0d\u662f\u6700\u597d\u7684\u672f\u8bed\uff09\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u771f\u6b63\u7684\u95ee\u9898\u662f\uff1a<strong>\u6211\u4eec\u5982\u4f55\u627e\u5230\u8fd9\u6837\u7684\u5ba2\u6237\uff1f<\/strong><br>\u6211\u6700\u521d\u7684\u76f4\u63a5\u7b54\u6848\u662f\uff1a\u542f\u52a8<a href=\"https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/procmon\">Procmon<\/a>\u5e76\u641c\u7d22\u5931\u8d25\u7684<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-createfilea\">CreateFile<\/a>\u7cfb\u7edf\u8c03\u7528\u3002\u4f46\u662f\u6211\u6d4b\u8bd5\u4e86\u8fd9\u4e2a\uff0c\u7ed3\u679c\u53d1\u73b0Procmon\u6ca1\u6709\u5217\u51fa\u8fd9\u4e9b\u7ba1\u9053\u8c03\u7528&#8230;&#8230;\u4e5f\u8bb8\u8fd9\u662f\u56e0\u4e3a\u8be5\u5de5\u5177\u4ec5\u901a\u8fc7NTFS\u9a71\u52a8\u7a0b\u5e8f\u68c0\u67e5\/\u4fa6\u542c\u6587\u4ef6\u64cd\u4f5c\uff0c\u4f46\u6211\u8fd8\u6ca1\u6709\u5bf9\u6b64\u8fdb\u884c\u6df1\u5165\u7814\u7a76\uff08\u4e5f\u8bb8\u6709\u4e00\u4e2a\u6211\u4e0d\u77e5\u9053\u7684\u6280\u5de7\/\u5f00\u5173\uff09 &#8211; \u5982\u679c\u6211\u5076\u7136\u53d1\u73b0\u7b54\u6848\uff0c\u6211\u4f1a\u66f4\u65b0&#8230;<\/p>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u9009\u9879\u662f IO Ninja \u5de5\u5177\u96c6\u7684<a href=\"https:\/\/ioninja.com\/plugins\/pipe-monitor.html\">\u7ba1\u9053\u76d1\u89c6\u5668<\/a>\u3002\u8be5\u5de5\u5177\u9700\u8981\u8bb8\u53ef\u8bc1\uff0c\u4f46\u63d0\u4f9b\u514d\u8d39\u8bd5\u7528\u671f\u6765\u4f7f\u7528\u5b83\u3002\u7ba1\u9053\u76d1\u89c6\u5668\u63d0\u4f9b\u68c0\u67e5\u7cfb\u7edf\u4e0a\u7ba1\u9053\u6d3b\u52a8\u7684\u529f\u80fd\uff0c\u5e76\u9644\u5e26\u4e00\u4e9b\u7528\u4e8e\u8fdb\u7a0b\u3001\u6587\u4ef6\u540d\u7b49\u7684\u57fa\u672c\u8fc7\u6ee4\u5668\u3002\u5f53\u60a8\u8981\u641c\u7d22\u6211\u7b5b\u9009\u201c*\u201d\u7684\u6240\u6709\u8fdb\u7a0b\u548c\u6240\u6709\u6587\u4ef6\u540d\u65f6\uff0c\u8bf7\u8ba9\u5b83\u8fd0\u884c\u5e76\u4f7f\u7528\u641c\u7d22\u529f\u80fd\u67e5\u627e\u201c\u65e0\u6cd5\u6253\u5f00\u201d\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csandker.io\/public\/img\/2021-01-10-Offensive-Windows-IPC-1-NamedPipes\/Unanswered_NamedPipe.png\" alt=\"\u672a\u5e94\u7b54\u7684\u547d\u540d\u7ba1\u9053\"\/><\/figure>\n\n\n\n<p>\u5982\u679c\u60a8\u77e5\u9053\u4f7f\u7528\u5f00\u6e90\u5de5\u5177\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u4efb\u4f55\u5176\u4ed6\u65b9\u6cd5\uff0c\u8bf7\u544a\u8bc9\u6211\uff08\/&nbsp;<a href=\"https:\/\/twitter.com\/0xcsandker\">0xcsandker<\/a>) \ud83d\ude09<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"killing-pipe-servers\">\u6740\u6b7b\u7ba1\u9053\u670d\u52a1\u5668<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#killing-pipe-servers\"><\/a><\/h4>\n\n\n\n<p>\u5982\u679c\u627e\u4e0d\u5230\u672a\u5e94\u7b54\u7684\u7ba1\u9053\u8fde\u63a5\u5c1d\u8bd5\uff0c\u4f46\u53d1\u73b0\u4e86\u4e00\u4e2a\u6709\u8da3\u7684\u7ba1\u9053\u5ba2\u6237\u7aef\uff0c\u60a8\u5e0c\u671b\u4e0e\u4e4b\u901a\u4fe1\u6216\u6a21\u62df\uff0c\u5219\u83b7\u53d6\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u53e6\u4e00\u4e2a\u9009\u9879\u662f\u7ec8\u6b62\u5176\u5f53\u524d\u7ba1\u9053\u670d\u52a1\u5668\u3002<br>\u5728<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#instance-creation-race-condition\">\u201c\u5b9e\u4f8b\u521b\u5efa\u4e89\u7528\u6761\u4ef6<\/a>\u201d\u90e8\u5206\u4e2d\uff0c\u6211\u5df2\u63cf\u8ff0\u8fc7\uff0c\u60a8\u53ef\u4ee5\u5728\u540c\u4e00\u201c\u547d\u540d\u7a7a\u95f4\u201d\u4e2d\u5177\u6709\u591a\u4e2a\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u547d\u540d\u7ba1\u9053\u3002<br>\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u5c06&nbsp;<em>nMaxInstances<\/em>&nbsp;\u53c2\u6570\u8bbe\u7f6e\u4e3a\u201c1\u201d\uff0c\u5219\u53ef\u4ee5\u521b\u5efa\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u7b2c\u4e8c\u4e2a\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\uff0c\u5e76\u5c06\u81ea\u5df1\u653e\u5165\u961f\u5217\u4e2d\u4ee5\u4e3a\u5ba2\u6237\u7aef\u63d0\u4f9b\u670d\u52a1\u3002\u53ea\u8981\u539f\u59cb\u7ba1\u9053\u670d\u52a1\u5668\u6b63\u5728\u63d0\u4f9b\u670d\u52a1\uff0c\u60a8\u5c31\u4e0d\u4f1a\u6536\u5230\u4efb\u4f55\u5ba2\u6237\u7aef\u8c03\u7528\uff0c\u56e0\u6b64\u6b64\u653b\u51fb\u7684\u60f3\u6cd5\u662f\u7834\u574f\u6216\u6740\u6b7b\u539f\u59cb\u7ba1\u9053\u670d\u52a1\u5668\u4ee5\u4ecb\u5165\u60a8\u7684\u6076\u610f\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<p>\u5f53\u6d89\u53ca\u5230\u6740\u6b7b\u6216\u7834\u574f\u539f\u59cb\u7ba1\u9053\u670d\u52a1\u5668\u65f6\uff0c\u6211\u65e0\u6cd5\u534f\u52a9\u4efb\u4f55\u901a\u7528\u7684\u5148\u51b3\u6761\u4ef6\u6216\u5b9e\u73b0\uff0c\u56e0\u4e3a\u8fd9\u59cb\u7ec8\u53d6\u51b3\u4e8e\u8c01\u5728\u8fd0\u884c\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u53ca\u60a8\u7684\u8bbf\u95ee\u6743\u9650\u548c\u7528\u6237\u6743\u9650\u3002<br>\u5728\u5206\u6790\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u83b7\u53d6 kill \u6280\u672f\u65f6\uff0c\u8bf7\u5c1d\u8bd5\u8df3\u51fa\u6846\u6846\u601d\u8003\uff0c\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u5411\u8fdb\u7a0b\u53d1\u9001\u5173\u95ed\u4fe1\u53f7\uff0c\u4f8b\u5982\uff0c\u53ef\u80fd\u5b58\u5728\u5bfc\u81f4\u670d\u52a1\u5668\u5173\u95ed\u6216\u91cd\u65b0\u542f\u52a8\u7684\u9519\u8bef\u6761\u4ef6\uff08\u8bf7\u8bb0\u4f4f\uff0c\u60a8\u5728\u961f\u5217\u4e2d\u6392\u540d\u7b2c 2 &#8211; \u91cd\u65b0\u542f\u52a8\u53ef\u80fd\u8db3\u4ee5\u8fdb\u5165\u4f4d\u7f6e\uff09\u3002<br>\u53e6\u8bf7\u6ce8\u610f\uff0c\u7ba1\u9053\u670d\u52a1\u5668\u53ea\u662f\u5728\u865a\u62dfFILE_OBJECT\u4e0a\u8fd0\u884c\u7684\u5b9e\u4f8b\uff0c\u56e0\u6b64\uff0c\u4e00\u65e6\u6240\u6709\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u7684\u53e5\u67c4\u5f15\u7528\u8ba1\u6570\u8fbe\u5230 0\uff0c\u6240\u6709\u547d\u540d\u7ba1\u9053\u670d\u52a1\u5668\u90fd\u5c06\u7ec8\u6b62\u3002\u4f8b\u5982\uff0c\u53e5\u67c4\u7531\u8fde\u63a5\u5230\u5b83\u7684\u5ba2\u6237\u7aef\u6253\u5f00\u3002\u56e0\u6b64\uff0c\u670d\u52a1\u5668\u4e5f\u53ef\u80fd\u901a\u8fc7\u6740\u6b7b\u5176\u6240\u6709\u53e5\u67c4\u6765\u6740\u6b7b\uff08\u5f53\u7136\uff0c\u53ea\u6709\u5f53\u5ba2\u6237\u7aef\u5728\u5931\u53bb\u8fde\u63a5\u540e\u8fd4\u56de\u7ed9\u60a8\u65f6\uff0c\u60a8\u624d\u80fd\u83b7\u5f97\u4e00\u4e9b\u4e1c\u897f\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"peeknamedpipe\">PeekNamedPipe<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#peeknamedpipe\"><\/a><\/h3>\n\n\n\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u5bf9\u4ea4\u6362\u7684\u6570\u636e\u611f\u5174\u8da3\uff0c\u800c\u4e0d\u662f\u5bf9\u64cd\u4f5c\u6216\u6a21\u62df\u7ba1\u9053\u5ba2\u6237\u7aef\u611f\u5174\u8da3\u3002<br>\u7531\u4e8e\u6240\u6709\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u90fd\u4f4d\u4e8e\u540c\u4e00\u5c4b\u6a90\u4e0b\uff0c\u56e0\u6b64\u3002\u5728\u540c\u4e00\u4e2a\u5168\u5c40\u201c\u547d\u540d\u7a7a\u95f4\u201d\u4e2d\u3002\u5728\u540c\u4e00\u865a\u62df NPFS \u8bbe\u5907\u9a71\u52a8\u5668\u4e0a\uff08\u5982\u524d\u6240\u8ff0\uff09\uff0c\u6ca1\u6709\u7cfb\u7edf\u5c4f\u969c\u963b\u6b62\u60a8\u8fde\u63a5\u5230\u4efb\u4f55\u4efb\u610f\uff08\u7cfb\u7edf\u6216\u975e\u7cfb\u7edf\uff09\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u5e76\u67e5\u770b\u7ba1\u9053\u4e2d\u7684\u6570\u636e\uff08\u4ece\u6280\u672f\u4e0a\u8bb2\uff0c\u201c\u5728\u7ba1\u9053\u4e2d\u201d\u662f\u6307\u7ba1\u9053\u670d\u52a1\u5668\u5206\u914d\u7684\u5171\u4eab\u5185\u5b58\u90e8\u5206\u5185\uff09\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"prerequisites-2\">\u5148\u51b3\u6761\u4ef6<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#prerequisites-2\"><\/a><\/h4>\n\n\n\n<p>\u5982<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#named-pipe-security\">\u547d\u540d\u7ba1\u9053\u5b89\u5168\u6027<\/a>\u4e00\u8282\u6240\u8ff0\uff0c\u5728\u4fdd\u62a4\u547d\u540d\u7ba1\u9053\u65f6\uff0c\u552f\u4e00\u53ef\u4ee5\u8f6c\u52a8\u7684\u9f7f\u8f6e\u662f\u4f7f\u7528<strong>\u5b89\u5168\u63cf\u8ff0\u7b26<\/strong>\u4f5c\u4e3a&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-createnamedpipea\">CreateNamedPipe<\/a>&nbsp;\u8c03\u7528\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570 \uff08<em>lpSecurityAttributes<\/em>\uff09\u3002\u8fd9\u5c31\u662f\u963b\u6b62\u60a8\u8bbf\u95ee\u4efb\u4f55\u4efb\u610f\u547d\u540d\u7ba1\u9053\u5b9e\u4f8b\u7684\u5168\u90e8\u5185\u5bb9\u3002\u56e0\u6b64\uff0c\u5728\u641c\u7d22\u76ee\u6807\u65f6\uff0c\u60a8\u9700\u8981\u68c0\u67e5\u7684\u53ea\u662f\u662f\u5426\u8bbe\u7f6e\u5e76\u4fdd\u62a4\u4e86\u6b64\u53c2\u6570\u4ee5\u9632\u6b62\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u3002<br>\u5982\u679c\u60a8\u9700\u8981\u6709\u5173\u5b89\u5168\u63cf\u8ff0\u7b26\u548c\u8981\u67e5\u627e\u7684\u5185\u5bb9\uff08DACL \u4e2d\u7684 ACL\uff09\u7684\u4e00\u4e9b\u80cc\u666f\u77e5\u8bc6\uff0c\u8bf7\u67e5\u770b\u6211\u7684\u5e16\u5b50\uff1a<a href=\"https:\/\/csandker.io\/2018\/06\/14\/AWindowsAuthorizationGuide.html#the-security-descriptor-dacl--sacl\">Windows \u6388\u6743\u6307\u5357<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"implementation-2\">\u5b9e\u73b0<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#implementation-2\"><\/a><\/h4>\n\n\n\n<p>\u627e\u5230\u5408\u9002\u7684\u76ee\u6807\u540e\uff0c\u8fd8\u6709\u4e00\u4ef6\u4e8b\u9700\u8981\u8bb0\u4f4f\uff1a\u5982\u679c\u4f7f\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-readfile\">ReadFile<\/a>&nbsp;\u4ece\u547d\u540d\u7ba1\u9053\u8bfb\u53d6\u6570\u636e\uff0c\u5219\u4ece\u670d\u52a1\u5668\u7684\u5171\u4eab\u5185\u5b58\u4e2d\u5220\u9664\u6570\u636e\uff0c\u800c\u4e0b\u4e00\u4e2a\u53ef\u80fd\u5408\u6cd5\u7684\u5ba2\u6237\u7aef\uff08\u5c1d\u8bd5\u4ece\u7ba1\u9053\u8bfb\u53d6\uff09\u5c06\u627e\u4e0d\u5230\u4efb\u4f55\u6570\u636e\uff0c\u5e76\u53ef\u80fd\u5f15\u53d1\u9519\u8bef\u3002<br>\u4f46\u662f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/namedpipeapi\/nf-namedpipeapi-peeknamedpipe\">PeekNamedPipe<\/a>&nbsp;\u51fd\u6570\u6765\u67e5\u770b\u6570\u636e\uff0c\u800c\u65e0\u9700\u5c06\u5176\u4ece\u5171\u4eab\u5185\u5b58\u4e2d\u5220\u9664\u3002<\/p>\n\n\n\n<p>\u57fa\u4e8e\u6211\u7684\u793a\u4f8b\u4ee3\u7801\u7684\u5b9e\u73b0\u7247\u6bb5\u53ef\u80fd\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ all the vars you need\nconst int MESSAGE_SIZE = 512;\nBOOL bSuccess;\nLPCWSTR pipeName = L\"\\\\\\\\.\\\\pipe\\\\fpipe\";\nHANDLE hFile = NULL;\nLPWSTR pReadBuf&#91;MESSAGE_SIZE] = { 0 };\nLPDWORD pdwBytesRead = { 0 };\nLPDWORD pTotalBytesAvail = { 0 };\nLPDWORD pBytesLeftThisMessage = { 0 };\n\/\/ connect to named pipe\nhFile = CreateFile(pipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS, NULL);\n\/\/ sneak peek data\nbSuccess = PeekNamedPipe(\n    hFile,\n    pReadBuf,\n    MESSAGE_SIZE,\n    pdwBytesRead,\n    pTotalBytesAvail,\n    pBytesLeftThisMessage\n);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"references\">\u5f15\u7528<a href=\"https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows-IPC-1-NamedPipes.html#references\"><\/a><\/h2>\n\n\n\n<p>\u5c31\u662f\u8fd9\u6837\uff0c\u5982\u679c\u4f60\u60f3\u7ee7\u7eed\u6df1\u5165\u7814\u7a76\u547d\u540d\u7ba1\u9053\uff0c\u8fd9\u91cc\u6709\u4e00\u4e9b\u5f88\u597d\u7684\u53c2\u8003\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5fae\u8f6f\u5173\u4e8e<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/ipc\/pipes\">\u7ba1\u9053 https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/ipc\/pipes<\/a><\/li><li>Blake Watts\u5173\u4e8e&nbsp;<a href=\"http:\/\/www.blakewatts.com\/namedpipepaper.html\">http:\/\/www.blakewatts.com\/namedpipepaper.html<\/a>&nbsp;\u547d\u540d\u7ba1\u9053\u5b89\u5168\u7684\u8bba\u6587<\/li><li>\u6211\u5728&nbsp;<a href=\"https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/tree\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server\">https:\/\/github.com\/csandker\/InterProcessCommunication-Samples\/tree\/master\/NamedPipes\/CPP-NamedPipe-Basic-Client-Server C++\u5b9e\u65bd<\/a>\u793a\u4f8b<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a https:\/\/csandker.io\/2021\/01\/10\/Offensive-Windows- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[43],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-infoarticle"],"views":1739,"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":1,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":178,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/178"}],"wp:attachment":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}