Reading Text Files

Microsoft® Windows® 2000 Scripting Guide

Method

Description

Read

Reads the specified number of characters and then stops. For example, the following command would read the first 12 characters of the first line ("Alerter,Shar") into the variable strText and then stop:strText = objTextFile.Read(12)

ReadLine

Reads one line from a text file and then stops before reaching the newline character. For example, the following command would read the first line ("Alerter,Share Process,Running,Auto,LocalSystem") into the variable strText and then stop:strText = objTextFile.ReadLine

To read an entire text file on a line-by-line basis, place the ReadLine function within a loop.

ReadAll

Reads the entire contents of a text file into a variable.

Skip

Skips the specified number of characters and then stops. For example, the following command would skip the first 12 characters. Any subsequent read operations would begin with the 13th character and continue from there ("e Process,Running,Auto,LocalSystem"):objTextFile.Skip(12)

SkipLine

Skips an entire line in a text file. For example, this code reads the first and third lines of a text file, skipping the second line:strText = objTextFile.Readline objTextFile.SkipLine strText = objTextFile.Readline

Listing 4.37 Verifying the Size of a File

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Windows\Netlogon.log")
If objFile.Size > 0 Then
 Set objReadFile = objFSO.OpenTextFile("C:\Windows\Netlogon.log", 1)
 strContents = objReadFile.ReadAll
 Wscript.Echo strContents
 objReadFile.Close
Else
 Wscript.Echo "The file is empty." 

End If


Listing 4.38 Reading a Text File Using the ReadAll Method

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\FSO\ScriptLog.txt", ForReading)
strContents = objFile.ReadAll
Wscript.Echo strContents
objFile.Close


Listing 4.39 Reading a Text File Using the ReadLine Method

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("C:\FSO\ServerList.txt", 1)
Do Until objFile.AtEndOfStream
 strLine = objFile.ReadLine
 Wscript.Echo strLine
Loop
objFile.Close


Listing 4.40 "Reading" a Text File from the Bottom to the Top

Dim arrFileLines()

i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\FSO\ScriptLog.txt", 1)
Do Until objFile.AtEndOfStream
 Redim Preserve arrFileLines(i)
 arrFileLines(i) = objFile.ReadLine
 i = i + 1
Loop
objFile.Close
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
 Wscript.Echo arrFileLines(l)
Next


6/19/2002   Success
6/20/2002   Failure
6/21/2002   Failure
6/22/2002   Failure
6/23/2002   Success


6/23/2002 Success

6/22/2002   Failure
6/21/2002   Failure
6/20/2002   Failure
6/19/2002   Success



Listing 4.41 Reading a Fixed-Width Text File


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("C:\FSO\ScriptLog.txt", 1)
Do Until objFile.AtEndOfStream
 objFile.Skip(5)
 strCharacters = objFile.Read(1)
 Wscript.Echo strCharacters
 objFile.SkipLine
Loop


C:\FSO\ScriptLog.txt
XXXXX1XXXXXXXXXXXXXX
XXXXX2XXXXXXXXXXXXXXXXXXX
XXXXX3XXXXXXXXXXXX
XXXXX4XXXXXXXXXXXXXXXXXXXXXXXXX


1

2

3

4



Posted by n3015m
:

"주요정보통신기반시설 기술적 취약점 분석평가"의 통신장비 취약점 분석평가 항목에 대하여  CISCO 네트워크 IOS 12.X 버전에 대해서 자동으로 분석하는 Excel입니다.


매년 인프라 점검을 전문업체 등을 통해 수행하고 있지만 간혹 자가 점검이 필요할때가 있어 옛 기억을 더듬어 최근에 새롭게 만들게 되어 동일 니즈를 가진 관리자 및 운영자가 많을거 같아 공유 드립니다.


별도 사용제한은 없습니다. 소규모 시설의 보안 담당자나 보안감사 전에 활용하시면 좋을거 같습니다.(다만, VBA는 악용 소지가 있어 비번을 설정하였습니다.)


※ 다운로드

CII_CISCO_NETWORK_v2.11.zip

CII_CISCO_NETWORK_v2.31.zip

CII_CISCO_NETWORK_v2.32.zip



※ 주의사항

- 충분한 config 확보가 어려워 일부 오탐이 포함되어 있습니다.

  오탐 및 오류는 엑셀에 기재된 내용을 참고하셔서 문의바랍니다.


※ 사용법

- Config 파일저장 

  시스코 스위치/라우터에 접속해서 enable모드에서 show config 내용을 텍스트 파일로

  저장합니다.

  <중요>파일명은 HOSTNAME, 확장자 CFG 또는 TXT를 저장해야 합니다.

  ex) INT_ROUTER.CFG


- 위의 엑셀 파일을 config 파일이 수집된 폴더에 복사해서 엑셀의 안내를 확인하시고

  H열의 시작버튼을 클릭합니다.


- EXCEL 버전은 2007 이상의 버전을 권장합니다.


- 압축 파일에는 테스트 config 3개 포함되어 있으니 config가 없이 테스트가 가능합니다.



※ 조치가이드 및 항목

   - 주요정보통신기반시설 기술적 취약점 분석평가 방법 상세가이드 참조

   - 다운로드 : http://www.mogaha.go.kr/frt/bbs/type001/commonSelectBoardArticle.do?bbsId=BBSMSTR_000000000012&nttId=41297


Posted by n3015m
:

BLOG main image
'네오이즘'의 보안LAB 블로그입니다........... n3oism@gmail.com by n3015m

카테고리

분류 전체보기 (228)
[ HappyDevTool ] (29)
[ HappyToolRelease ] (4)
[Book] (6)
[ Security Studies ] (0)
- CII (2)
- BigData (2)
- Web Hacking (10)
- SQL Injection (25)
- Mobile Security (9)
- Network (6)
- OperatingSystem (4)
- Malware & Reversing (4)
- Phishing (5)
- Compliance (0)
- Programming (13)
- Tools (13)
- IoT (6)
- etc (21)
[Pentration Testing] (3)
[OS X] (4)
[ Security Trends ] (16)
[ Fixing Guideline ] (7)
My Way, My Life (34)
About Me (2)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :