'Security/Server' + 7

  1. Apache 설정하기
yum 업데이트
설치
부팅시 자동시작
아파치 시작
yum -y update
yum -y install httpd
systemctl enable httpd.service
systemctl start httpd


  1. php 설치하기

php 버전확인
yum list | grep php


기본으로 지원하는 버전은 php5버전
php7버전을 다운받으려면 저장소를 추가한다
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

버전을 변경한 경우 아래와 같이 다운로드

yum --enablerepo=epel,remi install httpd mod_ssl
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

php 설치
아파치 재시작
yum -y install php php-mysql php-gd php-pear
systemctl restart httpd.service



  1. SSL 설정하기
아파치만 설치할 경우 기본으로 80만 서비스하게 된다
mod_ssl이 설치되어야 ssl.conf 로 443을 서비스 할 수 있다.

httpd 버전확인
mod_ssl 모듈 확인
mod_ssl 이 없다면 설치
/usr/local/apache/bin/httpd –v
/usr/sbin/httpd -l
yum -y install mod_ssl
find / -name ssl.conf
etc/httpd/conf.d/ssl.conf

Apache에 SSL 을 설치하기 위해서는 mod_ssl모듈이 설치되어 있어야 한다.
Apache는 두 가지 방식으로 모듈 설치를 지원하고 있으며, 정적일 경우와 동적일 경우 로 나뉜다.
정적인 방식의 경우 mod_ssl.c 이 없을 경우, Apache를 재 설치하여야 한다.
동적인 방식의 경우 mod_so.c 를 확인 후, module 디렉터리 내에 mod_ssl.so 이 있는지 확인 해야한다.


[ 인증서가 별도로 없을 경우 ]
아래부터는 인증서가 별도로 없을 경우 openssl로 생성 후 적용하기 위한 단계이다.
이미 공인으로 인증서를 발급받았을 경우 skip 한다.

openssl 있는지 확인
openssl 이 설치되어 있지 않은 경우, 설치해 주어야 합니다.
rpm –qa |grep openssl
yum –y install openssl-*

개인키 생성 - SSL 인증서를 보관할 디렉터리로 이동
개인키를 생성
생성한 개인키로 csr 파일을 생성.
cd /home/SSL
openssl genrsa -des3 -out [개인키파일명].key 1024 [개인키 암호 입력]
openssl req -new -key [개인키파일명].key -out [CSR파일명].csr

예시) 도메인이 www.ksidc.net 일 경우,

Country Name ( 국가코드) [] : KR State or Province Name ( 지역 ) [] : Seoul Locality Name ( 시/군/구 ) [] : Gangnam Organization Name ( 회사명 ) [] : company IDC Organizational Unit Name ( 부서명 ) [] : security Common Name ( 서비스도메인명 ) [] : www.domain.com Email Address [] :


개인키 및 CSR 파일 생성 완료.
생성한 CSR 파일 확인 방법 root@localhost# openssl req -noout -text -in [CSR파일명].csr
생성한 CSR 파일의 내용을 복사하여, 인증서 발급기관에 발송

cat [CSR파일명].csr
※ 복사한 CSR 파일 내용을 인증기관의 메일로 붙여 넣기 하여 보낸다. 
또는, 고객이 신청한 신청서와 인증서(CSR) 파일을 같이 첨부하여 인증기관 메일 로 보낸다.
※ 복사하여 붙여 넣을 때엔 „-----BEGIN‟ 부터 „REQUEST-----‟ 까지 모두 복사하 여야 한다.
 인증서 설치 - 인증기관에서 발급 받은 인증서를 서버에 업로드 한 뒤, httpd.conf와 httpd-ssl.conf 을 수정.
※ SSL 설정 파일 경로의 경우, Apache 버전 및 설치 환경에 따라 다르며, yum 으로 설치했을 경우, /etc/httpd/conf.d/ssl.conf 에 위치.



서비스 재실행
서비스 재실행, 환경설정에 오류가 있는지 확인.
service httpd restart
/usr/local/apache/bin/apachectl configtest

※ Syntax OK 라고 메시지가 나와야 설정에 문제가 없을 경우 나오는 메시지, 아닐 경우 error 메시지 출력

설정 파일에 문제가 없을 경우, 아래 명령어를 실행하여 서비스를 재실행합니다.

인증서 확인 - 웹 브라우저에서
https://도메인 입력시 인증서가 보이는지 확인.


제일 끝에 아래내용 넣기


vi /etc/httpd/conf/httpd.conf
인증서 경로의 이름 변경

SSLCertificateFile /etc/pki/tls/certs/cert_name.crt SSLCertificateKeyFile /etc/pki/tls/private/cert_name.key


# SSL Virtual host add
NameVirtualHost *:443

# SSL Virtual host add

    SSLEngine on
#    SSLCertificateFile /etc/pki/tls/certs/ca.crt
#    SSLCertificateKeyFile /etc/pki/tls/private/ca.key
    SSLCertificateFile /etc/pki/tls/certs/domain.com.pem
    SSLCertificateKeyFile /etc/pki/tls/private/domain.com.key
    ServerAdmin security@domain.com
    DocumentRoot /var/www/html
    ServerName www.domain.net
    ErrorLog logs/ssl_starkapin_com_error_log
    CustomLog logs/ssl_starkapin_com_error_log common



