[변경 전 확인]
[root@test ~]# curl https://api.luniverse.io
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

[root@test ~]# curl https://google.co.kr
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

[nameserver 설정 변경]
경로 : /etc/resolv.conf
nameserver 210.220.163.82 ( SK서버로 SK nameserver로 변경 조치 )

[설정 후 테스트]
[root@test ~]# curl https://api.luniverse.io

[root@test ~]# curl https://google.co.kr
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.co.kr/">here</A>.
</BODY></HTML>

'Security > OS 관련' 카테고리의 다른 글

curl 확인 방법  (0) 2023.11.14
공유메모리 관련  (0) 2023.11.07
QOS (트래픽 제한 두번째 방법)  (0) 2023.11.07
트래픽 용량 제한(QOS)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07

 

'Security > OS 관련' 카테고리의 다른 글

curl 오류 관련 문의  (0) 2023.11.14
공유메모리 관련  (0) 2023.11.07
QOS (트래픽 제한 두번째 방법)  (0) 2023.11.07
트래픽 용량 제한(QOS)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
*ipcs -s 로 세마포어 ID(semid) 확인한다음에 ipcs -ie [semid]로 자세한 내용 출력하면 PID값 확인 가능하다.
(문서-사진-공유메모리.png 참고)
 
 
<확인 작업>
1) 고객사 아파치 실행시 에러 발생한다고 문의접수
에러 내용 : httpd not running, trying to start 
 
2) 아파치 실행여부 확인
ㄴ 아파치 실행하였으나, netstat 으로 확인시 80 포트 오픈 안됨
 
3) 공유 메모리 이슈가 있었던 고객으로 공유 메모리 현황 확인
[root@ /opt/apache/bin]# ipcs -s
------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x00000000 2108227584 daemon     600        1         
0x00000000 2141749249 daemon     600        1         
0x00000000 27787266   daemon     600        1         
0x00000000 61308931   daemon     600        1         
0x00000000 94830596   daemon     600        1         
0x00000000 128352261  daemon     600        1         
0x00000000 161873926  daemon     600        1         
...........
 
<처리 작업>
 
1) 공유 메모리 kill 작업 진행
ipcs -s | grep daemon | perl -e 'while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}'
ㄴ daemon 권한일때 위처럼 실행
 
2) apache 실행
/opt/apache/bin/apachectl start
 
3) 80 포트 확인
[root@~]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      1761/vsftpd         
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1677/sshd           
tcp        0      0 :::3306                     :::*                        LISTEN      2433/mysqld         
tcp        0      0 :::80                       :::*                        LISTEN      10918/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      1677/sshd
 
4) 공유메모리 설정 관련 커널 확인
[root@~]# cat /proc/sys/kernel/sem
250     32000   32      128
 
5) 해당 커널 설정 변경
vi /etc/sysctl.conf 안에
kernel.sem = 1000 32000 100 512 수동 입력
ㄴ 해당 설정 정상적으로 적용되려면 재부팅 후 적용된다고 고객사 안내 완료
 

 

'Security > OS 관련' 카테고리의 다른 글

curl 오류 관련 문의  (0) 2023.11.14
curl 확인 방법  (0) 2023.11.14
QOS (트래픽 제한 두번째 방법)  (0) 2023.11.07
트래픽 용량 제한(QOS)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07

[TC로 세부 설정하는 방법]

아래 스크립트 생성 후(tc.sh) 실행 권한 부여

IF,  DNLD, UPLD, IP 부분만 수정

tc.sh start | stop | restart 로 구동

#!/bin/bash
#
#  tc uses the following units when passed as a parameter.
#  kbps: Kilobytes per second
#  mbps: Megabytes per second
#  kbit: Kilobits per second
#  mbit: Megabits per second
#  bps: Bytes per second
#       Amounts of data can be specified in:
#       kb or k: Kilobytes
#       mb or m: Megabytes
#       mbit: Megabits
#       kbit: Kilobits
#  To get the byte figure from bits, divide the number by 8 bit
#

#
# Name of the traffic control command.
TC=/sbin/tc

# The network interface we're planning on limiting bandwidth.
IF=p4p1             # Interface

# Download limit (in mega bits)
DNLD=300mbit          # DOWNLOAD Limit

# Upload limit (in mega bits)
UPLD=300mbit          # UPLOAD Limit

# IP address of the machine we are controlling
IP=211.110.140.56     # Host IP

# Filter options for limiting the intended interface.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"

start() {

# We'll use Hierarchical Token Bucket (HTB) to shape bandwidth.
# For detailed configuration options, please consult Linux man
# page.

    $TC qdisc add dev $IF root handle 1: htb default 30
    $TC class add dev $IF parent 1: classid 1:1 htb rate $DNLD
    $TC class add dev $IF parent 1: classid 1:2 htb rate $UPLD
    $U32 match ip dst $IP/32 flowid 1:1
    $U32 match ip src $IP/32 flowid 1:2

# The first line creates the root qdisc, and the next two lines
# create two child qdisc that are to be used to shape download
# and upload bandwidth.
#
# The 4th and 5th line creates the filter to match the interface.
# The 'dst' IP address is used to limit download speed, and the
# 'src' IP address is used to limit upload speed.

}

stop() {

# Stop the bandwidth shaping.
    $TC qdisc del dev $IF root

}

restart() {

# Self-explanatory.
    stop
    sleep 1
    start

}

show() {

# Display status of traffic control status.
    $TC -s qdisc ls dev $IF

}

case "$1" in

  start)

    echo -n "Starting bandwidth shaping: "
    start
    echo "done"
    ;;

  stop)

    echo -n "Stopping bandwidth shaping: "
    stop
    echo "done"
    ;;

  restart)

    echo -n "Restarting bandwidth shaping: "
    restart
    echo "done"
    ;;

  show)

    echo "Bandwidth shaping status for $IF:"
    show
    echo ""
    ;;

  *)

    pwd=$(pwd)
    echo "Usage: tc.bash {start|stop|restart|show}"
    ;;

esac

exit 0
이상준[sjlee03] (MX팀) 님의말 : [2022-06-21 15:45:53]
저는 예전에 이거 썼었는데 잘 되더라구요

1. 아래 스크립트 생성 후(tc.sh) 실행 권한 부여
2. IF,  DNLD, UPLD, IP 부분만 수정
3. tc.sh start | stop | restart 로 구동
4. 필요 시 크론 등록

'Security > OS 관련' 카테고리의 다른 글

curl 확인 방법  (0) 2023.11.14
공유메모리 관련  (0) 2023.11.07
트래픽 용량 제한(QOS)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07

트래픽 제한 스크립트

첨부파일 서버에 업로드하고 확장자만 txt-> sh 로 변경해서 아래처럼 쓰면되요

사용법

# 10Mbps 로 대역폭 제한
/root/script/traffic.sh eth0 10000

# 대역폭 제한 확인
/root/script/traffic.sh eth0

# 대역폭 제한 해제
/root/script/traffic.sh eth0 del


#!/bin/sh

