[windows] integrity level 권한 통신

2019. 8. 20. 20:36IT-개발/OS

반응형

경험한 내용 위주로 적어 놓습니다.

 

Service로 동작하는 (session : 0, intelgrity : System, User Name : NT AUTHORITY\SYSTEM) Program(A)이 있는데

 

UI 가 있는 (session : 2, intelgrity : Medium, User Name : NT AUTHORITY\유져) 인 Process(B) 를 생성한다.

 

(processtoken / CreateProcessAsUser 사용)

 

B가 동작한 결과를 A에게 알려줘야 한다. 별생각 없이 공유 메모리로 A가 만들고 B가 거기에 써주면 될거 같았다.

 

안된다. 그럼 B가 만들고 쓰고, A가 보기만 하면 되니까 하고 해보니, "Global\\" 이걸 Medium에서는 만들수가 없다.

 

공유 메모리는 말이다. 고민하다가

 

인터넷 검색, SecurityDescriptor를 활용한 방법이 있다고 해서 해봤다. 

 

중간에 엄청나게 이름이 긴 함수도 있다는걸 알게됐다. 근데 내가 api를 잘못써서 일까~ 별짓해도 안된다.

 

함수 이름 : ConvertStringSecurityDescriptorToSecurityDescriptor

 

A가 공유 메모리 생성까지는 했는데, B가 "Global\\" 이렇게 이름지어진 공유메모리는 open을 못한다.

 

공유 메모리는 intelgrity가 System인 녀석이 만든걸 2단계나 아래인 Medium에서 기본적으로 사용할수 없다고 한다.

 

High는 가능하다는 내용을 본거 같은데~ medium 이어야만 하는 상황이라 이렇게 해결할 수는 없다.

 

반전, 아래글 참조하니 또 된단다~  핵심은 'D:P(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GRGW;;;IU)'

 

 

 

https://m.blog.naver.com/PostView.nhn?blogId=jsf3rd&logNo=220796531332&proxyReferer=https%3A%2F%2Fwww.google.com%2F

 

Windows Services 와 User Processes 간 공유메모리(MMF) 사용.

[본 글에서 나오는 모든 예제는 델파이 코드입니다.] 프로세스간 공유메모리를 활용한 메시지 교환을 할때 ...

blog.naver.com

https://docs.microsoft.com/ko-kr/windows/win32/secauthz/sid-strings

 

SID Strings - Windows applications

SID Strings In this article --> In the security descriptor definition language (SDDL), security descriptor string use SID strings for the following components of a security descriptor: Owner Primary group The trustee in an ACE A SID string in a security de

docs.microsoft.com

https://docs.microsoft.com/ko-kr/windows/win32/secauthz/security-descriptor-string-format?redirectedfrom=MSDN

 

Security Descriptor String Format - Windows applications

Security Descriptor String Format In this article --> The Security Descriptor String Format is a text format for storing or transporting information in a security descriptor. The ConvertSecurityDescriptorToStringSecurityDescriptor and ConvertStringSecurity

docs.microsoft.com

https://docs.microsoft.com/ko-kr/windows/win32/secauthz/ace-strings?redirectedfrom=MSDN

 

ACE Strings - Windows applications

ACE Strings In this article --> The security descriptor definition language (SDDL) uses ACE strings in the DACL and SACL components of a security descriptor string. As shown in the Security Descriptor String Format examples, each ACE in a security descript

docs.microsoft.com

https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptora

 

ConvertStringSecurityDescriptorToSecurityDescriptorA function (sddl.h)

Converts a string-format security descriptor into a valid, functional security descriptor.

docs.microsoft.com

 

 

 

B에서 파일에 내용 저장 / event 로 A에게 알려주는 방식으로 Test 해봤다. 된다. Event는 B의 intelgrity level이 

 

medium 이어도 "Global\\" 로 이름지어진 event가 생성이 된다. A는 당연히 Open 할수 있다. 파일 열어서 내용

 

확인이 가능하다. 공유메모리만 이런 제약이 있는게 왤까? 커널객체들 다 test해보고 싶지만~ 시간이 부족하다.

 

지금까지 겪은 내용 이야기 하니 아는 분이 그런다. 그냥 B가 process exit code에 적당한 값을 써주고 A가 그걸 

 

보면 안되냐고~ 아하, 그 옛날의 process exit code를 해보니~ 또 잘된다. 물론 단순한 수치값만 전달 가능하지만

 

이렇게 라도 값이 전달이 되는게 어디인가... 

 

또, 어떤분은 그런다 파이프 사용하면 될꺼라고~

 

여기저기 뒤지다보니 System - High(관리자)   이렇게는 된다고 한다. process explorer 로 보니

 

integrity 가 AppContainer 라는 process 들도 보인다.

 

session : 0, User Name : Font Driver Host\UMFD-0 인 process들도 보인다. 배워야 겠다~ ㅜ_ㅜ

 

공부해서 정리되면 한번 올려야 할 듯~