DEP(Data Execution Prevention : 데이터 실행 방지) 탭에
일일히 프로그램 경로를 추가해야 하는 경우가 있다.
ATL의 Thunk로 메시지 Pump를 구현했거나,
Stack에 Asm으로 코드를 삽입하고 JMP로 EIP를 이동하여 Code Section이 아닌
Data Section에서 Code 실행이 이루어질 경우 DEP에 프로그램을 추가하면 해결된다.
그러나 DEP에 프로그램을 추가하는 MS에서 제공하는 옵션이 없기 때문에,
위와 같은 프로그램을 등록하기 위해선 손이 많이 간다.
아래의 WMI 스크립트를 이용해서 Drag And Drop으로 DEP를 추가해 보자!
Option Explicit ' 기본 Object 가져오기 Dim Shell : Set Shell = WScript.CreateObject("WScript.Shell") Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject") Dim WshEnv : Set WshEnv = Shell.Environment("Process") Dim ProgramDir : ProgramDir = WshEnv("ProgramFiles") Dim SystemRoot : SystemRoot = WshEnv("Systemroot") 'CMD 윈도우 98에서도 적용 가능하게 COMSPEC으로 가져온다. Dim COMSPEC : COMSPEC = Shell.ExpandEnvironmentStrings("%comspec%") Dim Exe01 : Exe01 = SystemRoot & "\system32\sysdm.cpl" '각 Step별 윈도우 Title 확인 Const WindowTitleName_01 = "시스템 등록 정보" 'Main 함수 실행 후 종료 MainFunction Wscript.quit Sub MainFunction ' Argument 검사 If Wscript.Arguments.Count = 0 Then Shell.Popup "DEP에 추가할 Argument를 입력하지 않았습니다.", 3, "No Arguments", 48 Wscript.quit End If ' Step 1. sysdm.cpl 시스템 등록 정보 열기 Install Exe01, "" SendKeys "{ESC}" Wscript.sleep 1000 Install Exe01, "" ' Step 1. "시스템 등록 정보" WaitForActiveWindow WindowTitleName_01, 3 ' SendKeys "{TAB}{TAB}" SendKeys "{RIGHT}{RIGHT}{RIGHT}" SendKeys "%s" SendKeys "{TAB}{TAB}{TAB}{TAB}" SendKeys "{RIGHT}{RIGHT}" SendKeys "%(ud)" Wscript.Sleep 500 SendKeys "%(n)" '설정파일 경로 구하기 Dim strAddToDepFile : strAddToDepFile = Wscript.Arguments.Item(0) Dim strFileFullPath GetFileFullPath strAddToDepFile, strFileFullPath SendKeys strFileFullPath Wscript.Sleep 500 SendKeys "%o" SendKeys "{ENTER}" Wscript.Sleep 500 SendKeys "{ESC}" End Sub Sub GetFileFullPath(strFileName, strFileFullPath) Dim objFile Set objFile = FSO.GetFile( strFileName ) strFileFullPath = FSO.GetAbsolutePathName(objFile) End Sub Sub Install (InstallFile, Arguments) If (FSO.FileExists(InstallFile)) Then Shell.Run COMSPEC & " /c " & InstallFile & Arguments &" & Exit", 0 Else Shell.Popup InstallFile & " 을(를) 찾을 수 없습니다.", 3, "File dose not exist", 48 Wscript.Quit End if End Sub Sub WaitForActiveWindow(WindowName, Second) if Second < 0 Then Shell.Popup "음수 시간을 설정할 수 없습니다.", 3, "Error!", 48 Wscript.Quit End if Dim TimeOutCount : TimeOutCount = Second * 10 Wscript.Sleep 1 'Winxp SP3에서 AppActivate() 버그 임시 해결용 by TTF While ( Shell.AppActivate( WindowName ) = False ) if TimeOutCount < 0 Then Shell.Popup WindowName & " 윈도우를 찾을 수 없습니다. 실행을 종료합니다.", 5, "Can't Find Window", 48 Wscript.Quit End if Wscript.Sleep 100 TimeOutCount = TimeOutCount - 1 WEnd 'Winxp SP3에서 AppActivate() 버그 임시 해결용 by TTF Wscript.Sleep 1 End Sub 'Shell.SendKeys 위를 Sleep(200)로 감싼다. XP SP3 버그 임시 해결 by TTF Sub SendKeys( Keys ) Wscript.Sleep 200 Shell.SendKeys Keys End Sub
덧글을 달아 주세요