if [ $# == 0 ]; then
  echo Please read the man page for the wondershaper and
  echo the file /usr/share/doc/wondershaper/README.Debian
  exit
fi

if [ $# == 1 ]; then
  /sbin/tc -s qdisc ls dev $1
  /sbin/tc -s class ls dev $1
  exit
fi

if [ "$2" == "del" ]; then
  /sbin/tc qdisc del dev $1 root    2> /dev/null > /dev/null
  echo Wondershaper queues have been cleared.
  exit
fi

# please read the README before filling out these values
#
# Set the following values to somewhat less than your actual download
# and uplink speed. In kilobits. Also set the device that is to be shaped.
UPLINK=$2
DEV=$1

#########################################################

# clean existing down- and uplink qdiscs, hide errors
/sbin/tc qdisc del dev $DEV root    2> /dev/null > /dev/null

###### uplink

# install root HTB
/sbin/tc qdisc add dev $DEV root handle 1:0 htb default 15

# main class
/sbin/tc class add dev $DEV parent 1:0 classid 1:1 htb rate ${UPLINK}kbit

# high prio class 1:5
/sbin/tc class add dev $DEV parent 1:1 classid 1:5 htb rate $(($UPLINK/2))kbit \
    ceil ${UPLINK}kbit prio 2

# bulk and default class 1:10 - gets slightly less traffic,
#  and a lower priority:
/sbin/tc class add dev $DEV parent 1:1 classid 1:10 htb rate $(($UPLINK/2))kbit \
    ceil ${UPLINK}kbit prio 6

# 'traffic we hate'
/sbin/tc class add dev $DEV parent 1:1 classid 1:15 htb rate $(($UPLINK/2))kbit \
    ceil ${UPLINK}kbit prio 10

# all get Stochastic Fairness:
/sbin/tc qdisc add dev $DEV parent 1:5 handle 5: sfq perturb 10
/sbin/tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
/sbin/tc qdisc add dev $DEV parent 1:15 handle 15: sfq perturb 10

'Security > OS 관련' 카테고리의 다른 글

공유메모리 관련  (0) 2023.11.07
QOS (트래픽 제한 두번째 방법)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
ModSecurity: Warning. Operator GE matched 4 at TX:outbound_anomaly_score. [file "/opt/apache/conf/modsecurity-crs/rules/RESPONSE-980-CORRELATION.conf"] [line "102"] [id "980140"] [msg "Outbound Anomaly Score Exceeded (score 4): individual paranoia level scores: 4, 0, 0, 0"] [ver "OWASP_CRS/3.2.0"] [tag "event-correlation"] [hostname "www.mangoi.co.kr"] [uri "/lms/class_order_list.php"] [unique_id "YOP5dK0sw8F5Z9UiuqLccQAAABA"], referer: http://www.mangoi.co.kr/lms/index.php
 
 
ㄴ 위와 같으면
/opt/apache/conf/modsecurity-crs/rules/RESPONSE-980-CORRELATION.conf 접속하여 
line 102 가보면
 
ver:'OWASP_CRS/3.2.0'" 해당 부분이며
 
해당 내용에 관련된 룰 전부 주석처리 하면된다.
 
93 #SecRule TX:OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_threshold}" \
94 #    "id:980140,\
95 #    phase:5,\
96 #    pass,\
97 #    t:none,\
98 #    log,\
99 #    noauditlog,\
100 #    msg:'Outbound Anomaly Score Exceeded (score %{TX.OUTBOUND_ANOMALY_SCORE}): individual paranoia level scores: %{TX.OUTBOUND_ANOMALY_SCORE_PL1}, %{TX.
    OUTBOUND_ANOMALY_SCORE_PL2}, %{TX.OUTBOUND_ANOMALY_SCORE_PL3}, %{TX.OUTBOUND_ANOMALY_SCORE_PL4}',\
101 #    tag:'event-correlation',\
102 #    ver:'OWASP_CRS/3.2.0'"

 

'Security > OS 관련' 카테고리의 다른 글

QOS (트래픽 제한 두번째 방법)  (0) 2023.11.07
트래픽 용량 제한(QOS)  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
OS 변조파일 검사 (rkhunter)  (0) 2023.11.07
SecRuleEngine On | Off | DetectionOnly
 
on : 차단
off : 끄기
DetectionOnly : 탐지
 
SecDefaultAction deny, pass 설정 까지 확인해야함
 
- 차단모드 변경 방법 : pass 구문 주석처리 및 deny 구문 주석해제후, apache 재시작
# SecDefaultAction "deny,log,phase:2,status:406,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"
SecDefaultAction "pass,log,auditlog,phase:2,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"

 

'Security > OS 관련' 카테고리의 다른 글

트래픽 용량 제한(QOS)  (0) 2023.11.07
mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
OS 변조파일 검사 (rkhunter)  (0) 2023.11.07
백도어 검사 (chrootkit)  (0) 2023.11.07
공개형 웹 방화벽 (Mod_security)
(1) apache 웹서비스에 Mod_security 모듈 적용
ㄴ 현재 로깅 모드로 적용되어 있으며, 충분한 로그 분석 후 차단모드로 변경 필요
ㄴ 정책파일 : /opt/apache/conf/mod_security2.conf
ㄴ 로그파일 : /opt/apache/logs/modsec_audit.log
 
(2) 차단모드 변경 방법
① vi 편집기로 정책파일 열기
vim /opt/apache/conf/mod_security2.conf
 
② 39번째 라인 주석 처리 및 38번째 라인 주석 해제 후, 저장
 38 SecDefaultAction "deny,log,phase:2,status:406,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"
 39 #SecDefaultAction "pass,log,auditlog,phase:2,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"
 
③ apache 재시작
/opt/apache/bin/apachectl restart
 
 
호스트 기반 탑재형 방화벽 설정
(1) iptables 방화벽 정책 확인
iptables -nvL
 
(2) IP 추가/삭제 방법
전체허용 : iptables -I WHITELIST -s 허용할IP -j ACCEPT
SSH만 허용 : iptables -I SSH -s 허용할IP -j ACCEPT

 

'Security > OS 관련' 카테고리의 다른 글

mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
OS 변조파일 검사 (rkhunter)  (0) 2023.11.07
백도어 검사 (chrootkit)  (0) 2023.11.07
휘슬 설치 프로세스  (0) 2023.11.07
 
cd /root/src; tar zxvf rkhunter-1.4.6.tar.gz
 
cd rkhunter-1.4.6
 
./installer.sh --layout default --install
 
rkhunter --update -c --rwo --propupd (결과만 나옴)
rkhunter --update -c (과정까지 나옴)
 

 

'Security > OS 관련' 카테고리의 다른 글

mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
백도어 검사 (chrootkit)  (0) 2023.11.07
휘슬 설치 프로세스  (0) 2023.11.07
cd /root/src; tar zxvf chkrootkit.tar.gz
cd chkrootkit-0.53
make sense
 
./chkrootkit
 
 
 
* 아래와 같은 오류가 나온다면
 
cc -DHAVE_LASTLOG_H -o chklastlog chklastlog.c
cc -DHAVE_LASTLOG_H -o chkwtmp chkwtmp.c
cc -DHAVE_LASTLOG_H   -D_FILE_OFFSET_BITS=64 -o ifpromisc ifpromisc.c
cc  -o chkproc chkproc.c
cc  -o chkdirs chkdirs.c
cc  -o check_wtmpx check_wtmpx.c
cc -static  -o strings-static strings.c
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
make: *** [strings-static] Error 1
 
# yum install glibc-static
 
glibc-static 를 설치해준다.
 
다시
 
# make sense 하면 된다.
 
cc -DHAVE_LASTLOG_H -o chklastlog chklastlog.c
cc -DHAVE_LASTLOG_H -o chkwtmp chkwtmp.c
cc -DHAVE_LASTLOG_H   -D_FILE_OFFSET_BITS=64 -o ifpromisc ifpromisc.c
cc  -o chkproc chkproc.c
cc  -o chkdirs chkdirs.c
cc  -o check_wtmpx check_wtmpx.c
cc -static  -o strings-stati
 

 

'Security > OS 관련' 카테고리의 다른 글

mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
OS 변조파일 검사 (rkhunter)  (0) 2023.11.07
휘슬 설치 프로세스  (0) 2023.11.07

ㄴ 모두 완료후 휘슬 에이전트에서 중지 처리 후, 고객 서버쪽에서도 반드시 agent 중지 및 삭제 해줘야한다!!
1)중지
[root@q391-0562 ~]# /etc/init.d/wh2 stop
Stopping wh2...
Stopped
[root@q391-0562 ~]# /etc/init.d/wh2 status
Stopped

