Hacker’s Elusive Thoughts The Web
Hacker’s Elusive Thoughts The Web
About the Book
This book is going to help Web Application developers, Professional Penetration Testers and Web Application Security Analysts to standardise their Web Application security assessments. It is also going to help them build a comprehensive penetration testing framework, that can easily be integrated to their custom Secure Life Cycle (SDLC) development.
Table of Contents
1 Formalizing Web Penetration Test
1.16 Chaining Scanners . . . . . . . . . . . . . . . . . . . . . . . . 23
1.17 Using Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.18 Why Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.19 Useful Python Libraries . . . . . . . . . . . . . . . . . . . . . 27
1.20 Python Useful Open Source Projects . . . . . . . . . . . . 28
1.21 The Python Version . . . . . . . . . . . . . . . . . . . . . . 29
1.22 Python Development Environment . . . . . . . . . . . . . . 29
1.23 Python Libraries Used . . . . . . . . . . . . . . . . . . . . . . 30
1.24 Installing Python . . . . . . . . . . . . . . . . . . . . . . . . 31
1.25 Installing Requests . . . . . . . . . . . . . . . . . . . . . . . 31
1.26 Installing Beautiful Soup 4 . . . . . . . . . . . . . . . . . . . 32
1.27 Python Comments . . . . . . . . . . . . . . . . . . . . . . . . . 34
1.28 Program Structure . . . . . . . . . . . . . . . . . . . . . . . . 34
1.29 Documenting Python code . . . . . . . . . . . . . . . . . . . . . 35
1.30 Writing Your Own Scanner . . . . . . . . . . . . . . . . . . . . 36
1.31 Problematic Scanning . . . . . . . . . . . . . . . . . . . . . . 38
1.32 The Scanner Design . . . . . . . . . . . . . . . . . . . . . . . 40
1.33 Python Useful Modules . . . . . . . . . . . . . . . . . . . . . . 42
1.34 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
1.35 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2 Scanning With Class
2.1 Manual Versus Automated Testing . . . . . . . . . . . . . . . . . 48
2.2 Why Commercial Scanners Fail . . . . . . . . . . . . . . . . . . . 49
2.3 Integrating Our Scanner To SDLC . . . . . . . . . . . . . . . . . .55
2.4 Problems When Writing A Scanner . . . . . . . . . . . . . . . 58
2.5 Scanning Time . . . . . . . . . . . . . . . . . . . . . . . . . . 58
2.6 Scanning Time Improvement . . . . . . . . . . . . . . . . . . . 59
2.7 Defining URL(s) . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.8 Choosing HTML Parser . . . . . . . . . . . . . . . . . . . . . 65
2.9 Defining HTML Pages . . . . . . . . . . . . . . . . . . . . . . 67
2.10 Parsing URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
2.11 Parsing HTML pages . . . . . . . . . . . . . . . . . . . . . . . 72
2.12 Restricting Scanning . . . . . . . . . . . . . . . . . . . . . . . 79
2.13 Connection Handling . . . . . . . . . . . . . . . . . . . . . . . 87
2.14 HTTP Handling . . . . . . . . . . . . . . . . . . . . . . . . . . 89
2.15 Fetching Pages . . . . . . . . . . . . . . . . . . . . . . . . . . 90
2.16 Avoiding Denial Of Service Conditions . . . . . . . . . . . . . 92
2.17 Performing Denial of Service . . . . . . . . . . . . . . . . . . . 96
2.18 Assessing Replies . . . . . . . . . . . . . . . . . . . . . . . . . 99
2.19 Sending Malicious Payloads . . . . . . . . . . . . . . . . . . . 101
2.20 Analysing Fuzz Data with Python . . . . . . . . . . . . . . . . 103
2.21 Passive Scanning Analysing Headers . . . . . . . . . . . . . . 105
2.22 Debugging Code . . . . . . . . . . . . . . . . . . . . . . . . . . 109
2.23 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
2.24 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
3 The Payload Management
3.1 Keeping Up To Date Payloads . . . . . . . . . . . . . . . . . . 116
3.2 Payloads And Fuzzing . . . . . . . . . . . . . . . . . . . . . . 117
3.3 Intelligent Fuzzing . . . . . . . . . . . . . . . . . . . . . . . . 117
3.4 Input Validation Obfuscation . . . . . . . . . . . . . . . . . . 118
3.5 The Teenage Mutant Ninja Turtles Project . . . . . . . . . . . 119
3.6 Encoding And Payloads . . . . . . . . . . . . . . . . . . . . . 119
3.7 Character Encoding . . . . . . . . . . . . . . . . . . . . . . . . 120
3.8 Code Point Explained . . . . . . . . . . . . . . . . . . . . . . 121
3.9 Encoding And Internet Browsers . . . . . . . . . . . . . . . . 123
3.10 Encoding And Rendering . . . . . . . . . . . . . . . . . . . . . 124
3.11 Payload Logistics . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.12 Browser Sandboxing Bypass . . . . . . . . . . . . . . . . . . . 125
3.13 Payload Size Calculation . . . . . . . . . . . . . . . . . . . . . 126
3.14 Building Universal Exploits . . . . . . . . . . . . . . . . . . . 127
3.15 Base64 Encoding And Cross Site Scripting . . . . . . . . . . . 132
3.16 UTF-7 Encoding And Cross Site Scripting . . . . . . . . . . . 134
3.17 Double URL Encoding And Cross Site Scripting . . . . . . . . 135
3.18 Encoding And Path-Traversal Attacks . . . . . . . . . . . . . 136
3.19 UTF-8 encoding And Path-traversal Attacks . . . . . . . . . . 137
3.20 UTF-16 encoding And Path Traversal Attacks . . . . . . . . . 139
3.21 NULL Character And Path Traversal Attacks . . . . . . . . . 140
3.22 Using Mangled Paths . . . . . . . . . . . . . . . . . . . . . . . 142
3.23 Octal encoding and XSS . . . . . . . . . . . . . . . . . . . . . 142
3.24 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4 Infiltrating Corporate Networks Using XML Injections
4.1 Why XXE Attacks Still Exist . . . . . . . . . . . . . . . . . . 145
4.2 How Extensible Markup Language Is Used . . . . . . . . . . . 148
4.3 About Document Type Definition . . . . . . . . . . . . . . . . 148
4.4 More On External Entities . . . . . . . . . . . . . . . . . . . . 150
4.5 A URI As Reference In Markup Languages . . . . . . . . . . . 153
4.6 Where XML Parsers Are Used . . . . . . . . . . . . . . . . . . 154
4.7 XML Parser Inner Workings . . . . . . . . . . . . . . . . . . . 155
4.8 XML Parser And XXE . . . . . . . . . . . . . . . . . . . . . . 156
4.9 Generating XML Errors . . . . . . . . . . . . . . . . . . . . . 156
4.10 Error Based XXE Injections . . . . . . . . . . . . . . . . . . . 157
4.11 The XML Web Application . . . . . . . . . . . . . . . . . . . 158
4.12 Generating XXE Errors . . . . . . . . . . . . . . . . . . . . . 159
4.13 Exploiting XXE Injections . . . . . . . . . . . . . . . . . . . . 160
4.14 XXE Injections And HTML Comments . . . . . . . . . . . . . 161
4.15 XXE Injections And CDATA Tags . . . . . . . . . . . . . . . 162
4.16 XXE Injections And Cross Site Scripting . . . . . . . . . . . . 164
4.17 XXE Injections And Open Redirections . . . . . . . . . . . . . 165
4.18 XXE Injections And Clickjacking . . . . . . . . . . . . . . . . 166
4.19 XXE Injections And HTML Forms . . . . . . . . . . . . . . . 168
4.20 XXE Injections And Internal Resource Extraction . . . . . . . 169
4.21 XXE Injections And Denial of Service . . . . . . . . . . . . . . 171
4.22 XXE Injections And Port Scanning . . . . . . . . . . . . . . . 173
4.23 XXE Injections And Post Exploitation . . . . . . . . . . . . . 181
4.24 XXE Injections And Service Fingerprint . . . . . . . . . . . . 181
4.25 XXE Injections And Host Discovery . . . . . . . . . . . . . . . 182
4.26 XXE Injections And Web Server Fingerprinting . . . . . . . . 183
4.27 The XXE Identification Scanner . . . . . . . . . . . . . . . . . 184
4.28 The XXE Port Scanner . . . . . . . . . . . . . . . . . . . . . . 186
4.29 The XXE Directory Enumerator . . . . . . . . . . . . . . . . . 187
4.30 Mitigating XXE Vulnerabilities . . . . . . . . . . . . . . . . . 188
4.31 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
4.32 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5 Phishing Like A Boss
5.1 Why Phishing Attacks Still Exist . . . . . . . . . . . . . . . . 192
5.2 Phishing Attacks Evolve . . . . . . . . . . . . . . . . . . . . . 193
5.3 Clickjacking Attacks . . . . . . . . . . . . . . . . . . . . . . . 195
5.4 Exploiting Clickjacking Attacks Using Cascading Style Sheets 196
5.5 CSRF Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
5.6 Exploiting CSRF Using GET Request . . . . . . . . . . . . . . 202
5.7 Exploiting CSRF Using POST To GET Interchanges . . . . . 204
5.8 Exploiting CSRF Using POST Requests . . . . . . . . . . . . 205
5.9 Exploiting CSRF And Enctype . . . . . . . . . . . . . . . . . 207
5.10 Exploiting CSRF Using XMLHttpRequest . . . . . . . . . . . 208
5.11 XSS Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
5.12 XSS Attacks And Clickjacking . . . . . . . . . . . . . . . . . . 212
5.13 XSS Attacks, Clickjacking And Payload Obfuscation . . . . . 216
5.14 Clickjacking And CSRF . . . . . . . . . . . . . . . . . . . . . 219
5.15 Countermeasures Against Phishing Attacks . . . . . . . . . . . 221
5.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
6 Obfuscating SQL Fuzzing For Fun and Profit
6.1 Why SQL Injection Attacks Still Exist . . . . . . . . . . . . . 224
6.2 SQL injection Attacks Evolve . . . . . . . . . . . . . . . . . . 225
6.3 SQL Obfuscation Techniques . . . . . . . . . . . . . . . . . . . 227
6.4 Using Case Variation . . . . . . . . . . . . . . . . . . . . . . . 229
6.5 Using SQL Comments . . . . . . . . . . . . . . . . . . . . . . 235
6.6 Using Single URL Encoding . . . . . . . . . . . . . . . . . . . 238
6.7 Using Double URL Encoding . . . . . . . . . . . . . . . . . . 241
6.8 Using Dynamic Query Execution . . . . . . . . . . . . . . . . 241
6.9 Using Conversion Functions . . . . . . . . . . . . . . . . . . . 245
6.10 Multil Layer SQL Obfuscation . . . . . . . . . . . . . . . . . . 248
6.11 SQL Injection Filter Design Mentality . . . . . . . . . . . . . 250
6.12 Whitelist Filters . . . . . . . . . . . . . . . . . . . . . . . . . . 251
6.13 Whitelist Filters In .NET . . . . . . . . . . . . . . . . . . . . 252
6.14 Whitelist Filters In Java . . . . . . . . . . . . . . . . . . . . . 253
6.15 Blacklist Filters . . . . . . . . . . . . . . . . . . . . . . . . . . 254
6.16 Blacklist Filters In ASP . . . . . . . . . . . . . . . . . . . . . 255
6.17 Blacklist Filters In Java . . . . . . . . . . . . . . . . . . . . . 257
6.18 Hybrid Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
6.19 Thinks To Consider When Automating Fuzzing . . . . . . . . 259
6.20 Stored Procedures And Parameterized Queries . . . . . . . . . 261
6.21 Web Application Firewall Bypassing . . . . . . . . . . . . . . 262
6.22 Python Library Requests . . . . . . . . . . . . . . . . . . . . 262
6.23 Automating SQL Fuzzing . . . . . . . . . . . . . . . . . . . . 264
6.24 Hiding SQL Injection Attacks From Logs . . . . . . . . . . 269
6.25 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$11,817,855writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Stratospheric
Tom Hombergs, Björn Wilmsmann, and Philip RiecksFrom Zero to Production with Spring Boot and AWS. All you need to know to get a Spring Boot application into production with AWS. No previous AWS knowledge required.
Go to stratospheric.dev for a tour of the contents.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
node-opcua by example
Etienne RossignonGet the best out of node-opcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
Advanced Web Application Architecture
Matthias NobackThe missing manual for making your web applications future-proof
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Thinking with Types
Sandy MaguireThis book aims to be the comprehensive manual for type-level programming. It's about getting you from here to there---from a competent Haskell programmer to one who convinces the compiler to do their work for them.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
Top Bundles
- #1
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #5
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #10
Cloud Architect: Transform Technology and Organization
2 Books
Architects don't just recite product names and features. They understand the options, decisions, and trade-offs behind them. They earn credibility and maintain authenticity by connecting the penthouse with the engine room. Get two essential books that redefine the role of the software and IT architect at one low price:37 Things One Architect...