Debugging (24) 썸네일형 리스트형 Understanding of Address(Segmentation and Paging) 주소에는 다음과 같은 기준이 사용 Code Stack Data Code의 몇 번지, Data의 몇 번지가 정확한 표현 Code, Stack, Data 별로 별도의 영역이 지정 Program을 동작(해석)하는 역할은 CPU(Microprocessor)가 담당하며, 해석되는 항목 중 하나가 Address CPU 안에는 Address를 이해하기 위해서 몇 가지 Register가 위치 : CS(Code Segment), SS(Stack Segment), DS(Data Segment) Register Address 표현 할 때는 Segment Register를 반드시 활용해야 함 CS의 0x1234 offset, SS의 0x5678 offset과 같은 표현이 정확한 주소 표현 어떤 Segment는 정의한 후 Ba.. Thread State Transition Windows OS의 Scheduling Unit은 Thread로 이 Thread는 생성되어서 종료될 때까지 여러 State를 가지게 됩니다. Thread의 State가 어떻게 변화되고, 각각의 State는 어떤 의미를 갖는지 살펴보겠습니다. Before After Description Debugger Command Init Thread가 처음 만들어진 상태 Init Terminated Init 상태에서 갑자기 종료되는 경우 Init Deferred Ready Init 상태의 Thread가 Ready 상태로 가기 전 잠시 머무는 단 Deferred Ready Ready Ready Queue로 들어간 상태 !ready Deferred Ready Standby 바로 다음 Scheduling 대상인 상태, P.. Registry 오늘은 지난 번 Windows Security 자료에 이어서 Windows OS의 Configuration Manager와 관련이 있는 Registry에 대해서 알아보도록 하겠습니다. Hive Kernel에서 Registry를 관리하는 Component는 Configuration Manager Registry는 Hive 파일에 저장되어 있다가, System이 Boot 되는 시점에 Memory에 로드되는 방식 Registry Structure는 다음과 같이 구성 대부분의 Hive는 파일에 저장되며, Hardware 같은 Hive는 System Boot 시점마다 생성 ## dir /a Volume in drive C has no label. Volume Serial Number is 78DC-9DD2 Dir.. Security Security Reference Monitor(SRM) SRM은 Security Access Check, Privilege Check, Auditing Events를 구현하는 Kernel-Mode Routine Local Security Authority subsystem(LSASS) 대부분의 Security Operation 담당 User-Mode Process LSASS policy database는 아래 관련 정보 보관 Logon 정보 Cached Logon 정보 권한 및 감사 정보 Domain Trust 정보 대부분의 LSA Policy 함수는 Policy Object에 대한 Handle이 필요 이를 위해 LsaOpenPolicy 함수 사용 https://learn.microsoft.com/en.. Objects and Handles Object A single, run-time instance of a statically defined object type (File, Process..) Object attribute A field of data in an object that partially defines the object's state Object methods The means for manipulating objects, usually read or change the object attributes Open method for a process would accept a process identifier as input and return a pointer to the object as output Handle A re.. 프로세스(EPROCESS, KPROCESS, PEB, HANDLE...) - (2) 5. Handle 여러 Create 함수들(CreateFile()...)을 호출할 때, Kernel Object가 생성되는데 이를 User mode 프로세스가 접근하기 위한 방법이 필요합니다. 이 때 사용되는 것이 Handle 입니다. Handle은 Windows의 Subsystem 중 Object Manager가 Kernel Object 생성 시, Return 해주는 값으로 Handle은 프로세스와 관련된 값으로 프로세스가 이를 관리할 필요가 있습니다. 특정 프로세스와 연관된 모든 Handle은 !handle extension을 이용하여 조회할 수 있습니다. 이 extension은 EPROCESS 구조체에 있는 ObjectTable 필드 값에 저장되어 있는 _HANDLE_TALBE 포인터 주소를 이용합.. 프로세스(EPROCESS, KPROCESS, PEB, HANDLE...) - (1) 프로세스의 주요 구조체 EPROCESS KPROCESS PEB(Process Environment Block) HANDLE OBJECT TOKEN 1. !process extension 위 프로세스 관련 주요 구조체에 대해서 notepad.exe 프로세스를 이용하여, 살펴보도록 하겠습니다. Windbg에서는 프로세스 관련 내용을 살펴보기 위해서 가장 많이 사용되는 extension으로 !process를 이용합니다. 우선 !process를 이용하여, notepad.exe 프로세스에 대해서 다음과 같은 내용을 살펴볼 수 있습니다. 3: kd> !process 0 0 notepad.exe PROCESS ffffbc0c19c33080 SessionId: 1 Cid: 0318 Peb: c1e88f0000 Pare.. How to configure network debugging using windbg Local Laptop의 Memory가 부족해서 Hypervisor를 설치하기는 어려워, 원격지에 있는 Windows VM을 이용하여 Debugging 환경 구성이 필요했습니다. 간단하게, 아래와 같은 환경에서 Windows Debugging이 필요할 때 네트워크 구성을 통해서 가능합니다. 1. Debugger에는 Windbg가 설치되어 있다고 가정합니다. Windbg는 Windows SDK를 설치할 때, 설치 항목 중 하나로 포함되어 있습니다. 2. Debuggee에는 몇 가지 설정이 필요합니다. 2-1. 우선, Debugger의 C:\Program Files (x86)\Windows Kits\10\Debuggers\x64 폴더 하위에서 kdnet.exe와 VerifiedNICList.xml 파일을 D.. Link and Symbol Table 오늘은 프로그램 build 시에 개별 source code들이 어떤 형식으로 compile 되고 생성된 relocatable object 파일들이 어떤게 연결되는지에 대해서 알아보겠습니다. 추가로, 지난 번 다뤘던 EFL Format의 Section 중 Symbol Table에 대해서도 다루도록 하겠습니다. 아래 예제로 두 source code를 compile 하면, 각각 relocatable object 파일을 생성하게 됩니다. hwjung@jhaewon-z01:~$ cat functionA.c int functionA(int n) { return n + 10; } hwjung@jhaewon-z01:~$ cat functionMain.c #include int functionA(int n); int m.. CPU Registers and Instructions - Instructions Assembly Language에서 Instruction은 opcode와 operands로 구성됩니다. opcode는 instruction이 어떤 동작을 하는지를 의미하고, operands는 instruction이 사용하는 값을 의미합니다. operands는 Instruction에 따라서, 없는 경우도 있을 수 있고 하나 또는 두 개의 operands가 올 수도 있습니다. operands에는 register나 memory address 또는 값 자체가 사용될 수 있습니다. Instruction Notation opcode와 operands는 AT&T 문법과 Intel 문법이 있는데, windows를 분석할 때 windbg를 사용하면 기본으로 Intel 문법으로 표현되지만 Linux를 분석할 때는 GDB에.. 이전 1 2 3 다음