2)삭제
[root@q391-0562 ~]# cd /wh2/
[root@q391-0562 /wh2]# sh uninstall_wh.sh
Not running
uninstall completed



1) openjdk 설치
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

2) 리눅스용 whistl 다운로드
sudo wget -qO- --no-check-certificate https://whistl.krcert.or.kr/download/sh | bash
ID : serverhosting@cafe24corp.com
PW : cafe24corp!)

3) 에이전트 실행
/etc/init.d/wh2 start
/etc/init.d/wh2 status

4) 방화벽에 443, 5672 포트 허용되어 있어야 함

5) 관리 페이지 : https://whistl.krcert.or.kr


설치 예시)


[root@q552-0980 /opt/apache/logs]# javac -version
javac 1.8.0_261

[root@q552-0980 ~]# sudo wget -qO- --no-check-certificate https://whistl.krcert.or.kr/download/sh | bash
--2021-04-05 11:20:18--  https://whistl.krcert.or.kr/download/linux/latest
Resolving whistl.krcert.or.kr... 192.5.90.134
Connecting to whistl.krcert.or.kr|192.5.90.134|:443... connected.
WARNING: cannot verify whistl.krcert.or.kr’s certificate, issued by “/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA”:
  Unable to locally verify the issuer’s authority.
HTTP request sent, awaiting response... 200 OK
Length: 10906433 (10M) [application/gzip]
Saving to: “wh2.tar.gz”

100%[===================================================================================================================>] 10,906,433  11.1M/s   in 0.9s    

2021-04-05 11:20:19 (11.1 MB/s) - “wh2.tar.gz” saved [10906433/10906433]


wh2 runner check....

[[Enter Username]]
serverhosting@cafe24corp.com
[[Enter Password]]

Starting wh2
Whistlv2 install successfully
[root@q552-0980 ~]# /etc/init.d/wh2 start
Already started
[root@q552-0980 ~]# /etc/init.d/wh2 status
Running




<점검 완료후 이상없을때 페이지 - https://whistl.krcert.or.kr>

'Security > OS 관련' 카테고리의 다른 글

mod_security 탐지 걸린 룰 해제시 방법  (0) 2023.11.07
apache 2.4 mod 시큐리티  (0) 2023.11.07
mod_security 적용 방법  (0) 2023.11.07
OS 변조파일 검사 (rkhunter)  (0) 2023.11.07
백도어 검사 (chrootkit)  (0) 2023.11.07

+ Recent posts