리눅스(24)
-
리눅스 시스템 PDT -> KST 타임존 변경
root#> ls /usr/share/zoneinfo root #> ls /usr/share/zoneinfo/Asia root #> ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime root#> date
2018.09.30 -
포인터 계산기
#include #include #include #include #define SIZE_4K 4096 int main(int argc, char *argv[]) { int trim; double num1, num2, result; char str[SIZE_4K] = {0,}; char oper; char *data, *data_tmp; printf("계산할 값을 입력해주세요.(예: 1+3, 2*5 ... 종료: exit)\n"); do { trim = 0; num1 = 0; num2 = 0; result = 0; oper = '\0'; data = NULL; data_tmp = NULL; printf("수식: "); fgets(str, sizeof(str), stdin); data_tmp = (char*..
2018.04.11 -
linux libpcap.h documentation
#define HAVE_REMOTE#include main(){ pcap_if_t *alldevs; pcap_if_t *d; int i=0; char errbuf[PCAP_ERRBUF_SIZE]; /* Retrieve the device list from the local machine */ if (pcap_findalldevs(&alldevs, errbuf) == -1) { fprintf(stderr,"Error in pcap_findalldevs(&alldevs, errbuf: %s\n", errbuf); exit(1); } /* Print the list */ for(d= alldevs; d != NULL; d= d->next) { printf("%d. %s", ++i, d->name); if (d..
2018.04.11 -
클라우드 솔루션 ceph를 구축해보자
centos7 64bit 환경의 서버 두대 node0 메인node1 슬레이브 #> root사용자$> ceph사용자 cpeh 계정생성 #> useradd ceph#> passwd ceph패스워드 입력 생성된 ceph 계정이 root 권한을 사용할수 있도록 설정 #> echo -e 'Defaults:ceph !requiretty\nceph ALL = (root) NOPASSWD:ALL' | tee /etc/sudoers.d/ceph #> chmod 440 /etc/sudoers.d/ceph #> yum install -y centos-release-ceph-hammer epel-release yum-plugin-priorities #> sed -i -e "s/enabled=1/enabled=1\npriori..
2017.12.30 -
웹엔진 헤더정보 숨기기
테스트는 아파치에서 함. curl -I http://localhostcurl -D- -o /dev/null http://localhost 를 입력하면 현재 웹서버의 헤더 정보를 볼수 있다. 그 때 server 항목에서 apache버전명이 노출이 된다. apache 버전이 노출이 되면 해당 버전의 exploit을 이용하여 침투,침해사고가 일어날 수 있다. 그것을 방지하기 위해 httpd.conf 에서 아래 내용을 추가하면 된다. 1. # Include conf/crs/modsecurity_crs_10_setup.conf Include conf/crs/modsecurity_crs_10_setup.confSecRuleEngine onServerTokens MinimalSecServerSignature "xxx..
2017.09.08 -
qmail 스팸차단
qmail 스팸차단 /var/qmail/control/badmailfrom badmailfrom은 기존 qmail을 설치하면 해당 파일이 없음 vi 로 파일 생성해서 차단하면됨 따로 qmail 재시작은 하지않아도 됨 xxxx@xxxx.com
2017.05.23 -
리눅스 시스템이 해킹을 당했을 경우
현장 보존이 가장중요 /tmp /var/tmp 등의 임시 디렉토리에 처음보는, 의심되는 파일이 있는지 확인이 부분을 확인해야 하는 이유는 /tmp 디렉토리에서 루트권한외에 일반계정으로 파일 실행이 가능함.따라서 루트 권한 탈취 프로그램이 /tmp 디렉토리에서 시도가 많다고 함. /dev 디렉토리하위에 일반파일이 있는지 확인. /dev디렉토리에는 일반파일이 있으면 안됨 ex) ssh 파일 같은거find /dev -type f --> /dev 디렉토리 하위에 일반파일이 있는지 찾음 ps -auxf 명령어로 의심되는 프로세스트리를 확인. 이과정에서 침투경로나 파일이 있는 위치등을 확인 할 수도 있다. netstat -an | grep LISTEN 으로 현재 listen 상태인 모든 포트를 확인 stat 명령어..
2017.03.15 -
chkrootkit rkhunter 설치 법
chkrootkit 폴더의 chkrootkit.tar.gz 를 서버에 옮기고 압축을 풀어준다.압축을 푼 디렉토리로 들어가서./chkrootkit 하면 시스템 체크를 진행한다. --------------------------------------------------------------- rkhunter 폴더의 rkhunter-1.4.2.tar.gz 를 서버에 옮기고 압축을 풀어준다.압축을 푼 디렉토리로 들어가서./installer.sh --layout default --install 하면 설치를 진행한다.설치가 끝나면 rkhunter -c명령어를 입력하면 시스템 체크를 진행한다.
2017.01.19 -
전날 날짜 구하는 스크립트
date 명령어의 옵션으로 가능 #!/bin/bash 는 해당 쉘이 위치한 곳을 알려주는 인자 yesterday는 변수 -d 옵션은 그 뒤에 나오는 '1 day ago'를 사용하기 위한 옵션 %Y 연도%m 달%d 30일중에 몇일인가 표시 find /root/ -name "*$yesterday*" ls * | grep yesterday.* | grep -v .yesterday | wc -l 오타가 났네요 %G = %Y 로 봐주세요 ㅎ
2016.12.27 -
간단한 ssh포트 접속하는 거
간단한거를 안써놨음 혹시나 잊어먹을까봐 써놔야겠음 ssh 기본 포트는 22번을 사용하지만 22번은 널리 알려진 well known포트. 아무리 보안 포트라지만서도 포트번호를 안다는 것은 좀... root#> vi /etc/ssh/sshd_configroot#> vi /etc/ssh/ssh_config 에서 #Port 22 로 되어 있는 부분에 주석을 지우고 원하는 포트 번호 입력 단 8000번대이상으로. root#> vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 포트번호 -j ACCEPT iptables 에 해당 포트 번호 추가 root#> service iptables restartroot#> service s..
2016.12.16