LogPaser 유용한 예제 Windows

Logparser는 MS에서 만든 강력한 IIS, W3C, 이벤트 로그 분석툴로서 SQL 쿼리타입으로 조건별 검색할 수 있는 강력한 툴입니다.

1) 가장 최근에 생성된 시간을 기준으로 ASP 스크립트를 변조한 Trojan Files 여부를 진단
 
C:\logparser2.2\logparser -i:FS "SELECT TOP 20 Path, CreationTime FROM C:\inetpub\wwwroot\*.* ORDER BY CreationTime DESC" -rtp:-1  


2). 가장 최근에 수정된 Files 로그 찾기

C:\logparser2.2\logparser -i:FS "SELECT TOP 20 Path, LastWriteTime FROM C:\inetpub\wwwroot\*.* ORDER BY LastWriteTime DESC" -rtp:-1    
   
3). 해커가 Trojan Files을 삭제한 경우에 HTTP 200 서버코드 흔적 로그를 찾는다.
 
C:\logparser "SELECT DISTINCT TO_LOWERCASE(cs-uri-stem) AS URL, Count(*) AS Hits FROM ex*.log WHERE sc-status=200 GROUP BY URL ORDER BY URL"    -rtp:-1   
  
* nc.exe, tini.exe, root.exe, cmd.exe, upload.asp, aspexec.asp, cmd.asp 같은 파일 이름이 있으면 의심

4) Script Abuse 분석(가장 많은 Request 요청을 받은 Executable 파일의 확장자 확인)

C:\logparser -i:FS "SELECT TO_LOWERCASE(SUBSTR(Name, LAST_INDEX_OF(Name, '.'),  STRLEN(Name))) AS Extenstion, Count(*) AS Files FROM C:\inetpub \wwwroot\*.*, C:\inetpub\scripts\*.* WHERE Attribute NOT LIKE 'D%' GROUP BY Extenstion ORDER BY Files DESC" -rtp:-1  

* 특히, .ASP, .DLL 파일 요청을 유심히 봐야함

5) HTTP 서버 500 에러코드 검사

C:\logparser "SELECT [cs-uri-stem], [cs-uri-query], Count(*) AS [Hits] FROM c:\logs\web\ex*.log WHERE sc-status = 500 GROUP BY [cs-uri-stem], [cs-uri-query] ORDER BY [hits], [cs-uri-stem] DESC" -rtp:-1 -i:iisw3c
  

6) 가장 많은 Request Hit 수를 높음 ASP, DLL 파일 확인

C:\logparser "SELECT TO_STRING(TO_TIMESTAMP(date, time), 'yyyy-MM-dd') AS Day, cs-uri-stem, Count(*) AS Total ex*.log WHERE (sc-status<400 or sc-status>=500) AND (TO_LOWERCASE(cs-uri-stem) LIKE '%.asp%' OR TO_LOWERCASE(cs-uri-stem) LIKE '%.exe') GROUP BY Day, cs-uri-stem ORDER BY cs-uri-stem, Day" -rtp:-1  

7) 시간당 에러수가 가장 많이 발생한 날짜 확인
  
C:\logparser "SELECT date, QUANTIZE(time, 3600) AS hour, sc-status, Count(*) AS Errors FROM ex03*.log WHERE sc-status>=400 GROUP BY date, hour, sc-status HAVING Errors>25 ORDER BY Error DESC" -rtp:-1  

* 25개 이상의 에러코드(404코드)를 발생한 날짜와 시간 결과를 출력

8) 하루동안 50번이상 동일 페이지에 접속을 시도한 클라이언트 IP 확인
  
C:\logparser "SELECT DISTINCT date, cs-uri-stem, c-ip, Count(*) AS Hits FROM ex*.log GROUP BY date, c-ip, cs-uri-stem HAVING Hits>50 ORDER BY Hits DESC" -rtp:-1  

9) 하루동안 50번이상 동일 페이지에 접속을 시도한 클라이언트 IP 확인
 
C:\logparser "SELECT DISTINCT date, cs-uri-stem, c-ip, Count(*) AS Hits FROM ex*.log GROUP BY date, c-ip, cs-uri-stem HAVING Hits>50 ORDER BY Hits DESC" -rtp:-1  

10)  모든 ASP 에러 기록 확인
  
C:\logparser "SELECT cs-uri-query, Count(*) AS Total FROM ex*.log WHERE sc-status>=500 GROUP BY cs-uri-query ORDER BY Total DESC" -rtp:-1  

