SlideShare uma empresa Scribd logo
1 de 35
Windows File Pseudonyms Strange Filenames and Haiku OR: Pwnage and Poetry Dan Crowley Core Security Technologies dcrowley@coresecurity.com
A quick disclaimer 		Most of the techniques presented here are demonstrated on web-based technologies. 		HOWEVER, the techniques and principles explained should apply to any application which takes a file path or name of any sort from user input which will be used on a Windows system. (Furthermore, I will provide a bottle of delicious beer to anyone who finds a use for these techniques which isn’t in this presentation!) Each slide of this talk ~ Shall hence be accompanied ~ By clever haiku
The Big Problem ™ Applications tend to do string-based analysis of file paths Often, to decide how to handle files Or whether or not files should be served Or whether the file path may be malicious in nature We can reference one file or directory with many different equivalent strings Applications may not expect some of these strings The OS interacts with the filesystem, not the app Developers may not even be aware that their application will accept such names! Some of these names are based on undocumented features One cannot expect ~ To judge books by their covers ~ And find success
8.3 Aliases 8 dot 3 format It’s self explanatory …only to a point
8.3 Aliases In DOS, file names must conform to the 8.3 format, meaning: A basename of (max) 8 characters Followed by one period Followed by a (max) three character extension Windows likes backwards compatibility Each file (and directory!) created on default Windows installations has a DOS-compatible name If the name isn’t 8.3 compatible, a second name (an 8.3 alias or short file name [SFN]) is made Simplified, they are generated as follows: Remove some characters (0x80-0xff) and convert some characters to underscores (like + and space) Start with the first six characters Add a tilde And a digit to distinguish from other files starting with the same characters Add a period And up to the first three characters of the file extension Windows might as well ~ Be backwards-compatible ~ With the abacus
Why do I (audience) care? Because “highlight.php” != “HIGHLI~1.PHP” If your IDS is looking for the old PHPBB highlight command exec flaw, it may not find it Because “.htpasswd” != “HTPASS~1” Your forbidden files may no longer be forbidden File type may be determined by user input Whatever follows the last dot is the file extension So perhaps you can upload file.phPWNED And request FILE~1.PHP Use removed characters to force an extension <3 chars And you will know me ~ By the trail of characters ~ After the last dot
Web App Authentication Bypass Consider the following scenario: Admin.php checks for authentication If authenticated, several external scripts can be called through Admin.php at the whim of the user DeleteUser.php, AddUser.php, UpdateWebPage.php These external scripts cannot be called directly if($_SERVER[‘PHP_SELF’] == ‘/admin/DeleteUser.php’){	die(‘O RLY?’);}else{ do_something_privileged(); } YA RLY ‘/admin/DeleteUser.php’ != ‘/admin/DELETE~1.PHP’ I’m taking a break ~ From sensible haiku now ~ Tonsillectomy
But wait, there’s more! Long file names Maximum length: 255 Approx. char set size: 63000 Approx. possible names:63000^255 = 6.78E+1223 Short file names (8.3 aliases) Maximum length: 12 (-1 for dot) Approx. char set size: 59 Approx. possible names:59^11 = 3.01E+18 	If every file on a Windows box has an 8.3 compatible name (and by default, this is the case) we can immensely reduce the time and resources needed to guess filenames when trying to enumerate file names by brute-force. This can be further reduced if the file extension is known, reducing the complexity to 59^8 = 1.46E+14, or  approx. 146,000,000,000,000 possibilities! Huge complexities ~ Collapsing conveniently ~ To simplicity
Discarded trailing characters “Let’s get rid of stuff At the end of filenames!” Must have once been said.
Discarded trailing characters Certain characters at the end of file names/paths are silently discarded by Windows! In Windows API calls, the following items are discarded: Periods Spaces The Windows shell will also allow, in specific configurations: Double quotes (as long as they are closed properly) Angle brackets (only in certain configurations) Extraneous current directory markers (“/.”) Extraneous parent directory markers with arbitrary items (fake or real) Trailing characters ~ Of certain varieties: ~ Removed, silently.
Equivalent file path examples All of the following paths are valid and equivalent when given to the Windows shell: file.txt file.txt..... file.txt<spaces> file.txt”””” file.txt<<<>><>< file.txt/././././. nonexistant/../file.txt Different technique, similar use “highlight.php” != “highlight.php.” “restricted.txt” != “restricted.txt<space>” Flexibility ~ In Windows nomenclature ~ Borders on silly
DOS special device files Ancient dinosaurs Used to redirect data With some devices
DOS special device files Similar to device files on *nix Allows file operations to be performed on devices Examples include: CON, the console PRN, a parallel printer COM1, the first serial port NUL, a bit bucket (/dev/null equivalent) Pretty well known already, BUT… When you speak to me ~ I redirect all of it ~ To slash-dev-slash-null.
DOS special files quirk #1 They exist “everywhere” Can be accessed from any path, even: In directories which you are denied access to With an existing file as a “directory” which “contains” the file Examples of equivalent paths to CON: CON C:CON C:ON C:.....ON C:estricted_dirON C:xisting_file.txtON Like apparitions ~ They exist in every place ~ And yet in no place
DOS special files quirk #2 They can have any file extension, it’s ignored The following examples are equivalent: CON CON.bat CON.php CON.conf CON.thisisalongandarbitraryfileextension CON.<1000x”A”> Mr. Shakespeare knows ~ A rose by another name ~ Still smells just as sweet
Denial-of-Service A theoretical application accepts file names and reads the associated files This application blocks any file named “CON”, “AUX”, “PRN” etc. to prevent DoS Applications will generally pause to read from a file until EOF EOF may never arrive from devices like AUX It does NOT block files named, for instance, “AUX.txt” Which we know is equivalent to AUX …And while we’re at it, ~ Since we’re speaking of Shakespeare… ~ All’s well that ends well!
Buffer overflow A Windows application takes in a file name The file is verified as existing If it exists, the program does something with the file name And might trust that it doesn’t exceed NTFS limitations What if the file name is “CON.<‘A’x1000>”? Technically, it exists… …but not in the filesystem, so it’s not bound to NTFS limitations Why one needs all this ~ DOS file extension stuff ~ Is just beyond me
You should know better! Microsoft Windows ~ Hoist upon its own petard ~ You should know better!
Defeating Windows file permissions Normal users have access to CON But not C:enied_direnied_file.txt C:enied_diron_existent_file.txtON No access C:enied_direnied_file.txtON Access to console Now you can check the existence of files which you cannot read in directories you cannot read! It is easiest ~ To acquire forgiveness ~ And not permission
TOOL:SFNBRUTE.PY Enumeration Filenames found through brute force Despite permissions
Controlling file handling Don’t forget: You can use ANY extension! Files are often handled based on extension DOS special files, then, can often be handled as ANYTHING YOU CHOOSE! http://www.example.com/com1.php What if COM1 was attached to a serial modem? …Or more likely, a Bluetooth dongle? A riddle for you… ~ When is a CON not a CON? ~ When it’s a dot-jar!
Namespace prefixes What an awful mess! I can’t write haiku about Namespace prefixes...
Namespace prefixes Used when files can’t be referred to with normal paths Because they’re really devices Because they don’t exist on the local filesystem Because they have strange names A distant echo ~ Of a victim, falling dead ~ The hunter shouts “PWNED!”
Minimal parsing prefix An invalid name or path can sometimes be used anyway MAX_PATH can be exceeded Some restricted characters can be used Reserved basenames can be used Just precede it with ?br />Must be an absolute path No current directory indicator ( ./ ) No parent directory indicator ( ../ ) You don’t like the rules? ~ Double wack, question mark, wack. ~ You’re welcome, buddy.
UNC (Short and Long) Used to refer to files on SMB shares Can be used to refer to files across the Internet server_name_or_iphareile This is “Short UNC” Nothing terribly special ?NCerver_name_or_iphareile This is “Long UNC” Allows for the use of the ?prefix with UNC paths What’s the best thing ~ About SMB traffic? ~ Credential replay!
NT device namespace prefix Used to refer to device namespace These paths start with .br />Examples include: .irpcap00br />An AirPcap card .LOBALROOTevicearddiskVolume1br />The first hard disk volume on the machine Might be equivalent to, for instance, C:br />Doesn’t need an assigned drive letter! .dRom0br />The first disc drive on the computer WinObj from Sysinternals will allow you to browse the NT device namespace The device namespace ~ Allows access to devices ~ Using file paths
NTLM credential capture When accessing SMB shares, authentication may be requested If an attacker runs the SMB server, you can bet it will The SMB client machine will often send stored credentials automatically And as you may know these credentials can be replayed or cracked And we can trigger a machine to access an SMB share with a UNC path! A replay attack ~ With SMB credentials ~ Should not still succeed!
Directory traversal “C: doesn’t match: ?:br />127.0.0.1$br />127.3.13.37$br />?NC27.0.0.1$br />.LOBALROOTevicearddiskVolume1br />…but they’re all equivalent! I ought to mention ~ Directory traversal ~ Ed Skoudis said so!
Buffer overflow Minimal parsing prefix allows for the use of paths exceeding MAX_PATH Some developers don’t know you can exceed MAX_PATH …or assume that if the file exists that it can’t exceed MAX_PATH NOP NOPNOPNOPNOP ~ NOP NOPNOPNOPNOPShellcode ~ Pointer to NOP sled
Making Windows rootkits deadlier Imagine that you’re a Windows sysadmin Someone creates a file named “CON” with the minimal parsing prefix You try “type CON” at the command line Your command prompt “hangs” None of your programs open it properly Windows Explorer can’t delete it You cry You pretend it doesn’t exist or convince yourself it really should be there My reaction to ~ “Undocumented feature” ~ Is unbridled rage.
Defeat AV systems Make files with illegal names (“con.exe”, “lol.exe.”, etc.) Put something malicious in them Execute them ??? PROFIT!!! An AV system ~ Should reliably open ~ All suspect files
Client-side Attacks Switching security zones Reference “C:ile.txt” NO THAT’S A LOCAL FILE BAD HACKER Reference 127.0.0.1$ile.txt A UNC path! I know these, they’re Intranet stuff. No prob, Bob. Check out “Internet Explorer turns your personal computer into a public file server”  Jorge Luis Alvarez Medina, BH DC 2010 How do I pwn thee? ~ Let me count the ways; No, wait: ~ Just one is enough!
DEMONSTRATION:nginx and php on windows Now I understand, But I still don’t believe you. SHOW ME THE MONEY!
Questions? There’s no dumb question… “Is the computer plugged in?” Is pretty bad, though. Dan Crowley Core Security Technologies dcrowley@coresecurity.com

