SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
Windows Handle 의
비밀
미친감자 김주생
Visual C++ MS MVP
2013년 7월 13일 발표
핸들이 뭐냐?
“System” 이분이
바로 커널 서비스를 해주시는
분이십니다.
안녕하세요~”System”님
보통 “커널”이라고도 하죠~
ㅊ
아..파일이 필요하시다구요
잠시만 기다려주세요.~
저 커널님아
저 파일좀 하나
만들어주세요~
KERNEL
SERVICE
LANDUSER LAND
고객님~
이 핸들만 있으면
파일을 사용하 실 수 있습니다.
자~ 받으세요~!
감사합니다. 커널님아~
그럼 저는
이 핸들만 있으면 되는
거죠^^?
KERNEL
SERVICE
LANDUSER LAND
파일을 하나 만들었더니..
핸들을 넘겨줍니다.
핸들에는 어떤 값이 있을
까요? 확인해 봅시다.
7cc
칠씨씨?
뭘까요??
자 이제
칠씨씨의비밀을
알아볼까요^^!!
499 번째
엔트리라는점
프로세스가 만들어지면
이 프로세스가 사용 하는
커널 오브젝트 장부(Table)를 하나 가지고 있다.
프로세스가 생성되면
커널에서는 해당 프로세스를
관리하기 위해 _EPROCESS
에 정보를 저장합니다.
그리고, 핸들정보도
이곳에 있습니다.
_EPROCESS 안에 핸들테이블인
ObjectTable 필드가 있죠^^!?
ObjectTable의 이 값이 의미하는 것은 무엇일까?
음..
구조체 _HANDLE_TABLE의 주소라는 것~!
구조체 _HANDLE_TABLE에는
각종 핸들테이블 정보가 들어 있습
니다.
바로 이 값이 핸들엔트리가 저장되어 있는
시작 위치 입니다.
Table
Code
Handle
/4
엔트리
크기(8)
Table Entry 주소
0xe10b9000 + 0x7cc/4 * 8
= 0xe10b9f98
4byte
Handle Entry 모양~(총 8bytes)
닫
힘
보
호
상
속
가
능
여
부
닫
힘
감
시
여
부
Object Header 포인터
Access Mask
32bit(4byte)
닫
힘
보
호
상
속
가
능
여
부
닫
힘
감
시
여
부
Object Header 포인터
Access Mask
_OBJECT_TYPE 을 통해앻
개체의 종류를 알 수 있습니다.
File 개체임을 알 수 있군요!
자 이제 제가 만들었던
Myfile.txt 파일인지를 알아보면 되겠군요
…
개체 Header
개체 Body
그런데
Object는 머리
와
몸통으로
되어 있습니다.
2등신~
개체 Header
개체 Body Header
대가리는 어떻게
생겼을까요?
개체 Header
개체 Body
헤더에
+ 0X18를 해주면
오브젝트 몸통!!!
오~~ 제가 만든 파일 맞네요~!!
+18 해주면..개체몸통이 되고요~
몸톰을 확인해 보니~!!
윈디비지에서 !handle 하면
아주 친절하게 나온다!!!!
핸들은 32bit
자료형입니다.
하지만 32bit 전부를 사용하지 않습니다.
핸들이란 녀석(xp)
이렇게 생겨먹었다!!!
Tag 2bit 때문에
윈도우 핸들값은 4씩 증가한다.
048C048C048C048C048C
EPROCESS
TableCode
Top
Level
Pointers
0
31
Middle
Level
Pointers
0
Sub Handle
Table
0
511
핸들은 총 몇 개까지 만들 수 있을까요?
32 1024 511
16,744,448
천육백칠십사만사천사백사십팔개
과연 실제로 16,744,448개까지 핸들
이 생성이 될까요? 실험해 봅시다~!
16,744,436개까지 생성이 되는군요..
12개는왜…생성이 되지 않았을까요?
Table Code의
하위2비트가
수상하다!!~~!~
Table Code의
하위2비트가
Table Layer
Table Code
Sub Handle
Table
0
511
0
511개까지는
Sub Handle
Table로 충분!!!
Table Code
Sub Handle
Table
0
511
0
511개까지는
Sub Handle
Table로 충분!!!
Sub Handle Table을 직접 확인해봅시다.
메모리 구경하러 갑시다.
511개까지 저장 되는지 확인해보죠~
EPROCESS
Middle
Level
Pointers
0
1023
Sub Handle
Table
0
511
Table Code
1
Table Code
Sub Handle
Table
0
511
1
Sub Handle
Table
0
511
Middle
Level
Pointers
0
1023
512번째 핸들은 정말 두번째 Sub handle
Table에 생길까요?
EPROCESS
TableCode
Top
Level
Pointers
0
31
Middle
Level
Pointers
0
1023
Sub Handle
Table
0
511
2
EPROCESS
TableCode
Top
Level
Pointers
0
31
Middle
Level
Pointers
0
1023
Sub Handle
Table
0
511
2
자 그러면 Top Level Pointers를 만들어보시다.
1024 * 511 개 + 1개 을 만들면 되겠죠~
523265개
핸들이란 녀석(2000까지)
이렇게 생겨먹었다!!!
Handle Table
Top
Level
Pointers
0
255
Middle
Level
Pointers
0
255
Sub
Handle
Table
0
255
또…OBJECT HEADER에서
건질게 없나 째려 봐봅시다^^
이름이 있는 위치를 알려주는 것입니다.~
자 확인해 봅시다.
그럼 NameInofOffset의
구조체를 찾아봅시다요~~
_OBJECT_HEADER 위에 개체 이름이 있었네요^^
ㅋ~
개체 Header
개체 Body
개체이름
머리에 이름을 이고
다녔니~^^?
개체의 이름을 알려주는 거였군요!!
프로세스의 핸들장부 내역을
보여 주는 프로그램이
뭐가 있을까요?
미친핸들을만들었어요
ExEnumHandleTable 함수를
호출해주면..
핸들에트리개수만큼
콜백함수를 호출해줍니다.
아니면 수동으로 핸들테이블을
스캔해도 되지요^^
테이블 level 별로 메모리를 직접
스캔하시면 되겠죠~
수고하셨습니다~~^^

