{"id":68,"date":"2015-07-02T10:59:19","date_gmt":"2015-07-02T02:59:19","guid":{"rendered":"http:\/\/yyshell.com\/?p=68"},"modified":"2015-09-14T10:09:52","modified_gmt":"2015-09-14T02:09:52","slug":"%e5%88%a9%e7%94%a8tcp_wrappers%e6%9d%a5%e5%8a%a0%e5%9b%balinux","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=68","title":{"rendered":"\u5229\u7528tcp_wrappers\u6765\u52a0\u56faLinux"},"content":{"rendered":"<p>\u4e00\u822c\uff0cLinux\u64cd\u4f5c\u7cfb\u7edf\u90fd\u81ea\u5e26tcp_wrappers-libs\u5305\uff0c\u5229\u7528tcp_wrappers\u89c4\u5219\uff0c\u914d\u5408\u9632\u706b\u5899\uff0c\u53ef\u4ee5\u5f88\u597d\u7684\u542f\u52a8\u52a0\u56faLinux\u7cfb\u7edf\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u5982\u4f55\u77e5\u9053\u7a0b\u5e8f\u662f\u5426\u652f\u6301\u8c03\u7528tcp_wrappers\u89c4\u5219\u5462\uff1f\u53ef\u4ee5\u7528ldd\u547d\u4ee4\u67e5\u8be2\u7a0b\u5e8f\u662f\u5426\u652f\u6301tcp_wrappers\uff0c\u4f8b\u5982\uff1a<br \/>\nldd \/usr\/sbin\/sshd | grep libwrap<br \/>\n\u5982\u679c\u6709\u7ed3\u679c\u51fa\u6765\uff0c\u90a3\u4e48\u8be5\u7a0b\u5e8f\u5c31\u662f\u652f\u6301tcp_wrappers\u7684\u3002<br \/>\ntcp_wrappers\u5229\u7528\/etc\/hosts.allow\u548c\/etc\/hosts.deny\u8fd9\u4e24\u4e2a\u6587\u4ef6\u6765\u63a7\u5236\u5404\u7c7b\u8bbf\u95ee\u3002\u8bb0\u4f4f\uff0callow\u7684\u4f18\u5148\u7ea7\u6bd4deny\u9ad8\uff01<br \/>\n\u9700\u8981\u8bb0\u4f4f\u7684\u662f\uff1a<\/p>\n<ol>\n<li>\u5728allow\u548cdeny\u6587\u4ef6\u4e2d\uff0c\u6bcf\u4e2a\u670d\u52a1\u53ea\u80fd\u6dfb\u52a0\u4e00\u6761\u89c4\u5219\uff01<\/li>\n<li>\u4efb\u4f55\u5bf9\u4e8ehosts.allow \u548c hosts.deny\u6587\u4ef6\u7684\u4fee\u6539\u90fd\u662f\u7acb\u5373\u751f\u6548\u7684\uff01<\/li>\n<\/ol>\n<p>\u8bed\u6cd5\u89c4\u5219\uff1a<br \/>\ndaemon : client [:option1:option2:\u2026]<br \/>\n\u4f8b\u5982\uff0c\u5141\u8bb8abc.com\u8bbf\u95eessh\uff0c\u62d2\u7edd\u6240\u6709\u5176\u4ed6\u7684ssh\u8bbf\u95eehosts.allow:<br \/>\nsshd:.abc.com<br \/>\nhosts.deny:<br \/>\nsshd:ALL<\/p>\n<p>\u62d2\u7edd\u6765\u81eaxyz.com\u548c192.168.1.0\u7f51\u6bb5\u7684ftp\u8bbf\u95ee<br \/>\nhosts.denyvsftpd:192.168.1.,.xyz.com<br \/>\n\u628a\u8bbf\u95ee\u5931\u8d25\u7684\u8bb0\u5f55\u5199\u5165\u65e5\u5fd7\uff1a<br \/>\nvsftpd : 192.168.1. , .xyz.co.in : spawn \/bin\/echo\u00a0 `\/bin\/date` access denied &gt;&gt; \/var\/log\/vsftpd.log : deny<br \/>\n\u901a\u8fc7spawn\u547d\u4ee4\uff0c\u8fd8\u53ef\u4ee5\u628a\u6bcf\u6b21\u5931\u8d25\u767b\u5f55\u7ed9\u7ba1\u7406\u5458\u53d1\u90ae\u4ef6\u901a\u77e5\u3002<\/p>\n<p>\u5ba2\u6237\u7aef\u90e8\u5206\u53ef\u4ee5\u6709\u4e00\u4e0b\u901a\u914d\u7b26\u53ef\u7528\uff1a<br \/>\nALL:\u5339\u914d\u6240\u6709\u670d\u52a1<br \/>\nLOCAL:\u5339\u914d\u6240\u6709\u4e0d\u542b\u70b9\uff08.\uff09\u7684\u4e3b\u673a\uff0c\u4f8b\u5982localhost<br \/>\nKNOWN:\u5339\u914d\u53ef\u4ee5\u88ab\u89e3\u6790\u7684\u4e3b\u673a<br \/>\nUNKNOWN:\u53ef\u4ee5\u88ab\u53cd\u5411\u89e3\u6790\u7684\u4e3b\u673a<br \/>\nPARANOID:\u6b63\u53cd\u5411\u90fd\u4e0d\u53ef\u4ee5\u88ab\u89e3\u6790\u7684\u4e3b\u673a<\/p>\n<p>\u793a\u4f8b\uff1a<br \/>\nALL : 123.12.<br \/>\n\u5339\u914d\u6240\u6709\u5728123.12.0.0\u7f51\u7edc\u7684\u4e3b\u673a\u3002\u6ce8\u610f\uff0c\u6709\u4e2a\u70b9.\u5728\u540e\u9762\u3002<br \/>\nALL : 192.168.0.1\/255.255.255.0<br \/>\nip\u5730\u5740\/\u5b50\u7f51\u63a9\u7801\u80fd\u591f\u5728\u89c4\u5219\u4e2d\u4f7f\u7528\u3002<br \/>\nsshd : \/etc\/sshd.deny<br \/>\n\u5982\u679c\u5ba2\u6237\u7aef\u5217\u8868\u4ee5slash\u5f00\u5934\uff08\/\uff09,\u4f1a\u88ab\u770b\u505a\u4e00\u4e2a\u6587\u4ef6\u540d.\u5728\u4e0a\u4e00\u6761\u89c4\u5219\u4e2d, TCP wrappers\u00a0\u67e5\u9605sshd.deny\u6587\u4ef6\u6765\u76d1\u89c6\u6240\u6709sshd\u8fde\u63a5\u3002<br \/>\nsshd : ALL EXCEPT 192.168.0.15<br \/>\n\u53ea\u5141\u8bb8IP\u5730\u5740192.168.0.15 ssh\u8fde\u63a5\uff0c\u62d2\u7edd\u5176\u4ed6\u6240\u6709\u8fde\u63a5\u3002<br \/>\n\u53ef\u4ee5\u4f7f\u7528allow\u548cdeny\u547d\u4ee4\u6765\u6539\u53d8\u8fde\u63a5\u7684\u5b9a\u4e49\uff08\u5373allow\u6587\u4ef6\u91cc\u9762\u5199\u62d2\u7edd\uff0cdeny\u5199\u5141\u8bb8\uff09<br \/>\nin.telnetd : 192.168.5.5 : deny<br \/>\nin.telnetd : 192.168.5.6 : allow<\/p>\n<p>Shell\u547d\u4ee4<br \/>\n\u4f7f\u7528\u5982\u4e0b\u4e24\u4e2a\u9009\u9879\u53ef\u4ee5\u7ec4\u5408\u6570\u4e2ashell\u547d\u4ee4\uff1a<br \/>\nspawn \u672c\u9009\u9879\u53ef\u4ee5\u628a\u4e00\u4e2ashell\u547d\u4ee4\u4f5c\u4e3a\u5b50\u8fdb\u7a0b\u8fd0\u884c\uff0c\u4f8b\u5982\uff1a<br \/>\nsshd : 192.168.5.5 : spawn \/bin\/echo `\/bin\/date` from %h &gt;&gt; \/var\/log\/ssh.log : deny<br \/>\n\u6bcf\u5f53\u6b64\u6761\u89c4\u5219\u88ab\u5339\u914d\u65f6, \u5f53\u524d\u65f6\u95f4\u548c\u5ba2\u6237\u7aef\u4e3b\u673a\u540d %h \u5c06\u88ab\u8ffd\u52a0\u5230 ssh.log\u00a0\u6587\u4ef6\u3002<br \/>\ntwist\u00a0\u672c\u9009\u9879\u7528\u4e8e\u66ff\u6362\u6307\u5b9a\u547d\u4ee4\u7684\u8bf7\u6c42\u3002\u4f8b\u5982\uff0c\u4f60\u60f3\u53d1\u9001\u901a\u77e5\u5230\u88ab\u8fdb\u9a7bssh\u767b\u5f55\u4f60\u670d\u52a1\u5668\u7684\u4e3b\u673a\u65f6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u9009\u9879\uff1a<br \/>\nsshd : client1.xyz.com : twist \/bin\/echo \u201cYou are prohibited from accessing this service!!\u201d : deny<br \/>\n\u603b\u4e4b\uff0c\u4f7f\u7528spawn\u548ctwist\u53ef\u4f7f\u7528\u5982\u4e0b\u8868\u8fbe\u5f0f\uff1a<br \/>\n%a \u2014\u00a0\u5ba2\u6237\u7aefIP\u5730\u5740\u3002<br \/>\n%A \u2014\u00a0\u670d\u52a1\u7aefIP\u5730\u5740\u3002<br \/>\n%c \u2014 \u63d0\u4f9b\u591a\u6837\u7684\u5ba2\u6237\u7aef\u4fe1\u606f\u3002\u4f8b\u5982\u7528\u6237\u540d\u548c\u4e3b\u673a\u540d\u6216\u8005\u7528\u6237\u540d\u548cIP\u5730\u5740\u3002<br \/>\n%d \u2014\u5b88\u62a4\u8fdb\u7a0b\u7684\u540d\u5b57\u3002<br \/>\n%h \u2014 \u5ba2\u6237\u7aef\u4e3b\u673a\u540d (\u5982\u679c\u4e3b\u673a\u540d\u4e0d\u53ef\u7528\uff0c\u5219\u63d0\u4f9bIP\u5730\u5740).<br \/>\n%H \u2014\u00a0 \u670d\u52a1\u7aef\u4f4f\u4e3b\u673a\u540d (\u5982\u679c\u4e3b\u673a\u540d\u4e0d\u53ef\u7528\uff0c\u5219\u63d0\u4f9bIP\u5730\u5740).<br \/>\n%n \u2014\u00a0\u5ba2\u6237\u7aef\u4e3b\u673a\u540d.\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u663e\u793a\u53cd\u5411\u89e3\u6790\u540d.\u00a0\u5982\u679c\u4e3b\u673a\u540d\u548c\u5730\u5740\u4e0d\u5339\u914d\uff0c\u663e\u793a\u6b63\u53cd\u5411\u89e3\u6790\u90fd\u4e0d\u884c\u3002<br \/>\n%N \u2014\u00a0 \u670d\u52a1\u7aef\u4e3b\u673a\u540d.\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u663e\u793a\u53cd\u5411\u89e3\u6790\u540d.\u00a0\u5982\u679c\u4e3b\u673a\u540d\u548c\u5730\u5740\u4e0d\u5339\u914d\uff0c\u663e\u793a\u6b63\u53cd\u5411\u89e3\u6790\u90fd\u4e0d\u884c\u3002<br \/>\n%p \u2014\u00a0\u5b88\u62a4\u8fdb\u7a0bID\u3002<br \/>\n%s \u2014\u00a0\u663e\u793a\u5927\u91cf\u670d\u52a1\u7aef\u4fe1\u606f\uff0c\u8bf8\u5982\u5b88\u62a4\u8fdb\u7a0b\u548c\u4e3b\u673a\u540d\u548cIP\u5730\u5740\u3002<br \/>\n%u \u2014\u00a0\u5ba2\u6237\u7aef\u7528\u6237\u540d.\u00a0\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53cd\u5411\u89e3\u6790\u4fe1\u606f\u88ab\u663e\u793a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u822c\uff0cLinux\u64cd\u4f5c\u7cfb\u7edf\u90fd\u81ea\u5e26tcp_wrappers-libs\u5305\uff0c\u5229\u7528tcp_<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":2,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}