Monitoring Using A Windows Box
Monitoring Using A Windows Box
2
Monitoring using a
Windows box
3
If you remember only one
slide
Task Suggested Windows Approach
Figure out what is going on locally with Run NetMon or Ethereal
your network interface (both freely available on the web)
Experiment with / write a Ethernet Start with Windows Filterering
based protocol Platform (WFP) code samples at
http://MSDN.microsoft.com or
RawEther sample (PCUSA.com)
Do network I/O in a Windows driver Try using Windows Sockets Kernel
(WSK) http://MSDN.microsoft.com
Capture all the traffic on a subnet / Learn about router monitor ports and
Enterprise network consider writing your own WFP /
NetMon SDK / WinPCAP capture
program (start with the existing
sample code)
Write network code for Windows Download the Windows Driver Kit
(WDK) from Microsoft.com
4
NetMon Demo
5
Windows XP Network
Stack Sockets Applications
(managed C#,VB.NET etc)
Sockets Applications (unmanaged)
MyApp.EXE
Overview MyDotNetApp.EXE
System.NET
Windows Sockets
(Winsock2.DLL)
Winsock User
TCP/IP stack Mode
TDI
NDIS – Network Device Kernel
Mode
TCP/IPv6.SYS TCP/IP.SYS
Interface Specification (IP v6) (IP v4)
TDI – Transport Data NDIS
NDIS Intermediate NDIS Intermediate
Interface Mode (IM) Driver Mode (IM) Driver
IPv6 and IPv4 NDIS Miniport
System.Net
NIC
6
Windows Vista Network
Stack Sockets Applications
(managed C#,VB.NET etc)
Sockets Applications (unmanaged)
MyApp.EXE
MyDotNetApp.EXE
Overview System.NET
Windows Sockets
(Winsock2.DLL)
Winsock Service
Provider
HTTP.SYS
Kernel
TDI Driver WSK Driver Mode
TCP/IP
(IP v6 and IP v4)
Winsock Service
Provider
HTTP.SYS
Kernel
TDI Driver WSK Driver Mode
TCP/IP
(IP v6 and IP v4)
WFP APIs
ALE kernel
Callout APIs
TDI/WSK
Callout modules
Stream Layer 3rd party anti-virus
Transport Layer
Filtering Engine 3rd party parental
IPsec control
Network Layer
3rd party IDS
Forward Layer
12
WFP Layers
Layers Data Representations
Protocol specific RPC, IKE
14
Extending WFP with Callouts
A callout extends the capabilities of WFP
Callouts can be registered at all layers
Each callout has a unique GUID
Callouts are used for
Deep Inspection
Packet Modification
Stream Modification
Data Logging
Boot time security
FwpmEngineOpen0(…);
blockFilter.layerKey = FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4;
blockFilter.action.type = FWP_ACTION_BLOCK;
blockFilter.filterCondition = &tcpCondition;
tcpCondition.fieldKey = FWPM_CONDITION_IP_PROTOCOL;
tcpCondition.matchType = FWP_MATCH_EQUAL;
tcpCondition.conditionValue.uint8 = 0x06; /// TCP
/// calloutKey holds the GUID that uniquely identifies the callout
typedef struct FWPS_CALLOUT0_ {
GUID calloutKey; UINT32 flags;
FWPS_CALLOUT_CLASSIFY_FN0 classifyFn;
FWPS_CALLOUT_NOTIFY_FN0 notifyFn;
FWPS_CALLOUT_FLOW_DELETE_NOTIFY_FN0 flowDeleteFn;
} FWPS_CALLOUT0;
19
Windows Monitoring Tools
NetMon2 – custom filters…
Ethereal (/ Tethereal) WinPCap – source available, buffering / perf issues
www.SysInternals.com tools: TDI Mon, TCPView
Custom Tools- rolling your own
User Mode (trade-off: simple programming environment for performance)
Raw Sockets: TCP limitations (an aside)
NDIS UIO - In Windows Dev Kit (WDK) pull up NDIS packets to User Mode used by Wireless
Zero Config user mode service – source available in WDK
RawEther – (PCUSA.com) Send/Receive NDIS packets from User Mode – source available
Kernel Drivers
Network Device Interface Specification (NDIS) common interface to NIC drivers
Intermediate Mode (IM) e.g. Firewalls - Passthru driver sample
MiniPort e.g. NIC drivers, SCSI miniport (lowest level wrapper for a class of drivers)
Vista: Better to use WinSock Kernel (WSK) / Windows Filter Platform (WFP)
20
Event Tracing for Windows
(ETW)
Many, many system
components wrapped
TCP/IP connection
establishment etc.
OS Context Switches
Disk IO events
IIS (web server) events
... And many more
Event Tracer Timestamp Information
Use PerfMon if you just •ETW time of the event
want to understand local •process ID under which the event occurs
performance •thread ID under which the event occurs
e.g. How long is the disk write •user-mode CPU time
queue •kernel-mode CPU time
21
Additional Windows Monitoring
Infrastucture
NETIO debug
New Vista TCP/IP stack internal debugging
Link Status Events OIDs (Object IDentiers)
WFP subsumes much of this
Native WiFi
IEEE 802.11 upper MAC functionality, lower MAC
and PHY management + Windows STA / AP
service
22
Handling a deluge of
network data
23
Managing a large network
Capture
(6TB of data in 14 days, 300 Hosts, 3 Capture
PCs, 3 Cisco SPAN ports, 50+ backup tapes)
Hardware requirements
Software Requirements
Meta Data
Privacy Issues
Security
Manpower Issues
Post Processing
24
Hardware requirements
CPU / Chassis
RAM – don’t want it swapping!
CPU – capturing should not be too CPU intensive
KVMs – multiple capturing PCs, single console...
Network Interface
Speed – 1000Mbps NIC even if network is 100Mbps
Offload support – CPU cost
Load balancing / redundancy – helps deal with bursts, failures
Interrupt Moderation... But issues with timestamps in packets
Storage
Reliability – RAID 5
Capacity
Performance – multi disk arrays, eSATA, Firewire –Perf not at cost of Reliability
Backup – offsite / disaster proof / reliable
Router/Network infrastructure
SPAN / Monitor ports
Fibre taps
Router performance impact
25
Software Requirements
Reliability
Soak test
Dry runs
Test sample output
Performance
Test under load – bursts, sustained loads
Turn-off Anti-Virus, search indexing service etc.
Time Sync – NTP etc
Important for merging data sets
26
Meta Data
DNS / WINS
Zone transfer records
DHCP data
Router config / Network config
Maintenance scheduling
Back-up this meta-data
It is as, if not more important than the captured
data
27
Privacy Issues
28
Security Issues
29
Manpower Issues
30
Post Processing
Make copies before post processing / discarding data
Process...
1. Raw -> backup
2. Validity check
3. Correct broken files
4. De-duplicate data
5. Process for packet data + generate NetFlow-like records
31
Questions?
© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not
be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Code Example 1
Copyright (c) Microsoft Corporation. All rights reserved.
…
#include <fwpmu.h>
status = FwpmEngineOpen0(0,
RPC_C_AUTHN_DEFAULT,
0,
&session,
&engineHandle);
UuidCreate(&sublayer.subLayerKey);
sublayer.displayData.name = L"Snipit Sublayer";
sublayer.displayData.description = L"Sublayer added by
Snipit.exe";
sublayer.weight = 1;
UuidCreate(&blockFilter.filterKey);
blockFilter.displayData.name = L"Snipit TCP block filter";
blockFilter.displayData.description = L"Filter added by
Snipit.exe";
blockFilter.layerKey = FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4;
blockFilter.action.type = FWP_ACTION_BLOCK;
blockFilter.subLayerKey = sublayer.subLayerKey;
blockFilter.numFilterConditions = 1;
blockFilter.filterCondition = &tcpCondition;
tcpCondition.fieldKey = FWPM_CONDITION_IP_PROTOCOL;
tcpCondition.matchType = FWP_MATCH_EQUAL;
tcpCondition.conditionValue.type = FWP_UINT8;
tcpCondition.conditionValue.uint8 = 0x06; /// TCP
/// calloutKey holds the GUID that uniquely identifies the callout
typedef struct FWPS_CALLOUT0_ {
GUID calloutKey; UINT32 flags;
FWPS_CALLOUT_CLASSIFY_FN0 classifyFn;
FWPS_CALLOUT_NOTIFY_FN0 notifyFn;
FWPS_CALLOUT_FLOW_DELETE_NOTIFY_FN0 flowDeleteFn;
} FWPS_CALLOUT0;
System.NET
Windows Sockets
(Winsock2.DLL)
Winsock
TCP/IP stack Windows Socket Switch User
NDIS – Network Device Interface Mode
Specification Kernel
IPv6 and IPv4 TCP/IP.SYS Mode
(IP v6 and IP v4)
WFP – Windows Filtering Platform
WSK – WinSock Kernel NDIS
NDIS Intermediate
System.Net Mode (IM) Driver
Http.sys + WinHttp / WinINet
NDIS Miniport
QoS
IPSec
NIC
37