Mais conteúdo relacionado

Mais procurados

Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5
Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5
Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5akbarfak
 
Hyper-V: Best Practices
Hyper-V: Best PracticesHyper-V: Best Practices
Hyper-V: Best PracticesTomica Kaniski
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpAhmed El-Arabawy
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk managementTanveer Malik
 
Mac osx basics
Mac osx basicsMac osx basics
Mac osx basicsRicha Jain
 
Windows series operating system
Windows series operating systemWindows series operating system
Windows series operating systemUmmara Khan
 
Linux Server vs Windows Server
Linux Server vs Windows ServerLinux Server vs Windows Server
Linux Server vs Windows ServerKongChunLeong1
 
Comfiguração completa do setup
Comfiguração completa do setupComfiguração completa do setup
Comfiguração completa do setupHebert3
 
Linux Administration
Linux AdministrationLinux Administration
Linux AdministrationHarish1983
 

Mais procurados (20)

File system
File systemFile system
File system
 
Comandos CMD
Comandos CMDComandos CMD
Comandos CMD
 
Xss ppt
Xss pptXss ppt
Xss ppt
 
Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5
Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5
Memblokir situs dengan squid proxy di linux debian server By: Fakhri akbar CC5
 
Hyper-V: Best Practices
Hyper-V: Best PracticesHyper-V: Best Practices
Hyper-V: Best Practices
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
MAC OS X - Caio
MAC OS X - CaioMAC OS X - Caio
MAC OS X - Caio
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk management
 
