SlideShare une entreprise Scribd logo
1  sur  13
Alexey Shytikov

http://github.com/shytikov
Was ist das NTLM?

• NTLM is Microsoft-designed security protocol;
• Since it’s Microsoft-designed, it’s weak;
• It’s so weak even MS does not recommend to use it;
• Despite this fact it is widely used in Intranet solutions;
• And for authentication in enterprise-oriented applications, such as
  IIS, MS SQL Server, MS Exchange;
• Specification is not available;
• Reverse-engeneered by Samba team;
NTLM in more details:

• NTLM provides a challenge-response authentication mechanism;
• NTLM is connection oriented rather session oriented protocol;
• NTLM could multiply your network traffic if connection become
  broken;
• NTLM uses one way hash algorithms to hide user-related
  information;
• Doubles information in two hashes: newer NT (weak) and older LM
  (even more weaker);
• Uses little-endian byte arrays for communication;
NT in more details:

•   NT stands for New Technology (originally by Microsoft);
•   There are two versions of NT hashes;
•   NT hashes (version 1) are made by using outdated MD4 algorithm;
•   Collision in MD4 hashes could be found in about an hour;
•   NT hashes (version 2) are made by using HMAC-MD5 algorithm;
•   Hashes are ‘salted’ with random 8-byte challenge from server;
LM in more details:

•   LM stands for LAN Manager (originally by OS/2 & NetBIOS);
•   LM hashes support passwords of 7 symbols long maximum;
•   Longer passwords are breaking in 7 symbol chunks and encoded;
•   7 symbols LM chunks could be brute-forced separately;
•   DES cryptographic algorithm was used.
So why should I use it?

• It’s simple;
• It’s supported in all browsers;
• It’s most time works seamlessly for users (single sign-in);
• It’s available by default in most of Microsoft’s products;
• It does not expose user credentials even without using SSL
  encryption (no need to purchase certificates);
• It’s secure enough for trusted environments, such as company
  intranet;
NTLM HTTP Authentication:
• Client first request:
   GET /index.html HTTP/1.1
• Server first response:
   HTTP/1.1 401 Unauthorized
   WWW-Authenticate: NTLM
   Connection: close
• Client second request (Message Type 1):
   GET /index.html HTTP/1.1
   Authorization: NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1
   JLU1RBVElPTkRPTUFJTg==
• Server second response (Message Type 2):
   HTTP/1.1 401 Unauthorized
   WWW-Authenticate: NTLM TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mrze8
   AAAAAAAAAAGIAYgA8AAAARABPAE0AQQBJAE4AAgAMAEQATwBNAEEASQBOAAEADABTA
   EUAUgBWAEUAUgAEABQAZABvAG0AYQBpAG4ALgBjAG8AbQADACIAcwBlAHIAdgBlAHI
   ALgBkAG8AbQBhAGkAbgAuAGMAbwBtAAAAAAA=
• Client third request (Message Type 3):
   GET /index.html HTTP/1.1
   Authorization: NTLM TlRMTVNTUAADAAAAGAAYAGoAAAAYABgAggAAAAwADABAAA
   AACAAIAEwAAAAWABYAVAAAAAAAAACaAAAAAQIAAEQATwBNAEEASQBOAHUAcwBlAHIA
   VwBPAFIASwBTAFQAQQBUAEkATwBOAMM3zVy9RPyXgqZnr21CfG3mfCDC0+d8ViWpjB
   wx6BhHRmspst9GgPOZWPuMITqcxg==
• Server third response:
   HTTP/1.1 200 OK
But HOW I could do it from .NET?




Nobody knows!!!
Ok, there are some ways:

• Include IIS to your setup
   Pros: don’t worry, be happy!
   Cons: you have limited control, large memory footprint, poor performance;
• Use Mono.Security.Protocol.Ntlm
   Pros: sources available;
   Cons: works only for client side;