# -> 인증서 만들때 설정해준 사용자명 혹은 서버 호스트명은 ServerAdmin과 ServerName에 똑같이 적어준다

-  서버 개인키와 인증서 관련 명령어

구   분 명   령   어
Key 생성  openssl genrsa -dec3 -out 도메인.key 1024
Key 확인 openssl rsa -noout -text -in 도메인.key
CSR 생성 openssl req -new -key 도메인.key -out 도메인.csr
CSR 확인 openssl req -noout -text -in 도메인.csr
인증서 내용 확인 openssl x509 –noout –text –in 도메인.crt
원격지 인증서 확인 openssl s_client –connect URL:Port
Key 패스워드 변경 openssl rsa -des3 -in 도메인.key -out 도메인_new.key
Key 패스워드 삭제 openssl rsa -in 도메인.key -out 도메인_new.key
삭제한 패스워드 복구 openssl rsa -in 도메인.key -des3 -out 도메인_new.key

2. 인증서 형식 변환 명령어

구   분 명   령   어
DER을 PEM형식으로 x509 -in cert.cer -inform DER -out cert.pem -outform PEM
PEM을 DER형식으로 x509 -in cert.pem -inform PEM -out cert.der -outform DER
PFX에서 키 추출 pkcs12 –in filename.pfx –nocerts –out key.pem
PFX에서 인증서 추출 pkcs12 –in filename.pfx –clcerts –nokeys –out cert.pem










,

[ Windows ] Powershell 명령어

Security/Server | 2017. 7. 5. 09:28 | 까까까


공감 버튼누르기 어렵지 않아요~~~!!! ^.^


♡♥ 공감 ♥♡ 버튼 눌러주세요 







Powershell 지원 명령어

 

   명령어
   분류
   간단한 설명

ac

Alias

Add-Content

asnp

Alias

Add-PSSnapin

clc

Alias

Clear-Content

cli

Alias

Clear-Item

clp

Alias

Clear-ItemProperty

clv

Alias

Clear-Variable

cpi

Alias

Copy-Item

cpp

Alias

Copy-ItemProperty

cvpa

Alias

Convert-Path

diff

Alias

Compare-Object

epal

Alias

Export-Alias

epcsv

Alias

Export-Csv

fc

Alias

Format-Custom

fl

Alias

Format-List

foreach

Alias

ForEach-Object

%

Alias

ForEach-Object

ft

Alias

Format-Table

fw

Alias

Format-Wide

gal

Alias

Get-Alias

gc

Alias

Get-Content

gci

Alias

Get-ChildItem

gcm

Alias

Get-Command

gdr

Alias

Get-PSDrive

ghy

Alias

Get-History

gi

Alias

Get-Item

gl

Alias

Get-Location

gm

Alias

Get-Member

gp

Alias

Get-ItemProperty

gps

Alias

Get-Process

group

Alias

Group-Object

gsv

Alias

Get-Service

gsnp

Alias

Get-PSSnapin

gu

Alias

Get-Unique

gv

Alias

Get-Variable

gwmi

Alias

Get-WmiObject

iex

Alias

Invoke-Expression

ihy

Alias

Invoke-History

ii

Alias

Invoke-Item

ipal

Alias

Import-Alias

ipcsv

Alias

Import-Csv

mi

Alias

Move-Item

mp

Alias

Move-ItemProperty

nal

Alias

New-Alias

ndr

Alias

New-PSDrive

ni

Alias

New-Item

nv

Alias

New-Variable

oh

Alias

Out-Host

rdr

Alias

Remove-PSDrive

ri

Alias

Remove-Item

rni

Alias

Rename-Item

rnp

Alias

Rename-ItemProperty

rp

Alias

Remove-ItemProperty

rsnp

Alias

Remove-PSSnapin

rv

Alias

Remove-Variable

rvpa

Alias

Resolve-Path

sal

Alias

Set-Alias

sasv

Alias

Start-Service

sc

Alias

Set-Content

select

Alias

Select-Object

si

Alias

Set-Item

sl

Alias

Set-Location

sleep

Alias

Start-Sleep

sort

Alias

Sort-Object

sp

Alias

Set-ItemProperty

spps

Alias

Stop-Process

spsv

Alias

Stop-Service

sv

Alias

Set-Variable

tee

Alias

Tee-Object

where

Alias

Where-Object

?

Alias

Where-Object

write

Alias

Write-Output

cat

Alias

Get-Content

cd

Alias

Set-Location

clear

Alias

Clear-Host

cp

Alias

Copy-Item

h

Alias

Get-History

history

Alias

Get-History

kill

Alias

Stop-Process

lp

Alias

Out-Printer

ls

Alias

Get-ChildItem

mount

Alias

New-PSDrive

mv

Alias

Move-Item

popd

Alias

Pop-Location

ps

Alias

Get-Process

pushd

Alias

Push-Location

pwd

Alias

Get-Location

r

Alias

Invoke-History

rm

Alias

Remove-Item

rmdir

Alias

Remove-Item

echo

Alias

Write-Output

cls

Alias

Clear-Host

chdir

Alias

Set-Location

copy

Alias

Copy-Item

del

Alias

Remove-Item

dir

Alias

Get-ChildItem

erase

Alias

Remove-Item

move

Alias

Move-Item

rd

Alias

