まめ知識 #2

悪意のあるソフトウェアの削除ツール

通常は MicrosoftUpdate 時に自動実行されるが、実は \system32\MRT.exe というファイルがあり、これを実行するとクイックスキャン、フルスキャン、カスタムスキャンなどを行うことができる。最後にはスキャンの結果が表示される。ちなみに、フルスキャンするとN時間単位で時間がかかるので注意。

ウィンドウを閉じる

タイトルバー左上にあるアイコンをダブルクリックすると、ウィンドウを閉じることができる。すげー。知らなかった。ちなみにこれを知ったきっかけは、会社の人がSolarisのCDEで同様の操作を行っているのを見かけたことだったりする。まさかUNIXGUIからWindowsGUI操作を学ぶことがあるとはおもわなんだ。

"%~f0"

と書いたバッチファイル(名前は任意)を用意し、叩く。それだけで自己呼び出し。ばっちかわいいよばっち。

livekd

Sysinternals の提供するカーネルデバッガ。正確にはWinDbgのもつカーネルデバッガ kd.exe のインターフェースで、カーネルのメモリダンプを取得し、それをデバッガにかませることでカーネルを止めずにデバッグするもの。以下に導入フローを。

  1. WinDbgをインストール
  2. livekdを展開(適当に解凍する)
  3. cmd.exe をAdministrator権限で起動
  4. livekdを起動
  5. シンボルパスについての問い合わせに応える
  6. デバッグが開始する

ドキュメントではNTから2003までのNT系(64bit含)となっているがVistaでも動くようだ。使い方はWinDbgのkdそのものなので省略。実際のカーネルデバッグまでしなくでもシンボルを出力できるのはよい。以下はVista SP1のEPROCESSとPEB構造体。