• Try to access via System.Net.Security.NegotiateStream class
   Pros: native .NET way to do the job;
   Cons: need to un-wrap underlying stream to get credentials;
• Call to native code of Security Support Provider Interface (SSPI);
   Pros: more straightforward way to do the job;
   Cons: calling unsafe code, comply with C procedure calls;
SSPI — exporting from secur32.dll:
 [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)]
 private static extern int AcquireCredentialsHandle(
     string pszPrincipal,
     string pszPackage,
     int fCredentialUse,
     IntPtr PAuthenticationID,
     IntPtr pAuthData,
     int pGetKeyFn,
     IntPtr pvGetKeyArgument,
     ref Common.SecurityHandle phCredential,
     ref Common.SecurityInteger ptsExpiry);


 [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)]
 private static extern int AcceptSecurityContext(ref Common.SecurityHandle phCredential,
     IntPtr phContext,
     ref Common.SecurityBufferDesciption pInput,
     uint fContextReq,
     uint TargetDataRep,
     out Common.SecurityHandle phNewContext,
     out Common.SecurityBufferDesciption pOutput,
     out uint pfContextAttr,
     out Common.SecurityInteger ptsTimeStamp);


 [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)]
 public static extern int AcceptSecurityContext(ref Common.SecurityHandle phCredential,
     ref Common.SecurityHandle phContext,
     ref Common.SecurityBufferDesciption pInput,
     uint fContextReq,
     uint TargetDataRep,
     out Common.SecurityHandle phNewContext,
     out Common.SecurityBufferDesciption pOutput,
     out uint pfContextAttr,
     out Common.SecurityInteger ptsTimeStamp);
Process is simple (for server):

• When Message Type 1 received — initiate SSPI by calling
  AcquireCredentialsHandle;
• Use acquired credentials for getting 8-byte challenge and
  composing Message Type 2 by calling AcceptSecurityContext;
• Sending Message Type 2 to client;
• Receiving Message Type 3 from client and validating it by calling
  AcceptSecurityContext;
• In case of success allow access;
• In case of failure, show an error;
Process is simple (for client):

• This is was not my task actually, so only in theory;
• After receiving Error 401, compose Message Type 1 using libraries
  available in Mono.Security.Protocol.Ntlm;
• Sending Message Type 1 to server;
• Receiving Message Type 2 from server, extracting 8-byte
  challenge;
• Using 8-byte challenge compose Message Type 3 using libraries
  available in Mono.Security.Protocol.Ntlm;
• Send Message Type 3 and pray…
More on NTLM:


•   http://davenport.sourceforge.net/ntlm.html
•   http://pinvoke.net/default.aspx/secur32/InitializeSecurityContext.html
•   https://github.com/mono/mono/tree/master/mcs/class/Mono.Security/Mon
    o.Security.Protocol.Ntlm
•   https://github.com/toolchain/Nancy.Authentication.Ntlm

Contenu connexe

Tendances

Kerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashKerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashAnkit Mehta
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Jen Andre
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF qualssnyff
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkChris Gates
 
Awesome_fuzzing_for _pentester_red-pill_2017
Awesome_fuzzing_for _pentester_red-pill_2017Awesome_fuzzing_for _pentester_red-pill_2017
Awesome_fuzzing_for _pentester_red-pill_2017Manich Koomsusi
 
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...Shakacon
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassRob Fuller
 
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat Security Conference
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new blackRob Fuller
 
Power on, Powershell
Power on, PowershellPower on, Powershell
Power on, PowershellRoo7break
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5usnyff
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedWill Schroeder
 
I Have the Power(View)
I Have the Power(View)I Have the Power(View)
I Have the Power(View)Will Schroeder
 
Jwt == insecurity?
Jwt == insecurity?Jwt == insecurity?
Jwt == insecurity?snyff
 
