{"id":6323,"date":"2023-05-12T20:18:55","date_gmt":"2023-05-12T17:18:55","guid":{"rendered":"http:\/\/surgery.moscow\/smos\/?p=6323"},"modified":"2023-05-15T10:33:09","modified_gmt":"2023-05-15T07:33:09","slug":"%d0%b7%d0%b0%d1%89%d0%b8%d1%82%d0%b0-%d0%be%d1%82-ddos-%d0%b0%d1%82%d0%b0%d0%ba","status":"publish","type":"post","link":"https:\/\/surgery.moscow\/smos\/2023\/05\/12\/%d0%b7%d0%b0%d1%89%d0%b8%d1%82%d0%b0-%d0%be%d1%82-ddos-%d0%b0%d1%82%d0%b0%d0%ba\/","title":{"rendered":"\u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 ddoS \u0430\u0442\u0430\u043a"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c \u0441\u0430\u0439\u0442  \u043e\u0442 ddoS \u0430\u0442\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e bash ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043b\u044f\u0435\u043c Bash \u0441\u043a\u0440\u0438\u043f\u0442,  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>#!\/bin\/bash\n\nTHRESHOLD=100 # \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439\nLOGFILE=\/var\/log\/apache2\/access.log # \u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u043b\u043e\u0433\u043e\u0432\n\nwhile true\ndo\n  COUNT=$(tail -n 1000 $LOGFILE | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{print $1}')\n  if &#91;&#91; $COUNT -gt $THRESHOLD ]]\n  then\n    echo \"Possible DDOS attack detected with $COUNT connections\"\n    echo \"Source IPs:\"\n    tail -n 1000 $LOGFILE | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{print $2}'\n    # \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 IP \u0430\u0434\u0440\u0435\u0441\u043e\u0432<\/strong>\n    # \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 IP \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043a\u043e\u0442\u043e\u0440\u044b\u0445\n    # \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f    \u0430\u0442\u0430\u043a\u0430<strong>\n  fi\n  sleep 10 # \u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438\ndone<\/strong><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c \u0441\u0430\u0439\u0442 \u043e\u0442 ddoS \u0430\u0442\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e bash ? \u041f\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043b\u044f\u0435\u043c Bash \u0441\u043a\u0440\u0438\u043f\u0442,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,12,22],"tags":[],"class_list":["post-6323","post","type-post","status-publish","format-standard","hentry","category-computer","category-internet","category-technology"],"_links":{"self":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/6323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/comments?post=6323"}],"version-history":[{"count":4,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/6323\/revisions"}],"predecessor-version":[{"id":6327,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/posts\/6323\/revisions\/6327"}],"wp:attachment":[{"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/media?parent=6323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/categories?post=6323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/surgery.moscow\/smos\/wp-json\/wp\/v2\/tags?post=6323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}