Remove-Item

ren

Alias

Rename-Item

set

Alias

Set-Variable

type

Alias

Get-Content

Get-Command

Cmdlet

Cmdlet 및 Windows Power...

Get-Help

Cmdlet

Windows PowerShell cmd...

Get-History

Cmdlet

현재 세션 중에 입력된 명령 목록을 가져...

Invoke-History

Cmdlet

세션 기록에서 명령을 실행합니다.

Add-History

Cmdlet

세션 기록에 항목을 추가합니다.

ForEach-Object

Cmdlet

각 입력 개체 집합에 대해 작업을 수행합니다.

Where-Object

Cmdlet

명령 파이프라인을 따라 전달될 개체를 제...

Set-PSDebug

Cmdlet

스크립트 디버깅 기능을 설정/해제하고 추...

Add-PSSnapin

Cmdlet

하나 이상의 Windows PowerSh...

Remove-PSSnapin

Cmdlet

현재 콘솔에서 Windows PowerS...

Get-PSSnapin

Cmdlet

컴퓨터의 Windows PowerShel...

Export-Console

Cmdlet

다시 사용하거나 공유할 수 있도록 현재 ...

Start-Transcript

Cmdlet

Windows PowerShell의 전체...

Stop-Transcript

Cmdlet

기록을 중지합니다.

Add-Content

Cmdlet

지정된 항목에 내용을 추가합니다.

Clear-Content

Cmdlet

파일에서 텍스트를 삭제하는 것과 같이 항...

Clear-ItemProperty

Cmdlet

속성 값을 삭제하지만 속성 자체는 삭제하...

Join-Path

Cmdlet

경로와 하위 경로를 단일 경로로 결합합니...

Convert-Path

Cmdlet

Windows PowerShell 경로에...

Copy-ItemProperty

Cmdlet

지정된 위치에서 다른 위치로 속성 및 값...

Get-EventLog

Cmdlet

로컬 이벤트 로그 또는 해당 이벤트 로그...

Get-ChildItem

Cmdlet

하나 이상의 지정된 위치에서 항목 및 하...

Get-Content

Cmdlet

지정된 위치에 있는 항목의 내용을 가져옵니다.

Get-ItemProperty

Cmdlet

지정된 항목의 속성을 검색합니다.

Get-WmiObject

Cmdlet

WMI 클래스의 인스턴스 또는 사용 가능...

Move-ItemProperty

Cmdlet

항목의 위치를 이동합니다.

Get-Location

Cmdlet

현재 작업 위치에 대한 정보를 가져옵니다.

Set-Location

Cmdlet

현재 작업 위치를 지정된 위치로 설정합니다.

Push-Location

Cmdlet

현재 위치를 스택에 밀어넣습니다.

Pop-Location

Cmdlet

현재 위치를 가장 최근에 스택에 밀어넣은...

New-PSDrive

Cmdlet

새 Windows PowerShell 드...

Remove-PSDrive

Cmdlet

Windows PowerShell 드라이...

Get-PSDrive

Cmdlet

Windows PowerShell 드라이...

Get-Item

Cmdlet

지정된 위치에 있는 항목을 가져옵니다.

New-Item

Cmdlet

네임스페이스에 새 항목을 만듭니다.

Set-Item

Cmdlet

항목의 값을 명령에 지정된 값으로 변경합니다.

Remove-Item

Cmdlet

지정된 항목을 삭제합니다.

Move-Item

Cmdlet

항목의 위치를 이동합니다.

Rename-Item

Cmdlet

Windows PowerShell 공급자...

Copy-Item

Cmdlet

네임스페이스 내의 다른 위치로 항목을 복...

Clear-Item

Cmdlet

항목의 내용을 삭제하지만 항목 자체는 삭...

Invoke-Item

Cmdlet

지정된 항목에 대한 공급자 기본 작업을 ...

Get-PSProvider

Cmdlet

지정된 Windows PowerShell...

New-ItemProperty

Cmdlet

특정 위치에 있는 항목의 새 속성을 설정...

Split-Path

Cmdlet

경로의 지정된 일부를 반환합니다.

Test-Path

Cmdlet

경로의 모든 요소가 있는지 여부를 확인합니다.

Get-Process

Cmdlet

로컬 컴퓨터에서 실행 중인 프로세스를 가...

Stop-Process

Cmdlet

실행 중인 하나 이상의 프로세스를 중지합니다.

Remove-ItemProperty

Cmdlet

항목에서 속성 및 해당 값을 삭제합니다.

Rename-ItemProperty

Cmdlet

항목의 속성 이름을 바꿉니다.

Resolve-Path

Cmdlet

경로에서 와일드카드 문자를 확인하고 경로...

Get-Service

Cmdlet

로컬 컴퓨터의 서비스를 가져옵니다.

Stop-Service

Cmdlet

실행 중인 하나 이상의 서비스를 중지합니다.

Start-Service

Cmdlet

하나 이상의 중지된 서비스를 시작합니다.

Suspend-Service

Cmdlet

실행 중인 하나 이상의 서비스를 일시 중...

Resume-Service

Cmdlet

하나 이상의 일시 중단(일시 중지)된 서...

Restart-Service

Cmdlet

하나 이상의 서비스를 중지한 다음 다시 ...

Set-Service

Cmdlet