Contenu connexe

Tendances

DevOps Monitoring and Alerting
DevOps Monitoring and AlertingDevOps Monitoring and Alerting
DevOps Monitoring and AlertingKhairul Zebua
 
Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?Katherine Golovinova
 
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...Vietnam Open Infrastructure User Group
 
Software architecture for high traffic website
Software architecture for high traffic websiteSoftware architecture for high traffic website
Software architecture for high traffic websiteTung Nguyen Thanh
 
The Mono-repo – a contradiction with Microservices
The Mono-repo – a contradiction with MicroservicesThe Mono-repo – a contradiction with Microservices
The Mono-repo – a contradiction with MicroservicesEficode
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in KubernetesRafał Leszko
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab IntroductionKrunal Doshi
 
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton PipelinesCloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton PipelinesNikhil Thomas
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Yurii Bychenok
 
Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesRed Hat Developers
 
OpenTelemetry: From front- to backend (2022)
OpenTelemetry: From front- to backend (2022)OpenTelemetry: From front- to backend (2022)
OpenTelemetry: From front- to backend (2022)Sebastian Poxhofer
 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentationAyanaRukasar
 
Build pipelines with bitbucket for Magento
Build pipelines with bitbucket for MagentoBuild pipelines with bitbucket for Magento
Build pipelines with bitbucket for MagentoRrap Software Pvt Ltd
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우Arawn Park
 
Domain-Driven Design in der Praxis
Domain-Driven Design in der PraxisDomain-Driven Design in der Praxis
Domain-Driven Design in der PraxisMichael Mirold
 

Tendances (20)

DevOps Monitoring and Alerting
DevOps Monitoring and AlertingDevOps Monitoring and Alerting
DevOps Monitoring and Alerting
 
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOpsMeetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOps
 
Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?
 
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...
Room 2 - 6 - Đinh Tuấn Phong - Migrate opensource database to Kubernetes easi...
 
Subversion
SubversionSubversion
Subversion
 
Software architecture for high traffic website
Software architecture for high traffic websiteSoftware architecture for high traffic website
Software architecture for high traffic website
 
The Mono-repo – a contradiction with Microservices
The Mono-repo – a contradiction with MicroservicesThe Mono-repo – a contradiction with Microservices
The Mono-repo – a contradiction with Microservices
 
Distributed Locking in Kubernetes
Distributed Locking in KubernetesDistributed Locking in Kubernetes
Distributed Locking in Kubernetes
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton PipelinesCloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
 
Devops
DevopsDevops
Devops
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.
 
Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on Kubernetes
 
OpenTelemetry: From front- to backend (2022)
OpenTelemetry: From front- to backend (2022)OpenTelemetry: From front- to backend (2022)
OpenTelemetry: From front- to backend (2022)
 
Angular 4 - Introdução
Angular 4 - IntroduçãoAngular 4 - Introdução
Angular 4 - Introdução
 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentation
 
Build pipelines with bitbucket for Magento
Build pipelines with bitbucket for MagentoBuild pipelines with bitbucket for Magento
Build pipelines with bitbucket for Magento
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우
 
Domain-Driven Design in der Praxis
Domain-Driven Design in der PraxisDomain-Driven Design in der Praxis
Domain-Driven Design in der Praxis
 

En vedette

