{"id":319,"date":"2025-03-06T17:48:29","date_gmt":"2025-03-06T09:48:29","guid":{"rendered":"https:\/\/jpeng.xyz\/?p=319"},"modified":"2025-03-06T18:14:41","modified_gmt":"2025-03-06T10:14:41","slug":"tcpdump%e6%8a%93%e5%8f%96%e6%8c%87%e5%ae%9a%e8%bf%94%e5%9b%9e%e7%a0%81%e7%9a%84http%e7%bd%91%e7%bb%9c%e5%8c%85","status":"publish","type":"post","link":"https:\/\/jpeng.xyz\/?p=319","title":{"rendered":"tcpdump\u6293\u53d6\u6307\u5b9a\u8fd4\u56de\u7801\u7684http\u7f51\u7edc\u5305"},"content":{"rendered":"<pre><code class=\"line-numbers\">tcpdump -i any -A -s 0 -n 'port 80 and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4] = 0x48545450) and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+4:4] = 0x2f312e31) and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+8:4] = 0x20323030)'\n<\/code><\/pre>\n<p>\u524d\u9762\u7684\u53c2\u6570\u6bd4\u8f83\u7b80\u5355\uff0c\u5c31\u4e0d\u518d\u8be6\u7ec6\u8bf4\u660e\u4e86\uff0c\u6211\u4eec\u5173\u6ce8\u4e0b\u540e\u9762\u88ab\u5355\u5f15\u53f7\u5305\u88f9\u8d77\u6765\u7684\u90a3\u4e32\u957f\u957f\u7684\u8ba9\u4eba\u6709\u70b9\u61f5\u903c\u7684\u8fc7\u6ee4\u8868\u8fbe\u5f0f\uff1a<\/p>\n<pre><code class=\"line-numbers\">port 80 and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4] = 0x48545450) and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+4:4] = 0x2f312e31) and (tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+8:4] = 0x20323030)\n<\/code><\/pre>\n<p>\u5176\u4e2dand\u8d77\u5230\u7684\u4f5c\u7528\u662f\u903b\u8f91\u8fd0\u7b97\u91cc\u9762\u7684\u4e0e\u64cd\u4f5c\u7b26\uff0c\u6211\u4eec\u628a\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u5206\u6210\u56db\u4e2a\u90e8\u5206\uff1a<\/p>\n<p><code>port 80<\/code><br \/>\n\u8fd9\u4e2a\u6bd4\u8f83\u597d\u7406\u89e3\uff0c\u610f\u601d\u5c31\u662f\u8bf4\u6293\u53d6\u53d1\u5f8080\u7aef\u53e3\u548c\u4ece80\u7aef\u53e3\u56de\u6765\u7684\u5305\uff1b<\/p>\n<p><code>tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4] = 0x48545450<\/code><br \/>\n\u8fd9\u6bb5\u7b49\u5f0f\u7684\u524d\u534a\u6bb5\u6bd4\u8f83\u590d\u6742\uff0c\u7b49\u5f0f\u5de6\u8fb9\u8868\u8fbe\u7684\u610f\u601d\u662ftcp\u6570\u636e\u5305\u5f00\u5934\u7684\u56db\u4e2a\u5b57\u8282\uff0c\u7b49\u5f0f\u53f3\u8fb9\u5176\u5b9e\u662fascii\u5b57\u7b26\u7f16\u7801\uff0c\u67e5\u9605\u4e0bascii\u5b57\u7b26\u7f16\u7801\u8868\uff08\u5728linux\u7cfb\u7edf\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7man ascii\u67e5\u9605ascii\u5b57\u7b26\u7f16\u7801\u8868\uff09\uff0c<strong>0x48545450<\/strong>\u5176\u5b9e\u5c31\u662fHTTP<br \/>\n\u90a3\u4e48\u8fd9\u4e2a\u7b49\u5f0f\u7684\u610f\u601d\u5c31\u662f\uff1atcp\u6570\u636e\u6bb5\u7684\u5934\u56db\u4e2a\u5b57\u8282 = HTTP\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u6293\u53d6\u7684\u662fHTTP\u5305\uff1b<\/p>\n<p><code>tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+4:4] = 0x2f312e31<\/code><br \/>\n\u7c7b\u4f3c\u4e8e\u524d\u9762\u7684\u8868\u8fbe\u5f0f\uff0c\u8868\u8fbe\u7684\u610f\u601d\u662f\uff1atcp\u6570\u636e\u6bb5\u7684\u5934\u56db\u4e2a\u5b57\u8282\u4e4b\u540e\u51fa\u73b0\u7684\u56db\u4e2a\u5b57\u8282 = \/1.1\uff0c\u5373http\u7684\u7248\u672c\uff0c\u4e0a\u9762\u89e3\u6790\u51fa\u6765\u7684HTTP\u8fde\u8d77\u6765\u5c31\u662fHTTP\/1.1<\/p>\n<p><code>tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2)+8:4] = 0x20323030<\/code><br \/>\n\u8fd9\u6bb5\u8868\u8fbe\u5f0f\u7684\u610f\u601d\u662f\uff1atcp\u6570\u636e\u6bb5\u7684\u5934\u516b\u4e2a\u5b57\u8282\u4e4b\u540e\u51fa\u73b0\u7684\u56db\u4e2a\u5b57\u8282 = &#8216; 200&#8217;<\/p>\n<p>\u90a3\u73b0\u5728\u6211\u4eec\u6765\u603b\u7ed3\u4e0b\uff0c\u524d\u9762\u90a3\u6bb5\u5784\u957f\u7684\u8868\u8fbe\u5f0f\u7684\u610f\u601d\u5176\u5b9e\u6bd4\u8f83\u7b80\u5355\uff1a<strong>tcp\u6570\u636e\u6bb5\u7684\u524d12\u4e2a\u5b57\u8282 = HTTP\/1.1 200<\/strong><br \/>\n\u8fd9\u5176\u5b9e\u5c31\u662fHTTP\u54cd\u5e94\u62a5\u6587\u7684\u8d77\u59cb\u884c\u3002<\/p>\n<p>\u90a3\u4e48<code>tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4]<\/code>\u8fd9\u79cd\u8868\u8fbe\u5f0f\u8be5\u600e\u4e48\u7406\u89e3\u5462\uff1f<br \/>\n\u6211\u4eec\u5bf9\u8fd9\u6bb5\u8868\u8fbe\u5f0f\u505a\u4e00\u4e2a\u62c6\u5206\uff1a<br \/>\n<code>tcp[12:1]<\/code><br \/>\n<code>tcp[12:1] &amp; 0xf0<\/code><br \/>\n<code>(tcp[12:1] &amp; 0xf0) &gt;&gt; 2<\/code><br \/>\n<code>((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4<\/code><br \/>\n\u7b2c\u4e00\uff0c<code>tcp[12:1]<\/code>\uff0c\u53c2\u8003tcp\u8868\u8fbe\u5f0f\u7684\u8bed\u6cd5\u89e3\u91ca\uff0c<code>tcp[x:y]<\/code>\u8868\u793a\u7684\u610f\u601d\u662f\uff1a\u4ecetcp\u62a5\u6587\u7684\u7b2cx\u5b57\u8282\uff08\u4e0d\u5305\u62ec\u7b2cx\u5b57\u8282\uff09\u4e4b\u540e\uff0c\u8bfb\u53d6y\u4e2a\u5b57\u8282\uff0c\u90a3\u4e48<code>tcp[12:1]<\/code>\u7684\u610f\u601d\u5c31\u662f\u8bf4\uff1a\u8bfb\u53d6tcp\u62a5\u6587\u7684\u7b2c12\u4e2a\u5b57\u8282\u540e\u7684\u4e00\u4e2a\u5b57\u8282\uff0c\u4e5f\u5c31\u662f\u7b2c13\u4e2a\u5b57\u8282\uff0c\u90a3\u4e48tcp\u62a5\u6587\u7684\u7b2c13\u4e2a\u5b57\u8282\u662f\u4ec0\u4e48\u5462\uff1f\u6765\u770b\u4e0btcp\u62a5\u6587\u7684\u7ed3\u6784\u56fe\uff1a<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_41b4467409dbed5cb592f5b5f06ad6be.jpg\"><img decoding=\"async\" src=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_41b4467409dbed5cb592f5b5f06ad6be.jpg\" alt=\"\" \/><\/a><br \/>\n\u4e0a\u9762\u7684\u6bcf\u4e00\u884c\u662f32\u4f4d\uff0c\u4e5f\u5c31\u662f4\u4e2a\u5b57\u8282\uff0c\u7b2c13\u4e2a\u5b57\u8282\uff0c\u4e5f\u5c31\u662f\uff1a4\u4f4d\u5934\u90e8\u957f\u5ea6 + 6\u4f4d\u4fdd\u7559\u7684\u524d\u56db\u4f4d\uff1b<\/p>\n<p>\u7b2c\u4e8c\uff0c<code>tcp[12:1] &amp; 0xf0<\/code>\uff0c \u5176\u5b9e\u5c31\u662f\u628atcp\u62a5\u6587\u7684\u7b2c13\u4e2a\u5b57\u8282\u8bfb\u53d6\u51fa\u6765\uff0c\u524d\u56db\u4f4d\u4e5f\u5c31\u662ftcp\u5934\u90e8\u91cc\u9762\u76844\u4f4d\u5934\u90e8\u957f\u5ea6\uff0c\u540e\u56db\u4f4d\u586b\u51454\u4e2a0\uff0c\u4e5f\u5c31\u662f\u5de6\u79fb\u4e86\u56db\u4f4d\u7684tcp\u62a5\u6587\u7684\u5934\u90e8\u957f\u5ea6\uff0c\u56e0\u4e3a\u6211\u4eec\u591a\u8bfb\u53d6\u4e86\u540e\u9762\u56db\u4f4d\uff1b<\/p>\n<p>\u7b2c\u4e09\uff0c<code>(tcp[12:1] &amp; 0xf0) &gt;&gt; 2<\/code>\uff0c\u4e3a\u4ec0\u4e48\u8981\u53f3\u79fb\u4e24\u4f4d\u5462\uff1f\u5982\u679c\u6211\u4eec\u8981\u5f97\u5230tcp\u62a5\u6587\u5934\u90e8\u7684\u957f\u5ea6\uff0c\u5e94\u8be5\u8981\u76f8\u5e94\u5730\u53f3\u79fb\u56db\u4f4d\u5bf9\u4e0d\u5bf9\uff0c\u56e0\u4e3a\u524d\u9762\u6211\u4eec\u591a\u8bfb\u4e86\u56db\u4f4d\u3002\u4f46\u662f\uff0ctcp\u62a5\u6587\u5934\u90e8\u91cc\u9762\u76844\u4f4d\u5934\u90e8\u957f\u5ea6\u5176\u5b9e\u662ftcp\u6709\u591a\u5c11\u4e2a4\u5b57\u8282\u3002\u90a3\u4e48\uff0c\u5982\u679c\u6211\u4eec\u8981\u5f97\u5230tcp\u62a5\u6587\u5230\u5e95\u6709\u591a\u5c11\u4e2a\u5b57\u8282\u7684\u8bdd\uff0c\u8981\u518d\u5de6\u79fb\u4e24\u4f4d<\/p>\n<p>\u6240\u4ee5\uff0c\u5148\u53f3\u79fb\u56db\u4f4d\u53bb\u6389\u5411\u540e\u591a\u8bfb\u7684\u56db\u4f4d\uff0c\u518d\u5de6\u79fb\u4e24\u4f4d\u4ece\u6709\u591a\u5c11\u4e2a4\u5b57\u8282\u6362\u7b97\u6210\u6709\u591a\u5c11\u4e2a\u5b57\u8282\uff0c\u603b\u5171\u5c31\u662f\u53f3\u79fb\u4e24\u4f4d\u3002<br \/>\n\u4e5f\u5c31\u662f\uff0c<code>(tcp[12:1] &amp; 0xf0) &gt;&gt; 2<\/code><span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\"> tcp\u5934\u90e8\u6709\u591a\u5c11\u4e2a\u5b57\u8282<\/span><\/p>\n<p>\u7b2c\u56db\uff0c<code>((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4<\/code>\uff0c\u7ed3\u54081\u91cc\u9762\u7684\u8868\u8fbe\u5f0f\u6765\u7406\u89e3\uff0c\u610f\u601d\u6bd4\u8f83\u6e05\u695a\u4e86\uff0c\u8bfb\u53d6tcp\u5934\u90e8\u4e4b\u540e\u7684\u6570\u636e\u6bb5\u7684\u524d\u56db\u4e2a\u5b57\u8282\uff01<\/p>\n<p>\u90a3\u4e48\uff0ctcp\u6570\u636e\u6bb5\u5f00\u5934\u7684\u56db\u4e2a\u5b57\u8282\u662f\u4ec0\u4e48\uff1f\u6211\u4eec\u6765\u770b\u4e0btcp\/ip\u56db\u5c42\u534f\u8bae\u4e0b\u7684\u5305\u7ed3\u6784\uff1a<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_c338cbc2d461d0aecadb642f34df18f4.jpg\"><img decoding=\"async\" src=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_c338cbc2d461d0aecadb642f34df18f4.jpg\" alt=\"\" \/><\/a><br \/>\n\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u8bb0\u4f4f\u4e00\u70b9\u5c31\u662f\uff0c\u4e0b\u5c42\u7684\u534f\u8bae\u6570\u636e\u662f\u5728\u4e0a\u5c42\u7684\u6574\u4e2a\u5305\u4f53\u7ed3\u6784\u4e0a\u52a0\u4e0a\u81ea\u5df1\u7684\u5934\u90e8\uff0c\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u7684\u7b49\u5f0f\u5173\u7cfb\uff1a<\/p>\n<p><code>tcp = http + tcp_header<\/code><\/p>\n<p><code>ip = tcp + ip_header<\/code><\/p>\n<p><code>ip = http + tcp_header + ip_header<\/code><\/p>\n<p>\u5982\u679c\u6700\u4e0a\u5c42\u7684\u5e94\u7528\u5c42\u534f\u8bae\u662fhttp\u534f\u8bae\u7684\u8bdd\uff0c\u90a3\u4e48\u53c2\u8003http\u54cd\u5e94\u5305\u62a5\u6587\uff1a<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_eab2b05c58057496594897be97d425e2.jpg\"><img decoding=\"async\" src=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_eab2b05c58057496594897be97d425e2.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u524d12\u4e2a\u5b57\u8282\u6070\u597d\u5c31\u662fHTTP\u7684\u7248\u672c+\u72b6\u6001\u7801<\/p>\n<p>\u4e0b\u9762\u662f\u4f7f\u7528\u4e0a\u9762\u7684tcpdump\u547d\u4ee4\u793a\u4f8b\u6293\u53d6\u5230\u7684\u6d4b\u8bd5\u673a\u54cd\u5e94\u62a5\u6587\uff1a<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_cfd75b98a5b3033fe66b4daaa4599e62.jpg\"><img decoding=\"async\" src=\"https:\/\/jpeng.xyz\/wp-content\/uploads\/2025\/03\/wp_editor_md_cfd75b98a5b3033fe66b4daaa4599e62.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u8bf4\u4e86\u8fd9\u4e48\u591a\uff0c\u662f\u4e0d\u662f\u89c9\u5f97\u6839\u636ehttp\u7684\u8fd4\u56de\u7801\u6765\u6293\u5305\u8fd8\u662f\u6709\u70b9\u590d\u6742\u5462\uff0c\u8981\u6bcf\u6b21\u624b\u64b8\u90a3\u4e32\u8868\u8fbe\u5f0f\u4f30\u8ba1\u4e5f\u662f\u86ee\u86cb\u75bc\u7684\u3002\u5176\u5b9e\u6211\u4eec\u53ef\u4ee5\u7528shell\u811a\u672c\u5bf9tcpdump\u518d\u8fdb\u4e00\u6b65\u5c01\u88c5\u6210httpdump\uff0c\u8f93\u5165\u53c2\u6570\u5c31\u662f\u4f60\u60f3\u6293\u53d6\u7684\u8fd4\u56de\u7801\uff1a<br \/>\n\u6bd4\u5982\u8fd9\u4e2a\u811a\u672c\u6587\u4ef6\u540d\u53ebdump.sh\uff0c\u6267\u884c<br \/>\n<code>.\/dump.sh 200<\/code><br \/>\n\u811a\u672c\u5185\u5bb9\u53c2\u8003\uff1a<\/p>\n<pre><code class=\"line-numbers\">#!\/bin\/sh\n\n#\u5c06\u8f93\u5165\u7684http\u8fd4\u56de\u7801\u8f6c\u6362\u6210ascii\u7801\ncode=`echo <span class=\"katex math inline\">1 | hexdump -C | awk '{print<\/span>2<span class=\"katex math inline\">3<\/span>4}' | grep -Ev \"^<span class=\"katex math inline\">\"`\n\n#\u6293\u5305\nsudo tcpdump -i any -A -s 0 -n \"port 80 and (tcp[((tcp[12:1]&0xf0) &gt;&gt; 2):4] = 0x48545450) and (tcp[((tcp[12:1]&0xf0) &gt;&gt; 2)+4:4] = 0x2f312e31) and (tcp[((tcp[12:1]&0xf0) &gt;&gt; 2)+8:4] = 0x20<\/span>code)\"\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>tcpdump -i any -A -s 0 -n &#8216;por&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[30,31,32,28,29],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-2","tag-http","tag-tcpdump","tag-32","tag-28","tag-29"],"_links":{"self":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":6,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":325,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/325"}],"wp:attachment":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}