{"id":45638,"date":"2024-10-07T00:47:13","date_gmt":"2024-10-06T16:47:13","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45638\/"},"modified":"2024-11-14T10:36:24","modified_gmt":"2024-11-14T02:36:24","slug":"%e8%a9%b3%e8%a7%a3-osquery-%e5%85%b7%e9%ab%94%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45638\/","title":{"rendered":"\u8a73\u89e3 osquery \u5177\u9ad4\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"%e8%a9%b3%e8%a7%a3-osquery-%e5%85%b7%e9%ab%94%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95-bwjTypULfK\">\u8a73\u89e3 osquery \u5177\u9ad4\u4f7f\u7528\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u4f4d\u6642\u4ee3\uff0c\u5b89\u5168\u6027\u548c\u76e3\u63a7\u6210\u70ba\u4e86\u4f01\u696d\u904b\u71df\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002osquery \u662f\u4e00\u500b\u958b\u6e90\u5de5\u5177\uff0c\u80fd\u5920\u5c07\u64cd\u4f5c\u7cfb\u7d71\u7684\u72c0\u614b\u8f49\u63db\u70ba SQL \u67e5\u8a62\uff0c\u8b93\u7528\u6236\u80fd\u5920\u8f15\u9b06\u5730\u6aa2\u7d22\u548c\u5206\u6790\u7cfb\u7d71\u4fe1\u606f\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e osquery \u7684\u5177\u9ad4\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u597d\u5730\u7406\u89e3\u548c\u61c9\u7528\u9019\u4e00\u5de5\u5177\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-osquery%ef%bc%9f-bwjTypULfK\">\u4ec0\u9ebc\u662f osquery\uff1f<\/h2>\n<p>osquery \u662f Facebook \u958b\u767c\u7684\u4e00\u500b\u958b\u6e90\u5de5\u5177\uff0c\u65e8\u5728\u63d0\u4f9b\u4e00\u7a2e\u7c21\u55ae\u7684\u65b9\u5f0f\u4f86\u67e5\u8a62\u64cd\u4f5c\u7cfb\u7d71\u7684\u72c0\u614b\u3002\u5b83\u5c07\u64cd\u4f5c\u7cfb\u7d71\u7684\u5404\u7a2e\u4fe1\u606f\uff08\u5982\u9032\u7a0b\u3001\u7528\u6236\u3001\u7db2\u7d61\u9023\u63a5\u7b49\uff09\u6620\u5c04\u70ba\u8868\u683c\uff0c\u4e26\u5141\u8a31\u7528\u6236\u4f7f\u7528 SQL \u8a9e\u8a00\u9032\u884c\u67e5\u8a62\u3002\u9019\u4f7f\u5f97\u7cfb\u7d71\u7ba1\u7406\u54e1\u548c\u5b89\u5168\u5c08\u5bb6\u80fd\u5920\u66f4\u8f15\u9b06\u5730\u7372\u53d6\u548c\u5206\u6790\u7cfb\u7d71\u6578\u64da\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-osquery-bwjTypULfK\">\u5b89\u88dd osquery<\/h2>\n<p>\u5728\u4f7f\u7528 osquery \u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88dd\u5b83\u3002\u4ee5\u4e0b\u662f\u91dd\u5c0d\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7d71\u7684\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e5%9c%a8-ubuntu-%e4%b8%8a%e5%ae%89%e8%a3%9d-bwjTypULfK\">\u5728 Ubuntu \u4e0a\u5b89\u88dd<\/h3>\n<pre><code>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6A8A1B1D\necho \"deb [arch=amd64] https:\/\/osquery-packages.s3.amazonaws.com\/ubuntu bionic main\" | sudo tee \/etc\/apt\/sources.list.d\/osquery.list\nsudo apt-get update\nsudo apt-get install osquery<\/code><\/pre>\n<h3 id=\"%e5%9c%a8-centos-%e4%b8%8a%e5%ae%89%e8%a3%9d-bwjTypULfK\">\u5728 CentOS \u4e0a\u5b89\u88dd<\/h3>\n<pre><code>sudo yum install https:\/\/osquery-packages.s3.amazonaws.com\/rpm\/osquery-4.8.0-1.x86_64.rpm<\/code><\/pre>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95-bwjTypULfK\">\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u901a\u904e\u547d\u4ee4\u884c\u555f\u52d5 osquery\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"%e5%95%9f%e5%8b%95-osquery-bwjTypULfK\">\u555f\u52d5 osquery<\/h3>\n<pre><code>osqueryi<\/code><\/pre>\n<p>\u9019\u5c07\u555f\u52d5 osquery \u7684\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u754c\u9762\uff0c\u60a8\u53ef\u4ee5\u5728\u6b64\u8f38\u5165 SQL \u67e5\u8a62\u3002<\/p>\n<h3 id=\"%e5%9f%b7%e8%a1%8c%e6%9f%a5%e8%a9%a2-bwjTypULfK\">\u57f7\u884c\u67e5\u8a62<\/h3>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u67e5\u8a62\u793a\u4f8b\uff1a<\/p>\n<ul>\n<li><code>SELECT * FROM processes;<\/code> &#8211; \u7372\u53d6\u7576\u524d\u904b\u884c\u7684\u6240\u6709\u9032\u7a0b\u3002<\/li>\n<li><code>SELECT * FROM users;<\/code> &#8211; \u7372\u53d6\u7cfb\u7d71\u4e2d\u7684\u6240\u6709\u7528\u6236\u3002<\/li>\n<li><code>SELECT * FROM listening_ports;<\/code> &#8211; \u7372\u53d6\u6240\u6709\u6b63\u5728\u76e3\u807d\u7684\u7aef\u53e3\u3002<\/li>\n<\/ul>\n<h2 id=\"%e9%80%b2%e9%9a%8e%e5%8a%9f%e8%83%bd-bwjTypULfK\">\u9032\u968e\u529f\u80fd<\/h2>\n<p>osquery \u4e0d\u50c5\u50c5\u662f\u4e00\u500b\u67e5\u8a62\u5de5\u5177\uff0c\u5b83\u9084\u652f\u6301\u8a31\u591a\u9032\u968e\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<\/p>\n<h3 id=\"%e5%ae%9a%e6%9c%9f%e6%9f%a5%e8%a9%a2-bwjTypULfK\">\u5b9a\u671f\u67e5\u8a62<\/h3>\n<p>\u7528\u6236\u53ef\u4ee5\u8a2d\u7f6e\u5b9a\u671f\u67e5\u8a62\uff0c\u5c07\u67e5\u8a62\u7d50\u679c\u5beb\u5165\u65e5\u8a8c\u6587\u4ef6\u3002\u9019\u5c0d\u65bc\u6301\u7e8c\u76e3\u63a7\u7cfb\u7d71\u72c0\u614b\u975e\u5e38\u6709\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<pre><code>{\n  \"schedule\": {\n    \"processes\": {\n      \"query\": \"SELECT * FROM processes;\",\n      \"interval\": 60\n    }\n  }\n}<\/code><\/pre>\n<h3 id=\"%e6%93%b4%e5%b1%95%e6%80%a7-bwjTypULfK\">\u64f4\u5c55\u6027<\/h3>\n<p>osquery \u652f\u6301\u81ea\u5b9a\u7fa9\u64f4\u5c55\uff0c\u5141\u8a31\u7528\u6236\u6839\u64da\u9700\u8981\u6dfb\u52a0\u65b0\u7684\u8868\u683c\u548c\u67e5\u8a62\u3002\u9019\u4f7f\u5f97 osquery \u53ef\u4ee5\u9748\u6d3b\u5730\u9069\u61c9\u4e0d\u540c\u7684\u9700\u6c42\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-bwjTypULfK\">\u7d50\u8ad6<\/h2>\n<p>osquery \u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u8f15\u9b06\u5730\u67e5\u8a62\u548c\u5206\u6790\u64cd\u4f5c\u7cfb\u7d71\u7684\u72c0\u614b\u3002\u7121\u8ad6\u662f\u7cfb\u7d71\u7ba1\u7406\u54e1\u9084\u662f\u5b89\u5168\u5c08\u5bb6\uff0c\u90fd\u53ef\u4ee5\u5229\u7528 osquery \u63d0\u4f9b\u7684\u529f\u80fd\u4f86\u589e\u5f37\u7cfb\u7d71\u7684\u5b89\u5168\u6027\u548c\u53ef\u898b\u6027\u3002\u901a\u904e\u672c\u6587\u7684\u4ecb\u7d39\uff0c\u5e0c\u671b\u80fd\u5920\u5e6b\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528 osquery\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\u6709\u8208\u8da3\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9748\u6d3b\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u63a2\u8a0e osquery \u7684\u5177\u9ad4\u4f7f\u7528\u65b9\u6cd5\uff0c\u5b78\u7fd2\u5982\u4f55\u6709\u6548\u67e5\u8a62\u548c\u5206\u6790\u7cfb\u7d71\u6578\u64da\uff0c\u63d0\u5347\u5b89\u5168\u6027\u8207\u7ba1\u7406\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-45638","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=45638"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45638\/revisions"}],"predecessor-version":[{"id":45639,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45638\/revisions\/45639"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}