{"id":73,"date":"2010-03-30T19:57:42","date_gmt":"2010-03-30T17:57:42","guid":{"rendered":"http:\/\/antynet.pl\/word\/?p=73"},"modified":"2010-08-24T21:10:22","modified_gmt":"2010-08-24T19:10:22","slug":"hak-na-bruteforce-ssh-blacklist","status":"publish","type":"post","link":"https:\/\/www.antynet.pl\/index.php\/2010\/03\/30\/hak-na-bruteforce-ssh-blacklist\/","title":{"rendered":"Hak na bruteforce &#8211; SSH blacklist"},"content":{"rendered":"<p>Bruteforce na SSH to strasznie irytuj\u0105ca plaga, szanse na udane w\u0142amanie s\u0105 niewielkie gdy admin dba o serwer.<br \/>\nJednak\u017ce wiecznie za\u015bmiecone logi i sam fakt &#8230; no krew zalewa.<br \/>\nOpisa\u0142em ju\u017c wcze\u015bniej metod\u0119 opart\u0105 o haslimit, dzia\u0142a dobrze ale&#8230; dzi\u015b dodamy jeszcze jedno rozwi\u0105zanie.<\/p>\n<p>Powsta\u0142 fajny projekt, sshbl.org &#8211; (the SSH blacklist), co 15 minut tworzona jest czarna lista adres\u00f3w IP z kt\u00f3rych przeprowadzane s\u0105 ataki.<br \/>\nW prosty spos\u00f3b wykorzystamy t\u0105 list\u0119.<\/p>\n<p>mkdir \/etc\/ssh-brute<br \/>\ncd \/etc\/ssh-brute<br \/>\ntouch ssh.brute<br \/>\nchmod +x ssh.brute<\/p>\n<p>w plik ssh.brute umieszczamy zawarto\u015b\u0107:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n#!\/bin\/bash<\/p>\n<p>PATH=&#8221;\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin&#8221;<\/p>\n<p>adresy=`cat \/tmp\/ipki | grep [0-9] | grep -v &#8222;#&#8221;`<br \/>\nfor x in $adresy<br \/>\ndo<br \/>\niptables -D INPUT -s $x -j DROP<br \/>\ndone<\/p>\n<p>wget\u00a0<a style=\"font-family: Tahoma, Arial, Helvetica, sans-serif; text-decoration: none; color: #34717f;\" title=\"http:\/\/www.sshbl.org\/lists\/base.txt\" href=\"http:\/\/www.sshbl.org\/lists\/base.txt\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.sshbl.org\/lists\/base.txt<\/a> -O \/tmp\/ipki<\/p>\n<p>adresy=`cat \/tmp\/ipki | grep [0-9] | grep -v &#8222;#&#8221;`<br \/>\nfor x in $adresy<br \/>\ndo<br \/>\niptables -I INPUT -s $x -j DROP<br \/>\ndone<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>Teraz do crona dodamy wywo\u0142anie skryptu:<br \/>\n*\/15 * * * * root \/etc\/ssh-brute\/ssh.brute &amp;&gt;\/dev\/null<\/p>\n<p>Powodzenia \ud83d\ude09<\/p>\n<p>Update:<\/p>\n<p>Kilka maszyn szala\u0142o przy dodaniu kolejnych paru tysi\u0119cy wpis\u00f3w w iptables. Dlatego te\u017c pomy\u015bla\u0142em o innej metodzie blokowania listy host\u00f3w z sshbl.org.<br \/>\nPad\u0142o na routing.<\/p>\n<p>Gotowy skrypt:<br \/>\n######################################<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>PATH=&#8221;\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin&#8221;<\/p>\n<p>rm \/tmp\/ipki<br \/>\nwget -q\u00a0<a style=\"font-family: Tahoma, Arial, Helvetica, sans-serif; text-decoration: none; color: #34717f;\" title=\"http:\/\/www.sshbl.org\/lists\/base.txt\" href=\"http:\/\/www.sshbl.org\/lists\/base.txt\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.sshbl.org\/lists\/base.txt<\/a> -O \/tmp\/ipki<\/p>\n<p>adresy=`route -n | grep \\!H | awk '{print $1}&#8217;`<br \/>\nfor x in $adresy<br \/>\ndo<br \/>\nroute del -host $x reject<br \/>\ndone<\/p>\n<p>adresy=`cat \/tmp\/ipki | grep [0-9] | grep -v &#8222;#&#8221;`<br \/>\nfor x in $adresy<br \/>\ndo<br \/>\nroute add -host $x reject<br \/>\ndone<\/p>\n<p>###########################################<\/p>\n<p>Dzia\u0142a wy\u015bmienicie \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bruteforce na SSH to strasznie irytuj\u0105ca plaga, szanse na udane w\u0142amanie s\u0105 niewielkie gdy admin dba o serwer. Jednak\u017ce wiecznie za\u015bmiecone logi i sam fakt &#8230; no krew zalewa. Opisa\u0142em ju\u017c wcze\u015bniej metod\u0119 opart\u0105 o haslimit, dzia\u0142a dobrze ale&#8230; dzi\u015b dodamy jeszcze jedno rozwi\u0105zanie. Powsta\u0142 fajny projekt, sshbl.org &#8211; (the SSH blacklist), co 15 minut [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[6,4],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-iptables","category-sciaga-admina"],"_links":{"self":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":2,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}