{"id":122293,"date":"2018-10-07T08:38:46","date_gmt":"2018-10-07T00:38:46","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=122293"},"modified":"2018-09-30T09:40:06","modified_gmt":"2018-09-30T01:40:06","slug":"shell-apache","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/shell-apache.html","title":{"rendered":"\u5982\u4f55\u5728Apache\u4e2d\u7528shell\u811a\u672c\u63d0\u4ea4\u7f51\u7ad9404\u6b7b\u94fe"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u7f51\u7ad9\u8fd0\u8425\u4eba\u5458\u5bf9\u4e8e\u6b7b\u94fe\u8fd9\u4e2a\u6982\u5ff5\u4e00\u5b9a\u4e0d\u964c\u751f\uff0c\u7f51\u7ad9\u7684\u4e00\u4e9b\u6570\u636e\u5220\u9664\u6216\u9875\u9762\u6539\u7248\u7b49\u90fd\u5bb9\u6613\u5236\u9020\u6b7b\u94fe\uff0c\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u4e0d\u8bf4\uff0c\u8fc7\u591a\u7684\u6b7b\u94fe\u8fd8\u4f1a\u5f71\u54cd\u5230\u7f51\u7ad9\u7684\u6574\u4f53\u6743\u91cd\u6216\u6392\u540d\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u00a0\u767e\u5ea6\u7ad9\u957f\u5e73\u53f0\u63d0\u4f9b\u7684\u6b7b\u94fe\u63d0\u4ea4\u5de5\u5177,\u53ef\u5c06\u7f51\u7ad9\u5b58\u5728\u7684\u6b7b\u94fe(\u534f\u8bae\u6b7b\u94fe\u3001404\u9875\u9762)\u8fdb\u884c\u63d0\u4ea4,\u53ef\u5feb\u901f\u5220\u9664\u6b7b\u94fe,\u5e2e\u52a9\u7f51\u7ad9SEO\u4f18\u5316\u3002\u5728\u63d0\u4ea4\u6b7b\u94fe\u7684\u6587\u4ef6\u4e2d\u9010\u4e2a\u624b\u52a8\u586b\u5199\u6b7b\u94fe\u7684\u8bdd\u592a\u9ebb\u70e6\uff0c\u5de5\u4f5c\u4e2d\u6211\u4eec\u63d0\u5021\u590d\u6742\u81ea\u52a8\u5316\uff0c\u6240\u4ee5\u672c\u6587\u6211\u4eec\u4e00\u8d77\u4ea4\u6d41\u5206\u4eabApache\u670d\u52a1\u4e2d\u901a\u8fc7shell\u811a\u672c\u6574\u7406\u7f51\u7ad9\u6b7b\u94fe\uff0c\u4fbf\u4e8e\u6211\u4eec\u63d0\u4ea4\u3002<\/p>\n

\u00a0\"\"<\/p>\n

1.\u914d\u7f6eApache\u8bb0\u5f55\u641c\u7d22\u5f15\u64ce<\/strong><\/div>\n

Apache\u662f\u76ee\u524d\u7f51\u7ad9\u5efa\u8bbe\u6700\u4e3a\u4e3b\u6d41\u7684web\u670d\u52a1\uff0c\u4f46\u662fapache\u7684\u65e5\u5fd7\u6587\u4ef6\u9ed8\u8ba4\u662f\u4e0d\u8bb0\u5f55\u767e\u5ea6\u3001\u8c37\u6b4c\u7b49\u5404\u5927\u641c\u7d22\u5f15\u64ce\u7684\u722c\u53d6\u7a0b\u5e8f\u7684\uff0c\u6240\u4ee5\u9996\u5148\u9700\u8981\u6211\u4eec\u8bbe\u7f6eApache\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

\u627e\u5230Apache\u7684\u914d\u7f6e\u6587\u4ef6httpd.conf\uff0c\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u5230\u4e0b\u9762\u4e24\u884c\uff1a<\/p>\n

CustomLog \"logs\/access_log\" common\r\n #CustomLog \"logs\/access_log\" combined<\/pre>\n

\u00a0
\n\u9ed8\u8ba4\u91c7\u7528\u7684\u662fcommon\uff0c\u8fd9\u91cc\u6211\u4eec\u53ea\u9700\u8981\u5c06common\u8fd9\u4e00\u884c\u524d\u9762\u52a0#\u6ce8\u91ca\u6389,\u7136\u540e\u5c06combined\u8fd9\u4e00\u884c\u524d\u7684#\u53bb\u6389\u5373\u53ef\u3002\u7136\u540e\u4fdd\u5b58\u91cd\u542fApache\u670d\u52a1\u3002<\/p>\n

\u6ce8\uff1a\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u4e0a\u6dfb\u52a0\u4e86\u591a\u4e2a\u7ad9\u70b9\uff0c\u6bcf\u4e2a\u7ad9\u70b9\u6709\u5355\u72ec\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5219\u6211\u4eec\u53ea\u9700\u8981\u5728\u76f8\u5e94\u7ad9\u70b9\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6eCustomLog\u9879\u5373\u53ef\uff0c\u4f8b\u5982\uff1a<\/p>\n

\r\nvim \/usr\/local\/apache\/conf\/vhost\/www.chanzhi.org.conf\r\n\r\n\r\n    ServerAdmin [email\u00a0protected] DocumentRoot \"\/data\/wwwroot\/www.chanzhi.org\"\r\n    ServerName www.chanzhi.org\r\n    ServerAlias chanzhi.org\r\n    ErrorLog \"\/data\/wwwlogs\/www.chanzhi.org_error_apache.log\"\r\n    CustomLog \"\/data\/wwwlogs\/www.chanzhi.org_apache.log\" combined\r\n\r\n    SetOutputFilter DEFLATE\r\n    Options FollowSymLinks ExecCGI\r\n    Require all granted\r\n    AllowOverride All\r\n    Order allow,deny\r\n    Allow from all\r\n    DirectoryIndex index.html index.php<\/pre>\n

\u4e0b\u9762\u662f\u914d\u7f6e\u524d\u540e\u7684\u7f51\u7ad9\u65e5\u5fd7\u8bb0\u5f55\u683c\u5f0f\uff1a<\/p>\n

\u914d\u7f6e\u524d\uff1a
\n\"\"<\/p>\n

\u914d\u7f6e\u540e\uff1a<\/p>\n

\"\"<\/p>\n

2.\u7f16\u5199shell\u811a\u672c<\/strong><\/div>\n

\u6211\u4eec\u901a\u8fc7shell\u811a\u672c\u83b7\u53d6\u7f51\u7ad9\u65e5\u5fd7\u4e2d\u6307\u5b9a\u722c\u866b\u7684\u6293\u53d6\u8bb0\u5f55\uff0c\u7136\u540e\u6c47\u603b\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4fbf\u4e8e\u540e\u671f\u4f7f\u7528\u3002\u4ee3\u7801\u5982\u4e0b\uff0c\u6bd4\u5982\u4fdd\u5b58\u4e3adeathlink.sh<\/p>\n

#!\/bin\/bash\r\n#\u521d\u59cb\u5316\u53d8\u91cf\r\n#\u5b9a\u4e49\u8718\u86dbUA\u4fe1\u606f\uff08\u9ed8\u8ba4\u662f\u767e\u5ea6\u8718\u86db\uff09\r\nUA='+http:\/\/www.baidu.com\/search\/spider.html'\r\n \r\n#\u524d\u4e00\u5929\u7684\u65e5\u671f\uff08apache\u65e5\u5fd7\uff09\r\nDATE=`date +%Y%m%d -d \"1 day ago\"`\r\n \r\n#\u5b9a\u4e49\u65e5\u5fd7\u8def\u5f84\r\nlogfile=\/data\/wwwlogs\/www.chanzhi.org_apache.log-${DATE}.log\r\n \r\n#\u5b9a\u4e49\u6b7b\u94fe\u6587\u4ef6\u5b58\u653e\u8def\u5f84\r\ndeathfile=\/data\/wwwroot\/www.chanzhi.org\/deathlink.txt\r\n \r\n#\u5b9a\u4e49\u7f51\u7ad9\u8bbf\u95ee\u5730\u5740\r\nwebsite=http:\/\/www.chanzhi.org\r\n \r\n#\u5206\u6790\u65e5\u5fd7\u5e76\u4fdd\u5b58\u6b7b\u94fe\u6570\u636e\r\nfor url in `awk -v str=\"${UA}\" '$9==\"404\" && $15~str {print $7}' ${logfile}`\r\ndo\r\n  grep -q \"$url\" ${deathfile} || echo ${website}${url} >>${deathfile}\r\ndone\r\n\u00a0<\/pre>\n

\u5927\u5bb6\u5728\u4f7f\u7528\u8be5\u811a\u672c\u65f6\uff0c\u6839\u636e\u81ea\u5df1\u670d\u52a1\u5668\u60c5\u51b5\u8c03\u6574\u4e0b\u8def\u5f84\u548c\u5b57\u6bb5\u5373\u53ef\uff0c\u7136\u540e\u6267\u884c\u811a\u672c,\uff1a<\/p>\n

bash deathlink.sh\r\n\u00a0<\/pre>\n
3.\u63d0\u4ea4\u6b7b\u94fe<\/strong><\/div>\n

\u6267\u884c\u4e0a\u9762\u811a\u672c\u65f6\u5019\uff0c\u5c31\u4f1a\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u751f\u6210\u5305\u542b\u6240\u6709\u83b7\u53d6\u7684404\u9875\u9762\u94fe\u63a5\u7684\u6587\u4ef6\uff0c\u6bcf\u4e2a\u8fde\u63a5\u5360\u4e00\u884c\u3002\u4f8b\u5982\uff1a<\/p>\n

\"\"<\/p>\n

\u6700\u540e\u5728\u7ad9\u957f\u5e73\u53f0\u63d0\u4ea4\u6b7b\u94fe\u9875\u9762\u4e2d\uff0c\u586b\u5199\u81ea\u5df1\u7684\u6b7b\u94fe\u6587\u4ef6\u5730\u5740\u5373\u53ef\uff0c\u4f8b\u5982\uff1a<\/p>\n

\"\"<\/p>\n

\u767e\u5ea6\u5728\u5ba1\u6838\u901a\u8fc7\u4e4b\u540e\uff0c\u4f1a\u5c06\u5df2\u7ecf\u6536\u5f55\u7684\u5931\u6548\u94fe\u63a5\u5220\u9664\uff0c\u4ee5\u907f\u514d\u5931\u6548\u9875\u9762\u94fe\u63a5\u5bf9\u7f51\u7ad9\u9020\u6210\u4e0d\u826f\u7684\u5f71\u54cd\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/my.oschina.net\/u\/1385850\/blog\/1544586<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/shell-apache.html<\/a>\u7f16\u8f91\uff1a\u5411\u91d1\u5e73\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u7f51\u7ad9\u8fd0\u8425\u4eba\u5458\u5bf9\u4e8e\u6b7b\u94fe\u8fd9\u4e2a\u6982\u5ff5\u4e00\u5b9a\u4e0d\u964c\u751f\uff0c\u7f51\u7ad9\u7684\u4e00\u4e9b\u6570\u636e\u5220\u9664\u6216\u9875\u9762\u6539\u7248\u7b49\u90fd\u5bb9\u6613\u5236\u9020\u6b7b\u94fe\uff0c\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u4e0d\u8bf4\uff0c […]<\/p>\n","protected":false},"author":1482,"featured_media":122319,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-122293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/122293","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\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=122293"}],"version-history":[{"count":10,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/122293\/revisions"}],"predecessor-version":[{"id":122506,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/122293\/revisions\/122506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/122319"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=122293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=122293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=122293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}