Get Windows security internals 1 / converted edition james forshaw free all chapters

Page 1


Windows Security Internals 1 / converted Edition James Forshaw

Visit to download the full and correct content document: https://textbookfull.com/product/windows-security-internals-1-converted-edition-james -forshaw/

More products digital (pdf, epub, mobi) instant download maybe you interests ...

Windows Security Internals: A Deep Dive into Windows Authentication, Authorization, and Auditing 1 / converted Edition James Forshaw

https://textbookfull.com/product/windows-security-internals-adeep-dive-into-windows-authentication-authorization-andauditing-1-converted-edition-james-forshaw/

Windows Security Internals - A Deep Dive into Windows Authentication, Authorization, and Auditing (for True Epub) 1st Edition James Forshaw

https://textbookfull.com/product/windows-security-internals-adeep-dive-into-windows-authentication-authorization-and-auditingfor-true-epub-1st-edition-james-forshaw/

Windows Internals Part 1 7th Edition Pavel Yosifovich

https://textbookfull.com/product/windows-internals-part-1-7thedition-pavel-yosifovich/

Windows Internals Part 2 Developer Reference 7th Edition Russinovich

https://textbookfull.com/product/windows-internalspart-2-developer-reference-7th-edition-russinovich/

Mastering Cloud Security Posture Management (CSPM) 1 / converted Edition Qamar Nomani

https://textbookfull.com/product/mastering-cloud-securityposture-management-cspm-1-converted-edition-qamar-nomani/

