mdm - krypted

115
MDM Charles Edge

Upload: others

Post on 08-Apr-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MDM - krypted

MDMCharles Edge

Page 2: MDM - krypted

Agenda• History

• Types of Profiles

• The MDM Check-In Protocol

• The MDM Protocol

• VPP

• Best Practices

Page 3: MDM - krypted

A Brief History Of Time

Page 4: MDM - krypted

2008

Page 5: MDM - krypted

Israel invades the Gaza Strip

Page 6: MDM - krypted

North Korea Claims Denuclearization

Page 7: MDM - krypted

Robert Mugabe Re-elected in Zimbabwe

Page 8: MDM - krypted

Hillary Clinton threatens to “obliterate” Iran

Page 9: MDM - krypted

iPhone OS 2

Page 10: MDM - krypted

Introduction of EAS support and

Configuration Profiles

Page 11: MDM - krypted

My first big iOS deployment

Page 12: MDM - krypted
Page 13: MDM - krypted

Hotmail

Page 14: MDM - krypted

The 1st Gen Of Management Tools

Page 15: MDM - krypted

iPhone Configuration Utility

Page 16: MDM - krypted
Page 17: MDM - krypted

Apple Configurator

Page 18: MDM - krypted
Page 19: MDM - krypted

Profiles

Page 20: MDM - krypted
Page 21: MDM - krypted
Page 22: MDM - krypted

Can be created programmatically

(e.g. mcxToProfile.py)https://github.com/timsutton/mcxToProfile/blob/master/

mcxToProfile.py

Page 23: MDM - krypted

Can be managed manually

http://krypted.com/mac-security/manage-profiles-from-the-command-line-in-os-x-10-9/

Page 24: MDM - krypted

Management companies built profile installers

Page 25: MDM - krypted

All management was opt-in

Page 26: MDM - krypted

Then came MDM

Page 27: MDM - krypted
Page 28: MDM - krypted

MDM Server

APNs

MDMclient

MDM Server Sends Push Notification

APNs Sends Push Magic

MDMclient checks in with MDM Server

MDM Server responds with action

Page 29: MDM - krypted

And it works, so Google

borrowed it

Image from ManageEngine

Page 30: MDM - krypted

The MDM Spec

Page 31: MDM - krypted

“It’s always the certificates that are a pain”

A Developer, Monday the 26th

Page 32: MDM - krypted

Why Are Certificates A Pain?

Page 33: MDM - krypted

The Certificate Chain

Apple Root Certificate

WWDR Intermediary

MDM Signing Certificate

Push Certificate

Device Based (DEP)

Your CA

Device Based (non-DEP)

Your SCEP (opt)

Page 34: MDM - krypted

The Beginning of the Certificate Chain

• WWDR intermediate certificate: http://developer.apple.com/certificationauthority/AppleWWDRCA.cer

• Apple root certificate: http://www.apple.com/appleca/AppleIncRootCertificate.cer

Page 35: MDM - krypted

Apple Root Certificate

Page 36: MDM - krypted

WWDR Intermediary

Page 37: MDM - krypted

MDM Signing Certificate

Page 38: MDM - krypted

MDM Signing Certificate• Establishes trust between MDM vendor/provider and

Apple to be able to do APNs

• Obtained from the iOS Provisioning portal so was restricted to vendors

• Contains a private key, public keys and trust certificates

• Used to sign a customer’s CSR

• As with all private keys, the private key should stay private

• Expire

Page 39: MDM - krypted
Page 40: MDM - krypted

Certificate Signing Request (CSR)

Page 41: MDM - krypted

CSR• Must be in DER (binary)

• Signed w/ the private key of the MDM Signing Cert

• Signed with SHA1WithRSA

• Signature and CSR are base64 encoded

• Push Certificate Request is generated as a base64 plist

Page 42: MDM - krypted

CSR (cont)• PushCertWebRequest is a file downloaded by

admins

• File is uploaded to https://identity.apple.com/pushcert

• Certificate is downloaded as MDM_<VendorName> _Certificate.pem and uploaded to the MDM solution

• MDM Solution can then do Apple Push Notifications

Page 43: MDM - krypted
Page 44: MDM - krypted