Case Study 1: Linux
Case Study 1: LinuxCase Study 1: Linux
Case Study 1: Linux
 
PowerShell-1
PowerShell-1PowerShell-1
PowerShell-1
 
Mac osx basics
Mac osx basicsMac osx basics
Mac osx basics
 
Win scp
Win scpWin scp
Win scp
 
Windows series operating system
Windows series operating systemWindows series operating system
Windows series operating system
 
Linux Server vs Windows Server
Linux Server vs Windows ServerLinux Server vs Windows Server
Linux Server vs Windows Server
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Comfiguração completa do setup
Comfiguração completa do setupComfiguração completa do setup
Comfiguração completa do setup
 
HDD Partition
HDD PartitionHDD Partition
HDD Partition
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Disk forensics
Disk forensicsDisk forensics
Disk forensics
 

Semelhante a Windows File Pseudonyms

Unix Basics
Unix BasicsUnix Basics
Unix BasicsDr.Ravi
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Vu Hung Nguyen
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338Cam YP Co., Ltd
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338Cam YP Co., Ltd
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08Tushar Jain
 
7.Canon & Dt
7.Canon & Dt7.Canon & Dt
7.Canon & Dtphanleson
 
Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Tushar B Kute
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentialsHaitham Raik
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsBITS
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line ToolsDavid Harris
 