서비스의 표시 이름, 설명 또는 시작 모...

New-Service

Cmdlet

레지스트리와 서비스 데이터베이스에 새 W...

Set-Content

Cmdlet

항목의 내용을 쓰거나 새 내용으로 바꿉니다.

Set-ItemProperty

Cmdlet

지정된 위치의 속성 값을 설정합니다.

Get-Acl

Cmdlet

파일 또는 레지스트리 키와 같은 리소스에...

Set-Acl

Cmdlet

파일 또는 레지스트리 키와 같은 지정된 ...

Get-PfxCertificate

Cmdlet

컴퓨터의 .pfx 인증서 파일 정보를 가...

Get-Credential

Cmdlet

사용자 이름 및 암호를 기반으로 자격 증...

Get-ExecutionPolicy

Cmdlet

셸에 대한 현재 실행 정책을 가져옵니다.

Set-ExecutionPolicy

Cmdlet

셸의 실행 정책에 대한 사용자 기본 설정...

Get-AuthenticodeSignature

Cmdlet

파일에서 Authenticode 서명 정...

Set-AuthenticodeSignature

Cmdlet

Authenticode 서명을 사용하여 ...

ConvertFrom-SecureString

Cmdlet

보안 문자열을 암호화된 기본 문자열로 변...

ConvertTo-SecureString

Cmdlet

암호화된 기본 문자열을 보안 문자열로 변...

Format-List

Cmdlet

출력의 형식을 각 속성이 새 줄에 표시되...

Format-Custom

Cmdlet

사용자 지정된 보기를 사용하여 출력 형식...

Format-Table

Cmdlet

출력 형식을 표로 지정합니다.

Format-Wide

Cmdlet

개체의 형식을 각 개체 속성을 하나만 표...

Out-Null

Cmdlet

출력을 콘솔로 보내는 대신 삭제합니다.

Out-Default

Cmdlet

출력을 기본 포맷터와 기본 출력 cmdl...

Out-Host

Cmdlet

출력을 명령줄로 보냅니다.

Out-File

Cmdlet

출력을 파일로 보냅니다.

Out-Printer

Cmdlet

출력을 프린터로 보냅니다.

Out-String

Cmdlet

개체를 연속 문자열로 호스트에 보냅니다.

Add-Member

Cmdlet

사용자가 정의한 사용자 지정 멤버를 Wi...

Compare-Object

Cmdlet

두 개체 집합을 비교합니다.

ConvertTo-Html

Cmdlet

개체 또는 개체 집합을 나타내는 HTML...

Export-Csv

Cmdlet