(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개nemoux
 
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개nemoux
 
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화윈도우 매니저 스터디: 2. 윈도우 매니저 최적화
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화nemoux
 
윈도우 매니저 스터디: 3. 윈도우 매니저 입력
윈도우 매니저 스터디: 3. 윈도우 매니저 입력윈도우 매니저 스터디: 3. 윈도우 매니저 입력
윈도우 매니저 스터디: 3. 윈도우 매니저 입력nemoux
 
윈도우 매니저 스터디: 0.윈도우 매니저 소개
윈도우 매니저 스터디: 0.윈도우 매니저 소개윈도우 매니저 스터디: 0.윈도우 매니저 소개
윈도우 매니저 스터디: 0.윈도우 매니저 소개nemoux
 
윈도우 매니저 스터디: 1. 윈도우 매니저 출력
윈도우 매니저 스터디: 1. 윈도우 매니저 출력윈도우 매니저 스터디: 1. 윈도우 매니저 출력
윈도우 매니저 스터디: 1. 윈도우 매니저 출력nemoux
 
(NEMO-UX) 미래 컴퓨팅 환경
(NEMO-UX) 미래 컴퓨팅 환경(NEMO-UX) 미래 컴퓨팅 환경
(NEMO-UX) 미래 컴퓨팅 환경nemoux
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기zupet
 

En vedette (8)

(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
 
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개
(NEMO-UX) WAYLAND 기반 컴포지팅 최적화 기술 소개
 
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화윈도우 매니저 스터디: 2. 윈도우 매니저 최적화
윈도우 매니저 스터디: 2. 윈도우 매니저 최적화
 
윈도우 매니저 스터디: 3. 윈도우 매니저 입력
윈도우 매니저 스터디: 3. 윈도우 매니저 입력윈도우 매니저 스터디: 3. 윈도우 매니저 입력
윈도우 매니저 스터디: 3. 윈도우 매니저 입력
 
윈도우 매니저 스터디: 0.윈도우 매니저 소개
윈도우 매니저 스터디: 0.윈도우 매니저 소개윈도우 매니저 스터디: 0.윈도우 매니저 소개
윈도우 매니저 스터디: 0.윈도우 매니저 소개
 
윈도우 매니저 스터디: 1. 윈도우 매니저 출력
윈도우 매니저 스터디: 1. 윈도우 매니저 출력윈도우 매니저 스터디: 1. 윈도우 매니저 출력
윈도우 매니저 스터디: 1. 윈도우 매니저 출력
 
(NEMO-UX) 미래 컴퓨팅 환경
(NEMO-UX) 미래 컴퓨팅 환경(NEMO-UX) 미래 컴퓨팅 환경
(NEMO-UX) 미래 컴퓨팅 환경
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
 

Similaire à Windows handle 의 비밀 2

요람(CreateProcess)에서 무덤(ResumeThread)까지
요람(CreateProcess)에서 무덤(ResumeThread)까지요람(CreateProcess)에서 무덤(ResumeThread)까지
요람(CreateProcess)에서 무덤(ResumeThread)까지Hyoje Jo
 
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰Eunhyang Kim
 
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)Dong Chan Shin
 
MFC 발견 (1)
MFC 발견 (1)MFC 발견 (1)
MFC 발견 (1)종훈 박
 
내 손에 픽셀을 쥐어다오
내 손에 픽셀을 쥐어다오내 손에 픽셀을 쥐어다오
내 손에 픽셀을 쥐어다오KwangSam Kim
 
만약 운영체제가 없다면? Computer Without OS
만약 운영체제가 없다면? Computer Without OS만약 운영체제가 없다면? Computer Without OS
만약 운영체제가 없다면? Computer Without OSssuser889640
 

Similaire à Windows handle 의 비밀 2 (7)

요람(CreateProcess)에서 무덤(ResumeThread)까지
요람(CreateProcess)에서 무덤(ResumeThread)까지요람(CreateProcess)에서 무덤(ResumeThread)까지
요람(CreateProcess)에서 무덤(ResumeThread)까지
 
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰
WTM 2018 2개월차 신입 백엔드 개발자의 따끈따끈 개발 썰
 
System+os study 1
System+os study 1System+os study 1
System+os study 1
 
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)
C# / .NET Framework로 미래 밥그릇을 챙겨보자 (Basic)
 
MFC 발견 (1)
MFC 발견 (1)MFC 발견 (1)
MFC 발견 (1)
 
내 손에 픽셀을 쥐어다오
내 손에 픽셀을 쥐어다오내 손에 픽셀을 쥐어다오
내 손에 픽셀을 쥐어다오
 
만약 운영체제가 없다면? Computer Without OS
만약 운영체제가 없다면? Computer Without OS만약 운영체제가 없다면? Computer Without OS
만약 운영체제가 없다면? Computer Without OS
 

Windows handle 의 비밀 2