'프로그램 사용/fail2ban'에 해당되는 글 8건

  1. 2019.03.20 fail2ban with 404 2
  2. 2017.03.06 fail2ban error 100
  3. 2017.03.06 fail2ban ssh 차단 실패???
  4. 2017.02.28 fail2ban phpmyadmin
  5. 2017.02.15 fail2ban 재시작을 위한 차단목록 추가?
  6. 2017.02.09 fail2ban 차단 관련...
  7. 2017.02.08 ssh 로그인 보안 - fail2ban 4
  8. 2017.02.08 apache ip deny

회사 홈페이지 보니 예전에 집에서 라즈베리 서버 돌리던때와 같이

권한탈취하기 위해서 각종 url 입력하는 놈들이 또 보이는데

항상 그렇지만 아이피 차단한다고 해서 어떻게 될 놈들도 아니고...


고민하다 보니 404 에러를 1초에 몇번 혹은

1분 이내에 몇번 이상 내는 놈들에게 한해서는 자동 차단하면 어떨까 싶어서 찾아보니 있다!


[링크 : https://serverfault.com/questions/849854/fail2ban-blocking-behaviours-depending-on-the-status-code]

[링크 : https://serverfault.com/questions/918151/how-to-block-ips-that-cause-excessive-404-errors-with-fail2ban]


2019.04.01

[링크 : https://medium.com/@animirr/brute-force-protection-node-js-examples-cd58e8bd9b8d]

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban error 100  (0) 2017.03.06
fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
Posted by 구차니

ssh가 차단이 안되서 좀 봤더니..

이런식으로 ssh 를 만들다가 실패하는거 같은데..

다시 보니.. unban이 실패네?

770 2017-03-06 11:33:08,276 fail2ban.actions[1253]: WARNING [ssh] Unban 117.179.164.237

771 2017-03-06 11:33:08,311 fail2ban.actions.action[1253]: ERROR   iptables -D fail2ban-ssh -s 117.179.164.237/24 -j REJECT --reject-with icmp-port-unreachable returned 100 


...


 828 2017-03-06 11:33:09,223 fail2ban.jail   [1253]: INFO    Jail 'ssh' stopped

 829 2017-03-06 11:33:09,893 fail2ban.jail   [1253]: INFO    Jail 'apache-multiport' stopped

 830 2017-03-06 11:33:09,896 fail2ban.server [1253]: INFO    Exiting Fail2ban

 831 2017-03-06 11:33:22,281 fail2ban.server [1184]: INFO    Changed logging target to /var/log/fail2ban.log for Fa     il2ban v0.8.13

 832 2017-03-06 11:33:22,297 fail2ban.jail   [1184]: INFO    Creating new jail 'ssh'

 833 2017-03-06 11:33:22,595 fail2ban.jail   [1184]: INFO    Jail 'ssh' uses pyinotify

 834 2017-03-06 11:33:22,891 fail2ban.jail   [1184]: INFO    Initiated 'pyinotify' backend


아무튼 이거는 race condition으로 추측되서 아래와 같이 수정해주면 된다는데 아직까진 티는 안나네

$ sudo vi /usr/bin/fail2ban-client

def __processCmd(self, cmd, showRet = True):

          beautifier = Beautifier()

          for c in cmd:

               time.sleep(0.1) 

               beautifier.setInputCmd(c)


[링크 : http://www.evilbox.ro/linux/fail2ban-iptables-error-on-ispconfig-on-ubuntu-11/]

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban with 404  (2) 2019.03.20
fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
Posted by 구차니

머지??

도대체 어떻게 차단되었는데 또 ssh로 접속을 하는거야?!?!?

혹시.. 차단되기 전에 동시에 세션 몇십개 열어두고 순차적으로 시도해서 끊어지던 말던

연결된것들 까진 차단 안되니 그렇게 하는건가?

720 2017-03-01 02:18:17,757 fail2ban.actions[1253]: WARNING [ssh] Ban 117.179.164.237

721 2017-03-01 02:18:26,883 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

722 2017-03-01 02:18:35,897 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

723 2017-03-01 02:18:53,922 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

724 2017-03-01 02:19:03,936 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

725 2017-03-01 02:19:14,952 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

726 2017-03-01 02:19:24,966 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

727 2017-03-01 02:19:34,981 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned

728 2017-03-01 02:19:43,995 fail2ban.actions[1253]: INFO    [ssh] 117.179.164.237 already banned 


엥? 차단 되었는데 어떻게 계속 접속하지?!?! 머지?!?!

8438 Mar  1 02:18:08 raspberrypi sshd[10320]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8439 Mar  1 02:18:08 raspberrypi sshd[10320]: input_userauth_request: invalid user root [preauth]

8440 Mar  1 02:18:08 raspberrypi sshd[10320]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8441 Mar  1 02:18:11 raspberrypi sshd[10320]: Failed password for invalid user root from 117.179.164.237 port 22077 ssh2

8442 Mar  1 02:18:13 raspberrypi sshd[10320]: Failed password for invalid user root from 117.179.164.237 port 22077 ssh2

8443 Mar  1 02:18:15 raspberrypi sshd[10320]: Failed password for invalid user root from 117.179.164.237 port 22077 ssh2

8444 Mar  1 02:18:17 raspberrypi sshd[10320]: Failed password for invalid user root from 117.179.164.237 port 22077 ssh2

8445 Mar  1 02:18:19 raspberrypi sshd[10320]: Failed password for invalid user root from 117.179.164.237 port 22077 ssh2

8446 Mar  1 02:18:19 raspberrypi sshd[10320]: fatal: Read from socket failed: Connection reset by peer [preauth]

8447 Mar  1 02:18:19 raspberrypi sshd[10320]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8448 Mar  1 02:18:19 raspberrypi sshd[10320]: PAM service(sshd) ignoring max retries; 5 > 3

8449 Mar  1 02:18:20 raspberrypi sshd[10336]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8450 Mar  1 02:18:20 raspberrypi sshd[10336]: input_userauth_request: invalid user root [preauth]

8451 Mar  1 02:18:20 raspberrypi sshd[10336]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8452 Mar  1 02:18:22 raspberrypi sshd[10336]: Failed password for invalid user root from 117.179.164.237 port 21532 ssh2

8453 Mar  1 02:18:24 raspberrypi sshd[10336]: Failed password for invalid user root from 117.179.164.237 port 21532 ssh2

8454 Mar  1 02:18:26 raspberrypi sshd[10336]: Failed password for invalid user root from 117.179.164.237 port 21532 ssh2

8455 Mar  1 02:18:28 raspberrypi sshd[10336]: Failed password for invalid user root from 117.179.164.237 port 21532 ssh2

8456 Mar  1 02:18:30 raspberrypi sshd[10336]: Failed password for invalid user root from 117.179.164.237 port 21532 ssh2

8457 Mar  1 02:18:30 raspberrypi sshd[10336]: fatal: Read from socket failed: Connection reset by peer [preauth]

8458 Mar  1 02:18:30 raspberrypi sshd[10336]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8459 Mar  1 02:18:30 raspberrypi sshd[10336]: PAM service(sshd) ignoring max retries; 5 > 3

8460 Mar  1 02:18:31 raspberrypi sshd[10344]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8461 Mar  1 02:18:31 raspberrypi sshd[10344]: input_userauth_request: invalid user root [preauth]

8462 Mar  1 02:18:31 raspberrypi sshd[10344]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8463 Mar  1 02:18:33 raspberrypi sshd[10344]: Failed password for invalid user root from 117.179.164.237 port 21892 ssh2

8464 Mar  1 02:18:35 raspberrypi sshd[10344]: Failed password for invalid user root from 117.179.164.237 port 21892 ssh2

8465 Mar  1 02:18:37 raspberrypi sshd[10344]: Failed password for invalid user root from 117.179.164.237 port 21892 ssh2

8466 Mar  1 02:18:39 raspberrypi sshd[10344]: Failed password for invalid user root from 117.179.164.237 port 21892 ssh2

8467 Mar  1 02:18:42 raspberrypi sshd[10344]: Failed password for invalid user root from 117.179.164.237 port 21892 ssh2

8468 Mar  1 02:18:42 raspberrypi sshd[10344]: fatal: Read from socket failed: Connection reset by peer [preauth]

8469 Mar  1 02:18:42 raspberrypi sshd[10344]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8470 Mar  1 02:18:42 raspberrypi sshd[10344]: PAM service(sshd) ignoring max retries; 5 > 3

8471 Mar  1 02:18:52 raspberrypi sshd[10352]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8472 Mar  1 02:18:52 raspberrypi sshd[10352]: input_userauth_request: invalid user root [preauth]

8473 Mar  1 02:18:52 raspberrypi sshd[10352]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8474 Mar  1 02:18:53 raspberrypi sshd[10352]: Failed password for invalid user root from 117.179.164.237 port 21949 ssh2

8475 Mar  1 02:18:55 raspberrypi sshd[10352]: Failed password for invalid user root from 117.179.164.237 port 21949 ssh2

8476 Mar  1 02:18:57 raspberrypi sshd[10352]: Failed password for invalid user root from 117.179.164.237 port 21949 ssh2

8477 Mar  1 02:18:59 raspberrypi sshd[10352]: Failed password for invalid user root from 117.179.164.237 port 21949 ssh2

8478 Mar  1 02:19:01 raspberrypi sshd[10352]: Failed password for invalid user root from 117.179.164.237 port 21949 ssh2

8479 Mar  1 02:19:01 raspberrypi sshd[10352]: fatal: Read from socket failed: Connection reset by peer [preauth]

8480 Mar  1 02:19:01 raspberrypi sshd[10352]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8481 Mar  1 02:19:01 raspberrypi sshd[10352]: PAM service(sshd) ignoring max retries; 5 > 3

8482 Mar  1 02:19:02 raspberrypi sshd[10361]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8483 Mar  1 02:19:02 raspberrypi sshd[10361]: input_userauth_request: invalid user root [preauth]

8484 Mar  1 02:19:02 raspberrypi sshd[10361]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8485 Mar  1 02:19:05 raspberrypi sshd[10361]: Failed password for invalid user root from 117.179.164.237 port 22141 ssh2

8486 Mar  1 02:19:07 raspberrypi sshd[10361]: Failed password for invalid user root from 117.179.164.237 port 22141 ssh2

8487 Mar  1 02:19:09 raspberrypi sshd[10361]: Failed password for invalid user root from 117.179.164.237 port 22141 ssh2

8488 Mar  1 02:19:11 raspberrypi sshd[10361]: Failed password for invalid user root from 117.179.164.237 port 22141 ssh2

8489 Mar  1 02:19:14 raspberrypi sshd[10361]: Failed password for invalid user root from 117.179.164.237 port 22141 ssh2

8490 Mar  1 02:19:14 raspberrypi sshd[10361]: fatal: Read from socket failed: Connection reset by peer [preauth]

8491 Mar  1 02:19:14 raspberrypi sshd[10361]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8492 Mar  1 02:19:14 raspberrypi sshd[10361]: PAM service(sshd) ignoring max retries; 5 > 3 

8493 Mar  1 02:19:15 raspberrypi sshd[10369]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8494 Mar  1 02:19:15 raspberrypi sshd[10369]: input_userauth_request: invalid user root [preauth]

8495 Mar  1 02:19:15 raspberrypi sshd[10369]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8496 Mar  1 02:19:17 raspberrypi sshd[10369]: Failed password for invalid user root from 117.179.164.237 port 21735 ssh2

8497 Mar  1 02:19:19 raspberrypi sshd[10369]: Failed password for invalid user root from 117.179.164.237 port 21735 ssh2

8498 Mar  1 02:19:21 raspberrypi sshd[10369]: Failed password for invalid user root from 117.179.164.237 port 21735 ssh2

8499 Mar  1 02:19:24 raspberrypi sshd[10369]: Failed password for invalid user root from 117.179.164.237 port 21735 ssh2

8500 Mar  1 02:19:26 raspberrypi sshd[10369]: Failed password for invalid user root from 117.179.164.237 port 21735 ssh2

8501 Mar  1 02:19:26 raspberrypi sshd[10369]: fatal: Read from socket failed: Connection reset by peer [preauth]

8502 Mar  1 02:19:26 raspberrypi sshd[10369]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8503 Mar  1 02:19:26 raspberrypi sshd[10369]: PAM service(sshd) ignoring max retries; 5 > 3

8504 Mar  1 02:19:27 raspberrypi sshd[10377]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8505 Mar  1 02:19:27 raspberrypi sshd[10377]: input_userauth_request: invalid user root [preauth]

8506 Mar  1 02:19:27 raspberrypi sshd[10377]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8507 Mar  1 02:19:29 raspberrypi sshd[10377]: Failed password for invalid user root from 117.179.164.237 port 21863 ssh2

8508 Mar  1 02:19:31 raspberrypi sshd[10377]: Failed password for invalid user root from 117.179.164.237 port 21863 ssh2

8509 Mar  1 02:19:34 raspberrypi sshd[10377]: Failed password for invalid user root from 117.179.164.237 port 21863 ssh2

8510 Mar  1 02:19:35 raspberrypi sshd[10377]: Failed password for invalid user root from 117.179.164.237 port 21863 ssh2

8511 Mar  1 02:19:38 raspberrypi sshd[10377]: Failed password for invalid user root from 117.179.164.237 port 21863 ssh2

8512 Mar  1 02:19:38 raspberrypi sshd[10377]: fatal: Read from socket failed: Connection reset by peer [preauth]

8513 Mar  1 02:19:38 raspberrypi sshd[10377]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8514 Mar  1 02:19:38 raspberrypi sshd[10377]: PAM service(sshd) ignoring max retries; 5 > 3

8515 Mar  1 02:19:39 raspberrypi sshd[10386]: User root from 117.179.164.237 not allowed because listed in DenyUsers

8516 Mar  1 02:19:39 raspberrypi sshd[10386]: input_userauth_request: invalid user root [preauth]

8517 Mar  1 02:19:39 raspberrypi sshd[10386]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8518 Mar  1 02:19:41 raspberrypi sshd[10386]: Failed password for invalid user root from 117.179.164.237 port 21996 ssh2

8519 Mar  1 02:19:43 raspberrypi sshd[10386]: Failed password for invalid user root from 117.179.164.237 port 21996 ssh2

8520 Mar  1 02:19:45 raspberrypi sshd[10386]: Failed password for invalid user root from 117.179.164.237 port 21996 ssh2

8521 Mar  1 02:19:48 raspberrypi sshd[10386]: Failed password for invalid user root from 117.179.164.237 port 21996 ssh2

8522 Mar  1 02:19:48 raspberrypi sshd[10386]: fatal: Read from socket failed: Connection reset by peer [preauth]

8523 Mar  1 02:19:48 raspberrypi sshd[10386]: PAM 3 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=117.179.164.237  user=root

8524 Mar  1 02:19:48 raspberrypi sshd[10386]: PAM service(sshd) ignoring max retries; 4 > 3




753 2017-03-04 19:45:18,761 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned

754 2017-03-04 19:45:21,767 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned

755 2017-03-04 19:45:26,777 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned

756 2017-03-04 19:45:28,781 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned

757 2017-03-04 19:45:44,806 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned

758 2017-03-04 19:45:58,828 fail2ban.actions[1253]: INFO    [ssh] 122.171.39.147 already banned


 938 Mar  4 19:45:11 raspberrypi sshd[30438]: User root from 122.171.39.147 not allowed because listed in DenyUsers

 939 Mar  4 19:45:11 raspberrypi sshd[30438]: input_userauth_request: invalid user root [preauth]

 940 Mar  4 19:45:11 raspberrypi sshd[30438]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 941 Mar  4 19:45:13 raspberrypi sshd[30442]: User root from 122.171.39.147 not allowed because listed in DenyUsers

 942 Mar  4 19:45:13 raspberrypi sshd[30442]: input_userauth_request: invalid user root [preauth]

 943 Mar  4 19:45:13 raspberrypi sshd[30442]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 944 Mar  4 19:45:13 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 945 Mar  4 19:45:14 raspberrypi sshd[30444]: User root from 122.171.39.147 not allowed because listed in DenyUsers

 946 Mar  4 19:45:14 raspberrypi sshd[30444]: input_userauth_request: invalid user root [preauth]

 947 Mar  4 19:45:14 raspberrypi sshd[30444]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 948 Mar  4 19:45:15 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 949 Mar  4 19:45:16 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 950 Mar  4 19:45:16 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 951 Mar  4 19:45:18 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 952 Mar  4 19:45:18 raspberrypi sshd[30455]: User root from 122.171.39.147 not allowed because listed in DenyUsers

 953 Mar  4 19:45:18 raspberrypi sshd[30455]: input_userauth_request: invalid user root [preauth]

 954 Mar  4 19:45:18 raspberrypi sshd[30455]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 955 Mar  4 19:45:18 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 956 Mar  4 19:45:18 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 957 Mar  4 19:45:20 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 958 Mar  4 19:45:20 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 959 Mar  4 19:45:20 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 960 Mar  4 19:45:20 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 961 Mar  4 19:45:23 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 962 Mar  4 19:45:23 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 963 Mar  4 19:45:23 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 964 Mar  4 19:45:24 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 965 Mar  4 19:45:25 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 966 Mar  4 19:45:26 raspberrypi sshd[30438]: Failed password for invalid user root from 122.171.39.147 port 50859 ssh2

 967 Mar  4 19:45:26 raspberrypi sshd[30438]: Disconnecting: Too many authentication failures for invalid user root from 122.171.39.147 port 50859 ssh2 [preauth]

 968 Mar  4 19:45:26 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 969 Mar  4 19:45:26 raspberrypi sshd[30438]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 970 Mar  4 19:45:26 raspberrypi sshd[30438]: PAM service(sshd) ignoring max retries; 6 > 3

 971 Mar  4 19:45:26 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 972 Mar  4 19:45:28 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 973 Mar  4 19:45:28 raspberrypi sshd[30444]: Failed password for invalid user root from 122.171.39.147 port 50876 ssh2

 974 Mar  4 19:45:28 raspberrypi sshd[30444]: Disconnecting: Too many authentication failures for invalid user root from 122.171.39.147 port 50876 ssh2 [preauth]

 975 Mar  4 19:45:28 raspberrypi sshd[30444]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 976 Mar  4 19:45:28 raspberrypi sshd[30444]: PAM service(sshd) ignoring max retries; 6 > 3

 977 Mar  4 19:45:28 raspberrypi sshd[30442]: Failed password for invalid user root from 122.171.39.147 port 50866 ssh2

 978 Mar  4 19:45:28 raspberrypi sshd[30442]: Disconnecting: Too many authentication failures for invalid user root from 122.171.39.147 port 50866 ssh2 [preauth]

 979 Mar  4 19:45:28 raspberrypi sshd[30442]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 980 Mar  4 19:45:28 raspberrypi sshd[30442]: PAM service(sshd) ignoring max retries; 6 > 3

 981 Mar  4 19:45:30 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 982 Mar  4 19:45:32 raspberrypi sshd[30455]: Failed password for invalid user root from 122.171.39.147 port 50906 ssh2

 983 Mar  4 19:45:32 raspberrypi sshd[30455]: Disconnecting: Too many authentication failures for invalid user root from 122.171.39.147 port 50906 ssh2 [preauth]

 984 Mar  4 19:45:32 raspberrypi sshd[30455]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 985 Mar  4 19:45:32 raspberrypi sshd[30455]: PAM service(sshd) ignoring max retries; 6 > 3

 986 Mar  4 19:45:42 raspberrypi sshd[30484]: User root from 122.171.39.147 not allowed because listed in DenyUsers

 987 Mar  4 19:45:42 raspberrypi sshd[30484]: input_userauth_request: invalid user root [preauth]

 988 Mar  4 19:45:42 raspberrypi sshd[30484]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 989 Mar  4 19:45:44 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 990 Mar  4 19:45:47 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 991 Mar  4 19:45:50 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 992 Mar  4 19:45:52 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 993 Mar  4 19:45:55 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 994 Mar  4 19:45:58 raspberrypi sshd[30484]: Failed password for invalid user root from 122.171.39.147 port 51032 ssh2

 995 Mar  4 19:45:58 raspberrypi sshd[30484]: Disconnecting: Too many authentication failures for invalid user root from 122.171.39.147 port 51032 ssh2 [preauth]

 996 Mar  4 19:45:58 raspberrypi sshd[30484]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=122.171.39.147  user=root

 997 Mar  4 19:45:58 raspberrypi sshd[30484]: PAM service(sshd) ignoring max retries; 6 > 3

 


+

[링크 : https://forums.gentoo.org/viewtopic-p-7521178.html]

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban with 404  (2) 2019.03.20
fail2ban error 100  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
Posted by 구차니

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban error 100  (0) 2017.03.06
fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
ssh 로그인 보안 - fail2ban  (4) 2017.02.08
Posted by 구차니

생각을 해보니..

차단될때 마다 blacklist 파일에 추가해주면

다음번 재시작 시에 blacklist를 보고 자동으로 DROP 하도록 되어 있으니

REJECT 하는 자동 차단이랑 섞어서 쓰면 쓸만할지도?!


$ cat /etc/fail2ban/action.d/iptables-multiport24.conf

actionban = iptables -I fail2ban-<name> 1 -s <ip>/24 -j <blocktype>

            echo <ip> >> /etc/fail2ban/ip.blacklist 


'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 차단 관련...  (0) 2017.02.09
ssh 로그인 보안 - fail2ban  (4) 2017.02.08
apache ip deny  (0) 2017.02.08
Posted by 구차니

밴하고 있을 시간을 -1로 하면 영구 차단이라고 한다.

bantime = -1

[링크 : http://serverfault.com/questions/415040/permanent-block-of-ip-after-n-retries-using-fail2ban]


그런데 fail2ban 설정을 바꾼다고 재시작 해버리니 밴이 풀리네?!

그걸 유지할 방법이 없을려나


192.168.0.xxx 이런식으로 대역을 전체 막는 방법

$ vi /etc/fail2ban/jail.conf

banaction = iptables-multiport


$ vi /etc/fail2ban/action.d/iptables-multiport.conf

actionban = iptables -I fail2ban-<name> 1 -s <ip>/24 -j <blocktype>

actionunban = iptables -D fail2ban-<name> -s <ip>/24 -j <blocktype>


$ man iptables

       [!] -s, --source address[/mask][,...]

              Source  specification.  Address  can  be either a network name, a hostname, a network IP address (with /mask), or a plain IP address. Hostnames will be

              resolved once only, before the rule is submitted to the kernel.  Please note that specifying any name to be resolved with a remote query such as DNS is

              a  really bad idea.  The mask can be either an ipv4 network mask (for iptables) or a plain number, specifying the number of 1's at the left side of the

              network mask.  Thus, an iptables mask of 24 is equivalent to 255.255.255.0.  A "!" argument before the address specification inverts the sense  of  the

              address.  The  flag  --src  is an alias for this option.  Multiple addresses can be specified, but this will expand to multiple rules (when adding with

              -A), or will cause multiple rules to be deleted (with -D).


[링크 : https://www.righter.ch/index.php/2014/12/10/block-a-whole-ip-range-with-fail2ban/]


블랙리스트 파일

[링크 : http://looke.ch/wp/list-based-permanent-bans-with-fail2ban]


수동 ban

$ fail2ban-client 

    set <JAIL> banip <IP>                    manually Ban <IP> for <JAIL>

    set <JAIL> unbanip <IP>                  manually Unban <IP> in <JAIL>


하나만 차단하기

$ sudo fail2ban-client set ssh banip 221.194.44.252

대역 차단하기

$ sudo fail2ban-client set ssh banip 221.194.44.252/24 


$ sudo iptables -L

Chain fail2ban-ssh (1 references)

target     prot opt source               destination

REJECT     all  --  221.194.44.0/24      anywhere             reject-with icmp-port-unreachable

REJECT     all  --  221.194.44.252       anywhere             reject-with icmp-port-unreachable

RETURN     all  --  anywhere             anywhere 


[링크 : https://www.howtoforge.com/community/threads/how-to-manually-unban-ip-blocked-by-fail2ban.51366/]

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
ssh 로그인 보안 - fail2ban  (4) 2017.02.08
apache ip deny  (0) 2017.02.08
Posted by 구차니

webalizer 보다가 웬지 불안해서 ssh 로그인 내역을 찾는다고

/var/log/auth.log* 파일을 보는데.. 일단은 5회 실패시 자동 접속 종료니까 그걸 기준으로 검색해보니

하루 한번씩은 꼭 누군가가 시도를 했네 -_-

$ grep "PAM 5 more authentication" /var/log/auth.log*


혹시나 해서 로그인 실패로 뒤져보니.. 헉... -_-

$ grep "Failed password for" /var/log/auth.log*  

시도하다 실패한 아이디 목록

[링크 : http://serverfault.com/questions/130482/how-to-check-sshd-log]


root 로그인 자체를 막는 방법. 인증에서 거부하지 root 로그인 시도를 거부하진 않는다.

$ sudo vi /etc/ssh/sshd_config

 28 #PermitRootLogin without-password

 29 PermitRootLogin no

 30 DenyUsers root


[링크 : https://mediatemple.net/community/products/dv/204643810/how-do-i-disable-ssh-login-for-the-root-user]

[링크 : http://askubuntu.com/questions/27559/how-do-i-disable-remote-ssh-login-as-root-from-a-server]

[링크 : http://superuser.com/questions/478341/automatically-deny-hacking-attempts-in-centos]


아무튼 검색을 해보니. fail2ban 이라는 패키지가 있나 보다.

[링크 : http://askubuntu.com/questions/178016/how-do-i-keep-track-of-failed-ssh-log-in-attempts]

[링크 : http://superuser.com/questions/476231/ban-ip-on-multiple-faild-ssh-login-attempts]


$ sudo apt-cache search fail2ban

fail2ban - ban hosts that cause multiple authentication errors 


설치는 항상 그렇듯 아래 복붙하면되고

$ sudo apt-get install fail2ban 


차단할 녀석들 찾으려고 로그를 보니

그리고 로그인 시도가 2~3초 간격으로 시도를 하는데 기본 ssh가 5번 까지 허용을 해주는 것 같은데

일부 한두번만 시도하고 도망가는 놈들까지 잡으려다가는 내가 오타내서 로그인 못하다가 잡힐수도 있으니

이거 참 고민이네 -_-

auth.log.1:Jan 23 10:50:45 raspberrypi sshd[2616]: Failed password for invalid user gopher from 106.247.230.226 port 39683 ssh2

auth.log.1:Jan 23 10:50:47 raspberrypi sshd[2616]: Failed password for invalid user gopher from 106.247.230.226 port 39683 ssh2

auth.log.1:Jan 23 10:52:14 raspberrypi sshd[2622]: Failed password for invalid user nfsnobody from 106.247.230.226 port 49373 ssh2

auth.log.1:Jan 23 10:52:16 raspberrypi sshd[2622]: Failed password for invalid user nfsnobody from 106.247.230.226 port 49373 ssh2

auth.log.1:Jan 23 10:52:18 raspberrypi sshd[2622]: Failed password for invalid user nfsnobody from 106.247.230.226 port 49373 ssh2

auth.log.1:Jan 23 10:52:58 raspberrypi sshd[2629]: Failed password for games from 106.247.230.226 port 49461 ssh2

auth.log.1:Jan 23 10:53:00 raspberrypi sshd[2629]: Failed password for games from 106.247.230.226 port 49461 ssh2

auth.log.1:Jan 23 10:53:02 raspberrypi sshd[2629]: Failed password for games from 106.247.230.226 port 49461 ssh2

auth.log.1:Jan 23 10:55:12 raspberrypi sshd[2638]: Failed password for invalid user teamspeak2 from 106.247.230.226 port 52864 ssh2

auth.log.1:Jan 23 10:55:15 raspberrypi sshd[2638]: Failed password for invalid user teamspeak2 from 106.247.230.226 port 52864 ssh2

auth.log.1:Jan 23 10:56:38 raspberrypi sshd[2647]: Failed password for invalid user teamspeak2 from 106.247.230.226 port 50460 ssh2

auth.log.1:Jan 23 10:57:21 raspberrypi sshd[2653]: Failed password for invalid user ts4 from 106.247.230.226 port 60900 ssh2

auth.log.1:Jan 23 11:00:14 raspberrypi sshd[2662]: Failed password for invalid user offline from 106.247.230.226 port 54433 ssh2

auth.log.1:Jan 23 11:00:56 raspberrypi sshd[2668]: Failed password for invalid user webdesign from 106.247.230.226 port 52505 ssh2

auth.log.1:Jan 23 11:02:19 raspberrypi sshd[2673]: Failed password for invalid user reddragon from 106.247.230.226 port 56955 ssh2 


설정은 집에서는 차단 안되도록 사용하는 아이피 대역을 추가해 주었고(lg u+ 공유기라 그런가?)

한번 걸리면 차단 시간 30일(60초*60분*24시간*30일)로 일단 설정해 주었다.

그리고 차단할 녀석을 찾는 시간은 1분내 5번 실패하는 녀석! 너무 좁혀놨을려나?

$ sudo vi /etc/fail2ban/jail.conf

[DEFAULT]

ignoreip = 127.0.0.1/8 192.168.219.1/24

ignorecommand =

bantime  = 2592000

findtime = 60

maxretry = 5


[ssh]

enabled  = true

port     = ssh

filter   = sshd

logpath  = /var/log/auth.log

maxretry = 5


[apache]

enabled  = false

port     = http,https

filter   = apache-auth

logpath  = /var/log/apache*/*error.log

maxretry = 5

[링크 : https://blog.lael.be/post/1209]

[링크 : https://www.conory.com/note_linux/11720]

일단 자고 나면 내일 한마리(!) 정도는 낚여 있을려나?



+

175.224.0.0/11 대역은 KT wibro 일려나?


+

2017.02.09

아싸 하나 낚았고 ㅋㅋㅋ

$ sudo iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination

fail2ban-ssh  tcp  --  anywhere             anywhere             multiport dports ssh


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination


Chain fail2ban-ssh (1 references)

target     prot opt source               destination

REJECT     all  --  221.194.44.252       anywhere             reject-with icmp-port-unreachable

RETURN     all  --  anywhere             anywhere


Feb  9 04:48:52 raspberrypi sshd[3342]: Invalid user admin from 221.194.44.252

Feb  9 04:48:52 raspberrypi sshd[3342]: input_userauth_request: invalid user admin [preauth]

Feb  9 04:48:52 raspberrypi sshd[3342]: pam_unix(sshd:auth): check pass; user unknown

Feb  9 04:48:52 raspberrypi sshd[3342]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.194.44.252

Feb  9 04:48:53 raspberrypi sshd[3342]: Failed password for invalid user admin from 221.194.44.252 port 2815 ssh2

Feb  9 04:48:53 raspberrypi sshd[3342]: pam_unix(sshd:auth): check pass; user unknown

Feb  9 04:48:55 raspberrypi sshd[3342]: Failed password for invalid user admin from 221.194.44.252 port 2815 ssh2

Feb  9 04:48:55 raspberrypi sshd[3342]: pam_unix(sshd:auth): check pass; user unknown

Feb  9 04:48:57 raspberrypi sshd[3342]: Failed password for invalid user admin from 221.194.44.252 port 2815 ssh2

Feb  9 04:48:57 raspberrypi sshd[3342]: pam_unix(sshd:auth): check pass; user unknown

Feb  9 04:48:59 raspberrypi sshd[3342]: Failed password for invalid user admin from 221.194.44.252 port 2815 ssh2

Feb  9 04:48:59 raspberrypi sshd[3342]: pam_unix(sshd:auth): check pass; user unknown

Feb  9 04:49:01 raspberrypi sshd[3342]: Failed password for invalid user admin from 221.194.44.252 port 2815 ssh2

Feb  9 04:49:01 raspberrypi sshd[3342]: fatal: Read from socket failed: Connection reset by peer [preauth]

Feb  9 04:49:01 raspberrypi sshd[3342]: PAM 4 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.194.44.252

Feb  9 04:49:01 raspberrypi sshd[3342]: PAM service(sshd) ignoring max retries; 5 > 3 


아파치 까지 적용하고 서비스 재시작했더니 밴이 풀려버리네?!?!

2017-02-09 04:49:01,756 fail2ban.actions[31809]: WARNING [ssh] Ban 221.194.44.252

2017-02-09 08:50:18,961 fail2ban.server [31809]: INFO    Stopping all jails

2017-02-09 08:50:19,255 fail2ban.actions[31809]: WARNING [ssh] Unban 221.194.44.252 


'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
apache ip deny  (0) 2017.02.08
Posted by 구차니

webalizer를 보다 보니 이상한 접속이 보여서 차단할 방법 찾는중

그런데.. 이건 자동화 된거 없나? 일일이 apache.conf 손대고 apache를 재시작 하긴 좀 그런데...


<Directory /var/www/>

Options FollowSymLinks MultiViews

AllowOverride None

Order deny,allow

Allow from xxx.xxx.xxx.xxx

Allow from xxx.xxx.xxx.xxx

Allow from xxx.xxx.xxx.xxx

Deny from all

</Directory>

[링크 : http://ngee.tistory.com/209]

[링크 : https://httpd.apache.org/docs/2.4/mod/mod_access_compat.html]

[링크 : https://httpd.apache.org/docs/2.4/howto/access.html]


mod_rewrite를 이용해서 외부 파일을 이용하는 방법.. 이건 좀 나아 보이긴 하네..

#Required set of rewrite rules

RewriteEngine on

RewriteMap    hosts-deny  txt:/etc/apache/banned-hosts

RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]

RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND

RewriteRule   ^  /why-am-i-banned.html


##  inside our banned hosts file, we have:

## /etc/apache2/banned-hosts (maintain the format .. its not just a plain text file)

## 


193.102.180.41 -

192.168.111.45 -

www.example.com -

www.sumwia.net - 

[링크 : http://stackoverflow.com/questions/23157707/apache-2-4-x-ip-blacklist]


다른것들을 찾아봐도.. 결론은 fail2ban을 이용한 ipfilter인데..

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
fail2ban 차단 관련...  (0) 2017.02.09
ssh 로그인 보안 - fail2ban  (4) 2017.02.08
Posted by 구차니