관리자 권한 실행 - UAC 고려하기

system/windows 2012/01/16 16:31
- 요약
1. ShellExecute runas
2. 링커 리콰이어
3. 매니페스트


- ShellExecute 를 사용 하는 방법

if(IsUserAnAdmin() == FALSE) //프로그램이 관리자 권한인지 알 수 있는 함수
{
//관리자 권한으로 실행 시킨다.
SHELLEXEGUTEINFO si
ZeroMemory(&si, sizeof(SHELLEXECUTEINFO));

si.cbSize = sizeof(SHELLEXECUTEINFO);
si.hwnd = NULL;
si.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
si.lpVerb = _T("runas");
si.lpFile = _T("프로그램명");
si.lpParameters = _T("파라미터");
si.nShow = SW_SHOWNORMAL;
si.lpDirectory  = NULL;
ShellExecuteEx(&si);
}

- Visual C++ 2008 일 경우 설정

 Project > Properties 메뉴를  선택
 Linker > Manifest File 항목에서
 Enable User Account Control (UAC)를 Yes로 설정하고
 UAC Execution Level을 requireAdministrator로 설정한다.

- 매니페스트 파일 생성

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.00.0"
     processorArchitecture="X86"
     name="IsUserAdmin"                       
     type="win32"/>
  <description>Description of your application</description>
  <!—어플리케이션 보안 요구 사항을 식별합니다. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

위의 내용으로 manifest 라는 XML 파일을 생성한다.

name="IsUserAdmin" 여기에 실행파일 명을 명시!!!
level="requireAdministrator" 인 경우 관리자 권한으로 프로그램 실행됨.
level="asInvoker" 인 경우 부모 프로세스와 동일한 토큰으로 실행됨(경험적 결과이나 일반사용자 권한으로 실행됨)


위의 파일을 응용프로그램 안으로 통합하는 방법은 여기 http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx  를 참고하십시오.


- 출처
http://happybird.tistory.com/13  
 

'system > windows' 카테고리의 다른 글

관리자 권한 실행 - UAC 고려하기  (0) 2012/01/16
Segmentation 시발점 찾다가  (0) 2011/10/31
110901 긁적긁적  (0) 2011/09/01
dll injection 기초  (0) 2010/09/03
win 명령어  (0) 2010/08/05
컬링 컨벤션 세가지(cdecl,stdcall,fastcall)  (0) 2010/07/07
Trackback 0 : Comment 0

[불편한 진실] 울트라에디트 설치 후 소스보기

prg.Project/windows 2012/01/16 16:18


UAC 고려하여 리빌드


- 이전 게시글 -

포멧하는 일이 자주 있다보니 매시마다 설정을 바꾸는게 불편함

따라서, 디폴트로 복원되도록 실행파일로 만들어서 해결
 
Trackback 0 : Comment 0

프로세스 시작시 자동 디버깅

Reversing 2012/01/05 04:04
Image File Execution options 설정으로 프로세스 시작시 자동 디버깅 가능

1. Regedit.exe
 
2. 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\

3. 서브키로 디버깅 하려는 Program의 이름을 추가 (Ex. clarus.exe)


4. 추가한 서브키에 "이름:Debugger ; 종류:문자열 값(REG_SZ) ; 데이터:디버거 Full path" 추가


by MSDN

You can set up your application to start Visual Studio when you launch the application from Windows. Visual Studio will load your application, ready for debugging, but will not commence debugging until you issue an execution command. Having Visual Studio launch the debugger in this way is useful for debugging services and COM out-of-proc servers.

To setup an application to launch the debugger automatically

  1. Start the Registry Editor (regedit).
  2. In the Registry Editor, open the HKEY_LOCAL_MACHINE folder.
  3. Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\currentversion\image file execution options.
  4. Under the Image File Execution Options folder, locate the name of the application you want to debug (myapp.exe, for example). If you cannot find the application you want to debug:
    1. Right-click the Image File Execution Options folder and choose New Key from the shortcut menu.
    2. Right-click the new key and choose Rename from the shortcut menu.
    3. Edit the key name to the name of your application, for example, myapp.exe.
  5. Right-click the myapp.exe folder and choose New String Value from the shortcut menu.
  6. Right-click the new string value and choose Rename from the shortcut menu.
  7. Change the name to debugger.
  8. Right-click the new string value and choose Modify from the shortcut menu.

    The Edit String dialog box appears.

  9. In the Value data box, type devenv /debugexe.
  10. Click OK.
  11. From the Registry menu, choose Exit.

    The directory containing devenv.exe must be in your system path.

    Now, use any method to start your application. Visual Studio .NET will start and load the application.

 





'Reversing' 카테고리의 다른 글

프로세스 시작시 자동 디버깅  (0) 2012/01/05
Restructuring01  (0) 2011/12/12
unpack 참고 url  (0) 2011/11/08
Inline patch 로 해결  (0) 2011/10/28
IMAGE_SECTION_HEADER structure - Characteristics  (0) 2011/10/28
VA, RVA, RAW  (0) 2011/09/22
Trackback 0 : Comment 0
◀ PREV : [1] : [2] : [3] : [4] : [5] : ... [33] : NEXT ▶