Device Identity Certificate

Page 45: MDM - krypted

Device Identity Certificate

• Used to encrypt profiles sent to devices

• Any time a device checks in, validate that the certificate was signed against the CA as the device includes the certificate at each checkin

• DEP devices bootstrap with a certificate signed by Apple

Page 46: MDM - krypted

APNs Token (aka Device Token)

• String broken up, each is sent in push notifications in binary

• Stored as 32 binary characters

Page 47: MDM - krypted

With All These Certificates, Wat Could

Go Wrong?!?!

Page 48: MDM - krypted

Why Do I Have To Open Port 2195?

Page 49: MDM - krypted

Glue It Together

{aps”:{“mdm”:”PushMagicValue"}}APN Token

gateway.push.apple.com:2195gateway.push.apple.com:443

Page 51: MDM - krypted

If you don’t open the ports?

Page 52: MDM - krypted

Test Ittelnet gateway.push.apple.com 2195

Page 53: MDM - krypted

This is outgoing traffic

Page 54: MDM - krypted

What IP range again?17.0.0.0/8

Page 55: MDM - krypted

Feedback (port 2196) checks if devices still

have tokens

Page 56: MDM - krypted

Devices Talk Back Over 5223

Page 57: MDM - krypted

Can fall back to 443 over wi-fi

Page 58: MDM - krypted

telnet 1-courier.push.apple.com 5223

Page 59: MDM - krypted

A 410 error means the device token is expired

Page 62: MDM - krypted

/System/Library/PrivateFrameworks/ApplePushService.framework/apsctl status

Page 63: MDM - krypted

Why can’t I use my proxy server?

Page 64: MDM - krypted

Certificate Pinninghttps://www.bluecoat.com/ko/documents/download/

7ff09c94-7b88-4319-a766-191c9dedde22

Page 65: MDM - krypted

Is that the same for all vendors?

Page 66: MDM - krypted

Yes

Page 67: MDM - krypted

If I don’t open ports to the MDM Server?

Page 68: MDM - krypted

Webhook on MDM Server<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>RequestType</key> <string>InstallProfile</string> <key>Payload</key> <string>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhRE9DVFlQRSBwbGlzdCBQVUJMSUMgIi0vL0FwcGxlLy9EVEQgUExJU1QgMS4wLy9FTiIgImh0dHA6Ly93d3cuYXBwbGUuY29tL0RURHMvUHJvcGVydHlMaXN0LTEuMC5kdGQiPg0KPHBsaXN0IHZlcnNpb249IjEuMCI+DQo8ZGljdD4NCiAgICAgICAgPGtleT5SZXF1ZXN0VHlwZTwva2V5Pg0KICAgICAgICA8c3RyaW5nPkluc3RhbGxQcm9maWxlPC9zdHJpbmc+DQogICAgICAgIDxrZXk+UGF5bG9hZDwva2V5Pg0KICAgICAgICA8c3RyaW5nPjwvc3RyaW5nPg0KPC9kaWN0PiANCjwvcGxpc3Q+</string> </dict> </plist>

Page 69: MDM - krypted

Do I need SCEP?

Page 70: MDM - krypted

SCEP• Device uses SCEP to obtain a cert and then

communicates that cert back to us during enrollment

• Each client receives a unique cert

• If certs are from SCEP they should be unique

• Can install SCEP payloads with a profile

Page 71: MDM - krypted

Per-vendor

Page 72: MDM - krypted

What if devices fail to enroll?

Page 74: MDM - krypted

What a Check-in Request Looks Like

PUT api.jamfnow.com HTTP/1.1

Host: jamfnow.com

Content-Length: 1234

Content-Type: application/x-apple-aspen-mdm-checkin

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"

"http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>MessageType</key>

<string>Authenticate</string>

<key>Topic</key>

<string>.com.jamf.as83yuptsl-1934</string>

<key>UDID</key>

<string>...</string>

</dict>

</plist>

Page 75: MDM - krypted

Use iOS Console To View Transactions

https://lemonjar.com/iosconsole/

Page 76: MDM - krypted

AuthenticateVerify that a device can enroll

Page 77: MDM - krypted

Authenticate• MessageType: Authenticate

• Topic

• UDID

• OSVersion

• BuildVersion

• ProductName

• SerialNumber

• IMEI

• MEID

Page 78: MDM - krypted

200 = Success 401 = Failure

Page 79: MDM - krypted

What if a device stops responding to MDM

commands?

Page 80: MDM - krypted

TokenUpdateUpdates token used to communicate with server (push

magic and APNs token)

Page 81: MDM - krypted

TokenUpdate• MessageType: TokenUpdate

• Topic (must match push notification cert)

• UDID

• Token

• PushMagic

• UnlockToken

• Awaiting-Configuration (for DEP - send commands during bootstrap)

Page 82: MDM - krypted

CheckOutDevice sends a command that it’s leaving management

Page 83: MDM - krypted

CheckOut

• Best effort…

• MessageType: CheckOut

• Topic

• UDID

Page 84: MDM - krypted

Can I change the URL of my MDM Server?

Page 85: MDM - krypted
Page 86: MDM - krypted
Page 87: MDM - krypted

Commands

Page 88: MDM - krypted

Activation Lock BypassEscrowKeyUnlock

Page 89: MDM - krypted

FileWave

Page 90: MDM - krypted

X-ADM-Auth-Session

Page 91: MDM - krypted

How’d we get that code?

• ActivationLockBypassCode

• Obtained at enrollment

• If Supervised

• Then you can EscrowKeyUnlock

Page 92: MDM - krypted

Settings

Page 93: MDM - krypted
Page 94: MDM - krypted

AirWatch Profiles

Page 95: MDM - krypted

Delete Profiles

Page 96: MDM - krypted
Page 97: MDM - krypted

Does the MDM inventory contain app information?

Page 98: MDM - krypted

VPP

Page 99: MDM - krypted

What’s In The stoken

Page 100: MDM - krypted

Stoken• eyJ0b2tlbuKAnTrigJ1hYWFhUnpwTEV0YWFhYStuc3hDZH

dyY3QwUmp3ZGljTmFhYWFUWXE4VVAyc2hSYTBMUnVGcVpQM0pLQmJUTWxDSE42ZzNtc1J6WVlQbVVkVXJBS2x3PT0iLCJleHBEYXRlIjoiMjAxNi0wNC0yMVQxMjowNzozMi0wNzAwIiwib3JnTmFtZeKAnTrigJ1rcnlwdGVkLjIwMTAxMTE4MDAifQ==

• base64 -i stoken

• {"token”:”aaaaRzpLEtaaaa+nsxCdwrct0RjwdicNaaaaTYq8UP2shRa0LRuFqZP3JKBbTMlCHN6g3msRzYYPmUdUrAKlw==","expDate":"2016-04-21T12:07:32-0700","orgName”:”krypted.2010111800"}

Page 101: MDM - krypted

The VPP Service• Mostly per-device and per-user

• Some places buy 10k copies of free apps

• Syncs all data back

• For privacy, VPP endpoint doesn’t know which user is which (we get a hash)

• If the service isn’t available a GUI might go unresponsive

Page 102: MDM - krypted

Polling VPP Is Weird

Page 103: MDM - krypted

Who wants to talk about DEP?

Page 104: MDM - krypted
Page 105: MDM - krypted

Best Practices

Page 106: MDM - krypted

Make sure to open those ports

Page 107: MDM - krypted

Use Profile Manager For Comparison Testing

Page 108: MDM - krypted

No profile conflicts

Page 109: MDM - krypted

Who’s enrolling?!?!

Page 110: MDM - krypted

Use libimobiledevicehttp://krypted.com/uncategorized/command-line-ios-

device-management/

Page 111: MDM - krypted

Resources• MDM Protocol Reference: https://developer.apple.com/

library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/1-Introduction/Introduction.html#//apple_ref/doc/uid/TP40017387-CH1-SW1

• Security Concepts: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/OTASecurity/OTASecurity.html

• MicroMDM: https://github.com/micromdm

Page 113: MDM - krypted

Client-side configuration options

defaults write /Library/Preferences/com.apple.mdmclient BypassPreLoginCheck -bool YES

Page 114: MDM - krypted

Q&A

Page 115: MDM - krypted

Thank you!