* 특히, ODBC와 ADO 에러는 SQL Injection 가능성이 있으므로 주의깊게 살펴봐야 함

11) 스크립트 및 Executable 파일의 HTTP 서버 코드 기록 확인
  
C:\logparser "SELECT cs-uri-stem, sc-status, Count(*) AS Total FROM ex*.log WHERE TO_LOWERCASE(cs-uri-stem) LIKE '%.asp%' or TO_LOWERCASE(cs-uri-stem) LIKE '%.exe%' GROUP BY cs-uri-stem, sc-status ORDER BY cs-uri-stem, sc-status" -rtp:-1  

12) Win32 Status Code 분석을 통한 Attack 확인
  
C:\logparser "SELECT cs-uri-stem, WIN32_ERROR_DESCRIPTION(sc-win32-status) AS Error, Count(*) AS Total FROM ex*.log WHERE sc-win32-status>0 AND (TO_LOWERCASE(cs-uri-stem) LIKE '%.asp%' OR TO_LOWERCASE(cs-uri-stem) LIKE '%.exe%') GROUP BY cs-uri-stem, Error ORDER BY cs-uri-stem, Error" -rtp:-1 
  

13) HTTP Method 통계 분석
  
C:\logparser "SELECT cs-uri-stem, cs-method, Count(*) AS Total FROM ex*.log WHERE (sc-status<400 or sc-status>=500) AND (TO_LOWERCASE(cs-uri-stem) LIKE '%.asp%' or TO_LOWERCASE(cs-uri-stem) LIKE '%.exe%') GROUP BY cs-uri-stem, cs-method ORDER BY cs-uri-stem, cs-method" -rtp:-1 

PurposeQuerySample Output
Number of Hits per Client IP, including a Reverse DNS lookup (SLOW)SELECT c-ip As Machine,  
        
REVERSEDNS(c-ip) As Name,  
        
COUNT(*) As Hits  
 
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
 
GROUP BY Machine ORDER BY Hits DESC
MachineNameHits
::1CARLOSAGDEV57
127.0.0.1MACHINE128
127.X.X.XMACHINE21
Top 25 File TypesSELECT TOP 25  
    
EXTRACT_EXTENSION(cs-uri-stem) As Extension,  
    
COUNT(*) As Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY Extension  
ORDER BY Hits DESC
ExtensionHits
gif52127
bmp20377
axd10321
txt460
htm362
Top 25 URLsSELECT TOP 25  
    
cs-uri-stem as Url,  
    
COUNT(*) As Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY cs-uri-stem  
ORDER By Hits DESC
UrlHits
/WebResource.axd10318
/favicon.ico8523
/Tools/CodeTranslator/Translate.ashx6519
/App_Themes/Silver/carlosag.css5898
/images/arrow.gif5720
Number of hits per hour for the month of MarchSELECT  
   
QUANTIZE(TO_LOCALTIME(TO_TIMESTAMP(date, time)), 3600) AS Hour, 
    
COUNT(*) AS Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
WHERE date>'2010-03-01' and date<'2010-04-01'  
Group By Hour
Hour Hits
3/3/201010:00:0033
3/3/201011:00:005
3/3/201012:00:003
Number of hits per Method (GET, POST, etc)SELECT  
    
cs-method As Method,  
    
COUNT(*) As Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY Method
MethodHits
GET133566
POST10901
HEAD568
OPTIONS11
PROPFIND18
Number of requests made by userSELECT TOP 25  
    
cs-username As User,  
    
COUNT(*) as Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
WHERE User Is Not Null  
GROUP BY User
UserCount
Administrator566
Guest1
Extract Values from Query String (d and t) and use them for AggregationSELECT TOP 25  
    
EXTRACT_VALUE(cs-uri-query,'d') as Query_D,  
    
EXTRACT_VALUE(cs-uri-query,'t') as Query_T,  
    
COUNT(*) As Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
WHERE Query_D IS NOT NULL  
GROUP BY Query_D, Query_T  
ORDER By Hits DESC
Query_DQuery_THits
Value in Query1Value in T11556
Value in Query2Value in T2938
Value in Query3Value in T3877
Value in Query4Value in T4768
Find the Slowest 25 URLs (in average) in the siteSELECT TOP 25  
    
cs-uri-stem as URL,  
    
MAX(time-taken) As Max,  
    
MIN(time-taken) As Min,  
    