LINUX
LINUXLINUX
LINUXARJUN
 

Semelhante a Windows File Pseudonyms (20)

Unix Basics
Unix BasicsUnix Basics
Unix Basics
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Shell intro
Shell introShell intro
Shell intro
 
7.Canon & Dt
7.Canon & Dt7.Canon & Dt
7.Canon & Dt
 
Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
 
lec1.docx
lec1.docxlec1.docx
lec1.docx
 
Shell intro
Shell introShell intro
Shell intro
 
Shell intro
Shell introShell intro
Shell intro
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line Tools
 
Command
CommandCommand
Command
 
LINUX
LINUXLINUX
LINUX
 

Mais de BaronZor

The Patsy Proxy
The Patsy ProxyThe Patsy Proxy
The Patsy ProxyBaronZor
 
No-Knowledge Crypto Attacks
No-Knowledge Crypto AttacksNo-Knowledge Crypto Attacks
No-Knowledge Crypto AttacksBaronZor
 
Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013BaronZor
 
Why UPnP is awesome and terrifying
Why UPnP is awesome and terrifyingWhy UPnP is awesome and terrifying
Why UPnP is awesome and terrifyingBaronZor
 
Advanced SQL Injection with SQLol
Advanced SQL Injection with SQLolAdvanced SQL Injection with SQLol
Advanced SQL Injection with SQLolBaronZor
 
Jack of all Formats
Jack of all FormatsJack of all Formats
Jack of all FormatsBaronZor
 
Daniel Crowley - Speaking with Cryptographic Oracles
Daniel Crowley - Speaking with Cryptographic OraclesDaniel Crowley - Speaking with Cryptographic Oracles
Daniel Crowley - Speaking with Cryptographic OraclesBaronZor
 

Mais de BaronZor (7)

The Patsy Proxy
The Patsy ProxyThe Patsy Proxy
The Patsy Proxy
 
No-Knowledge Crypto Attacks
No-Knowledge Crypto AttacksNo-Knowledge Crypto Attacks
No-Knowledge Crypto Attacks
 
Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013
 
Why UPnP is awesome and terrifying
Why UPnP is awesome and terrifyingWhy UPnP is awesome and terrifying
Why UPnP is awesome and terrifying
 
