음.. 웹쪽이야 svn으로 하면되는데

db의 구조가 변경되는건 어떻게 이력으로 남길수 있지?

라는 생각이 들어 검색을 해보니


결론은.. db 스키마 덤프해서 버전관리해라 정도의 느낌?

[링크 : https://blog.codinghorror.com/get-your-database-under-version-control/]

[링크 : https://blog.codinghorror.com/is-your-database-under-version-control/] <<


[링크 : http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your-database-items]

[링크 : http://stackoverflow.com/questions/175451/how-do-you-version-your-database-schema]

[링크 : http://stackoverflow.com/questions/173/versioning-sql-server-database]

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

mysql view  (0) 2017.03.14
db designer  (0) 2017.03.14
mysql 통화관련 변수타입  (0) 2017.02.07
mysql 다국어 문자길이  (0) 2017.02.06
mysql select case insensitive  (0) 2017.02.06
Posted by 구차니
프로그램 사용/vi2017. 2. 13. 09:37

:ls 버퍼 목록

:bn buffer next

:bp buffer previous

:b0 0번째로 이동

:bf buffer first 처음

:bl buffer last 마지막


:[N]bn[ext][!] [+cmd] [N]                               *:bn* *:bnext* *E87*

                Go to [N]th next buffer in buffer list.  [N] defaults to one.

                Wraps around the end of the buffer list.

                See |:buffer-!| for [!].

                Also see ||+cmd|.

                If you are in a help buffer, this takes you to the next help

                buffer (if there is one).  Similarly, if you are in a normal

                (non-help) buffer, this takes you to the next normal buffer.

                This is so that if you have invoked help, it doesn't get in

                the way when you're browsing code/text buffers.  The next three

                commands also work like this. 


bN이 대문자임

:[N]bN[ext][!] [+cmd] [N]               *:bN* *:bNext* *:bp* *:bprevious* *E88*

:[N]bp[revious][!] [+cmd] [N]

                Go to [N]th previous buffer in buffer list.  [N] defaults to

                one.  Wraps around the start of the buffer list.

                See |:buffer-!| for [!] and 'switchbuf'.

                Also see ||+cmd|. 


:br[ewind][!] [+cmd]                                    *:br* *:brewind*

                Go to first buffer in buffer list.  If the buffer list is

                empty, go to the first unlisted buffer.

                See |:buffer-!| for [!].


:bf[irst] [+cmd]                                        *:bf* *:bfirst*

                Same as |:brewind|.

                Also see |+cmd|. 


:bl[ast][!] [+cmd]                                      *:bl* *:blast*

                Go to last buffer in buffer list.  If the buffer list is

                empty, go to the last unlisted buffer.

                See |:buffer-!| for [!]. 


:[N]bd[elete][!]                        *:bd* *:bdel* *:bdelete* *E516*

:bd[elete][!] [N]

                Unload buffer [N] (default: current buffer) and delete it from

                the buffer list.  If the buffer was changed, this fails,

                unless when [!] is specified, in which case changes are lost.

                The file remains unaffected.  Any windows for this buffer are

                closed.  If buffer [N] is the current buffer, another buffer

                will be displayed instead.  This is the most recent entry in

                the jump list that points into a loaded buffer.

                Actually, the buffer isn't completely deleted, it is removed

                from the buffer list |unlisted-buffer| and option values,

                variables and mappings/abbreviations for the buffer are

                cleared. 


:[N]bw[ipeout][!]                       *:bw* *:bwipe* *:bwipeout* *E517*

:bw[ipeout][!] {bufname}

:N,Mbw[ipeout][!]

:bw[ipeout][!] N1 N2 ...

                Like |:bdelete|, but really delete the buffer.  Everything

                related to the buffer is lost.  All marks in this buffer

                become invalid, option settings are lost, etc.  Don't use this

                unless you know what you are doing. 


[링크 : http://gyuha.tistory.com/157]


+

ctrl-n,n은 새 버퍼로 수평 창을 여는데

ctrl-n,v는 이전 창의 버퍼를 연결해서 수직 창으로 연다


 CTRL-W CTRL-V                                           *CTRL-W_CTRL-V*

CTRL-W v                                                *CTRL-W_v*

:[N]vs[plit] [++opt] [+cmd] [file]                      *:vs* *:vsplit*

                Like |:split|, but split vertically.  The windows will be

                spread out horizontally if

                1. a width was not specified,

                2. 'equalalways' is set,

                3. 'eadirection' isn't "ver", and

                4. one of the other windows is wider than the current or new

                   window.

                Note: In other places CTRL-Q does the same as CTRL-V, but here

                it doesn't!


CTRL-W n                                                *CTRL-W_n*

CTRL-W CTRL_N                                           *CTRL-W_CTRL-N*

:[N]new [++opt] [+cmd]                                  *:new*

                Create a new window and start editing an empty file in it.

                Make new window N high (default is to use half the existing

                height).  Reduces the current window height to create room (and

                others, if the 'equalalways' option is set and 'eadirection'

                isn't "hor").

                Also see |++opt| and |+cmd|.

                If 'fileformats' is not empty, the first format given will be

                used for the new buffer.  If 'fileformats' is empty, the

                'fileformat' of the current buffer is used.  This can be

                overridden with the |++opt| argument.

                Autocommands are executed in this order:

                1. WinLeave for the current window

                2. WinEnter for the new window

                3. BufLeave for the current buffer

                4. BufEnter for the new buffer

                This behaves like a ":split" first, and then an ":enew"

                command.


:[N]vne[w] [++opt] [+cmd] [file]                        *:vne* *:vnew*

                Like |:new|, but split vertically.  If 'equalalways' is set

                and 'eadirection' isn't "ver" the windows will be spread out

                horizontally, unless a width was specified.


:[N]new [++opt] [+cmd] {file}

:[N]sp[lit] [++opt] [+cmd] {file}                       *:split_f*

                Create a new window and start editing file {file} in it.  This

                behaves like a ":split" first, and then an ":e" command.

                If [+cmd] is given, execute the command when the file has been

                loaded |+cmd|.

                Also see |++opt|.

                Make new window N high (default is to use half the existing

                height).  Reduces the current window height to create room

                (and others, if the 'equalalways' option is set).



[링크 : http://stackoverflow.com/.../vim-how-do-you-open-another-no-name-buffer-like-the-one-on-startup]

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

vi 여러개 파일 편집하기(동시 x)  (0) 2017.09.16
vi 반복 입력  (0) 2017.09.16
vi buffer window tab 차이점?  (0) 2017.02.11
vi 창 분할해서 보기  (0) 2017.02.10
vi 현재 위치에서 끝까지 복사  (0) 2017.02.01
Posted by 구차니
프로그램 사용/vi2017. 2. 11. 16:27

사용에 옳은 방법이 있겠냐 마는

버퍼는 일종의 파일 하나당 할당된 메모리 개념 같고

윈도우는 버퍼를 골라서 띄우는 역할

그리고 탭은 윈도우에서 레이아웃을 담당하는 역할이라고 하는데

솔찍히 탭 + 윈도우로 쓰긴 또 에러고

가장 무난한건 윈도우 여러개 분할해서 버퍼 골라가며 쓰는거?


[링크 : http://bakyeono.net/post/2015-08-13-vim-tab-madness-translate.html]


[링크 : https://sanctum.geek.nz/arabesque/buffers-windows-tabs/]

[링크 : http://stackoverflow.com/questions/26708822/why-do-vim-experts-prefer-buffers-over-tabs]

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

vi 반복 입력  (0) 2017.09.16
vi 버퍼 컨트롤  (0) 2017.02.13
vi 창 분할해서 보기  (0) 2017.02.10
vi 현재 위치에서 끝까지 복사  (0) 2017.02.01
vi 단어 단위 이동  (0) 2017.02.01
Posted by 구차니
프로그램 사용/vi2017. 2. 10. 20:43


:sp

:vsp


[링크 : https://www.linux.com/learn/vim-tips-using-viewports]


보이는 것만 둘로 나눈 것이기에

다른쪽에서 수정하면 동시에 수정되는 것이 보인다

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

vi 버퍼 컨트롤  (0) 2017.02.13
vi buffer window tab 차이점?  (0) 2017.02.11
vi 현재 위치에서 끝까지 복사  (0) 2017.02.01
vi 단어 단위 이동  (0) 2017.02.01
vi syntax highlight 선택하기  (0) 2017.01.03
Posted by 구차니
프로그램 사용/sdl2017. 2. 9. 21:18

sdl 이라는 녀석으로 한번 해봐야 하려나..

윈도우에서는 DirectDraw를 쓴다고 하니 일단 Platformsdk 안깔아도 되서 편할듯


[링크 : http://prog3.com/sbdm/blog/hjl240/article/details/47857175] sdl + mfc

[링크 : http://dranger.com/ffmpeg/] // ffmpeg + sdl + mfc

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

sdl tutorial  (0) 2022.05.27
SDL - Simple DirectMedia Layer  (0) 2021.07.06
SDL - Simple DirectMedia Layer  (0) 2011.12.12
Posted by 구차니

auth.log에서 정규표현식으로 아이피 빼내니 편하긴 하네

공부해봐야지 ㅠㅠ


.*?((?:\d{1,3}\.){3}\d{1,3})|.+

$1



[링크 : http://stackoverflow.com/questions/23707270/notepad-keep-only-ip-addresses]

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 구차니

간단하게 요약하면..

이번 로그 파일을 합치고

/etc/webalizer/webalizer.conf를 복사해서

새로운 설정파일을 만든 후

아래와 같이 설정파일을 지정해서(-c) 돌리는 방법이라고 해야하나?

$ sudo webalizer -c /etc/webalizer/webalizer.conf.old 


[링크 : http://www.pc-freak.net/blog/linux-generating-web-statistics-apache-logs-webalizer/]



실험을 해보니.. incremental이나 history 적용하니

옛날 버전이 되지 않아서, 두개 설정 데이터를 지우거나 구버전 설정파일에서는 해당 기능을 꺼야

이전 버전들이 새로 생성된다.

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 구차니