입력 개체를 나타내는 쉼표로 구분된 값(...

Import-Csv

Cmdlet

Export-CSV cmdlet이 만든 ...

Export-Alias

Cmdlet

현재 정의된 별칭에 대한 정보를 파일로 ...

Invoke-Expression

Cmdlet

문자열 형식으로 제공된 Windows P...

Get-Alias

Cmdlet

현재 세션의 별칭을 가져옵니다.

Get-Culture

Cmdlet

컴퓨터의 국가별 설정 정보를 가져옵니다.

Get-Date

Cmdlet

현재 날짜 및 시간을 가져옵니다.

Get-Host

Cmdlet

현재 콘솔 호스트 개체에 대한 참조를 가...

Get-Member

Cmdlet

개체 또는 개체의 컬렉션에 대한 정보를 ...

Get-UICulture

Cmdlet

Windows PowerShell의 현재...

Get-Unique

Cmdlet

정렬된 목록에서 고유한 항목을 반환합니다.

Import-Alias

Cmdlet

파일에서 별칭 목록을 가져옵니다.

Select-String

Cmdlet

문자열에서 패턴을 확인합니다.

Measure-Object

Cmdlet

개체의 특징 및 속성을 측정합니다.

New-Alias

Cmdlet

새 별칭을 만듭니다.

New-TimeSpan

Cmdlet

TimeSpan 개체를 만듭니다.

Read-Host

Cmdlet

콘솔에서 입력 줄을 읽습니다.

Set-Alias

Cmdlet

Cmdlet 또는 현재 Windows P...

Set-Date

Cmdlet

컴퓨터의 시스템 시간을 지정한 시간으로 ...

Start-Sleep

Cmdlet

지정된 기간 동안 shell, scrip...

Tee-Object

Cmdlet

개체 입력을 파일이나 변수로 파이프한 다...

Measure-Command

Cmdlet

스크립트 블록 및 cmdlet을 실행하는...

Update-TypeData

Cmdlet

*.types.ps1xml 파일을 메모리...

Update-FormatData

Cmdlet

형식 데이터 파일을 업데이트하고 추가합니다.

Write-Host

Cmdlet

호스트 사용자 인터페이스를 사용하여 개체 표시

Write-Progress

Cmdlet

Windows PowerShell 명령 ...

New-Object

Cmdlet

.Net 또는 COM 개체의 인스턴스를 ...

Select-Object

Cmdlet

개체의 지정된 속성이나 개체의 설정을 선...

Group-Object

Cmdlet

지정한 속성에 대해 같은 값이 있는 개체...

Sort-Object

Cmdlet

속성 값에 따라 개체를 정렬합니다.

Get-Variable

Cmdlet

현재 콘솔에 있는 변수를 가져옵니다.

New-Variable

Cmdlet

새 변수를 만듭니다.

Set-Variable

Cmdlet

변수 값을 설정합니다. 요청한 이름이 있...

Remove-Variable

Cmdlet

변수와 그 값을 삭제합니다.

Clear-Variable

Cmdlet

변수 값을 삭제합니다.

Export-Clixml

Cmdlet

개체의 XML 기반 표시를 만들고 이 표...

Import-Clixml

Cmdlet

CLIXML 파일을 가져오고 Window...

Write-Debug

Cmdlet

호스트 표시에 디버그 메시지를 기록합니다.

Write-Verbose

Cmdlet

호스트의 상세 정보 표시에 문자열을 기록...

Write-Warning

Cmdlet

경고 메시지를 작성합니다.

Write-Error

Cmdlet

오류 파이프라인에 개체를 기록합니다.

Write-Output

Cmdlet

성공 파이프라인에 개체를 기록합니다.

Get-TraceSource

Cmdlet

추적을 위해 계측된 Windows Pow...

Set-TraceSource

Cmdlet

Windows PowerShell 구성 ...

Trace-Command

Cmdlet

Trace-Command cmdlet은 ...

Alias

Provider

Windows PowerShell 별칭 ...

Environment

Provider

Windows 환경 변수에 대한 액세스를...

FileSystem

Provider

Windows PowerShell의 파일...

Function

Provider

Windows PowerShell에 정의...

Registry

Provider

Windows PowerShell의 시스...

Variable

Provider

Windows PowerShell 변수 ...

Certificate

Provider

Windows PowerShell 내의 ...

about_alias

HelpFile

Windows PowerShell에서 c...

about_arithmetic_operators

HelpFile

Windows PowerShell에서 산...

about_array

HelpFile

데이터 요소를 저장하기 위한 간단한 데이...

about_assignment_operators

HelpFile

Windows PowerShell에서 변...

about_associative_array

HelpFile

쌍을 이루는 키와 값 집합을 저장하기 위...

about_automatic_variables

HelpFile

Windows PowerShell에 의해...

about_break

HelpFile

foreach, for, while, d...

about_command_search

HelpFile

Windows PowerShell에서 명...

about_command_syntax

HelpFile

Windows PowerShell의 명령 형식

about_commonparameters

HelpFile

모든 cmdlet이 지원하는 매개 변수

about_comparison_operators

HelpFile

Windows PowerShell에서 값...

about_continue

HelpFile

프로그램 루프의 맨 위로 즉시 돌아가기

about_core_commands

HelpFile

데이터 저장소와 관련된 Windows P...

about_display.xml

HelpFile

개체의 표시 방법 제어

about_environment_variable

HelpFile

Windows PowerShell에서 W...

about_escape_character

HelpFile

Windows PowerShell이 문자...

about_execution_environ...

HelpFile

명령이 실행되는 방법에 영향을 주는 요인

about_filter

HelpFile

Windows PowerShell에서 W...

about_flow_control

HelpFile

Windows PowerShell에서 흐...

about_for

HelpFile

간단한 설명

about_foreach

HelpFile

항목 컬렉션에 있는 모든 항목을 트래버스...

about_function

HelpFile

Windows PowerShell에서 함...

about_globbing

HelpFile

와일드 카드 참조

about_history

HelpFile

Windows PowerShell 명령 ...

about_if

HelpFile

하나 이상의 조건 테스트 결과를 기반으로...

about_line_editing

HelpFile

Windows PowerShell 명령 ...

about_location

HelpFile

Windows PowerShell에서 작...

about_logical_operator

HelpFile

Windows PowerShell에서 여...

about_method

HelpFile

Windows PowerShell에서 메...

about_namespace

HelpFile

Windows PowerShell에서 유...

about_object

HelpFile

Windows PowerShell에서 개...

about_operator

HelpFile

Windows PowerShell에서 지...

about_parameter

HelpFile

Windows PowerShell에서 C...

about_parsing

HelpFile

Windows PowerShell에서 명...

about_path_syntax

HelpFile

Windows PowerShell에서 사...

about_pipeline

HelpFile

Windows PowerShell에서 명...

about_property

HelpFile

Windows PowerShell 개체 ...

about_provider

HelpFile

Windows PowerShell 공급자...

about_pssnapins

HelpFile

Windows PowerShell 스냅인...

about_quoting_rules

HelpFile

문자열 경계를 설정하는 규칙

about_redirection

HelpFile

Windows PowerShell의 출력...

about_ref

HelpFile

참조 변수 유형을 만드는 방법

about_regular_expression

HelpFile

Windows PowerShell에서 C...

about_reserved_words

HelpFile

특별한 의미를 갖고 있기 때문에 식별자로...

about_scope

HelpFile

Windows PowerShell 환경에...

about_script_block

HelpFile

Windows PowerShell에서 문...

about_shell_variable

HelpFile

Windows PowerShell에서 만...

about_signing

HelpFile

Windows PowerShell 실행 ...

about_special_characters

HelpFile

Windows PowerShell이 명령...

about_switch

HelpFile

스위치를 사용하여 여러 if 문 처리

about_system_state

HelpFile

셸이 실행 중일 때 Windows Pow...

about_types

HelpFile

Windows PowerShell에서 ....

about_where

HelpFile

개체 속성에 따라 개체 필터링

about_while

HelpFile

조건 테스트 결과를 기반으로 명령 블록을...

about_wildcard

HelpFile

Windows PowerShell에서 c...

default

HelpFile

PowerShell cmdlet 및 개념...

 


,
운영중인 IIS 서버에서 장애가 났다....ㅠㅠㅠㅠㅠㅠㅠㅠ OMG

처리를 담당하는 IIS 서비스가 정상적으로 실행되지 않고
백신 서비스만 90-100%의 메모리 점유가 되는 바람에 IIS가 메모리 점유가 안되고 정상 동작이 안되었다..

그덕에 IIS 서버에 어마어마한 양의 큐가 ..........


백신의 평균 메모리 점유율은 150MB 정도...
무슨 백신인지는 비밀로........

[ 정상인 상태의 IIS ]




일단 장애는 장애이고 당시 백신을 정지 후에 해결이 되었으니 후조치 대응을 해야한다
재발생이 되더라도 즉각으로 대응할 수 있도록
 
조치방법으로는
     1. 백신에서 IIS 실행파일자체를 예외처리
          ( 기본적으로 백신에서는 IIS 는 예외처리되어있지만.. IIS 프로세스명과 해당폴더를 예외처리적용했다 )
     2. 스크립트를 이용해 memory monitoring




powershell을 이용하여 memory moniring 스크립트를 작성하였다.

process를 가져와서 mb 단위로 변경하여 백신의 메모리가 500MB 이상이 될 경우 SMS로 alert
IIS 도 함께 메모리가 정상인지 확인하기 위해 함께 알림


그리고 각 서버에 task scheduler 에 등록하기

> 실행주기 설정



> 뭘할지 Action 설정 
powershell로 action을 등록하면 powershell 경로를 또 지정해줘야하기 때문에 bat 파일 간단히 작성해서 bat파일로 등록했다

windows server 초기엔 powershell 실행 권한?이 없기 때문에 실행할수 있도록 모드를 변경해줘야한다


[bat 파일]
powershell set-executionpolicy unrestricted
powershell C:\***_mon.ps1
powershell set-executionpolicy remotesigned





[ memory monitoring script ]
$ComputerName=$ENV:ComputerName
# 백신 프로세스 메모리 확인
$vaccine=Get-Process-ProcessNameekrn|SelectName,@{n="PrivateMemory";e={$_.PrivateMemorySize/1mb}}
# IIS ( w3wp ) - 프로세스 메모리 확인
$IIS = Get-Process -ProcessName w3wp | Select Name,@{n="PrivateMemory";e={$_.PrivateMemorySize/1mb}}

$vaccine _name = $vaccine .Name
$vaccine _memory = $vaccine .PrivateMemory
$vaccine _memory = "{0:N1}" -f $vaccine _memory
$IIS_name = $IIS.Name
$IIS_memory = $IIS.PrivateMemory
$IIS_memory = "{0:N1}" -f $IIS_memory

# $vaccine_process 가 500 이상 (-gt) 일 경우 sms을 보내주는 url을 호출해줭 
if($vaccine_process-gt 500){
    $url = ‘SMS으로 alert을 호출하는 API URL'
    Invoke-WebRequest -Uri $url
}





[ 수신한 SMS ]



끝~

2주동안 아직은 안오고 있긴한데.........





,
아래 리스트들은 바이러스 맬웨어 방지 솔루션의 제품인증 기본 표준 순위를 나타내 주는 기관?이다

관리자에게는 바이러스의 기본기능인 탐지 / 빠른 DB업데이트 에 추가로 
낮은오탐율 / 운영시 가벼움 / 추가기능 / 가격 / 인지도 등이  여러가지의 백신 선택 기준이 된다

물론 서버 백신인지 클라이언트 백신인지에 따라서도 여러 기준의 비율이 달라질 수 있는데 

백신의 경우 일일이 설치해서 확인해보기가 쉽지 않기 때문에
공신력있는 여러 기관?의 테스트와 평판이 그 백신을 결정하는데에 참고에 많은 도움이 된다.

실제로 백신을 한번 잘못선택할 경우 두고두고 후회하는... 불상사가 되지 않길 바라며

총 4개의 백신 test 순위를 갖는 기관?을 모아 보았다.

개인적으로 직접 사용후기를 보는것도..........
클라이언트 백신으로 Kaspersky를 썼다가 엄청난 고생을 했다................ 하.... ;;; 
물론 좋은점도 있지만.....(끔찍) 


  1. AV-comparatives
    http://www.av-comparatives.org/

          연간 Awards를 한눈에 볼수있는 페이지 
          
          AWARDS > Statics 를 통해 확인이 가능하다.

          



          아래와 같이 카테고리를 선택해서 연도별로 확인이 가능하다.

          


          



  1. VB100 ( Virus Bulletin, 바이러스 블러틴 ) 

          
          2개월에 한번씩 발표하는 테스트 결과이다.
          RAP ( Reactive And Proactive ) 테스트 결과로, 위-오른쪽일 수록 높은 점수가 된다. ( 구버전의 그래프일때 )

          Reactive - 새롭게 등장하는 바이러스 샘플을 찾는 능력
          Proactive - 데이터베이스에 정식 등록되지 않은 샘플을 찾아내는 능력

          예전에는 그래프로 나왔으나 요즘에는 표로 변경된 듯 하다..  ( 그래프가 더 보기쉬웠는데....... )
          

          


  1. TOPTEN Reviews 

          백신 프로그램의 성능/가격/인지도등을 한눈에 확인 가능하다.
          




  1. AV Test  
          
          용도 / OS / 날짜에 따라서 순위를 확인 할 수 있다.
          



무엇이 좋은 백신인지는 운영 환경에 따라 너무도 다르기때문에
딱히 추천한다고 할 수 없지만 비추는 가려낼 수 있을 것 같다..................;;

 


,

 

 

Server Security Guide


 

 

Idle time 설정 - 설정되있음

 

로그인 실패 횟수 제한 ( 계정 잠금 카운터 ) - 설정안되어있음

계정 잠금기간 (5) / 계정잠금 임계값 5/ 계정잠금 카운터 재설정 5

 

공유폴더 확인 ( ex. 프린터 공유 - 예시. \\ IP address \print$

 

1. Windows Server

1.1 Windows Update

Control Panel\All Control Panel\Windows Update

Check for updates > Install

* 비즈니스에 방해가 되는 경우를 제외한 최신 보안 패치는 즉시 설치되어야 함

 

 

 

 

1.2 Shared Folder

1.2.1 시스템 기본 공유폴더 제거

* IPS$는 서비스에 영향을 미칠 수 있으므로 삭제 전 검토가 필요함

방법 1. 컴퓨터 관리 설정 변경

Computer Management\System Tolls\Shared Folders\Shares

C$ / D$ / ADMIN$ Stop Sharing

* 서버 또는 서비스 재시작 시 재설정 필요함

 

방법2. Command 실행

cmd.exe

> net share

> netshare 공유 이름 /delete

* 서버 또는 서비스 재시작 시 재설정 필요함

>위 설정후에는 재부팅후에 설정이 원복됨 ( 레지스트리를 수정해줘야 원복되지 않음 )

 

 

방법3. 레지스트리 수정

*방법 1, 2은 서버 또는 서비스 재시작시 공유폴더가 활성화되어 재시작이 필요하나

레지스트리를 수정하면 시스템 재부팅 후 디폴트 폴더가 자동 공유되는 것 방지 가능함.

그러나 레지스트리 수정 방법은 IPC$를 포함한 모든 기본 공유 폴더 비활성화하므로

주의가 필요함

regedit.exe >

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameter

Value name : AutoShareServer

DataType : REG_DWORD

Value : 0 (Zero)

 

1.2.2 공유폴더 Everyone 권한 제한

Computer Management\System Tolls\Shared Folders\Shares

공유된 폴더의 Everyone 권한 Read Only 또는 Deny All

 

 

 

1.3 Remote Desktop

1.3.1 Drive redirection 비활성화

* 터미널 서버에서 로컬 드라이브 액세스 제한

방법 1. 레지스트리 수정

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Serivice

Value name : fDisableCdm

DataType : REG_DWORD

Value : 1

 

 

방법 2. 컴퓨터 구성 수정

gpedit.msc >

Computer Configuration\Policies\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Device and Resource Redirection\Do not allow drive redirection

Enabled: All drives

 

1.3.2 원격 접속 권한 제한 설정

방법 1. 컴퓨터 관리 수정

Computer Management\Local Users and Groups\Users

일반 User계정: Deny the user permissions to log on to Remote Desktop Session Host server

 

방법 2. 컴퓨터 구성 수정

gpedit.msc >

Computer Configuration\Policies\Windows Settings\Security Settings\Local Policies\User Rights Assignment\Allow log on through Remote Desktop Services

Administrators / (Remote Desktop Users)

 

 

 

 

 

1.3.3 Idle time 설정

방법 1. 레지스트리 수정

regedit.exe >

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services

Value name : MaxIdleTime

DataType : REG_DWORD

Value : 900000 (Dec)

 

 

방법 2. 컴퓨터 구성 수정

gpedit.msc

Computer Configuration\Policies\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Session Time Limits\Set time limit for active but idle Remote Desktop Services sessions

15 minutes

 

1.3.4 Plug & Play redirection리다이렉션 제한

* Plug & Play : 장치 자동 인식 기능

방법 1. 레지스트리 수정

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services

Value Name: fDisablePNPRedir
Type: REG_DWORD
Value: 1

 

방법 2. 컴퓨터 구성 수정

gpedit.msc >

Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Device and Resource Redirection\Do not allow supported Plug and Play device redirection

Enabled

 

 

1.4 Drive

1.4.1 Autorun 비활성화

          * Autorun : autorun.inf라는 파일을 자동으로 읽어, 특정 프로그램을 자동으로 실행하는 기능

방법 1. 레지스트리 수정

regedit.exe >
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

Value name : NoAutorun

DataType : REG_DWORD

Value : 1

              

           

방법 2. 컴퓨터 구성 수정

Computer Configuration\Administrative Templates\Windows Components\AutoPlay Policies\Set the default behavior for AutoRun

Enabled: Do not execute any autorun commands

 

 

1.4.2 Autoplay 비활성화

* Autoplay : 드라이브의 미디어를 읽어들여 자동으로 재생하는 기능

방법 1. 레지스트리 수정

regedit.exe >
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

Value name : NoDriveTypeAutoRun

DataType : REG_DWORD

Value : FF

               

 

방법 2. 컴퓨터 구성 수정

gpedit.msc >

Computer Configuration\Administrative Templates\Windows Components\AutoPlay Policies\Turn off Autoplay

Enabled: All drives

1.5. Etc.

1.5.1 네트워크로부터의 접근 권한 제어

* 네트워크의 다른 사용자가 SMB / NetBIOS / CIFS / COM+ 등의 프로토콜에 접근할 수 있는 권한

설정

Computer Configuration\Policies\Windows Settings\Security Settings\Local Policies\User Rights Assignment\Access this computer from the network

Administrators / Authenticated Users / (ENTERPRISE DOMAIN CONTROLLERS)

1.5.2 불필요한 서비스 비활성화

* 서버의 기능에 따라 서비스 사용 여부 확실히 판단 후 disable

Control Panel\All Control Panel Items\Administrative Tools\Services

불필요한 Service 속성 > Startup type: disable

 

* 참고 : 오픈 포트 확인

CMD

Netstat -nao

 

* 대표적인 불필요한 서비스 ( 아래 서비스 사용 여부 확인 후 disable / 굵은 글씨 : 특히 주의 )

- File and printer sharing services (NetBIOS / NFS / FTP)

 - Wireless networking services

 - Remote control and remote access programs, particularly those that do not strongly encrypt their -communications (Telnet)

 - Directory services (LDAP, NIS)

- Web servers and services

- Email services (SMTP)

- Language compilers and libraries

 - System development tools

 - System and network management tools and utilities (SNMP)

 

 

 

 

 

 

 

 

 

2. 참고 문서

     - CIS Microsoft Windows Server 2012 R2 Benchmark (v2.2.1)

     - NIST Guide to General Server Security (Special Publication 800-123)

     - SANS Server Security Policy (2016)

,


Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a

 policy defined at a more specific scope.  Due to the override, your shell will retain its current effective execution

policy of Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information p

lease see "Get-Help Set-ExecutionPolicy".

At line:1 char:1

+ Set-ExecutionPolicy “RemoteSigned” -Scope CurrentUser -Confirm:$false

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException

    + FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand


그냥 콘솔에서 실행할 때는 에러가 나지 않았지만

오른쪽클릭 후 powershell 실행 후에는 위와 같은 에러가 났다.

> Get-ExecutionPolicy -List

아무래도 MachinePolicy 가 허용안됨으로 되있어서 그런듯 하여

( 다른항목은 userpolicy / currentuser 등 모두 undefined로 변경해도 동일한 증상이었기 때문에 )

해당 값을 변경하려 했으나 다시 오류

그룹정책을 먼저 변경해 줘야 한다고 한다.....

그래서 그룹정책을 변경하기 위해

command 창을 켜고 ( win + r )

gpedit.msc

컴퓨터 구성> 관리 템플릿> Windows 구성 요소> Windows PowerShell

 Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell

위 경로로 이동한다

그리고 Not Configured 에서 Enabled 로 변경해주고 Apply 한다.

그리고 레지스트르 값을 변경하기 위해

Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\PowerShell -Name ExecutionPolicy -Value Bypass

명령어 실행 후 다시 확인해보면 값이 변경되있다.

그리고 다시 파워쉘 스크립트를 실행해 보면 정상실행~!




,



오늘 퇴근시간이 다 되어서 갑자기 앞에 아이디만 변경해서 수십통의 메일이 수신된다는 문의를 받았다

평소처럼 스팸메일 솔루션에 해당 도메인을 예외처리 하려고 하던 중  발신인을 보니 모두 IP 예외처리가 되있는게 아닌가?

오잉??? 하고 보니 사내 IP를 가진 Sendmail 서버가 발송한 메일이었다.......

분명히 내용은 사내 메일내용이 아니고 발신자도 아니었다. 

원인은?????


우선

메일서버에서 내부로 들어오는 메일에 대해서 내 도메인이 아닌 메일이 들어왔을 때 메일서버는 두가지 방식을 취한다.

1. 그냥 씹는다.

2. 그 잘못 들어온 메일의 도메인 주인에게 넘겨준다 ( Relay 한다라고 한다. )


결국 원인은 

Sendmail 서버로 무작위 하게 누군가가 스팸성 메일을 보냈는데 이 중 하나 걸린게 우리 내부 도메인인 것이었다.

( 보안상 메일 서버에는 보통 릴레이 설정을 해두지 않는다. 다만, 사내 도메인만 Relay 설정을 해둔다. ) 

결국은 운좋게 보낸 메일 중 모두가 씹히?고, 내부 도메인 하나가 걸려서 사내 도메인이네 하고 Relay 설정되있어서 그렇게 

내부 Exchange 서버로 전달을 한것이었다.


정상 경로

외부 -> Exchange -> SpamMail Server ( 스팸?? - 불통!! / 정상? - 통! ) -> 사내 메일 직원 에게로


비정상 경로

외부 -> SendMail Server -> Exchange -> SpamMail Server ( 응? 사내 IP? - 내부 IP 잖아 그냥 예외~~ 즉시 통! ) -> 사내 메일 내부 직원 에게로



MX레코드란? ( Mail Exchange record )

특정 도메인에 대한 메일을 수신하는 메일 서버를 지정하는 레코드

















,