Advanced SQL Injection with SQLol
Advanced SQL Injection with SQLolAdvanced SQL Injection with SQLol
Advanced SQL Injection with SQLol
 
Jack of all Formats
Jack of all FormatsJack of all Formats
Jack of all Formats
 
Daniel Crowley - Speaking with Cryptographic Oracles
Daniel Crowley - Speaking with Cryptographic OraclesDaniel Crowley - Speaking with Cryptographic Oracles
Daniel Crowley - Speaking with Cryptographic Oracles
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.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
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Windows File Pseudonyms

  • 1. Windows File Pseudonyms Strange Filenames and Haiku OR: Pwnage and Poetry Dan Crowley Core Security Technologies dcrowley@coresecurity.com
  • 2. A quick disclaimer Most of the techniques presented here are demonstrated on web-based technologies. HOWEVER, the techniques and principles explained should apply to any application which takes a file path or name of any sort from user input which will be used on a Windows system. (Furthermore, I will provide a bottle of delicious beer to anyone who finds a use for these techniques which isn’t in this presentation!) Each slide of this talk ~ Shall hence be accompanied ~ By clever haiku
  • 3. The Big Problem ™ Applications tend to do string-based analysis of file paths Often, to decide how to handle files Or whether or not files should be served Or whether the file path may be malicious in nature We can reference one file or directory with many different equivalent strings Applications may not expect some of these strings The OS interacts with the filesystem, not the app Developers may not even be aware that their application will accept such names! Some of these names are based on undocumented features One cannot expect ~ To judge books by their covers ~ And find success
  • 4. 8.3 Aliases 8 dot 3 format It’s self explanatory …only to a point
  • 5. 8.3 Aliases In DOS, file names must conform to the 8.3 format, meaning: A basename of (max) 8 characters Followed by one period Followed by a (max) three character extension Windows likes backwards compatibility Each file (and directory!) created on default Windows installations has a DOS-compatible name If the name isn’t 8.3 compatible, a second name (an 8.3 alias or short file name [SFN]) is made Simplified, they are generated as follows: Remove some characters (0x80-0xff) and convert some characters to underscores (like + and space) Start with the first six characters Add a tilde And a digit to distinguish from other files starting with the same characters Add a period And up to the first three characters of the file extension Windows might as well ~ Be backwards-compatible ~ With the abacus
  • 6. Why do I (audience) care? Because “highlight.php” != “HIGHLI~1.PHP” If your IDS is looking for the old PHPBB highlight command exec flaw, it may not find it Because “.htpasswd” != “HTPASS~1” Your forbidden files may no longer be forbidden File type may be determined by user input Whatever follows the last dot is the file extension So perhaps you can upload file.phPWNED And request FILE~1.PHP Use removed characters to force an extension <3 chars And you will know me ~ By the trail of characters ~ After the last dot
  • 7. Web App Authentication Bypass Consider the following scenario: Admin.php checks for authentication If authenticated, several external scripts can be called through Admin.php at the whim of the user DeleteUser.php, AddUser.php, UpdateWebPage.php These external scripts cannot be called directly if($_SERVER[‘PHP_SELF’] == ‘/admin/DeleteUser.php’){ die(‘O RLY?’);}else{ do_something_privileged(); } YA RLY ‘/admin/DeleteUser.php’ != ‘/admin/DELETE~1.PHP’ I’m taking a break ~ From sensible haiku now ~ Tonsillectomy
  • 8. But wait, there’s more! Long file names Maximum length: 255 Approx. char set size: 63000 Approx. possible names:63000^255 = 6.78E+1223 Short file names (8.3 aliases) Maximum length: 12 (-1 for dot) Approx. char set size: 59 Approx. possible names:59^11 = 3.01E+18 If every file on a Windows box has an 8.3 compatible name (and by default, this is the case) we can immensely reduce the time and resources needed to guess filenames when trying to enumerate file names by brute-force. This can be further reduced if the file extension is known, reducing the complexity to 59^8 = 1.46E+14, or approx. 146,000,000,000,000 possibilities! Huge complexities ~ Collapsing conveniently ~ To simplicity
  • 9. Discarded trailing characters “Let’s get rid of stuff At the end of filenames!” Must have once been said.
  • 10. Discarded trailing characters Certain characters at the end of file names/paths are silently discarded by Windows! In Windows API calls, the following items are discarded: Periods Spaces The Windows shell will also allow, in specific configurations: Double quotes (as long as they are closed properly) Angle brackets (only in certain configurations) Extraneous current directory markers (“/.”) Extraneous parent directory markers with arbitrary items (fake or real) Trailing characters ~ Of certain varieties: ~ Removed, silently.
  • 11. Equivalent file path examples All of the following paths are valid and equivalent when given to the Windows shell: file.txt file.txt..... file.txt<spaces> file.txt”””” file.txt<<<>><>< file.txt/././././. nonexistant/../file.txt Different technique, similar use “highlight.php” != “highlight.php.” “restricted.txt” != “restricted.txt<space>” Flexibility ~ In Windows nomenclature ~ Borders on silly
  • 12. DOS special device files Ancient dinosaurs Used to redirect data With some devices
  • 13. DOS special device files Similar to device files on *nix Allows file operations to be performed on devices Examples include: CON, the console PRN, a parallel printer COM1, the first serial port NUL, a bit bucket (/dev/null equivalent) Pretty well known already, BUT… When you speak to me ~ I redirect all of it ~ To slash-dev-slash-null.
  • 14. DOS special files quirk #1 They exist “everywhere” Can be accessed from any path, even: In directories which you are denied access to With an existing file as a “directory” which “contains” the file Examples of equivalent paths to CON: CON C:CON C:ON C:.....ON C:estricted_dirON C:xisting_file.txtON Like apparitions ~ They exist in every place ~ And yet in no place
  • 15. DOS special files quirk #2 They can have any file extension, it’s ignored The following examples are equivalent: CON CON.bat CON.php CON.conf CON.thisisalongandarbitraryfileextension CON.<1000x”A”> Mr. Shakespeare knows ~ A rose by another name ~ Still smells just as sweet
  • 16. Denial-of-Service A theoretical application accepts file names and reads the associated files This application blocks any file named “CON”, “AUX”, “PRN” etc. to prevent DoS Applications will generally pause to read from a file until EOF EOF may never arrive from devices like AUX It does NOT block files named, for instance, “AUX.txt” Which we know is equivalent to AUX …And while we’re at it, ~ Since we’re speaking of Shakespeare… ~ All’s well that ends well!
  • 17. Buffer overflow A Windows application takes in a file name The file is verified as existing If it exists, the program does something with the file name And might trust that it doesn’t exceed NTFS limitations What if the file name is “CON.<‘A’x1000>”? Technically, it exists… …but not in the filesystem, so it’s not bound to NTFS limitations Why one needs all this ~ DOS file extension stuff ~ Is just beyond me
  • 18. You should know better! Microsoft Windows ~ Hoist upon its own petard ~ You should know better!
  • 19. Defeating Windows file permissions Normal users have access to CON But not C:enied_direnied_file.txt C:enied_diron_existent_file.txtON No access C:enied_direnied_file.txtON Access to console Now you can check the existence of files which you cannot read in directories you cannot read! It is easiest ~ To acquire forgiveness ~ And not permission
  • 20. TOOL:SFNBRUTE.PY Enumeration Filenames found through brute force Despite permissions
  • 21. Controlling file handling Don’t forget: You can use ANY extension! Files are often handled based on extension DOS special files, then, can often be handled as ANYTHING YOU CHOOSE! http://www.example.com/com1.php What if COM1 was attached to a serial modem? …Or more likely, a Bluetooth dongle? A riddle for you… ~ When is a CON not a CON? ~ When it’s a dot-jar!
  • 22. Namespace prefixes What an awful mess! I can’t write haiku about Namespace prefixes...
  • 23. Namespace prefixes Used when files can’t be referred to with normal paths Because they’re really devices Because they don’t exist on the local filesystem Because they have strange names A distant echo ~ Of a victim, falling dead ~ The hunter shouts “PWNED!”
  • 24. Minimal parsing prefix An invalid name or path can sometimes be used anyway MAX_PATH can be exceeded Some restricted characters can be used Reserved basenames can be used Just precede it with ?br />Must be an absolute path No current directory indicator ( ./ ) No parent directory indicator ( ../ ) You don’t like the rules? ~ Double wack, question mark, wack. ~ You’re welcome, buddy.
  • 25. UNC (Short and Long) Used to refer to files on SMB shares Can be used to refer to files across the Internet server_name_or_iphareile This is “Short UNC” Nothing terribly special ?NCerver_name_or_iphareile This is “Long UNC” Allows for the use of the ?prefix with UNC paths What’s the best thing ~ About SMB traffic? ~ Credential replay!
  • 26. NT device namespace prefix Used to refer to device namespace These paths start with .br />Examples include: .irpcap00br />An AirPcap card .LOBALROOTevicearddiskVolume1br />The first hard disk volume on the machine Might be equivalent to, for instance, C:br />Doesn’t need an assigned drive letter! .dRom0br />The first disc drive on the computer WinObj from Sysinternals will allow you to browse the NT device namespace The device namespace ~ Allows access to devices ~ Using file paths
  • 27. NTLM credential capture When accessing SMB shares, authentication may be requested If an attacker runs the SMB server, you can bet it will The SMB client machine will often send stored credentials automatically And as you may know these credentials can be replayed or cracked And we can trigger a machine to access an SMB share with a UNC path! A replay attack ~ With SMB credentials ~ Should not still succeed!
  • 28. Directory traversal “C: doesn’t match: ?:br />127.0.0.1$br />127.3.13.37$br />?NC27.0.0.1$br />.LOBALROOTevicearddiskVolume1br />…but they’re all equivalent! I ought to mention ~ Directory traversal ~ Ed Skoudis said so!
  • 29. Buffer overflow Minimal parsing prefix allows for the use of paths exceeding MAX_PATH Some developers don’t know you can exceed MAX_PATH …or assume that if the file exists that it can’t exceed MAX_PATH NOP NOPNOPNOPNOP ~ NOP NOPNOPNOPNOPShellcode ~ Pointer to NOP sled
  • 30. Making Windows rootkits deadlier Imagine that you’re a Windows sysadmin Someone creates a file named “CON” with the minimal parsing prefix You try “type CON” at the command line Your command prompt “hangs” None of your programs open it properly Windows Explorer can’t delete it You cry You pretend it doesn’t exist or convince yourself it really should be there My reaction to ~ “Undocumented feature” ~ Is unbridled rage.
  • 31. Defeat AV systems Make files with illegal names (“con.exe”, “lol.exe.”, etc.) Put something malicious in them Execute them ??? PROFIT!!! An AV system ~ Should reliably open ~ All suspect files
  • 32. Client-side Attacks Switching security zones Reference “C:ile.txt” NO THAT’S A LOCAL FILE BAD HACKER Reference 127.0.0.1$ile.txt A UNC path! I know these, they’re Intranet stuff. No prob, Bob. Check out “Internet Explorer turns your personal computer into a public file server” Jorge Luis Alvarez Medina, BH DC 2010 How do I pwn thee? ~ Let me count the ways; No, wait: ~ Just one is enough!
  • 33. DEMONSTRATION:nginx and php on windows Now I understand, But I still don’t believe you. SHOW ME THE MONEY!
  • 34.
  • 35. Questions? There’s no dumb question… “Is the computer plugged in?” Is pretty bad, though. Dan Crowley Core Security Technologies dcrowley@coresecurity.com