0: kd> dt nt!_eprocess
nt!_EPROCESS
   +0x000 Pcb              : _KPROCESS
   +0x080 ProcessLock      : _EX_PUSH_LOCK
   +0x088 CreateTime       : _LARGE_INTEGER
   +0x090 ExitTime         : _LARGE_INTEGER
   +0x098 RundownProtect   : _EX_RUNDOWN_REF
   +0x09c UniqueProcessId  : Ptr32 Void
   +0x0a0 ActiveProcessLinks : _LIST_ENTRY
   +0x0a8 QuotaUsage       : [3] Uint4B
   +0x0b4 QuotaPeak        : [3] Uint4B
   +0x0c0 CommitCharge     : Uint4B
   +0x0c4 PeakVirtualSize  : Uint4B
   +0x0c8 VirtualSize      : Uint4B
   +0x0cc SessionProcessLinks : _LIST_ENTRY
   +0x0d4 DebugPort        : Ptr32 Void
   +0x0d8 ExceptionPortData : Ptr32 Void
   +0x0d8 ExceptionPortValue : Uint4B
   +0x0d8 ExceptionPortState : Pos 0, 3 Bits
   +0x0dc ObjectTable      : Ptr32 _HANDLE_TABLE
   +0x0e0 Token            : _EX_FAST_REF
   +0x0e4 WorkingSetPage   : Uint4B
   +0x0e8 AddressCreationLock : _EX_PUSH_LOCK
   +0x0ec RotateInProgress : Ptr32 _ETHREAD
   +0x0f0 ForkInProgress   : Ptr32 _ETHREAD
   +0x0f4 HardwareTrigger  : Uint4B
   +0x0f8 PhysicalVadRoot  : Ptr32 _MM_AVL_TABLE
   +0x0fc CloneRoot        : Ptr32 Void
   +0x100 NumberOfPrivatePages : Uint4B
   +0x104 NumberOfLockedPages : Uint4B
   +0x108 Win32Process     : Ptr32 Void
   +0x10c Job              : Ptr32 _EJOB
   +0x110 SectionObject    : Ptr32 Void
   +0x114 SectionBaseAddress : Ptr32 Void
   +0x118 QuotaBlock       : Ptr32 _EPROCESS_QUOTA_BLOCK
   +0x11c WorkingSetWatch  : Ptr32 _PAGEFAULT_HISTORY
   +0x120 Win32WindowStation : Ptr32 Void
   +0x124 InheritedFromUniqueProcessId : Ptr32 Void
   +0x128 LdtInformation   : Ptr32 Void
   +0x12c Spare            : Ptr32 Void
   +0x130 VdmObjects       : Ptr32 Void
   +0x134 DeviceMap        : Ptr32 Void
   +0x138 EtwDataSource    : Ptr32 Void
   +0x13c FreeTebHint      : Ptr32 Void
   +0x140 PageDirectoryPte : _HARDWARE_PTE
   +0x140 Filler           : Uint8B
   +0x148 Session          : Ptr32 Void
   +0x14c ImageFileName    : [16] UChar
   +0x15c JobLinks         : _LIST_ENTRY
   +0x164 LockedPagesList  : Ptr32 Void
   +0x168 ThreadListHead   : _LIST_ENTRY
   +0x170 SecurityPort     : Ptr32 Void
   +0x174 PaeTop           : Ptr32 Void
   +0x178 ActiveThreads    : Uint4B
   +0x17c ImagePathHash    : Uint4B
   +0x180 DefaultHardErrorProcessing : Uint4B
   +0x184 LastThreadExitStatus : Int4B
   +0x188 Peb              : Ptr32 _PEB
   +0x18c PrefetchTrace    : _EX_FAST_REF
   +0x190 ReadOperationCount : _LARGE_INTEGER
   +0x198 WriteOperationCount : _LARGE_INTEGER
   +0x1a0 OtherOperationCount : _LARGE_INTEGER
   +0x1a8 ReadTransferCount : _LARGE_INTEGER
   +0x1b0 WriteTransferCount : _LARGE_INTEGER
   +0x1b8 OtherTransferCount : _LARGE_INTEGER
   +0x1c0 CommitChargeLimit : Uint4B
   +0x1c4 CommitChargePeak : Uint4B
   +0x1c8 AweInfo          : Ptr32 Void
   +0x1cc SeAuditProcessCreationInfo : _SE_AUDIT_PROCESS_CREATION_INFO
   +0x1d0 Vm               : _MMSUPPORT
   +0x218 MmProcessLinks   : _LIST_ENTRY
   +0x220 ModifiedPageCount : Uint4B
   +0x224 Flags2           : Uint4B
   +0x224 JobNotReallyActive : Pos 0, 1 Bit
   +0x224 AccountingFolded : Pos 1, 1 Bit
   +0x224 NewProcessReported : Pos 2, 1 Bit
   +0x224 ExitProcessReported : Pos 3, 1 Bit
   +0x224 ReportCommitChanges : Pos 4, 1 Bit
   +0x224 LastReportMemory : Pos 5, 1 Bit
   +0x224 ReportPhysicalPageChanges : Pos 6, 1 Bit
   +0x224 HandleTableRundown : Pos 7, 1 Bit
   +0x224 NeedsHandleRundown : Pos 8, 1 Bit
   +0x224 RefTraceEnabled  : Pos 9, 1 Bit
   +0x224 NumaAware        : Pos 10, 1 Bit
   +0x224 ProtectedProcess : Pos 11, 1 Bit
   +0x224 DefaultPagePriority : Pos 12, 3 Bits
   +0x224 PrimaryTokenFrozen : Pos 15, 1 Bit
   +0x224 ProcessVerifierTarget : Pos 16, 1 Bit
   +0x224 StackRandomizationDisabled : Pos 17, 1 Bit
   +0x224 AffinityPermanent : Pos 18, 1 Bit
   +0x224 AffinityUpdateEnable : Pos 19, 1 Bit
   +0x224 CrossSessionCreate : Pos 20, 1 Bit
   +0x228 Flags            : Uint4B
   +0x228 CreateReported   : Pos 0, 1 Bit
   +0x228 NoDebugInherit   : Pos 1, 1 Bit
   +0x228 ProcessExiting   : Pos 2, 1 Bit
   +0x228 ProcessDelete    : Pos 3, 1 Bit
   +0x228 Wow64SplitPages  : Pos 4, 1 Bit
   +0x228 VmDeleted        : Pos 5, 1 Bit
   +0x228 OutswapEnabled   : Pos 6, 1 Bit
   +0x228 Outswapped       : Pos 7, 1 Bit
   +0x228 ForkFailed       : Pos 8, 1 Bit
   +0x228 Wow64VaSpace4Gb  : Pos 9, 1 Bit
   +0x228 AddressSpaceInitialized : Pos 10, 2 Bits
   +0x228 SetTimerResolution : Pos 12, 1 Bit
   +0x228 BreakOnTermination : Pos 13, 1 Bit
   +0x228 DeprioritizeViews : Pos 14, 1 Bit
   +0x228 WriteWatch       : Pos 15, 1 Bit
   +0x228 ProcessInSession : Pos 16, 1 Bit
   +0x228 OverrideAddressSpace : Pos 17, 1 Bit
   +0x228 HasAddressSpace  : Pos 18, 1 Bit
   +0x228 LaunchPrefetched : Pos 19, 1 Bit
   +0x228 InjectInpageErrors : Pos 20, 1 Bit
   +0x228 VmTopDown        : Pos 21, 1 Bit
   +0x228 ImageNotifyDone  : Pos 22, 1 Bit
   +0x228 PdeUpdateNeeded  : Pos 23, 1 Bit
   +0x228 VdmAllowed       : Pos 24, 1 Bit
   +0x228 SmapAllowed      : Pos 25, 1 Bit
   +0x228 ProcessInserted  : Pos 26, 1 Bit
   +0x228 DefaultIoPriority : Pos 27, 3 Bits
   +0x228 ProcessSelfDelete : Pos 30, 1 Bit
   +0x228 SpareProcessFlags : Pos 31, 1 Bit
   +0x22c ExitStatus       : Int4B
   +0x230 Spare7           : Uint2B
   +0x232 SubSystemMinorVersion : UChar
   +0x233 SubSystemMajorVersion : UChar
   +0x232 SubSystemVersion : Uint2B
   +0x234 PriorityClass    : UChar
   +0x238 VadRoot          : _MM_AVL_TABLE
   +0x258 Cookie           : Uint4B
   +0x25c AlpcContext      : _ALPC_PROCESS_CONTEXT