Avg(time-taken) As Average  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY URL  
ORDER By Average DESC
URLMaxMinAverage
/Test/Default.aspx232152321523215
/WebSite/Default.aspx575727524178
/Remote2008.jpg351035103510
/wordpress/654123271
/RemoteVista.jpg331421658
List the count of each Status and Substatus codeSELECT TOP 25  
    
STRCAT(TO_STRING(sc-status),  
    
STRCAT('.', TO_STRING(sc-substatus))) As Status,  
    
COUNT(*) AS Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY Status  
ORDER BY Status ASC
StatusHits
200144
30438
4009
403.1410
40464
404.32
500.1923
List all the requests by user agentSELECT  
    
cs(User-Agent) As UserAgent,  
    
COUNT(*) as Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
GROUP BY UserAgent  
ORDER BY Hits DESC
UserAgentHits
iisbot/1.0+(+http://www.iis.net/iisbot.html)104
Mozilla/4.0+(compatible;+MSIE+8.0;…77
Microsoft-WebDAV-MiniRedir/6.1.760023
DavClnt1
List all the Win32 Error codes that have been loggedSELECT  
    
sc-win32-status As Win32-Status,  
    
WIN32_ERROR_DESCRIPTION(sc-win32-status) as Description,  
    
COUNT(*) AS Hits  
FROM c:\inetpub\logs\LogFiles\W3SVC1\*  
WHERE Win32-Status<>0  
GROUP BY Win32-Status  
ORDER BY Win32-Status ASC
Win32-StatusDescriptionHits
2The system cannot find the file specified.64
13The data is invalid.9
50The request is not supported.2

docx, xlsx, pptx Mime type IIS

.docx, application/vnd.openxmlformats-officedocument.wordprocessingml.document
.pptx, application/vnd.openxmlformats-officedocument.presentationml.presentation
.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

MIME 확장명

파일 확장명 

 application/x-silverlight-app .xap
 application/manifest .manifest 
 application/x-ms-application .application 
 application/x-ms-xbap .xbap
 application/octet-stream .deploy
 application/vnd.ms-xpsdocument .xps 
 application/xaml+xml .xaml
 application/vnd.ms-cab-compressed .cab
 application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
 application/vnd.openxmlformats-officedocument.wordprocessingml.document .docm
 application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx
 application/vnd.openxmlformats-officedocument.presentationml.presentation .pptm
 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsm
 application/msaccess .accdb
 application/x-mspublisher .pub
 image/svg+xml .svg
 application/xhtml+xml .xht
 application/xhtml+xml .xhtml

SQL 2005 설치 오류 (Error Code 1053) SQL


Windows 2003 DHCP 데이터베이스 내보내기 가져오기 Windows

내보내기
netsh dhcp server export C:\dhcp.txt all

가져오기
netsh dhcp server import c:\dhcpdatabase.txt all

windows 2008 sp1 / windows 2008 R2 winsxs 폴더 용량 줄이기 Windows

이 두 버전은 winsxs 폴더의 용량을 줄이기 위한 별도의 툴이 존재하지 않는다.
그렇다 무덕대고 지우다가는 OS 재 설치라는 재앙이 밀려 올지도 모르고.. (한번 해 봤는데.. 확인 된건 windows update가 안된다는 것만 확인 됨)

안전하게 cache 폴더라도 지우자.

c:\windows\winsxs>Net stop trustedinstaller [Enter]

Takeown /f %windir%\winsxs\ManifestCache\* [Enter]

Icacls %windir%\winsxs\ManifestCache\* /GRANT administrators:F [Enter]

Del /q %windir%\winsxs\ManifestCache\* [Enter]


명령문 보면 알겠지만 ownership 가지고 와서 권한주고 폴더에 저장된 파일 모두 삭제..


그래봤자.. 2~300MB 다.. 


PS.

 진정으로 C 드라이브 용량이 모자라 줄이고 싶다면 C:\Windows\SoftwareDistribution 폴더를 삭제 해라.. 

 삭제 방법은 windows update 서비스 중지 후 폴더 삭제, 서비스 시작.

 그럼 아마 최소 1G 이상 확보 할 수 있을 것 이다.

 


exchange 2010 연결이 끊어진 사서함 목록 갱신 Exchange

계정 삭제 해도 메일 사서함은 30일 동안 삭제 되지 않고 연결이 끊어진 사서함으로 빠진다.

바로 목록이 보이지 않고 일정 시간이 지나야 보인다..

기다리지 못하고 빨라 보고 싶으면

Clean-MailBoxDatabase -Identity 사서함이름

그럼 바로 나온다

SQL 2005 DB 백업 설정 SQL

우선 기본적으로 백업을 설정할   가지의 백업을 설정합니다.

하나는 전체 백업이고 하나는 로그 백업입니다.

 

백업을 설정하기 전에 우선 데이터베이스의 복구 모델(Recovery Model) 어떻게 설정되어 있는지 확인해 보시기 바랍니다.

 

 

Recovery  FULL 또는 BULK_LOGGED, SIMPLE   중의 하나입니다.

로그 백업을 수행하려면 복구 모델이 FULL 또는 BULK_LOGGED   하나여야 합니다.

 

데이터베이스의 복원 모델을 변경하려면 다음과 같은 명령을 사용하면 됩니다.

 

ALTER DATABASE databaseName SET RECOVERY FULL

go

 

 

백업을 설정하는 간단한 방법으로 유지 관리 계획을 이용할  있습니다우선 스크립트 보다 편리하며오래된 파일 삭제 등과 같은 기능을 수행할 수도 있기 때문이지요.

 



 유지 관리 계획을 선택하고 유지 관리 계획의 이름을 FullBackup이라고 지정합시다. (이름은 마음대로~)

도구 상자에서 데이터베이스 백업 작업을 끌어서 작업 영역(분홍색) 갖다 놓습니다.


 

아래와 같이 백업 유형을 전체로 설정하고 백업을 받을 데이터베이스를 선택한 아래 부분에서 백업 파일을 저장할 디렉터리를 설정합니다 디렉터리에다가 받으려면  데이터베이스에 대한 하위 디렉터리 만들기” 옵션을 체크하지 않으면 되고데이터베이스 별로 만들려면  옵션을 체크하면 됩니다.



 

확인을 눌러 편집 창을 닫고도구 상자에서 유지 관리 정리 작업을 추가한 데이터베이스 백업 작업과 연결(녹색시킵니다.

 

 작업은 오래된 백업 파일을 삭제하는 역할을 수행합니다.




디렉터리와
 파일 확장명을 지정하고파일을 보관할 기간을 설정합니다.

 

이와 같이 설정한 상단에 있는 버튼을 클릭해서  작업이 수행될 일정을 설정합니다.



 

전체 백업은 짧게는 하루에   정도길게는 1주일에   정도 수행하면 됩니다상황에 맞게 설정한 확인을 누르면 자동으로 SQL Agent 작업이 등록됩니다.

 




 

로그 백업 설정도 이와 비슷합니다 번째 그림에서 백업 유형을 트랜잭션 로그 설정하면 됩니다.

 

로그 백업은 보통  시간 단위로 수행하도록 설정합니다.

 

http://www.sqlleader.com/mboard.asp?exec=view&strBoardID=SS2005Admin&strSearchCategory=|s_name|s_subject|&intSeq=2324

출처 : 


exchange 2010 Event id 2601 / 1121 Exchange

exchang 2010 sp1 롤업 3르를 설치 하는 중에 아래와 같은 이벤트가 발생하며, 서비스 시작 안되어 롤백을 했다.

Event ID: 2601 
Source: MSExchange ADAccess 
Category: General 
Type: Warning 
Description: Process MSEXCHANGEADTOPOLOGY (PID=1624). When initializing a remote procedure call (RPC) to the Microsoft Exchange Active Directory Topology service, Exchange could not retrieve the SID for account <WKGUID=DC1301662F547445B9C490A52961F8FC,CN=Microsoft Exchange,CN=Services,CN=Configuration,...> - Error code=80040934. The Microsoft Exchange Active Directory Topology service will continue starting with limited permissions.


Event ID: 1121 
Source: MSExchangeIS 
Category: General 
Type: Error 
Description: Error 0x96e connecting to the Microsoft Active Directory.


위 이벤트 관련 해서 문서를 찾아보니 아래 문서 확인하여 방법 2번 3번 적용 후 다시 설치 시도 했다.


http://support.microsoft.com/kb/940845/en-us


불안 불안하게 설치는 완료 하였다.


역시 AD와 분리해서 설치를 해야 하는데.. 서버는 안 사주니 어찌할 도리가 없다.. ㅠ.,ㅠ


아~~ 이런식으로 운영을 해야 하나.. 




Dextupload 네트워크 경로에 대한 파일 업로드/다운로드 (파일서버로 업로드) IIS


Exchange 2010 Event ID 1009 Exchange

로그 이름:         Application
원본:            MSExchangeMailSubmission
날짜:            2011-07-07 오후 3:40:54
이벤트 ID:        1009
작업 범주:         MSExchangeMailSubmission
수준:            오류
키워드:           클래식
사용자:           해당 없음
컴퓨터:           EXCH.imbc.co.kr
설명:
Microsoft Exchange 메일 전송 서비스가 현재 로컬 Active Directory 사이트의 허브 전송 서버에 연결할 수 없습니다. 서버 사용량이 많아서 지금은 새 연결을 받지 못하는 경우일 수 있습니다.


내가 한 작업은

Set-TransportServe -Identity 메일서버이름 -MaxConcurrentMailboxSubmissions 40 (40이란 값은 순전히 나의 생각으로 입력)

exchange 2010 event id 2937(MSExchange ADAccess) Exchange

ADSI 편집기로 해당 계정의 속성에 homeMTA 속성 값을 보면 [도메인네임/Configuration/Deleted Objects/Microsoft MTA
DEL:] 이런 값 들어 가 있다.

그럼 아래 명령 실행 하자

Get-Mailbox 계정이름 | Update-Recipient


Exchange 관리 셸을 사용하여 구성할 데이터베이스의 GUID 확인 Exchange

Get-MailboxDatabase -Identity MailDB_Name | Format-List GUID

Exchange 2010 Mailbox를 pst 파일로 export/import Exchange

사전 작업으로는 sp1이 설치 되어야 한다.

New-MailboxExportRequest -Mailbox 계정이름 -FilePath UNC경로

ex) New-MailboxExportRequest -Mailbox HEW -FilePath \\EX02\PSTFileShare\HEW.pst

New-MailboxImportRequest -Mailbox 계정이름 -FilePath UNC경로

ex) New-MailboxImportRequest -Mailbox HEW -FilePath \\EX02\PSTFileShare\HEW.pst

sql 2005 awe 관련 링크 모음 SQL


CentOS 네트워크 관리 Linux

Ping

 

ping명령어를 이용하면 다른 시스템의 네트워크가 현재 동작 중인지 알 수 있다.

 

Ping [옵션] 호스트

 

옵션

 - s : 보낼 패킷 사이트 지정해 준다.

 - c : 보낼 패킷 수를 지정해 준다.

 

ifconfig

 

네트워크 인터페이스를 설정하고, 현재 네트워크 인터패이스의 정보를 알아보는 명령어

 

ifconfig –a

모든 이더넷의 정보 표시

 

ifconfig eth 0 192.168.0.1 netmask 255.255.255.0 [up/down]

 IP 설정 및 넷마스크 설정 하고 eth 0를 활성화 비활성화

 

ip alias

 하나의 이더넷 카드에 여러 개의 IP를 설정하고자 한다면, IP Alias 기능을 사용한다.

 ifconfig eth0:0 192.168.0.2

 ifconfig eth0:1 192.168.0.3

 

ifup / ifdown

 NIC 중지 동작

 

nslookup

 도메인 네임서버에 질의를 할 수 있도록 해주는 프로그램

 이 명령을 이용하여 도메인 네임 서버가 가지고 있는저옵를 검색하고, 도메인 네임 서버가 올바르게 동작하고 있는지 확인

 

nslookup 도메인

 

netstat

 네트워크 연결, 라우팅 테이블, 네트워크 장치의 통계정보등 네트워크에 관련된 여러가지 정보를 확인

 

netstat [옵션]

 

옵션

 -a : 연결된 모든 소켓을 출력

 -r : 라우팅 테이블을 출력

-t : tcp를 이용하여 접속한 리스트를 출력

-u : udp를 이용하여 접속한 리스트를 출력

 

netstat –ant

 현재 열려있는 모든 포트를 검색해 보여준다.

 

hostname

 호스트네임 출력 및 변경

 

hostname [옵션]

 -v : 호스트네임을 출력

 -d : DNS 도메인 네임 출력

 -f : FQDN 출력

 -i : 호스트 네임에 대한 IP 주소 출력

 

hostname linux.lug.or.kr

 호스트 네임 변경

 로그오프 후 로그온 해야 적용 됨. 하지만 재 부팅하면 원복 됨

완전히 변경하기 위해

vi /etc/sysconfig/network

HOSTNAME 부분 변경 후 로그아웃 or 재부팅 하면 적용


1 2 3 4 5 6 7 8 9


메모장