{"id":1731,"date":"2016-04-14T15:47:06","date_gmt":"2016-04-14T07:47:06","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1731"},"modified":"2016-04-14T17:42:51","modified_gmt":"2016-04-14T09:42:51","slug":"%e4%b8%ba%e5%9f%ba%e4%ba%8elinux%e5%b5%8c%e5%85%a5%e5%bc%8f%e7%b3%bb%e7%bb%9f%e7%9a%84%e4%b8%b2%e5%8f%a3%e5%91%bd%e4%bb%a4%e5%bc%80%e5%90%af%e7%94%a8%e6%88%b7%e5%90%8d%e5%af%86%e7%a0%81%e7%99%bb","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1731","title":{"rendered":"\u4e3a\u57fa\u4e8eLinux\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7684\u4e32\u53e3shell\u5f00\u542f\u7528\u6237\u540d\/\u5bc6\u7801\u767b\u5f55\u529f\u80fd"},"content":{"rendered":"<p>\u4e32\u53e3shell\u7ed9\u5f00\u53d1\u5e26\u6765\u5f88\u591a\u4fbf\u5229\uff0c\u4f46\u91cf\u4ea7\u7684\u4ea7\u54c1\u4e3a\u4e86\u5b89\u5168\u6027\u8003\u8651\uff0c\u8fdb\u884c\u4e32\u53e3\u767b\u5165\u7684\u65f6\u5019\u4e5f\u5e0c\u671b\u50cfssh\u90a3\u6837\u8981\u6c42\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u624d\u80fd\u8fdb\u5165\u63a7\u5236\u53f0\u3002<\/p>\n<p>\u4e00\u3001\u5ba2\u5236\u5316busybox<br \/>\nmake menuconfig<br \/>\nLogin\/Password Management Utilities &#8212;&gt;<br \/>\n[*] login (NEW)<\/p>\n<p>\u4e8c\u3001\u4fee\u6539\u542f\u52a8\u811a\u672c<br \/>\nvim \/etc\/inittab<br \/>\n::askconsole:\/bin\/ash &#8211;login<br \/>\n\u6539\u4e3a<br \/>\n::askconsole:\/bin\/login<\/p>\n<p>\u4e09\u3001root\u5bc6\u7801\u9ed8\u8ba4\u8bbe\u7f6e<br \/>\npackage\/base-files\/files\/etc\/shadow \/\/\u53ef\u4ee5\u901a\u8fc7webui\u8bbe\u7f6e\u597d\uff0c\u67e5\u770b\/etc\/shadow\u6587\u4ef6\uff0c\u518d\u5199\u5230\u6e90\u7801\u3002<\/p>\n<h1 id=\"\u5b98\u7f51wiki\">\u5b98\u7f51wiki<\/h1>\n<p><a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/serial.console.password\" target=\"_blank\">http:\/\/wiki.openwrt.org\/doc\/howto\/serial.console.password<\/a><\/p>\n<h1 id=\"\u6b65\u9aa4\">\u6b65\u9aa4<\/h1>\n<p>\u6b65\u9aa4<br \/>\n\u786e\u8ba4\u5f00\u542fbusybox\u7684login<br \/>\nCONFIG_BUSYBOX_CONFIG_LOGIN=y<\/p>\n<p>\u4fee\u6539\/etc\/inittab<br \/>\n\u628a\u539f\u6765\u7684<br \/>\n::askconsole:\/bin\/ash &#8211;login<br \/>\n\u6539\u6210<br \/>\n::askconsole:\/bin\/login<\/p>\n<p>\u8fd9\u4e2a\u5730\u65b9\u662f\u4f9d\u60c5\u51b5\u800c\u5b9a\u7684\uff0c\u6bd4\u5982\u6211\u76847620A\u56fa\u4ef6\u662f\u8fd9\u6837\u7684<\/p>\n<p>ttyS0::askfirst:\/bin\/ash &#8211;login<br \/>\nttyS1::askfirst:\/bin\/ash &#8211;login<\/p>\n<p>\u76f8\u5e94\u7684\u6539\u6210<\/p>\n<p>ttyS0::askfirst:\/bin\/login<br \/>\nttyS1::askfirst:\/bin\/login<\/p>\n<p>\u5373\u53ef\u3002<br \/>\n\u7981\u7528\u5355\u7528\u6237\u6a21\u5f0f<\/p>\n<p>Single user mode is available through GRUB and allows to boot without password. An attacker is then able to change root password and reboot.<\/p>\n<p>A solution would be to lock-down OpenWRT booloader process, to make sure that booting in linux single user mode is impossible. This has to be discussed and this is not yet documented.<\/p>\n<p>\u7981\u7528\u5355\u7528\u6237\u6a21\u5f0f\u53ef\u4ee5\u505a\u5230\u4e32\u53e3\u4e00\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0croot\u4e00\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u4e0d\u51b2\u7a81\u3002<\/p>\n<p>\u7981\u7528\u4e32\u53e3\u5199\u5165<\/p>\n<p>\u5982\u679c\u50cf\u7981\u7528\u4e32\u53e3\u7684\u5199\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06::askconsole:\/bin\/login\u8fd9\u4e2a\u4e00\u884c\u6ce8\u91ca\u6389\uff0c\u7528#\u6ce8\u91ca\u5373\u53ef\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1>\u4ee5\u4e0a\u4e3a\u53c2\u8003\u6587\u7ae0\uff0c\u5b9e\u9645\u5e94\u7528\u4ee5\u81ea\u5df1\u7684\u7cfb\u7edf\u7248\u672c\u4e3a\u51c6\uff0c\u6bd4\u5982\u6211\u7684\u5f00\u53d1\u5e73\u53f0\uff1a<\/h1>\n<p>&nbsp;<\/p>\n<p>1.busybox\u4e2d\u6ca1\u6709login\u8fd9\u4e00\u9879\u7684\u8bbe\u7f6e\uff0c\u4e8e\u662f\u7f6e\u4e4b\u4e0d\u7406\uff1b<\/p>\n<p>&nbsp;<\/p>\n<p>2.<br \/>\n\u4fee\u6539\/etc\/inittab\uff0c\u539f\u6765\u7684\uff1a<\/p>\n<pre class=\"prettyprint linenums\">::sysinit:\/etc\/init.d\/rcS<br \/>\n#ttyS0::respawn:\/sbin\/getty 115200 ttyS0<br \/>\n#-\/bin\/sh means a login shell<br \/>\n::askfirst:\/bin\/sh<br \/>\n::ctrlaltdel:\/sbin\/reboot<br \/>\n::shutdown:\/bin\/umount ar<br \/>\n::shutdown:\/bin\/mount \/ o remount,ro<\/p>\n<p>&nbsp;<\/p>\n<p>\u6539\u6210\uff1a<\/p>\n<pre class=\"prettyprint linenums\">::sysinit:\/etc\/init.d\/rcS<br \/>\n#ttyS0::respawn:\/sbin\/getty 115200 ttyS0<br \/>\n#-\/bin\/sh means a login shell<br \/>\n::askfirst:\/bin\/login<br \/>\n::ctrlaltdel:\/sbin\/reboot<br \/>\n::shutdown:\/bin\/umount ar<br \/>\n::shutdown:\/bin\/mount \/ o remount,ro<\/p>\n<p>3.\u4fee\u6539\u767b\u5f55\u5bc6\u7801\uff1a<\/p>\n<p>\u6253\u5f00etc\/shadow\uff1a<\/p>\n<pre class=\"prettyprint linenums\">root:<span class=\"katex math inline\">1<\/span>zopmh9fR<span class=\"katex math inline\">spg5skhBiAD10n6Zp0Pu.1:14610:0:99999:7:::<\/p>\n<p>\u4e0a\u9762\u8868\u793a\uff1a\u767b\u5f55\u7528\u6237\u540d\u4e3aroot\uff0c\u5bc6\u7801\u4e3a<\/span>1<span class=\"katex math inline\">zopmh9fR<\/span>spg5skhBiAD10n6Zp0Pu.1<\/p>\n<p>&nbsp;<\/p>\n<p>\u52a0\u5bc6\u540e\u5bc6\u7801\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u751f\u6210\uff1a<\/p>\n<pre class=\"prettyprint linenums\">openssl passwd -1 -salt <span class=\"katex math inline\">(&lt; \/dev\/urandom tr -dc '[:alnum:]' | head -c 32)<\/p>\n<p>Password: # input your password\uff0c\u6bd4\u5982123456<br \/>\n\u7136\u540e\u751f\u6210\uff1a<\/span>1<span class=\"katex math inline\">zopmh9fR<\/span>spg5skhBiAD10n6Zp0Pu.1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e32\u53e3shell\u7ed9\u5f00\u53d1\u5e26\u6765\u5f88\u591a\u4fbf\u5229\uff0c\u4f46\u91cf\u4ea7\u7684\u4ea7\u54c1\u4e3a\u4e86\u5b89\u5168\u6027\u8003\u8651\uff0c\u8fdb\u884c\u4e32\u53e3\u767b\u5165\u7684\u65f6\u5019\u4e5f\u5e0c\u671b\u50cfssh\u90a3\u6837\u8981\u6c42\u8f93\u5165\u7528\u6237 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1731","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1731"}],"version-history":[{"count":6,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1731\/revisions"}],"predecessor-version":[{"id":1737,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1731\/revisions\/1737"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1731"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}