Attacking Network Protocols A Hacker s Guide to Capture Analysis and Exploitation 1st Edition James Forshaw [Forshaw

https://textbookfull.com/product/attacking-network-protocols-ahacker-s-guide-to-capture-analysis-and-exploitation-1st-editionjames-forshaw-forshaw/

Learning OpenTelemetry 1 / converted Edition Ted Young

https://textbookfull.com/product/learningopentelemetry-1-converted-edition-ted-young/

Android Software Internals Quick Reference: A Field Manual and Security Reference Guide to Java-based Android Components 1st Edition James Stevenson

https://textbookfull.com/product/android-software-internalsquick-reference-a-field-manual-and-security-reference-guide-tojava-based-android-components-1st-edition-james-stevenson/

PowerShell 7 Workshop 1

/

converted Edition Nick Parlow

https://textbookfull.com/product/powershell-7-workshop-1converted-edition-nick-parlow/

CONTENTS IN DETAIL

TITLE PAGE

COPYRIGHT

DEDICATION

ABOUT THE AUTHOR AND TECHNICAL REVIEWER

FOREWORD

ACKNOWLEDGMENTS

INTRODUCTION

Who Is This Book For?

What Is in This Book?

PowerShell Conventions Used in This Book

Getting in Touch

PART

I: AN OVERVIEW OF THE WINDOWS OPERATING SYSTEM

1

SETTING

UP A POWERSHELL TESTING ENVIRONMENT

Choosing a PowerShell Version

Configuring PowerShell

An Overview of the PowerShell Language

Understanding Types, Variables, and Expressions

Executing Commands

Discovering Commands and Getting Help

Defining Functions

Displaying and Manipulating Objects

Filtering, Ordering, and Grouping Objects

Exporting Data

Wrapping Up

2

THE WINDOWS KERNEL

The Windows Kernel Executive

The Security Reference Monitor

The Object Manager

Object Types

The Object Manager Namespace

System Calls

NTSTATUS Codes

Object Handles

Query and Set Information System Calls

The Input/Output Manager

The Process and Thread Manager

The Memory Manager

NtVirtualMemory Commands

Section Objects

Code Integrity

Advanced Local Procedure Call

The Configuration Manager

Worked Examples

Finding Open Handles by Name

Finding Shared Objects

Modifying a Mapped Section

Finding Writable and Executable Memory

Wrapping Up

3

USER-MODE APPLICATIONS

Win32 and the User-Mode Windows APIs

Loading a New Library

Viewing Imported APIs

Searching for DLLs

The Win32 GUI

GUI Kernel Resources

Window Messages

Console Sessions

Comparing Win32 APIs and System Calls

Win32 Registry Paths

Opening Keys

Listing the Registry’s Contents

DOS Device Paths

Path Types

Maximum Path Lengths

Process Creation

Command Line Parsing

Shell APIs

System Processes

The Session Manager

The Windows Logon Process

The Local Security Authority Subsystem

The Service Control Manager

Worked Examples

Finding Executables That Import Specific APIs

Finding Hidden Registry Keys or Values

Wrapping Up

PART II: THE WINDOWS SECURITY REFERENCE MONITOR

4 SECURITY ACCESS TOKENS

Primary Tokens

Impersonation Tokens

Security Quality of Service

Explicit Token Impersonation

Converting Between Token Types

Pseudo Token Handles

Token Groups

Enabled, EnabledByDefault, and Mandatory

LogonId

Owner

UseForDenyOnly

Integrity and IntegrityEnabled

Resource

Device Groups

Privileges

Sandbox Tokens

Restricted Tokens

Write-Restricted Tokens

AppContainer and Lowbox Tokens

What Makes an Administrator User?

User Account Control

Linked Tokens and Elevation Type

UI Access

Virtualization

Security Attributes

Creating Tokens

Token Assignment

Assigning a Primary Token

Assigning an Impersonation Token

Worked Examples

Finding UI Access Processes

Finding Token Handles to Impersonate

Removing Administrator Privileges

Wrapping Up

5

SECURITY DESCRIPTORS

The Structure of a Security Descriptor

The Structure of a SID

Absolute and Relative Security Descriptors

Access Control List Headers and Entries

The Header

The ACE List

Constructing and Manipulating Security Descriptors

Creating a New Security Descriptor

Ordering the ACEs

Formatting Security Descriptors

Converting to and from a Relative Security Descriptor

The Security Descriptor Definition Language

Worked Examples

Manually Parsing a Binary SID

Enumerating SIDs

Wrapping Up

6

READING AND ASSIGNING SECURITY DESCRIPTORS

Reading Security Descriptors

Assigning Security Descriptors

Assigning a Security Descriptor During Resource Creation

Assigning a Security Descriptor to an Existing Resource

Win32 Security APIs

Server Security Descriptors and Compound ACEs

A Summary of Inheritance Behavior

Worked Examples

Finding Object Manager Resource Owners

Changing the Ownership of a Resource

Wrapping Up

7

THE ACCESS CHECK PROCESS

Running an Access Check

Kernel-Mode Access Checks

User-Mode Access Checks

The Get-NtGrantedAccess PowerShell Command

The Access Check Process in PowerShell

Defining the Access Check Function

Performing the Mandatory Access Check

Performing the Token Access Check

Performing the Discretionary Access Check

Sandboxing

Restricted Tokens

Lowbox Tokens

Enterprise Access Checks

The Object Type Access Check

The Central Access Policy

Worked Examples

Using the Get-PSGrantedAccess Command

Calculating Granted Access for Resources

Wrapping Up

8

OTHER ACCESS CHECKING USE CASES

Traversal Checking

The SeChangeNotifyPrivilege Privilege

Limited Checks

Handle Duplication Access Checks

Sandbox Token Checks

Automating Access Checks

Worked Examples

Simplifying an Access Check for an Object

Finding Writable Section Objects

Wrapping Up

9

SECURITY AUDITING

The Security Event Log

Configuring the System Audit Policy

Configuring the Per-User Audit Policy

Audit Policy Security

Configuring the Resource SACL

Configuring the Global SACL

Worked Examples

Verifying Audit Access Security

Finding Resources with Audit ACEs

Wrapping Up

PART III: THE LOCAL SECURITY AUTHORITY

AND AUTHENTICATION

10 WINDOWS AUTHENTICATION

Domain Authentication

Local Authentication

Enterprise Network Domains

Domain Forests

Local Domain Configuration

The User Database

The LSA Policy Database

Remote LSA Services

The SAM Remote Service

The Domain Policy Remote Service

The SAM and SECURITY Databases

Accessing the SAM Database Through the Registry

Inspecting the SECURITY Database

Worked Examples

RID Cycling

Forcing a User‘s Password Change

Extracting All Local User Hashes

Wrapping Up

11

ACTIVE DIRECTORY

A Brief History of Active Directory

Exploring an Active Directory Domain with PowerShell

The Remote Server Administration Tools

Basic Forest and Domain Information

The Users

The Groups

The Computers

Objects and Distinguished Names

Enumerating Directory Objects

Accessing Objects in Other Domains

The Schema

Inspecting the Schema

Accessing the Security Attributes

Security Descriptors

Querying Security Descriptors of Directory Objects

Assigning Security Descriptors to New Directory Objects

Assigning Security Descriptors to Existing Objects

Inspecting a Security Descriptor’s Inherited Security

Access Checks

Creating Objects

Deleting Objects

Listing Objects

Reading and Writing Attributes

Checking Multiple Attributes

Analyzing Property Sets

Inspecting Control Access Rights

Analyzing Write-Validated Access Rights

Accessing the SELF SID

Performing Additional Security Checks

Claims and Central Access Policies

Group Policies

Worked Example

Building the Authorization Context

Gathering Object Information

Running the Access Check

Wrapping Up

12

INTERACTIVE AUTHENTICATION

Creating a User’s Desktop

The LsaLogonUser API

Local Authentication

Domain Authentication

Logon and Console Sessions

Token Creation

Using the LsaLogonUser API from PowerShell

Creating a New Process with a Token

The Service Logon Type

Worked Examples

Testing Privileges and Logon Account Rights

Creating a Process in a Different Console Session

Authenticating Virtual Accounts

Wrapping Up

13

NETWORK AUTHENTICATION

NTLM Network Authentication

NTLM Authentication Using PowerShell

The Cryptographic Derivation Process

Pass-Through Authentication

Local Loopback Authentication

Alternative Client Credentials

The NTLM Relay Attack

Attack Overview

Active Server Challenges

Signing and Sealing

Target Names

Channel Binding

Worked Example

Overview

The Code Module

The Server Implementation

The Client Implementation

The NTLM Authentication Test

Wrapping Up

14

KERBEROS

Interactive Authentication with Kerberos

Initial User Authentication

Network Service Authentication

Performing Kerberos Authentication in PowerShell

Decrypting the AP-REQ Message

Decrypting the AP-REP Message

Cross-Domain Authentication

Kerberos Delegation

Unconstrained Delegation

Constrained Delegation

User-to-User Kerberos Authentication

Worked Examples

Querying the Kerberos Ticket Cache

Simple Kerberoasting

Wrapping Up

15

NEGOTIATE AUTHENTICATION AND OTHER SECURITY PACKAGES

Security Buffers

Using Buffers with an Authentication Context

Using Buffers with Signing and Sealing

The Negotiate Protocol

Less Common Security Packages

Secure Channel

CredSSP

Remote Credential Guard and Restricted Admin Mode

The Credential Manager

Additional Request Attribute Flags

Anonymous Sessions

Identity Tokens

Network Authentication with a Lowbox Token

Authentication with the Enterprise Authentication Capability

Authentication to a Known Web Proxy

Authentication with Explicit Credentials

The Authentication Audit Event Log

Worked Examples

Identifying the Reason for an Authentication Failure

Using a Secure Channel to Extract a Server’s TLS Certificate Wrapping Up

Final Thoughts

A

BUILDING A WINDOWS DOMAIN NETWORK FOR TESTING

The Domain Network

Installing and Configuring Windows Hyper-V

Creating the Virtual Machines

The PRIMARYDC Server

The GRAPHITE Workstation

The SALESDC Server

SDDL SID ALIAS MAPPING

INDEX

WINDOWS SECURITY

San Francisco

WINDOWS

SECURITY INTERNALS. Copyright © 2024 by James Forshaw.

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

First printing

ISBN-13: 978-1-7185-0198-0 (print)

ISBN-13: 978-1-7185-0199-7 (ebook)

Published by No Starch Press®, Inc. 245 8th Street, San Francisco, CA 94103 phone: +1.415.863.9900 www.nostarch.com; info@nostarch.com

Publisher: William Pollock

Managing Editor: Jill Franklin

Production Manager: Sabrina Plomitallo-González

Production Editor: Sydney Cromwell

Developmental Editors: Alex Freed and Frances Saux

Cover Illustrator: Garry Booth

Interior Design: Octopod Studios

Technical Reviewer: Lee Holmes

Copyeditor: Rachel Head

Proofreader: Audrey Doyle

Indexer: BIM Creatives, LLC

Library of Congress Cataloging-in-Publication Data

Name: Forshaw, James, author.

Title: Windows security internals / James Forshaw.

Description: San Francisco : No Starch Press, [2024] | Includes index. | Identifiers: LCCN 2023040842 (print) | LCCN 2023040843 (ebook) | ISBN 9781718501980 (print) | ISBN 9781718501997 (ebook)

Subjects: LCSH: Computer security. | Microsoft Windows (Computer file) | Computer networks—Security measures.

Classification: LCC QA76.9.A25 F65655 2024 (print) | LCC QA76.9.A25 (ebook) | DDC 005.8—dc23/eng/20231208

LC record available at https://lccn.loc.gov/2023040842

LC ebook record available at https://lccn.loc.gov/2023040843

For customer service inquiries, please contact info@nostarch.com. For information on distribution, bulk sales, corporate sales, or translations: sales@nostarch.com. For permission to translate this work: rights@nostarch.com. To report counterfeit copies or piracy: counterfeit@nostarch.com.

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

Dedicated to my amazing wife, Huayi, and my little Jacob, without whom I would never get anything done.

About the Author

James Forshaw is a renowned computer security expert on Google’s Project Zero team. In his more than 20 years of experience analyzing and exploiting security issues in Microsoft Windows and other products, he has discovered hundreds of publicly disclosed vulnerabilities in Microsoft platforms. Others frequently cite his research, which he presents in blogs, on the world stage, or through novel tooling, and he has inspired numerous researchers in the industry. When not breaking the security of other products, James works as a defender, advising teams on their security design and improving the Chromium Windows sandbox to secure billions of users worldwide.

About the Technical Reviewer

Lee Holmes is a security architect in Azure security, an original developer on the PowerShell team, a fanatical hobbyist, and the author of The PowerShell Cookbook (O’Reilly Media, 2010). You can find him on Mastodon (@Lee_Holmes@infosec.exchange), as well as on his personal website (https://leeholmes.com).

FOREWORD

A Microsoft Technical Fellow once told me he had never met someone who understood how the security of the Windows operating system actually worked. While I don’t think he was right (and plan to send him a copy of this book to prove it), he had a point. Though critical, there is no doubt that Windows security is complex.

One of the reasons for this is related to the core architectural difference between Linux and Windows. Linux is a file-oriented operating system, while Windows is API oriented, and though APIs can provide a much richer set of capabilities, they come at the expense of simplicity. So, exploring an API-oriented operating system is more difficult. You need to read the API documentation, write code, compile and run it, and debug the results.

This is a very time-consuming loop, and it’s why so few people have a deep understanding of how Windows security works—it’s just too hard to explore.

It was because of these problems that I invented PowerShell. I wanted administrators to automate Windows and had originally tried to do so by distributing Unix tools for free. (Remember Windows Services for Unix?) This failed because Unix tools work on files, while everything important in Windows lives behind an API. Thus, awk didn’t work against the registry, grep didn’t work against Windows Management Instrumentation (WMI), sed didn’t work against Active Directory, and so on. What we needed was an API-oriented command line interface and scripting tool. So, I created PowerShell.

Today, James is using PowerShell to address the difficulty of acquiring Windows security expertise; he has made the system explorable. Step one: install his PowerShell module, NTObjectManager, which provides over 550

cmdlets to experiment with all aspects of Windows security. This hands-on exploration will allow you to understand how things really work.

This book belongs on the desk of every security professional and developer working with Windows security. Part I provides an overview of Windows security’s architecture, Part II covers the details of the operating system’s security mechanisms and services, and Part III explores the various aspects of Windows authentication. Each chapter includes a set of PowerShell examples.

I strongly encourage you to follow the examples provided; exploration turns words into experience, and experience is the foundation of competence. Run the commands, make intentional mistakes, and see what errors you get. In doing so, you’ll acquire a deep understanding of the system.

And trust me: it will be fun.

Inventor of PowerShell, former chief architect for Windows Server, and former Microsoft Technical Fellow

ACKNOWLEDGMENTS

Few books are written in complete isolation, and this one certainly doesn’t break that mold. I’d like to take the opportunity to thank some of the many people who have contributed to making this tome a reality. I apologize to anyone I’ve forgotten.

I must start by acknowledging the contribution of my wife, Huayi, who cheers me up when I’m down and kicks me (metaphorically) when I’m being lazy. Without her by my side, the past few years would have been much less agreeable. The rest of my family are just as important; without them, my life would be so very different.

Next, I’d like to thank my technical reviewer, Lee Holmes, who has made the review a valuable experience, teaching me many PowerShell tricks I didn’t know existed and providing important feedback on the structure and content.

I’m not the only person doing significant research on Windows. While there are far too many to list here, I’d like to acknowledge the following people who have made important contributions to my work. First is Alex Ionescu, well-known Windows internals guru and my sometimes collaborator (or competitor), who always seems to know some weird bit of operating system esoterica. Then there are the many practitioners of Windows enterprise security research and testing, such as Lee Christensen, Will Schroeder, and Nick Landers. They’ve been important sounding boards for my understanding of software like Active Directory and Kerberos and have actively tested and contributed to my tooling projects.

I’d be remiss not to mention the amazing researchers from my more formative years, especially Pete and Rich; you know who you are. Also, I’d like to thank Rob and his team for looking at early drafts of my book’s

chapters and providing valuable feedback.

My relationship with Microsoft has had its ups and downs. That said, I’d like to thank many of its current and former employees who have helped me along the way. This includes Katie Moussouris, who was instrumental in convincing me that it pays to find bugs in Microsoft products. Without her friendship and contributions, I doubt I’d be as successful as I am today. Then there’s Nate Warfield, who for many years was my point of contact at the Microsoft Security Response Center (MSRC), where he shielded me from much of the company’s party politics and ensured the bugs I reported got fixed in a timely manner. Finally, I’d like to thank current MSRC representatives, including Nic Fillingham and Stephanie Calabrese, for helping me when I need to contact someone deep inside the beast, and for providing me with swag.

Special thanks to my Google colleagues, who support me in making and breaking things on Windows. This includes the entirety of the current Google Project Zero team and its alumni: the best set of security researchers you’ll likely ever find in a single room, or even two. Then there’s Will Harris, my friend and colleague on the Chromium Windows sandbox team, who asked me many of the questions about Windows security on which this book is based. Finally, thanks to Heather Adkins, who was instrumental in my being allowed to write a book of this nature while keeping a job at Google.

I’d also like to thank everyone at No Starch Press who has worked on this book and been patient with me: especially Alex Freed, my longtime editor, who unfortunately left before this book was published, and Frances Saux, who became my new editor after Alex’s departure and pulled this book, kicking and screaming, to completion. Finally, I must thank Bill Pollock, who is a good friend and always has amazing advice on the book writing process, as well as the latest recommendations for incredible restaurants.

I don’t have the space here to name everyone, but to wrap up I’d like to express my gratitude to all the friends and colleagues who contribute massively every day to my life and success. Thanks also to you, for picking up my book. I hope you find the information about Windows security contained herein to be useful.

INTRODUCTION

Hundreds of millions of devices use the Microsoft Windows platform. Many of the world’s largest companies rely on its security to protect their data and communications, as does anyone hosting their code in the Azure cloud. But because Windows is so important to the security of the modern internet, it’s also a popular target for attack.

The Windows NT operating system began including security in its design in 1993, when it introduced user accounts, control over resources, and remote access from a network. In the more than 20 years since then, much has changed in Windows security. Microsoft has replaced its original authentication process with modern technology, granted the access control mechanism additional capabilities, and significantly hardened the platform against attack.

Today, the security of the Windows platform is surprisingly complex, and many attacks rely on abusing this complexity. Unfortunately, Microsoft’s documentation in this area can be lacking. As Windows is not open source, sometimes the only way to understand its security is through deep research and analysis.

This is where I come in. I’ve spent more than 20 years as a developer and security researcher on Windows platforms, cultivating an understanding of the operating system’s undocumented corners. In this book, I share some of my extensive expertise in an easy-to-understand form. By mastering the

principles of Windows security, you’ll be able to kick-start your own research project or improve your software product.

Who Is This Book For?

I wrote this book for people who work with Windows security. Perhaps you’re a developer of Windows software and want to ensure that your product is secure. Or maybe you’re a system administrator tasked with securing Windows across an enterprise and don’t fully understand how various security features combine to protect the platform. Or you might want to poke holes in the operating system to find security vulnerabilities as a researcher.

This book assumes reasonable familiarity with the Windows user interface and its basic operations, such as manipulating files. That said, you don’t need to be a low-level Windows expert: for those who need a little more grounding, Chapters 2 and 3 provide an overview of the operating system and how it’s put together.

I rely heavily on the use of PowerShell scripting, so you’ll find it helpful to have some experience with the language, as well as with the .NET framework on which it’s based. To get you up to speed, Chapter 1 gives a very quick overview of some of PowerShell’s features. Elsewhere, I’ll do my best to avoid using esoteric features of the language, to keep the code accessible to readers with knowledge of other scripting languages or shell environments (such as bash).

What Is in This Book?

In each chapter, we’ll cover core security features implemented in modern versions of Windows. We’ll also walk through several worked examples written in PowerShell, which should give you a better understanding of the commands introduced in the chapter. Here’s a brief summary of what each chapter covers.

Part I surveys the Windows operating system from a programming perspective. It should provide you with the foundation needed to understand the material in the rest of the book.

Chapter 1: Setting Up a PowerShell Testing Environment    In this chapter, you’ll set up PowerShell to run the examples included in the subsequent chapters. This includes installing a PowerShell module I’ve

written to interact with Windows and its security features. The chapter also provides an overview of the PowerShell scripting language.

Chapter 2: The Windows Kernel    This chapter covers the basics of the Windows kernel and its system call interface, a topic crucial to developing a solid understanding of Windows security. I also describe the object manager, used to manage resources.

Chapter 3: User-Mode Applications    Most applications don’t directly use the system call interface from the kernel; instead, they use a set of higher-level programming interfaces. This chapter covers Windows features such as file handling and the registry.

Part II covers the most important component of the Windows kernel for security, the Security Reference Monitor. We’ll look at all aspects of access control, from constructing the user’s identity to securing an individual resource, such as a file.

Chapter 4: Security Access Tokens    Windows assigns every running process an access token, which represents the user’s identity to the system. This chapter describes the various components stored in the token that are used to check access.

Chapter 5: Security Descriptors    Each securable resource needs a description of who is allowed to access it and what type of access they are granted. This is the purpose of security descriptors. In this chapter, we’ll cover their internal structure and how you can create and manipulate them.

Chapter 6: Reading and Assigning Security Descriptors    To inspect the security of the system, you need to be able to query the security descriptor of a resource. This chapter explains how this querying happens for different types of resources. It also covers the many complex ways that Windows assigns security descriptors to resources.

Chapter 7: The Access Check Process    Windows uses the access check to determine what access to grant a user to a resource. This operation takes the token and the security descriptor and follows an algorithm to determine the granted access. This chapter works through a PowerShell implementation of the algorithm to explore its design in depth.

Chapter 8: Other Access Checking Use Cases    Although Windows primarily uses access checks to grant access to resources, it sometimes uses them to determine other security properties, such as the visibility of resources and whether a process is running with a low level of privilege. This chapter covers these alternative use cases for the access check.

Chapter 9: Security Auditing    The access check process can also create logs of the resources a user has accessed, and with what level of access. This chapter covers these system auditing policies.

Part III contains details of Windows authentication, the mechanisms that verify a user’s identity for the purposes of access control.

Chapter 10: Windows Authentication    As the topic of authentication is quite complex, this chapter summarizes the authentication structure and services on which the rest of the authentication mechanisms depend.

Chapter 11: Active Directory    Windows 2000 introduced a new model for networking Windows systems in an enterprise, with all authentication information stored in a network directory that users and administrators could query and modify. This chapter covers how Active Directory stores information and secures it from malicious modification.

Chapter 12: Interactive Authentication    The most common authentication scenario on Windows occurs when a user enters their username and password into their computer and gains access to the desktop. This chapter covers how the operating system implements this authentication process.

Chapter 13: Network Authentication    When a user wants to access a network service in a Windows enterprise network, they typically must authenticate to it. Windows provides special network protocols to implement this authentication without disclosing the user’s credentials to a potentially hostile network. This chapter explains the network authentication process, focusing on the New Technology LAN Manager (NTLM) authentication protocol.

Chapter 14: Kerberos    Along with Active Directory, Windows 2000 also introduced the use of the open Kerberos authentication protocol for enterprise network authentication. This chapter explains how Kerberos works in Windows to authenticate a user interactively and over a

network.

Chapter 15: Negotiate Authentication and Other Security Packages    Over the years, Windows has added other types of network authentication protocols. This chapter covers these new types, including Negotiate, to supplement those discussed in Chapters 13 and 14. Finally, the two appendices provide configuration details and further resources.

Appendix A: Building a Windows Domain Network for Testing    To run some of the examples in the book, you’ll need a Windows domain network. This appendix provides some steps for using PowerShell to configure a network for testing.

Appendix B: SDDL SID Alias Mapping    This appendix provides a table of constants referenced in Chapter 5.

PowerShell Conventions Used in This Book

The PowerShell scripting language, which is included with all versions of Windows, is one of the best ways to flexibly experiment with the internals of the operating system without needing to install much additional software. As PowerShell is based on the .NET runtime, this book will use a .NET library I’ve written for interacting with Windows, making it easy to develop complex scripts. All example scripts in the book will be available to download from https://github.com/tyranid/windows-security-internals.

The PowerShell examples in each chapter follow a common set of style conventions that should help you understand how to use them. Each example is provided as a listing, of which there are two types: interactive and noninteractive. Interactive PowerShell listings are those you should enter on the command line to observe the results. Here is an example of an interactive listing:

An interactive listing precedes each command to enter with a PowerShell- style prompt (PS>) and shows the command in bold ❶. You’ll see the resulting output below the command ❷. Sometimes the output can be quite long, so to save space, I use --snip-- to indicate that the output has been truncated ❸. Also note that in some examples the output is indicative; it might be subtly different depending on your operating system or network configuration.

Most of the interactive listings are designed to be executed from a normal user account. However, some must run under an administrator account to access certain protected features. If you don’t run the commands as an administrator, the results won’t be correct. The text preceding each listing will clarify whether you must run the command as an administrator.

A non-interactive listing contains PowerShell code that you can copy into a script file for reuse, like this:

function Get-Hello { "Hello" }

Non-interactive listings don’t include the PowerShell prompt and aren’t in bold.

If you’ve written any scripts in PowerShell, you’ll know that the language is notorious for verbose command and parameter names. This makes it difficult to fit certain commands on a single line in the book. Here is an example of a long PowerShell line and a few ways the book might split it to make it fit on the page:

PS> Get-ChildItem -LiteralPath "C:\" -Filter "*.exe" -Recurse -Hidden ❶ -System -Depth 5 | Where-Object { ❷ $_.Name -eq "Hello" }

The first line, using the Get-ChildItem command, is too long to fit on the page, so it wraps onto a subsequent line ❶. You can’t just add a newline

in the middle of such a command, so when you’re entering it into the shell or a file, you should treat it as a single line. The key indicator that the line continues, instead of being part of the output, is that there’s a bold character in the first column.

PowerShell can break long lines on certain characters, such as the pipe (|), the comma (,), or braces ({}). In this listing, I’ve added a newline following the opening brace ({) and placed the subsequent commands in the braced block, indented one level ❷. In this case, the shell will handle the introduction of the new line. Note that the closing brace (}) is in the first column, so you might assume it needs to be placed on the previous line. While moving the brace to the previous line will still work in this specific case, it’s unnecessary.

Note that the Windows operating system is still under active development. While all the PowerShell examples have been tested on the latest versions of Windows available at the time of writing, there is a chance that new security features will have been introduced, or older ones deprecated, by the time you come to read this book. The following is a list of the versions on which the examples were tested, along with the major OS build number:

Windows 11 (OS build 22631)

Windows 10 (OS build 19045)

Windows Server 2022 (OS build 20384)

Windows Server 2019 (OS build 17763)

Any mentions of “the latest versions” in the text refer to these versions.

Getting in Touch

I’m always interested in receiving feedback, both positive and negative, on my work, and this book is no exception. You can email me at winsecinternals.book@gmail.com. You can also subscribe to my blog at https://www.tiraniddo.dev, where I post some of my latest advanced security research.

PART I

AN OVERVIEW OF THE WINDOWS OPERATING SYSTEM

1

SETTING UP A POWERSHELL TESTING ENVIRONMENT

In this chapter, you’ll configure PowerShell so you can work through the code examples presented in the rest of the book. Then, we’ll walk through a very quick overview of the PowerShell language, including its types, variables, and expressions. We’ll also cover how to execute its commands, how to get help, and how to export data for later use.

Choosing a PowerShell Version

The most important tool you’ll need to use this book effectively is PowerShell, which has been installed on the Windows operating system by default since Windows 7. However, there are many different versions of this tool. The version installed by default on currently supported versions of Windows is 5.1, which is suitable for our purposes, even though Microsoft no longer fully supports it. More recent versions of PowerShell are cross platform and open source but must be installed separately on Windows. All the code presented in this book will run in both PowerShell 5.1 and the latest open source version, so it doesn’t matter which you choose. If you

Another random document with no related content on Scribd:

Yrjö oikaisihe ikäänkuin olisi ollut heräämäisillään. Laskin käteni

hänen otsallensa ja tunsin, että se oli viileä. Kumarruin hänen ylitsensä ja katselin kauan hänen rauhoittuneita piirteitänsä ja kuuntelin hänen tasaista hengitystään.

— Onko mahdollista? Joko tauti on ohi? Jättikö se todella pojan?

Kiviä ja santaa! Jumalan kiitos — se oli ollut tyhjää kuumehouretta eikä mikään ennustus. Ah, Jumalan kiitos!

Ja suuri, suloinen raukeus valtasi minut. Olin voittanut ja saisin levähtää. Ja poikani saisi elää! Ja tulla terveeksi jälleen!

Olin niin kiitollinen, että vedet kihosivat silmiini.

Ja taas tuli mieleeni eräs muisto.

Hän oli kerran pannut minut arvaamaan, kuka oli hänen kaikkein paras ystävänsä. Olin maininnut Erikin, Väinön, Etan —?

— Ei, sinähän se olet, äiti — ja Jumala tietysti — mutta Jumalasta pidän vain aivan vähän enemmän, sillä täytyyhän Jumalasta enemmän pitää, äiti?

Mutta nyt vihdoinkin heräsit. Katseesi siirtyi ympäri huonetta kuin siihen pitkän ajan perästä taas perehtyäkseen. Sitten se pysähtyi minuun. Käsivartesi nousivat, laihtuneet kasvosi säteilivät, ja sellaisessa äkillisessä rakkaudenpuuskassa, joka välistä sai sinut valtoihinsa, tartuit kaulaani, pusersit minut kovasti rintaasi ja tunnustit rehellisesti ja rajoituksitta:

— Voi, kuinka sinua rakastan, äiti — enemmän kuin mitään, mitään muuta maailmassa!

11.

Pian sen jälkeen alkoi ensimmäinen koulusi. Muistat ruokailuhuoneen, joka eteläänpäin päättyi puolikaareen kolmine suurine ikkunoineen. Ja näet vielä neliskulmaisen pöydän keskellä lattiaa.

Sen pöydän ääressä sait kaiken opin perusteet, sinä ja muutamat toverisi.

Et ottanut ensin uskoaksesi, että äiti osaisi opettaa. Siitä ei tulisi mikään oikea koulu. Mutta kun hän kertoi, että hän kerran ennen oli opettanut suuriakin poikia ja tyttöjä oikeassa koulussa, vaikenit ja aivan jäykistyit ihmetyksestä.

— Niinkö?

Ja tajunnassasi tapahtui taas tuollainen uudestaan arvioiminen, joka muutti jo vakiintuneen arvon — sillä kertaa edukseni. Sen johdosta myöhemmin tovereillesi kehuskelit, että äiti olikin paras opettaja maailmassa.

Myöhemmin muistelimme joskus yhdessä tätä ensimmäistä kouluasi ja kokemuksiasi siellä. Maailma alkoi käydä entistään paljon laajemmaksi. Ei pääasiallisesti kirjojen ja numeroiden avulla, vaan toverien vaikutuksesta. Varsinkin Erik, lääkärin poika, ällistytti Yrjöä uusilla harrastuksillaan. Hänellä oli pieniä tölkkejä rivissä hyllyllään, ja niissä oli pikkueläviä spriissä. Sitten hän oli isoisältään, joka oli ollut hyönteis-professori, saanut suuren hyönteiskokoelman, ja päät yhdessä he tarkastivat neulan päässä törröttäviä kärpäsiä ja perhosia. Isältään hän oli sen lisäksi saanut kasvikokoelman, jossa

oli kasveja Suomen eri seuduilta ja muistakin maista. Ja Erik kertoi näistä kaikista aarteistaan yhtä tottuneesti ja yliolkaisesti kuin muut kertoivat tinasotamiehistään tai keilapelistään.

Hänen oppineisuutensa teki toveriin vakaavan vaikutuksen. Ja Erik huomasi hänen tietämättömyytensä näillä aloilla.

Eräänä päivänä lukea jankkasimme, kuten tavallisesti — tavata jauhoimme vuorotellen — mitä lie ollut jostakin talonpoikaistuvasta, jossa oli torakoita uunin takana. Jokainen oli innokas kertomaan, mitä tiesi näistä ihastuttavista elukoista — miten ne pudottautuvat katosta alas — miten ne tarttuvat tikkuun — miten ne luikkivat seinän rakoon tai pärekasan alle piiloon. Ainoastaan Yrjö oli niistä asioista tietämätön. Hän ei ollut torakoita edes nähnytkään.

Vihdoin oli tietovarasto loppunut ja jatkoimme tavailemista. Mutta huomasin, ettei Erik seurannut. Hän oli jostakin levoton. Nähtävästi hänellä oli jotakin sydämellään, mutta hän ei tiennyt, miten saisi sen sanotuksi. Näin hänen silmistään, ettei sitä sopinut sanoa muitten kuullen — mitä lie ollut salaisuutta. Vihdoin hän nousi, tuli luokseni, pani käsivartensa kaulaani, kuten oli tottunut äitinsä kanssa jutellessa tekemään, ja käsi suun edessä jotteivät muut kuulisi, hän kuiskasi:

— Eikö olisi jo aika ruveta opettamaan Yrjölle luonnontiedettä?

— Miksi niin? — kuiskasin vastaukseksi.

— No, kun hän ei tunne torakkaakaan!

Niin, olihan se hämmästyttävää! Todella halveksittavaa ja pöyristyttävää!

Käden liike oli ylenkatseellinen. Hän oli sitä paitsi huolissaan niin suunnattomasta tietämättömyydestä tieteitten tieteestä.

Ja Erik oli oikeassa. Osoitin hänelle katseellani, että hän oli ehdottomasti oikeassa, ja rauhoitin häntä lupaamalla tehdä parastani. Hän syventyikin lukukirjaansa tyytyväisenä siihen, että oli omantuntonsa ääntä noudattanut ja vetänyt Yrjöä edes kappaleen matkaa tietämättömyyden alennuksesta.

Mutta miten täytin lupaukseni, sen tiedät hyvin. Isänhän olisi pitänyt apuun rientää, mutta miten kävi hänen? Niin. Eihän minulla ollut sammakoita spriissä eikä neulaperhosia eikä muutakaan ainehistoa. Minulla oli juuri sillä alalla se heikko kohtani, jonka hyvin tunsit. Ja isältä puuttui aikaa.

Sentakia jäi kuin jäikin Erik yhä edelleen siksi, joka toverilleen avasi luonnontieteitten salaisuudet. Ja Yrjö oli hänen kiitollinen oppilaansa.

Kun tuli kevät ja aurinko paahtoi sammaltuneita rantapaasia kaupungin ulkopuolella, silloin te yhdessä juoksentelitte pitkin kallioita molemmin puolin Havin tietä, harhailitte harventuneessa metsässä, istua kyykötitte kevätlampien liepeillä kooten haaveihinne sammakonpoikasia ja sisiliskoja. Aarteita! Aarteita! Muistatko, miten kostea sammal tuoksui! Ja miten vesi lätäköissä lämpimänä huokui! Ja miten lakki kuumensi päätä! Havi! Se oli ihmemaa, mistä saattoi löytää mitä tahansa. Hiostunein kasvoin ja kiihkein käsin te sitten siellä kotona Erikin luona täytitte pesuvadit vedellä antaen sammakoiden niissä uiskennella ja veditte esille säiliöistänne lehtiä ja korsia ja ensimmäisiä horroksissa olevia kovakuoriaisia.

Kun sitten tulit kotiin, tuoksuit kosteaa multaa, havumetsää ja kevättä. Kengistä miltei tippui vettä — ja kaulus! Missä se oli? — No niin, se oli kaulusnapin syy. Mutta minkänäköinen oli nenäliina?

Nautimme keväästä yhdessä. Nuo illat, nuo läpikuultavat kevätillat, jolloin vedet siinsivät ikkunoihimme ja aavistimme käen kukuntaa ja pihkan hajua noitten Saimaan reittien metsiköissä! Muistatko ne?

Sellaisena kevätiltana poika sai kerran sattumalta käsiinsä pienen rasian, joka pitkät ajat oli ollut unohduksissa hänen hyllyllään ja jonka hän oli saanut Etalta pikkujouluksi. Siinä oli pienen pieniä puisia elukoita, kaikki jokseenkin yhdennäköisiä. Neljä jäykkää jalkaa ja häntä.

Illat olivat niin valoisat, ettei tarvinnut mennä niin aikaisin nukkumaan kuin muuten. Äitikin unohti muistuttaa, ja isä viipyi kävelyllä. Ja näin, miten poika ikäänkuin aikansa kuluksi alkoi asetella pikkuelukoita riviin, kaksi ja kaksi aina vierekkäin.

— Oli sentään hyvä — sanoi hän äkkiä — että Noak oli.

— Noak! Miten niin? — kysäisin, kummastellen hänen ajatusjuoksuaan.

— Niin, no, muutenhan Jumalalla olisi ollut niin paljon vaivaa olisi pitänyt synnyttää ihmisetkin uudestaan ja kaikki eläimet! — Nyt ei tarvinnut muuta kuin antoi näiden vain mennä arkkiin joka lajia aina kaksi — kaksi aina joka lajia.

— Niin, jokaisen eläinlajin isä ja äiti.

— Eihän?!

Hän katsahti minuun epäröiden ja miettiväisenä:

— Miten niin isä ja äiti?

— Onhan eläimilläkin isänsä ja äitinsä kuten ihmisillä.

— Niin taitaa —.

Hän vaikeni taasen ja antoi elukkainsa jatkaa matkaa arkkia kohti. Minä ikkunan luona parsin sukkaa käyttäen illan heikkenevää valoa, ja molemmat vaivuimme mietteisiimme.

— Mutta äiti — keskeytti hän hiljaisuuden ja katsoi minuun — on niitä muijia, jotka eivät ollenkaan ole kihloissa, ja sentään he synnyttävät poikia tai tyttöjä.

— Vai on! — Se tuli niin odottamatta, että minun oli vaikea pysyä totisena. — Tiedätkö sinä sitten semmoisia?

— En minä tiedä, mutta kyllä niitä on.

Taasen oli hiljaista. Poika oli sovitellut elukat rasiaan ja asettanut sen takaisin hyllylle. Mutta hän ei halunnut mennä vielä nukkumaan. Hän lojui mieluummin lattialla piirtäen koukerolta paperille.

— Äiti — tuli sieltä taas — aina kun joku saa lapsia, niin hän laskee ensin mätiä.

Kumarruin työni yli ja odotin jatkoa.

— Niin, niin — älä naura — aivan kuin sammakot.

— Mutta eihän ihmiset ole sammakoita.

— Jos kohta — ne tekevät vain samalla lailla.

— Miksi niin luulet?

— Minä luulen vaan — ja tiedätkös äiti, että kun sammakko on laskenut mätinsä rannalle, niin sitten tulee isä ja panee semmoista maidon tapaista päälle, ja siitä syntyy sitten poikasia. — Minäkin olen mädistä syntynyt ja ollut noin rannalla. Jos olisit aikaisemmin hakenut, niin olisit voinut löytää minut sieltä — mutta sinäpä et etsinyt silloin. Etta ja Erikkin ovat syntyneet mädistä — niin minä uskon.

— Jaha — ja sen on Erik kertonut?

— Eikä vain Erik, vaan myös hänen isänsä — ja olen minä senkin nähnyt, miten mäti kelluu veden pinnalla ja tarttuu pesuvadin reunoihin. Ja siitä tulee sitten mitä tahansa.

Mikä saattoi olla vakuuttavampaa? Newton oli puhunut. Arkimedes oli pisteensä löytänyt. Pieni mieheni paisui viisautta.

Silti otti äiti hänet polvellensa ja alkoi kertoa hänelle vielä merkillisempiä asioita. Eihän sen aina tarvinnut olla mätiäkään, mutta jotakin sinne päin se kyllä aina oli. Kukkiin muodostui siemeniä, ja munista tuli linnunpoikasia. Ja oliko poju äskettäin nähnyt Väinön Donnaa? Sille tulee pian pentuja. Ihmeellisiä asioita oli muutenkin elämässä, mutta nämä ne olivat kaikkein ihmeellisimmät. Ja kaunista oli paljon, mutta tämä oli kaikkein kauneinta. Sillä siten elämä aina uudistui ja loi aina uutta elämää vanhan sijalle.

Niin kai se sitten oli, päättivät pojan suuret silmät. Ja äiti kertoi vieläkin enemmän. Niin viisaasti oli Jumala kaikki järjestänyt, että vaikka ihmiset vuosisadasta toiseen sitä tutkivat, niin se kävi vain yhä ihmeellisemmäksi heidän silmissään. Ja kuta enemmän oppi siitä tietämään, sitä enemmän huomattiin siinä olevan sellaista, jota ei vielä ymmärretty. Sillä se on kaikki Jumalan suurta satua, jota hän ei koskaan kerro loppuun asti, jotta ihmisten silmät vain aina häneen katsoisivat jatkoa odottaen. Jumala näes on suurin kaikista satujen kertojista — ja hänkin pitää siitä, että hänellä on jokin kohta ikäänkuin erikoisena salaisuutena kunkin ihmislapsen kanssa. Pojullekin hän tulisi vielä paljon kertomaan — tämä oli vain pikkiriikkinen alku, tämä nyt äidiltä kuultu — ja Yrjöllä voi vielä olla merkillisiä yhteisiä salaisuuksia sen hyvän ja viisaan Jumalan kanssa.

Nojasit minuun ja katsoit totisin silmin ulos ikkunasta punertavaa iltataivasta.

12.

Mutta maailma kasvoi Yrjön silmissä ja antoi yhä enemmän tuumimisen aihetta. Nyt hänestä oli päivänselvä asia, että piti olla sekä poikia että tyttöjä.

Isä tuli eräänä iltana sanomaan hänelle hyvää yötä ja istuutui kuten muulloinkin pojan levolle mentyä hänen vuoteensa laidalle jutellen hänen kanssaan niitä näitä.

— Tiedätkös, kenen otan rouvakseni sitten kun tulen suureksi? kysyi poika.

— Mistäpä minä sen tietäisin?

— Otan Ainon.

— Vai Ainon! Mutta ethän sinä voi tietää sitä niin hirveän paljon aikaisemmin!

— Tiedän minä, kun kerran niin paljon pidän Ainosta.

— Mutta sinähän vasta olet pieni poika ja Aino pieni tyttö, eikä rouvaa tarvitse ajatella ennenkuin vasta sitten suurena.

— Jaa, mutta itsehän sanot, ettei saa olla ajattelematon — aina pitää kaikkea punnita, ennenkuin mitä tekee.

— Tietenkin — hymyili isä.

— Ja kun oikein kauan tuumii yhtä asiaa, niin siitä tulee sitten hyvä.

— Voi niinkin olla — myönsi isä — mutta tiedätkös, sellaisia asioita ei voi lainkaan edeltäkäsin tietää. Ne tulla tupsahtavat arvaamatta eteen, ja paras ystävä on usein sellainen, jota ei ole koskaan ennen nähnytkään.

Yrjö katsoi pienellä epäluulolla isää. Isä vain ei hänelle Ainoa suonutkaan. Siinä kaikki.

— Jaa. Kyllä minä hänet otan.

— Mutta mitäs, ellei Aino huolisikaan?

— Kyllä hän huolii. Ja voi kuinka hän ihastuisi, jos minä sen hänelle sanoisin!

— Älähän toki — isän ääni kävi hyvin vakuuttavaksi — ei sellaista

saa sanoa ennenkuin sitten, kun on aikamies. Älähän nyt vain virka mitään — tottele isää! Eikö niin — ethän? Ajatteles, kun sinun pitää vielä paljon oppia ja käydä monet koulut ennenkuin tulet suureksi ja saat ottaa rouvan itsellesi tai edes sitä ajatellakaan.

Niin tosiaankin — oppia! — Sen hän tässä oli vallan unohtanut. Yrjön silmät kävivät tummiksi. Hänenhän piti oppia tuntemaan kaikki sisiliskot, kovakuoriaiset ja kärpäset ja muut Erikin elukat. — Ja ennen kaikkea koneet, miltä ne näyttivät sisäpuolelta — ja lokomotiivit ja laivat. Se oli tärkeintä. Menisi siihen aikaa.

— Menee siihen vuosia — vakuutti isä. — Kas, sellaisissa asioissa pitää osata odottaa, siksi kunnes se oikea tulee. Opit sitten joskus tuntemaan jonkun, josta pidät yhtä paljon kuin nyt äidistä ja joka on sinulle kuin sisar ja kuitenkin vielä rakkaampi kuin sisar. Ehkäpä hänellä onkin tumma tukka kuin äidillä ja ehkäpä hänen silmänsä nauravat. Hän puhuu ehkä pehmeällä äänellä ja katsoo pehmeällä katseella, ja koskettaa pehmeällä kädellä. Sellaisen isä sinulle toivoo sitten kun olet aikamies.

Poika katsoi isää tutkivin silmin. Hän puhui kuin olisi hän jotakin tietänyt. Kai tiesikin. Piti siis sellaista odottaa.

— Mutta sen minä nyt ainakin sanon hänelle — lopetti hän keskustelun — ettei heillä aina olisi riisiryynipuuroa päivälliseksi, kun tulen sinne vieraisille. En pidä niin suurista ryyneistä.

Siihen asia jäi. Ja hän käytti ensimmäistä tilaisuutta saadakseen asiansa toimitetuksi Ainon äidille. Hän sanoi sen hänelle heti jo eteisessä.

— Teillä ei aina pitäisi olla riisiryynipuuroa kun tulen teille kylään.

Ja Ainon äiti oli kumma kyllä ihastuksissaan huomautuksesta.

Tulevaisuuden suunnitelmat saivat siis toistaiseksi väistyä tuonnemmaksi, mutta ei aivan kokonaan.

Eräänä päivänä hain, esille hänen vanhoja, pieniksi käyneitä vaatteitaan antaakseni ne pois. Hän seisoi siinä tarkastellen, miten tein niistä mytyn ja sidoin nuoran sen ympäri.

— Panisit talteen, niin ne sopisivat sitten lapsilleni.

— Kuinka monta lasta sinulle sitten tulee?

— Neljä, kaksi poikaa ja kaksi tyttöä, niin että ne voivat leikkiä keskenään.

— Jaha — jaa — en tullut sitä ajatelleeksi. Mutta kyllä melkein luulen, että vaatteet kävisivät liian vanhoiksi.

— No niin, anna vain. Täytyyhän minullekin aina vähän väliä ostaa uudet kengät ja kalossit, kun se isä ei ole säästänyt minulle yhtään paria vanhoistaan.

Yrjölle oli säästäväisyyden ihanne selvinnyt erään keskustelun jälkeen äidin kanssa heidän ja muiden ihmisten varallisuussuhteista.

Poika nimittäin eräänä päivänä kysyi, olivatko he rikkaita, kun asuivat niin suuressa talossa. Johon äiti antoi hänelle sen

hämmästyttävän tiedon, ettei tämä talo heidän omansa ollutkaan, se oli sen vanhan herran, joka oli täyttänyt hiekkalaatikon pihalla ja joka joskus tuli vastaan portaissa aina kiirehtien heitä niin kohteliaasti tervehtimään. Hän oli kohtelias, vaikka oli rikas, ja samalla lailla kohtelias kaikille. Ottihan hän hatun päästään Yrjöllekin, kun poju seisoa töllisteli pihalla ja vanha herra kulki ohitse — eikö totta? —

Äiti oli nähnyt parvekkeelta, kun se vanha herra tälle äidin nassikalle oikein kumarsi. Niin. Hän oli hieno herra, ei sentakia että oli rikas, vaan sentakia että oli hieno. Hänellä oli tämä talo ja monta muuta taloa ja metsiä ja sahoja ja kaivoksia ja saikin olla — hän oli hyvä ihminen — äiti hänestä piti. Ja hän antoi meidän asua tässä kodissamme. Meillä oli mitä me tarvitsimme, ja meitä sentakia voitiin sanoa toimeentuleviksi, mutta ei rikkaiksi. Rikkaus sitä paitsi ei aina ollut onneksi — välistä oli, mutta toisinaan ei ensinkään — ja usein teki se ihmiset ylpeiksi ja tuhmiksi.

Niin. Yrjö oli nähnyt muutamia ylpeitä rouvia — ne olivat varmaan rikkaita.

— Mahtoivat olla. Mutta kaikki ne, joilla on mitä he tarvitsevat, ne ovat toimeentulevia.

— Onko Väinökin toimeentuleva?

— On Väinökin.

— Minusta olisi hauskempi, jos meilläkin olisi vain kaksi huonetta kuin Väinölläkin.

— Miksi niin?

— Silloin sinä lakaisisit ja keittäisit — vaikka minä kyllä Liisasta pidän — mutta me olisimme aina yhdessä.

— Niin, miksikä ei? Mutta olemmehan nytkin yhdessä, kun melkein aina olemme samassa huoneessa. Ja kun se vanha herra nyt on rakentanut meille näin monta huonetta, niin ollaan me nyt täällä tyytyväisiä. — Ja kukapa sen tiennee, vaikka meillä joskus toiste olisi kaksi huonetta ja Väinöllä ties miten monta.

Jaa! — Yrjö paisui jo etukäteen Väinön rikkauksista.

Mutta sen keskustelun jälkeen hän ei enää ollut niin varma vanhempiensa loppumattomista tulolähteistä. Kun hän eräänä päivänä aukaisi eteisen oven äidillensä ja huomasi hänellä olevan kädet täynnä paketteja, niin että hän tuskin mahtui ovesta sisään, nosti hän vakavasti sormensa ja sanoi varoittavasti:

— Ai, ai, äiti — älä osta vain niin paljon tavaraa, että leipä loppuu!

13. Seuraavana syksynä koulu jatkui Erikin tädin luona, joka asui kaupungissa. Hänellä oli se suuri etu minun rinnallani, että hänen luokseen piti mennä oikein katua pitkin kuten muihin kouluihin. Sielläkään ei ollut kuin kuusi oppilasta. Mutta vaikkei heitä ollutkaan sen useampia, oli tädillä täysi työ koettaessaan hillitä heidän puheluintoansa tunnilla. Sillä he olivat tottuneet heti paikalla ilmaisemaan kaikki ajatuksensa ja tunteensa, ja luettava kappale tai laskettava esimerkki toi usein niin merkillisen tärkeitä muistoja tai

mielijohteita kielelle. Täti keksi sentakia sen keinon, että rupesi

vetämään muistikirjaansa viivan aina kun joku heistä turhanpäiten jutteli heidän siinä lukiessaan tai laskiessaan.

Kysyin jonkun ajan kuluttua pieneltä rupattelijaltani, montako viivaa hän oli jo saanut.

— En minä tiedä.

— Kuinka? Etkö ole laskenut?

— Tiedätkö äiti, ne muut ovat niin uteliaita, että ne laskevat viivansa joka päivä — minä en huoli.

Ymmärsin yskän. Vedin hänet luokseni kuiskaten:

— Sanopas oikein totta — eikö sinulla lie kaikkein eniten viivoja?

O-on! — kuiskasi hän vastaukseksi.

Myöhemmin koetettiin tehostaa huolellisuutta antamalla pieniä kotimuistutuksia. Kerran sai Yrjökin sellaisen ja hän toi kotiin pienen vihkosen. Näin hänestä selvään, ettei hän oikein tiennyt, oliko se suuri vai mahdollisesti aivan pieni häpeä, mutta kun otin näyttääkseni vakavalta, punastui hän ja häpesi — kuten täti oli tarkoittanutkin.

Jonkun ajan kuluttua oli Erikin vuoro, ja silloin Yrjö ehdotti, että he menisivät joukolla katsomaan, mitä Erikin äiti sanoo. Erikillä ei ollut mitään sitä vastaan, ja koko roikka karkasi sisään lääkärin ruokahuoneeseen, jossa tohtorinna istui ompelunsa äärellä. Siinä he sitten äänetönnä seisoa töllistelivät odottaen vihkosen vaikutusta, Erik ensimmäisenä, tirkistäen syrjästä tovereitaan. Mutta kun Yrjö

palasi kotiin ja kertoi äidilleen retkeilystään, niin hän ei ollut hullua hurskaampi, sillä Erikin äiti ei ollut sanonut mitään. Eikä hän liioin ollut miltään näyttänyt.

Tässä pienessä koulussa luki Yrjö maantiedettänsä ja raamatunhistoriaansa ilman päähänpänttäystä vapaasti ja iloisesti, ja kaikki tuli eläväksi. Hänellä oli kaikesta oma käsityksensä ja hän lausui sen rohkeasti julki. Kun hän luki syntiinlankeemuksesta, oli hän kovin pahoillaan Aatamin ja Eevan tottelemattomuudesta. Mutta hän arveli samalla, ettei Jumalan olisi pitänyt millään muotoa istuttaa paratiisiin sellaista puuta, jossa oli niin makeat kielletyt omenat, ettei niihin voinut olla vilkaisematta ohitse kulkiessaan. Jumala ei koskaan sanonut. No ota nyt sieltä omena! Ei. Niihin ei saanut koskea. Olisi ainakin asettanut sen puun vähän syrjemmälle lähelle aitausta! Kun sitten kerran nuo ihmisparat olivat syöneet yhden omenan, oli hän niin pahoillaan, että ajoi heidät ulos. Kaikki olisi mennyt hyvin, ellei sitä puuta olisi ollut.

Ja kun hän kerran kuuli puhuttavan Jumalan pojasta, löi hän kätensä yhteen huudahtaen.

— Ai, onko hänelläkin poika!

Eräänä iltana riisuutuessaan mennäkseen levolle kiskoi hän takkinsa niin rajusti auki että nappeja lensi irti:

— Näin ne papit tekevät!

— Papit? Milloin olet nähnyt pappien tekevän sillä lailla?

— Näin tekivät papit Jerusalemissa. He repivät vaatteensa eivätkä yhtään välittäneet siitä, mitä heidän äitinsä sanoi.

Minulla oli loppumatonta iloa hänen välittömyydestään ja vastaanottavaisuudestaan. Ja ajattelin usein, että sellaisena pitäisi ihmisen säilyä myöhemminkin, kun syvemmät tiedonlähteet hänelle avautuvat. Miten paljon rikkaampia olisimmekaan, jos kaikki tietomme tulisivat eläviksi tajunnassamme!

14.

OLI KAUNIS kesäpäivä. Seisoin pienen höyrylaivan kannella keskellä vakkoja ja voipyttyjä tähystellen sitä saaristolaituria, jonne minun oli noustava. Puitten lomitse näkyi kesähuvilamme katto. Poukamassa oli kyläläisten verkkoja kuivumassa pitkät rivit, oli nähtävästi ollut hyvä kalansaalis-aika. Veneitään olivat vetäneet korkealle hiekkarannalle, lieneekö ollut myrsky viime yönä. Siinä olivat joukolla vastassa vanhat ja nuoret, vilisi valkoisia liinoja ja lippalakkeja laivasillalla. Ja ilma henki merisammalta, ruskolevää ja hailia, auringon paahdetta ja apilasta.

Ja laituri oli pitkä ja kallistunut.

Olin ollut poissa parin viikon ajan ja odotin näkeväni perheeni sillalla. Siellä havaitsinkin ensin isän ja sitten mummon, mutta Yrjöä ei näkynyt missään. Ja kuitenkin hän oli tavallisesti etumaisena huitomassa lakkiansa tervetuliaisiksi sille, jota odotettiin. Hänen piti aina jollakin näkyvällä tavalla purkaa ilonsa.

Olin ihmeissäni. Varjostin silmiäni kädelläni nähdäkseni paremmin. Vaikka hän olisi seisonutkin toisten takana, olisin sittenkin huomannut hänet, sillä hän oli yksitoistavuotiaaksi tavattoman

kookas. Ja kotona hän oli varmaan. Retkeltään serkkujensa luo Saimaan rannalle hän oli jo viikko sitten kotiutunut.

Laiva laski maihin. Isä otti kantamukseni ja aukoi minulle tietä tutussa tungoksessa. Pari kertaa piti pysähtyä tervehtimään naapuria. Sitten noustiin käsikoukussa koivumäkeä huvilallemme.

Miten ihanaa taas olla kotona!

— Mutta missä on Yrjö? — kysäisin samalla.

Isä katsahti hiukan kummissaan ympärilleen. Niin tosiaankin! Äsken hän oli ollut verannalla ja isä oli luullut hänen juosseen alas rantaan. Poika oli ollut tavallista vakavampi viime aikoina, kertoi isä, eikä Väinönkään tulo ollut saanut muutosta aikaan. Hän oli iltaisin soittanut selloa isän säestyksellä, ja he olivat harjoittaneet uuttakin äidin tuloa varten. Mutta ei siihenkään saatu oikein vauhtia. Nyt isäkin oudoksuen etsi poikaa silmillään. Mutta kylläpä hän löytynee.

Jatkoimme matkaamme koivumetsikön halki. Pihalla tuli poika meitä vastaan hitaasti astuen.

— Mikä sinun on, Yrjö? — kysyin heti hänet nähtyäni levottomana.

Oletko sairas?

— En.

— Mikä sinua sitten vaivaa? Oletko jostakin pahoillasi?

Hän ei vastannut, tarttui vain käteeni ja veti minut portaita ylös eteiseen.

Nyt oli jotain aivan erikoista tapahtunut. Hädissäni heitin jonnekin päällystakkini ja hattuni, laukkuni ja päivänvarjoni. Poika ei ollut lainkaan entisellään.

— Tule!

Tuokiossa olimme ullakkohuoneessa ja ovi kiinni. Vaisto neuvoi puhumaan hänen kanssaan kahden kesken.

Hän hyökkäsi heti kaulaani ja itki rajusti.

— Mitä on tapahtunut, Yrjö? Miksi olet noin suruissasi?

— Äiti! — tuli nyyhkytysten kesken hätäisesti ja puoliääneen — onko totta, ettei tämä ole minun oma kotini?

— Oma kotisi! — Miten tulet sellaista ajatelleeksi?

— Sanottiin Toivolassa, ettei ole.

— Kuka sanoi sellaisen valheen?

— Hanna

— Ja kuka Hanna on?

— Heidän palvelijansa.

— Ja kuinka hän sen sinulle sanoi?

— Sitä en tiedä.

— Hänkö se vain niin sinulle sanoi?

— Hän, mutta serkut olivat siinä myöskin eivätkä sanoneet mitään.

Vedin pojan viereeni sohvaan ja olin aivan masentunut. — Olipa siis sittenkin tullut se, jota olin niin huolellisesti koettanut välttää! — Ja hän nosti minuun katseensa ikäänkuin hänen sielunsa autuus olisi riippunut siitä, mitä tulisin hänelle sanomaan.

Kokosin voimani ja puhuin hitaasti ja vakuuttavasti:

— Se ei ole totta. Ilman vain on Hanna sen keksinyt, koska hän on raaka ja häijy ihminen. Eikö tämä muka ole sinun kotisi? Onko kummempaa kuultu? Kenellä sitten koti on! — Ei, hyvä lapsi, ajattelepa vähän ja sano oikein totta! Etkö aina ole ollut täällä kotonasi? — Rakastammeko ketään tai mitään niinkuin sinua? —

Onko olemassa ketään tai mitään, josta huolehdimme enemmän kuin sinusta? — Sano, kyllä sinä sen tiedät! — Tiedäthän ja uskothan, että joka päivä ja kaikessa ajatellaan sinua? Oletko koskaan muuta huomannut?

Ei. Ei hän ollut muuta huomannut. Hän nojasi minuun, uupuneena mielenliikutuksesta hänkin, mutta jo tyynempänä. Ei hän sitä ollut uskonut itsekään. Hän oli vain tullut niin surulliseksi ja ajatellut että ehkä sentään. Kun kerran niin voitiin sanoa.

— Niinpä niin — tuo Hanna kai niin ajatteli — mitäpä hän ymmärsi, hän oli mitä oli. Sanoiko hän ehkä vielä muutakin?

— Hän sanoi vielä, ettei minulla ollut oikeaa isää ja äitiä — että olin vain kasvatti — ja ettei minulla siksi ollut oikein omaa kotiakaan.

— Oliko hän jostain syystä suuttunut sinuun?

— Ei ensinkään — muuten vain hän niin puhui.

Sisässäni kuohui. Jos tuo ihmishirviö olisi ollut edessäni, olisin halunnut hänet nujertaa ja olisin voinut syytää hänen silmillensä mitä vihansanoja tahansa. On niitä ilkiöitä maailmassa, eikä maa kuitenkaan aukea nielaisemaan heitä.

Ja heidän tähtensä piti minun lapseni kärsiä! Minun poikani, joka kuitenkin oli sellainen, ettei heidän olisi tullut saada kajota häneen pikkusormellaankaan, saatikka sitten tällä lailla haavoittaa häntä hänen sielunsa syvimpään.

Saisi kosto kohdata sekä häntä että kaikkia hänen laisiansa! Koko tuota kylmäkiskoista, pahansuopaa, järkeilevää ihmislajia, jolla voi olla sivistynytkin kuori päällä. Kyllä minä ne tiesin!

En voinut heti vastata. Minun piti ensin rauhoittua. Eikä tässä sitä paitsi viha auttanut. En saanut itse myrkyttyä enkä millään ehdolla myrkyttää häntä. Vahinkoa olivat nuo ilkeämieliset sanat saaneet aivan tarpeeksi jo aikaan. Karistin siis pois kaikki pahat päältäni ja jatkoin:

— Katsos Yrjö! — On kummallista, mutta totta, että on ihmisiä, jotka nauttivat siitä, että he pahoittavat muitten mieltä. He eivät viihdy, elleivät saa lausua pistäviä sanoja — se on heidän virkistyskeinonsa. Tuo Hanna kuuluu niihin. Mutta ei välitetä hänestä. Et tiedä, miten olen hyvilläni yhdestä asiasta!

— Mistä niin?

— Siitä, että kerroin sinulle sen sadun!

Poika hymyili.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.