{"id":281859,"date":"2023-09-03T04:04:12","date_gmt":"2023-09-02T20:04:12","guid":{"rendered":"https:\/\/lrxjmw.cn\/lzkbzydkjyhs.html"},"modified":"2023-09-03T04:04:12","modified_gmt":"2023-09-02T20:04:12","slug":"lzkbzydkjyhs","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lzkbzydkjyhs.html","title":{"rendered":"Linux\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\uff1a\u7ecf\u9a8c\u548c\u5b9e\u4f8b\uff01"},"content":{"rendered":"

Linux<\/a>\u4f5c\u4e3a\u4e00\u79cd\u5f00\u6e90\u64cd\u4f5c\u7cfb\u7edf<\/a>\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u670d\u52a1\u5668\u548c\u7f51\u7edc\u8bbe\u5907\u4e2d\u3002\u5728\u65e5\u5e38\u7ef4\u62a4\u548c\u6545\u969c\u6392\u67e5\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\u4fe1\u606f\uff0c\u4ee5\u4fbf\u53ca\u65f6\u5904\u7406\u95ee\u9898\u3002\u672c\u6587\u5c06\u5206\u4eab\u5982\u4f55\u5728Linux\u4e2d\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\u7684\u7ecf\u9a8c\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u6b65\u9aa4\u548c\u5b9e\u4f8b\u3002<\/p>\n

1.\u4f7f\u7528netstat\u547d\u4ee4<\/a><\/p>\n

\u4f7f\u7528netstat\u547d\u4ee4\u662f\u6700\u5e38\u89c1\u7684\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u6d3b\u52a8\u8fde\u63a5\u5e76\u663e\u793a\u76f8\u5e94\u7684\u7aef\u53e3\u4fe1\u606f\uff1a<\/p>\n

\n

bash\nnetstat -tuln\n<\/pre>\n<\/p>\n

\u5176\u4e2d\uff0c-t\u53c2\u6570\u8868\u793aTCP\u8fde\u63a5\uff0c-u\u53c2\u6570\u8868\u793aUDP\u8fde\u63a5\uff0c-l\u53c2\u6570\u8868\u793a\u76d1\u542c\u72b6\u6001\uff0c-n\u53c2\u6570\u8868\u793a\u4ee5\u6570\u5b57\u5f62\u5f0f\u663e\u793a\u7aef\u53e3\u3002<\/p>\n

2.\u4f7f\u7528lsof\u547d\u4ee4<\/p>\n

lsof\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5217\u51fa\u7cfb\u7edf\u4e2d\u6253\u5f00\u6587\u4ef6\u548c\u7f51\u7edc\u8fde\u63a5\u7b49\u76f8\u5173\u4fe1\u606f\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\uff1a<\/p>\n

\n

bash\nlsof -i:\u7aef\u53e3\u53f7\n<\/pre>\n<\/p>\n

linux\u67e5\u770b\u5360\u7528\u7684\u7aef\u53e3\u53f7_\u5360\u7528\u7aef\u53e3\u67e5\u770b_linux \u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3<\/p>\n

\u4f8b\u5982\uff0c\u8981\u67e5\u770b80\u7aef\u53e3\u662f\u5426\u88ab\u5360\u7528\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

bash\nlsof -i:80\n<\/pre>\n<\/p>\n

3.\u4f7f\u7528ss\u547d\u4ee4<\/p>\n

ss\u662f\u4e00\u4e2a\u66ff\u4ee3netstat\u7684\u5de5\u5177\uff0c\u529f\u80fd\u66f4\u52a0\u5f3a\u5927\u4e14\u6548\u7387\u66f4\u9ad8\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u5957\u63a5\u5b57(Sockets)\u4fe1\u606f\uff0c\u5e76\u7b5b\u9009\u51fa\u4e0e\u7279\u5b9a\u7aef\u53e3\u76f8\u5173\u7684\u8bb0\u5f55\uff1a<\/p>\n

\n

bash\nss -tuln | grep \u7aef\u53e3\u53f7\n<\/pre>\n<\/p>\n

\u4f8b\u5982linux \u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3<\/strong>\uff0c\u8981\u67e5\u770b22\u7aef\u53e3\u662f\u5426\u88ab\u5360\u7528\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

bash\nss -tuln | grep 22\n<\/pre>\n<\/p>\n

4.\u4f7f\u7528fuser\u547d\u4ee4<\/p>\n

fuser\u547d\u4ee4\u7528\u4e8e\u8bc6\u522b\u5e76\u7ec8\u6b62\u6b63\u5728\u4f7f\u7528\u67d0\u4e2a\u6587\u4ef6\u3001\u5957\u63a5\u5b57\u6216\u6587\u4ef6\u7cfb\u7edf\u7684\u8fdb\u7a0b\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\u4ee5\u53ca\u5bf9\u5e94\u7684\u8fdb\u7a0b\u4fe1\u606f\uff1a<\/p>\n

\n

bash\nfuser \u7aef\u53e3\u53f7\/tcp\n<\/pre>\n<\/p>\n

\u4f8b\u5982\uff0c\u8981\u67e5\u770b3306\u7aef\u53e3\u662f\u5426\u88ab\u5360\u7528linux\u64cd\u4f5c\u7cfb\u7edf\u600e\u4e48\u6837\uff0c\u5e76\u627e\u51fa\u5bf9\u5e94\u7684\u8fdb\u7a0bID\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

bash\nfuser 3306\/tcp\n<\/pre>\n<\/p>\n

5.\u4f7f\u7528nmap\u547d\u4ee4<\/p>\n

nmap\u662f\u4e00\u6b3e\u7f51\u7edc\u626b\u63cf\u5de5\u5177\uff0c\u9664\u4e86\u7528\u4e8e\u626b\u63cf\u4e3b\u673a\u548c\u7aef\u53e3\u72b6\u6001\u5916\uff0c\u8fd8\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u626b\u63cf\u6307\u5b9aIP\u5730\u5740\u4e0a\u7684\u6240\u6709\u5f00\u653e\u7aef\u53e3\uff1a<\/p>\n

\n

bash\nnmap IP\u5730\u5740\n<\/pre>\n<\/p>\n

\u4f8b\u5982\uff0c\u8981\u626b\u63cf192.168.0.1\u4e0a\u7684\u6240\u6709\u5f00\u653e\u7aef\u53e3\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

bash\nnmap 192.168.0.1\n<\/pre>\n<\/p>\n

6.\u4f7f\u7528tcpdump\u547d\u4ee4<\/p>\n

tcpdump\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7f51\u7edc\u6293\u5305\u5de5\u5177\uff0c\u53ef\u4ee5\u6355\u83b7\u548c\u5206\u6790\u7f51\u7edc\u6570\u636e\u5305\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u76d1\u542c\u6307\u5b9a\u7aef\u53e3\u7684\u6570\u636e\u6d41\u91cf\uff1a<\/p>\n

\n

bash\ntcpdump -i\u7f51\u7edc\u63a5\u53e3 port \u7aef\u53e3\u53f7\n<\/pre>\n<\/p>\n

\u4f8b\u5982\uff0c\u8981\u76d1\u542ceth0\u63a5\u53e3\u4e0a\u768480\u7aef\u53e3\u6570\u636e\u6d41\u91cf\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

bash\ntcpdump -i eth0 port 80\n<\/pre>\n<\/p>\n

7.\u4f7f\u7528iptables\u547d\u4ee4<\/p>\n

iptables\u662fLinux\u4e2d\u7684\u4e00\u4e2a\u9632\u706b\u5899\u5de5\u5177\uff0c\u4e5f\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u5f00\u653e\u7684\u7aef\u53e3\uff1a<\/p>\n

\n

bash\niptables -L-n\n<\/pre>\n<\/p>\n

\u5176\u4e2d\uff0c-L\u53c2\u6570\u8868\u793a\u5217\u51fa\u89c4\u5219\uff0c-n\u53c2\u6570\u8868\u793a\u4ee5\u6570\u5b57\u5f62\u5f0f\u663e\u793a\u7aef\u53e3\u3002<\/p>\n

8.\u4f7f\u7528\/6844acdce7e192c21c184914d73ab6be\u6587\u4ef6\u7cfb\u7edf<\/p>\n

\u5728Linux\u4e2d\uff0c\/6844acdce7e192c21c184914d73ab6be\u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u5bf9\u5185\u6838\u548c\u8fdb\u7a0b\u4fe1\u606f\u7684\u8bbf\u95ee\u3002\u901a\u8fc7\u8bfb\u53d6\/6844acdce7e192c21c184914d73ab6be\/net\/tcp\u548c\/6844acdce7e192c21c184914d73ab6be\/net\/udp\u6587\u4ef6\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6253\u5f00\u7684TCP\u548cUDP\u8fde\u63a5\u4fe1\u606f\uff0c\u4ece\u800c\u83b7\u53d6\u88ab\u5360\u7528\u7684\u7aef\u53e3\u3002<\/p>\n

9.\u4f7f\u7528GUI\u5de5\u5177<\/p>\n

\u9664\u4e86\u547d\u4ee4\u884c\u5de5\u5177\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u56fe\u5f62\u5316\u754c\u9762(GUI)\u5de5\u5177\u53ef\u4f9b\u9009\u62e9\u3002\u4f8b\u5982\uff0c\u4f7f\u7528net-tools\u5305\u4e2d\u7684GUI\u5de5\u5177netstat\u6216\u4f7f\u7528lsof\u547d\u4ee4\u7684\u56fe\u5f62\u524d\u7aeflsofGUI\u7b49\u3002<\/p>\n

10.\u603b\u7ed3\u4e0e\u6ce8\u610f\u4e8b\u9879<\/p>\n

\u5728\u4f7f\u7528\u4ee5\u4e0a\u65b9\u6cd5\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n

-\u9700\u8981root\u6743\u9650\u6216\u76f8\u5e94\u7684\u7528\u6237\u6743\u9650\u624d\u80fd\u6267\u884c\u67d0\u4e9b\u547d\u4ee4\uff1b<\/p>\n

-\u7ed3\u679c\u4e2d\u663e\u793a\u7684\u8fdb\u7a0bID\uff08PID\uff09\u53ef\u4ee5\u901a\u8fc7ps\u547d\u4ee4\u8fdb\u4e00\u6b65\u67e5\u770b\u5bf9\u5e94\u7684\u8fdb\u7a0b\u4fe1\u606f\uff1b<\/p>\n

-\u5bf9\u4e8e\u5b89\u5168\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u7cfb\u7edflinux \u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3<\/strong>\uff0c\u5e94\u5b9a\u671f\u68c0\u67e5\u88ab\u5360\u7528\u7aef\u53e3\u5e76\u53ca\u65f6\u5904\u7406\u5f02\u5e38\u60c5\u51b5\u3002<\/p>\n

\u901a\u8fc7\u672c\u6587\u4ecb\u7ecd\u7684\u591a\u79cd\u65b9\u6cd5linux\u5b89\u5168\u52a0\u56fa\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u88ab\u5360\u7528\u7684\u7aef\u53e3\u4fe1\u606f\u3002\u5728\u5b9e\u9645\u8fd0\u7ef4\u548c\u6545\u969c\u6392\u67e5\u4e2d\uff0c\u719f\u7ec3\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\u5c06\u6781\u5927\u5730\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u5e2e\u52a9\u60a8\u5feb\u901f\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002\u795d\u60a8\u5728Linux\u7cfb\u7edf\u7ba1\u7406\u548c\u7ef4\u62a4\u4e2d\u53d6\u5f97\u66f4\u597d\u7684\u6210\u679c\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u672c\u6587\u5c06\u5206\u4eab\u5982\u4f55\u5728Linux\u4e2d\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\u7684\u7ecf\u9a8c\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u6b65\u9aa4\u548c\u5b9e\u4f8b\u3002\u4f7f\u7528netstat\u547d\u4ee4\u662f\u6700\u5e38\u89c1\u7684\u67e5\u770b\u88ab\u5360\u7528\u7aef\u53e3\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002iptables\u662fLinux\u4e2d\u7684\u4e00\u4e2a\u9632\u706b\u5899\u5de5\u5177\uff0c\u4e5f\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u88ab\u5360\u7528\u7684\u7aef\u53e3\u3002<\/p>\n","protected":false},"author":1,"featured_media":281860,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-281859","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/281859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=281859"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/281859\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/281860"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=281859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=281859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=281859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}