0: kd> dt nt!_peb
nt!_PEB
   +0x000 InheritedAddressSpace : UChar
   +0x001 ReadImageFileExecOptions : UChar
   +0x002 BeingDebugged    : UChar
   +0x003 BitField         : UChar
   +0x003 ImageUsesLargePages : Pos 0, 1 Bit
   +0x003 IsProtectedProcess : Pos 1, 1 Bit
   +0x003 IsLegacyProcess  : Pos 2, 1 Bit
   +0x003 IsImageDynamicallyRelocated : Pos 3, 1 Bit
   +0x003 SkipPatchingUser32Forwarders : Pos 4, 1 Bit
   +0x003 SpareBits        : Pos 5, 3 Bits
   +0x004 Mutant           : Ptr32 Void
   +0x008 ImageBaseAddress : Ptr32 Void
   +0x00c Ldr              : Ptr32 _PEB_LDR_DATA
   +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS
   +0x014 SubSystemData    : Ptr32 Void
   +0x018 ProcessHeap      : Ptr32 Void
   +0x01c FastPebLock      : Ptr32 _RTL_CRITICAL_SECTION
   +0x020 AtlThunkSListPtr : Ptr32 Void
   +0x024 IFEOKey          : Ptr32 Void
   +0x028 CrossProcessFlags : Uint4B
   +0x028 ProcessInJob     : Pos 0, 1 Bit
   +0x028 ProcessInitializing : Pos 1, 1 Bit
   +0x028 ProcessUsingVEH  : Pos 2, 1 Bit
   +0x028 ProcessUsingVCH  : Pos 3, 1 Bit
   +0x028 ReservedBits0    : Pos 4, 28 Bits
   +0x02c KernelCallbackTable : Ptr32 Void
   +0x02c UserSharedInfoPtr : Ptr32 Void
   +0x030 SystemReserved   : [1] Uint4B
   +0x034 SpareUlong       : Uint4B
   +0x038 SparePebPtr0     : Uint4B
   +0x03c TlsExpansionCounter : Uint4B
   +0x040 TlsBitmap        : Ptr32 Void
   +0x044 TlsBitmapBits    : [2] Uint4B
   +0x04c ReadOnlySharedMemoryBase : Ptr32 Void
   +0x050 HotpatchInformation : Ptr32 Void
   +0x054 ReadOnlyStaticServerData : Ptr32 Ptr32 Void
   +0x058 AnsiCodePageData : Ptr32 Void
   +0x05c OemCodePageData  : Ptr32 Void
   +0x060 UnicodeCaseTableData : Ptr32 Void
   +0x064 NumberOfProcessors : Uint4B
   +0x068 NtGlobalFlag     : Uint4B
   +0x070 CriticalSectionTimeout : _LARGE_INTEGER
   +0x078 HeapSegmentReserve : Uint4B
   +0x07c HeapSegmentCommit : Uint4B
   +0x080 HeapDeCommitTotalFreeThreshold : Uint4B
   +0x084 HeapDeCommitFreeBlockThreshold : Uint4B
   +0x088 NumberOfHeaps    : Uint4B
   +0x08c MaximumNumberOfHeaps : Uint4B
   +0x090 ProcessHeaps     : Ptr32 Ptr32 Void
   +0x094 GdiSharedHandleTable : Ptr32 Void
   +0x098 ProcessStarterHelper : Ptr32 Void
   +0x09c GdiDCAttributeList : Uint4B
   +0x0a0 LoaderLock       : Ptr32 _RTL_CRITICAL_SECTION
   +0x0a4 OSMajorVersion   : Uint4B
   +0x0a8 OSMinorVersion   : Uint4B
   +0x0ac OSBuildNumber    : Uint2B
   +0x0ae OSCSDVersion     : Uint2B
   +0x0b0 OSPlatformId     : Uint4B
   +0x0b4 ImageSubsystem   : Uint4B
   +0x0b8 ImageSubsystemMajorVersion : Uint4B
   +0x0bc ImageSubsystemMinorVersion : Uint4B
   +0x0c0 ActiveProcessAffinityMask : Uint4B
   +0x0c4 GdiHandleBuffer  : [34] Uint4B
   +0x14c PostProcessInitRoutine : Ptr32     void
   +0x150 TlsExpansionBitmap : Ptr32 Void
   +0x154 TlsExpansionBitmapBits : [32] Uint4B
   +0x1d4 SessionId        : Uint4B
   +0x1d8 AppCompatFlags   : _ULARGE_INTEGER
   +0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER
   +0x1e8 pShimData        : Ptr32 Void
   +0x1ec AppCompatInfo    : Ptr32 Void
   +0x1f0 CSDVersion       : _UNICODE_STRING
   +0x1f8 ActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
   +0x1fc ProcessAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
   +0x200 SystemDefaultActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
   +0x204 SystemAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
   +0x208 MinimumStackCommit : Uint4B
   +0x20c FlsCallback      : Ptr32 _FLS_CALLBACK_INFO
   +0x210 FlsListHead      : _LIST_ENTRY
   +0x218 FlsBitmap        : Ptr32 Void
   +0x21c FlsBitmapBits    : [4] Uint4B
   +0x22c FlsHighIndex     : Uint4B
   +0x230 WerRegistrationData : Ptr32 Void
   +0x234 WerShipAssertPtr : Ptr32 Void