Understanding Active Directory Enumeration
Understanding Active Directory EnumerationUnderstanding Active Directory Enumeration
Understanding Active Directory EnumerationDaniel López Jiménez
 
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...CODE BLUE
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationWill Schroeder
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Rob Fuller
 

Tendances (20)

Kerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashKerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-Hash
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF quals
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit Framework
 
Awesome_fuzzing_for _pentester_red-pill_2017
Awesome_fuzzing_for _pentester_red-pill_2017Awesome_fuzzing_for _pentester_red-pill_2017
Awesome_fuzzing_for _pentester_red-pill_2017
 
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
 
A Year in the Empire
A Year in the EmpireA Year in the Empire
A Year in the Empire
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new black
 
I Hunt Sys Admins
I Hunt Sys AdminsI Hunt Sys Admins
I Hunt Sys Admins
 
Power on, Powershell
Power on, PowershellPower on, Powershell
Power on, Powershell
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5u
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting Revisisted
 
I Have the Power(View)
I Have the Power(View)I Have the Power(View)
I Have the Power(View)
 
Jwt == insecurity?
Jwt == insecurity?Jwt == insecurity?
Jwt == insecurity?
 
Understanding Active Directory Enumeration
Understanding Active Directory EnumerationUnderstanding Active Directory Enumeration
Understanding Active Directory Enumeration
 
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege Escalation
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
 

Similaire à Shytikov on NTLM Authentication

BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.Jakub Kałużny
 
Shameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocolsShameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocolsSlawomir Jasek
 
Application Security
Application SecurityApplication Security
Application Securityflorinc
 
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014Jakub Kałużny
 
The Golden Rules - Detecting more with RSA Security Analytics
The Golden Rules  - Detecting more with RSA Security AnalyticsThe Golden Rules  - Detecting more with RSA Security Analytics
The Golden Rules - Detecting more with RSA Security AnalyticsDemetrio Milea
 
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiInSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiYossi Sassi
 
[Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things![Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things!OWASP
 
Operations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your CompanyOperations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your CompanyAmazon Web Services
 
Start Up Austin 2017: Security Crash Course and Best Pratices
Start Up Austin 2017: Security Crash Course and Best PraticesStart Up Austin 2017: Security Crash Course and Best Pratices
Start Up Austin 2017: Security Crash Course and Best PraticesAmazon Web Services
 
Insecurity-In-Security version.1 (2010)
Insecurity-In-Security version.1 (2010)Insecurity-In-Security version.1 (2010)
Insecurity-In-Security version.1 (2010)Abhishek Kumar
 
Slide cipher based encryption
Slide cipher based encryptionSlide cipher based encryption
Slide cipher based encryptionMizi Mohamad
 

Similaire à Shytikov on NTLM Authentication (20)

BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.
 
Coporate Espionage
Coporate EspionageCoporate Espionage
Coporate Espionage
 
Shameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocolsShameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocols
 
Windows network
Windows networkWindows network
Windows network
 
Windows Domains Part 2
Windows Domains Part 2Windows Domains Part 2
Windows Domains Part 2
 
Application Security
Application SecurityApplication Security
Application Security
 
FreeBSD and Hardening Web Server
FreeBSD and Hardening Web ServerFreeBSD and Hardening Web Server
FreeBSD and Hardening Web Server
 
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
 
The Golden Rules - Detecting more with RSA Security Analytics
The Golden Rules  - Detecting more with RSA Security AnalyticsThe Golden Rules  - Detecting more with RSA Security Analytics
The Golden Rules - Detecting more with RSA Security Analytics
 
Operations: Security
Operations: SecurityOperations: Security
Operations: Security
 
Secure Your Encryption with HSM
Secure Your Encryption with HSMSecure Your Encryption with HSM
Secure Your Encryption with HSM
 
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiInSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
 
[Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things![Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things!
 
Operations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your CompanyOperations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your Company
 
Hacking
HackingHacking
Hacking
 
Start Up Austin 2017: Security Crash Course and Best Pratices
Start Up Austin 2017: Security Crash Course and Best PraticesStart Up Austin 2017: Security Crash Course and Best Pratices
Start Up Austin 2017: Security Crash Course and Best Pratices
 
Insecurity-In-Security version.1 (2010)
Insecurity-In-Security version.1 (2010)Insecurity-In-Security version.1 (2010)
Insecurity-In-Security version.1 (2010)
 
Slide cipher based encryption
Slide cipher based encryptionSlide cipher based encryption
Slide cipher based encryption
 
03-SSL (1).ppt
03-SSL (1).ppt03-SSL (1).ppt
03-SSL (1).ppt
 
03-SSL (2).ppt
03-SSL (2).ppt03-SSL (2).ppt
03-SSL (2).ppt
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Shytikov on NTLM Authentication

  • 2. Was ist das NTLM? • NTLM is Microsoft-designed security protocol; • Since it’s Microsoft-designed, it’s weak; • It’s so weak even MS does not recommend to use it; • Despite this fact it is widely used in Intranet solutions; • And for authentication in enterprise-oriented applications, such as IIS, MS SQL Server, MS Exchange; • Specification is not available; • Reverse-engeneered by Samba team;
  • 3. NTLM in more details: • NTLM provides a challenge-response authentication mechanism; • NTLM is connection oriented rather session oriented protocol; • NTLM could multiply your network traffic if connection become broken; • NTLM uses one way hash algorithms to hide user-related information; • Doubles information in two hashes: newer NT (weak) and older LM (even more weaker); • Uses little-endian byte arrays for communication;
  • 4. NT in more details: • NT stands for New Technology (originally by Microsoft); • There are two versions of NT hashes; • NT hashes (version 1) are made by using outdated MD4 algorithm; • Collision in MD4 hashes could be found in about an hour; • NT hashes (version 2) are made by using HMAC-MD5 algorithm; • Hashes are ‘salted’ with random 8-byte challenge from server;
  • 5. LM in more details: • LM stands for LAN Manager (originally by OS/2 & NetBIOS); • LM hashes support passwords of 7 symbols long maximum; • Longer passwords are breaking in 7 symbol chunks and encoded; • 7 symbols LM chunks could be brute-forced separately; • DES cryptographic algorithm was used.
  • 6. So why should I use it? • It’s simple; • It’s supported in all browsers; • It’s most time works seamlessly for users (single sign-in); • It’s available by default in most of Microsoft’s products; • It does not expose user credentials even without using SSL encryption (no need to purchase certificates); • It’s secure enough for trusted environments, such as company intranet;
  • 7. NTLM HTTP Authentication: • Client first request: GET /index.html HTTP/1.1 • Server first response: HTTP/1.1 401 Unauthorized WWW-Authenticate: NTLM Connection: close • Client second request (Message Type 1): GET /index.html HTTP/1.1 Authorization: NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1 JLU1RBVElPTkRPTUFJTg== • Server second response (Message Type 2): HTTP/1.1 401 Unauthorized WWW-Authenticate: NTLM TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mrze8 AAAAAAAAAAGIAYgA8AAAARABPAE0AQQBJAE4AAgAMAEQATwBNAEEASQBOAAEADABTA EUAUgBWAEUAUgAEABQAZABvAG0AYQBpAG4ALgBjAG8AbQADACIAcwBlAHIAdgBlAHI ALgBkAG8AbQBhAGkAbgAuAGMAbwBtAAAAAAA= • Client third request (Message Type 3): GET /index.html HTTP/1.1 Authorization: NTLM TlRMTVNTUAADAAAAGAAYAGoAAAAYABgAggAAAAwADABAAA AACAAIAEwAAAAWABYAVAAAAAAAAACaAAAAAQIAAEQATwBNAEEASQBOAHUAcwBlAHIA VwBPAFIASwBTAFQAQQBUAEkATwBOAMM3zVy9RPyXgqZnr21CfG3mfCDC0+d8ViWpjB wx6BhHRmspst9GgPOZWPuMITqcxg== • Server third response: HTTP/1.1 200 OK
  • 8. But HOW I could do it from .NET? Nobody knows!!!
  • 9. Ok, there are some ways: • Include IIS to your setup Pros: don’t worry, be happy! Cons: you have limited control, large memory footprint, poor performance; • Use Mono.Security.Protocol.Ntlm Pros: sources available; Cons: works only for client side; • Try to access via System.Net.Security.NegotiateStream class Pros: native .NET way to do the job; Cons: need to un-wrap underlying stream to get credentials; • Call to native code of Security Support Provider Interface (SSPI); Pros: more straightforward way to do the job; Cons: calling unsafe code, comply with C procedure calls;
  • 10. SSPI — exporting from secur32.dll: [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern int AcquireCredentialsHandle( string pszPrincipal, string pszPackage, int fCredentialUse, IntPtr PAuthenticationID, IntPtr pAuthData, int pGetKeyFn, IntPtr pvGetKeyArgument, ref Common.SecurityHandle phCredential, ref Common.SecurityInteger ptsExpiry); [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern int AcceptSecurityContext(ref Common.SecurityHandle phCredential, IntPtr phContext, ref Common.SecurityBufferDesciption pInput, uint fContextReq, uint TargetDataRep, out Common.SecurityHandle phNewContext, out Common.SecurityBufferDesciption pOutput, out uint pfContextAttr, out Common.SecurityInteger ptsTimeStamp); [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = false)] public static extern int AcceptSecurityContext(ref Common.SecurityHandle phCredential, ref Common.SecurityHandle phContext, ref Common.SecurityBufferDesciption pInput, uint fContextReq, uint TargetDataRep, out Common.SecurityHandle phNewContext, out Common.SecurityBufferDesciption pOutput, out uint pfContextAttr, out Common.SecurityInteger ptsTimeStamp);
  • 11. Process is simple (for server): • When Message Type 1 received — initiate SSPI by calling AcquireCredentialsHandle; • Use acquired credentials for getting 8-byte challenge and composing Message Type 2 by calling AcceptSecurityContext; • Sending Message Type 2 to client; • Receiving Message Type 3 from client and validating it by calling AcceptSecurityContext; • In case of success allow access; • In case of failure, show an error;
  • 12. Process is simple (for client): • This is was not my task actually, so only in theory; • After receiving Error 401, compose Message Type 1 using libraries available in Mono.Security.Protocol.Ntlm; • Sending Message Type 1 to server; • Receiving Message Type 2 from server, extracting 8-byte challenge; • Using 8-byte challenge compose Message Type 3 using libraries available in Mono.Security.Protocol.Ntlm; • Send Message Type 3 and pray…
  • 13. More on NTLM: • http://davenport.sourceforge.net/ntlm.html • http://pinvoke.net/default.aspx/secur32/InitializeSecurityContext.html • https://github.com/mono/mono/tree/master/mcs/class/Mono.Security/Mon o.Security.Protocol.Ntlm • https://github.com/toolchain/Nancy.Authentication.Ntlm

Notes de l'éditeur

  1. A little bit about my project: I wanted to create slick & quick web application and I need authentication mechanism simple yet secure;I didn’t wanted to use heavy and slow IIS;I didn’t wanted to purchase SSL certificates;I didn’t wanted to keep users data in my database;I was limited to Intranet only;
  2. Challenge-response — that’s why NTLM is also referenced as “negotiation protocol”.Connection oriented — not session oriented, thus authentication process will fail if connection will break during negotiation.This negotiation need to take place for every TCP connection to the server, for each resource on the web page, thus number of challenges and responses will grow.
  3. String is base64 encoded byte array, which holds NTLM Messages
  4. Out of scope: Samba — since we need it’s Linux oriented, replacing Active Directory, thus will not applicable for Windows.