Fuzzing:
Finding Bugs FASTER
Alper Basaran
basaranalper@gmail.com
Alper Basaran - basaranalper@gmail.com
• Alper Basaran
• Founder of Sparta Bilisim
• 15+ years as penetration tester
• Published author
Alper Basaran - basaranalper@gmail.com
‫ֶם‬‫כ‬‫י‬ֵ‫ֲל‬‫ע‬ ‫לֹום‬ ָׁ‫ש‬
Today
• We’ll see where fuzzing fits
• We’ll discuss fuzzing approaches
• We’ll try to find zero-days*
• Hotel booking application
• Rentacar application
• Students Test Results System
Alper Basaran - basaranalper@gmail.com
Fuzzing...
«(...)There is no teacher but the enemy. No one but the enemy will tell
you what the enemy is going to do. No one but the enemy will ever
teach you how to destroy and conquer. Only the enemy shows you
where you are weak.»
- Ender’s Game
Alper Basaran - basaranalper@gmail.com
Fuzzing...
«πόλλ' οἶδ' ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα»
- Archilochus
Alper Basaran - basaranalper@gmail.com
Fuzzing...
«a fox knows many things, but a hedgehog one
important thing»
- Archilochus
Alper Basaran - basaranalper@gmail.com
Fuzzing is NOT new..
• «We didn't call it fuzzing back in the 1950s, but it was our
standard practice to test programs by inputting decks of punch
cards taken from the trash. We also used decks of random
number punch cards. We weren't networked in those days, so
we weren't much worried about security, but our random/trash
decks often turned up undesirable behavior. Every programmer
I knew (and there weren't many of us back then, so I knew a
great proportion of them) used the trash-deck technique.»
- Gerald M. Weinberg
Alper Basaran - basaranalper@gmail.com
Fuzzing in a Nutshell
Fuzzer Application
• SQLi
• XSS
• RCE
• Directory traversal
• Errors
• Crashes
• No response
Alper Basaran - basaranalper@gmail.com
Fuzzing in a Nutshell (Corrected)
Fuzzer Application
• SQLi
• XSS
• RCE
• Directory traversal
• Errors
• Crashes
• No response
• Different response
Alper Basaran - basaranalper@gmail.com
Fuzzing in a Nutshell (Corrected)
Fuzzer Application
• SQLi
• XSS
• RCE
• Directory traversal
• Errors
• Crashes
• No response
• Different response
Monitor These
Alper Basaran - basaranalper@gmail.com
Fuzzing Data
• Mutation-based: Mutate existing data
• Tested URL: http://example.com/test?id=user
• Mutation: http://example.com/test?id=user2 ?
• Mutation: http://example.com/test?id=admin ?
• Generated: Generate/use other data
• Tested URL: http://example.com/test?id=user
• Mutation: http://example.com/test?id=1 ?
• Mutation: http://example.com/test?id=../../../../../../etc/passwd ?
Alper Basaran - basaranalper@gmail.com
Penetration Testing (Reminder)
• Trying to find vulnerabilities
• Types of penetration testing
• White box
• Black box
• Grey box
• Where’s «penetration testing» located?
• Usually at the end ☺
• At the end of what?
Alper Basaran - basaranalper@gmail.com
Software Development Lifecycle
• Ideally:
Source: http://download.microsoft.com/download/B/8/2/B8282D75-433C-4B7E-B0A0-FFA413E20060/microsoft_security_development_lifecycle.pdf
Alper Basaran - basaranalper@gmail.com
In Reality
From: ITguy@customerisright.com
To: alper@sparta.com.tr
Subject: URGENT!!!!!
I’ve just been told that our Marketing department is
launching a promotional website tomorrow!!
Could you please quickly do a pentest.
K thanx, bye
Alper Basaran - basaranalper@gmail.com
Software Development Lifecycle
• In real life:
Source: http://download.microsoft.com/download/B/8/2/B8282D75-433C-4B7E-B0A0-FFA413E20060/microsoft_security_development_lifecycle.pdf
Tests
About there:
Alper Basaran - basaranalper@gmail.com
Penetration Testing
Alper Basaran - basaranalper@gmail.com
Penetration Testing (Limitations)
• Time, time and time
• Resources
• Job probably goes to the lowest offer
• Time?
Alper Basaran - basaranalper@gmail.com
Source Code Review
• Will require access to source code
• How does it work?
Alper Basaran - basaranalper@gmail.com
Source Code Review
https://www.geeksforgeeks.org/buffer-overflow-attack-with-example/Alper Basaran - basaranalper@gmail.com
Source Code Review
• https://owasp.org/www-community/Source_Code_Analysis_Tools
Alper Basaran - basaranalper@gmail.com
Source Code Review
https://dwheeler.com/flawfinder/
• apt install python-pip
• pip install flawfinder
Alper Basaran - basaranalper@gmail.com
Source Code Review (Limitations)
• How does it work?
• cat, grep, awk...
• What about third party libraries/modules?
• What about comments?
• Can ONLY find POTENTIAL vulnerabilities
Alper Basaran - basaranalper@gmail.com
So What Happens when?
• Testing time is limited
• You don’t have access to the source code
Alper Basaran - basaranalper@gmail.com
«Start fuzzing»
WE FUZZ!
Why do we Fuzz?
• We try to find inputs that lead to errors or insecurities
• It’s not an «elegant» technique
• Used for:
• Quality assurance
• Vulnerability assessment
Alper Basaran - basaranalper@gmail.com
Fuzzing (limitations)
• Doesn’t understand the logic of the application
• Normally you get a 404
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from admin accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
• 404 (from user accessible page)
Fuzzer will most likely miss this
Alper Basaran - basaranalper@gmail.com
Fuzzing (limitations)
• Doesn’t understand the logic of the application
• Looking for a buffer overflow
• no crash
• no crash
• no crash
• no crash
• no crash
• no crash (login successful)
• no crash
• no crash
• no crash
• Crash
Alper Basaran - basaranalper@gmail.com
Fuzzer will most likely miss this
Fuzzing (limitations)
• You’ll have to investigate exploitability
• Fuzzing live systems can be «dangerous»
• You’ll miss complex vulnerabilities
Alper Basaran - basaranalper@gmail.com
Why do we fuzz? (Software bugs/tests)
• Quality testers fuzz to make sure
• Everything works
• App doesn’t crash
• App can handle number of requests
Source: https://stackoverflow.com/questions/16521143/fuzz-test-framework-web-applicationAlper Basaran - basaranalper@gmail.com
Why do we fuzz? (Software vulnerabilities)
• Types of vulnerabilities:
• Design errors: Authentication by-pass
• Execution errors: Buffer Overflows
• Installation errors: Configuration flaws
• We fuzz mainly to;
• Uncover anything that can impact CIA
• Map attack surface
• Locate trust boundaries
• Find «hostile» data
Source: f5.com
Alper Basaran - basaranalper@gmail.com
Hostile Data
• Mostly characters but also any data that can make the app do
something it shouldn’t
• Special characters would mainly be:
~ $ * _ }  / '
! % ( + ] ` ? "
@ ^ ) = [ , ; <
# & _ { | . : >
Alper Basaran - basaranalper@gmail.com
Hostile Data
• Mostly characters but also any data that can make the app do
something it shouldn’t
• Special characters would mainly be:
~ $ * _ }  / '
! % ( + ] ` ? "
@ ^ ) = [ , ; <
# & _ { | . : >
Breaks SQL
Adds Command
Comments
Alper Basaran - basaranalper@gmail.com
Hostile Data
• Mostly characters but also any data that can make the app do
something it shouldn’t
• Special characters
• File types
• File metadata
• Headers
• ...
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
Fuzzer Target
Request 1
Expected response (e.g. 404)
Request 2
Unexpected response (e.g. 503)
Request n
Unexpected response (No response)
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases:
1. Identify targets
2. Identify inputs
3. Generate data
4. Execute
5. Monitor anomalies
6. Check exploitability
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 1 - Identify targets
• Parameters (GET and POST)
• Google
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 1 - Identify targets
• Google Hacking
• https://www.exploit-db.com/google-hacking-database
• GH is interested in results, we look for inputs
• E.g. php?id=
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 2 - Identify inputs
• What is the app «normally» expecting
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 3 - Generate data
• Fuzzing payloads
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 4 - Execute
• Fuzz ☺
• Fuzz 
• Fuzz ...
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 5 - Monitor anomalies
• What would the «normal» response be?
• Is there anything different in the response?
• HTTP code?
• Response size?
• Error?
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing phases: 6 - Check exploitability
• So?
• How can we exploit this?
1 - Identify targets
2 - Identify inputs
3 - Generate data
4 - Execute
5 - Monitor anomalies
6 - Check exploitability
Alper Basaran - basaranalper@gmail.com
How do we fuzz?
• Fuzzing web applications:
1. Find data entry points
• Anything sent from the client
2. Generate payload list
• Long
• Odd characters (encoded)
• Special characters (new line character, line feed, etc.)
3. Fuzz
4. Detect anomalies
5. Check exploitation
Alper Basaran - basaranalper@gmail.com
What do we fuzz?
• Short answer: Everything!
• GET data
• POST data
• User agent
• Cookies
• File metadata
• etc...
Alper Basaran - basaranalper@gmail.com
What do we fuzz?
• GET
• Host
• User-Agent
• Accept
• Accept-Language
• Accept-Encoding
• Connection
• Cookie
• Upgrade-Insecure-Requests
Alper Basaran - basaranalper@gmail.com
A Few Reminders
Alper Basaran - basaranalper@gmail.com
HTTP Requests
Alper Basaran - basaranalper@gmail.com
Request
Response
Special Characters in URLs
• #: Anchor (or %23)
• ?: Query string (or %3F)
• &: Seperating query elements (or %26)
• +: Space (or %2B)
• https://www.w3schools.com/tags/ref_urlencode.asp
Alper Basaran - basaranalper@gmail.com
HTTP Methods
• HTTP works as a communication protocol between clients and servers
• HTTP methods defines the type of the request made by the client
• You’ll mostly see;
• GET
• POST
Alper Basaran - basaranalper@gmail.com
HTTP Methods
• You might also see:
• GET
• POST
• PUT
• HEAD
• DELETE
• PATCH
• OPTIONS
Alper Basaran - basaranalper@gmail.com
HTTP Methods
• But we are fuzzers!
• so;
ACL GET MKCOL PRI UNBIND
BASELINE-CONTROL HEAD MKREDIRECTREF PROPFIND UNCHECKOUT
BIND LABEL MKWORKSPACE PROPPATCH UNLINK
CHECKIN LINK MOVE PUT UNLOCK
CHECKOUT LOCK OPTIONS REBIND UPDATE
CONNECT MERGE ORDERPATCH REPORT UPDATEREDIRECTREF
COPY MKACTIVITY PATCH SEARCH VERSION-CONTROL
DELETE MKCALENDAR POST TRACE
Alper Basaran - basaranalper@gmail.com
HTTP Response Codes
• 1xx informational response: The request was received, continuing
process
• 2xx successful: The request was successfully received, understood,
and accepted
• 3xx redirection: Further action needs to be taken in order to complete
the request
• 4xx client error: The request contains bad syntax or cannot be fulfilled
• 5xx server error: The server failed to fulfil an apparently valid request
Alper Basaran - basaranalper@gmail.com
Input / Output Validation
• Application should distinguish between a valid input and a malformed
input
• Application should NOT trust the user
• Input fields are not the only way to send data to the server
• Anything on the HTTP connection can be an input
Alper Basaran - basaranalper@gmail.com
Input / Output Validation
• Two main approaches:
• Blacklist:
• Don’t accept these:
• <script>
• ‘ or ‘1’=‘1
• Whitelist:
• Only accept these
• [a-z]
• [0-9]
Alper Basaran - basaranalper@gmail.com
Client
Side
Server
Side
Input
Validation
Tools: HTTP Headers Live
Alper Basaran - basaranalper@gmail.com
Tools: Cookie Quick Manager
Alper Basaran - basaranalper@gmail.com
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
Tools: Burp Suite
• Sniper: Uses a single set of payloads.
• Battering ram: Uses a single set of payloads. It iterates through the
payloads and places the same payload into all of the defined payload
positions at once.
• Pitchfork: Uses multiple payload sets. There is a different payload set for
each defined position (up to a maximum of 20). The attack iterates through
all payload sets simultaneously, and places one payload into each defined
position.
• Cluster bomb: Uses multiple payload sets. There is a different payload set
for each defined position (up to a maximum of 20). The attack iterates
through each payload set in turn, so that all permutations of payload
combinations are tested.
Alper Basaran - basaranalper@gmail.com
Tools: Burp Suite
source: http://www.iana.org/assignments/http-methods/http-methods.xhtmlAlper Basaran - basaranalper@gmail.com
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
• Method: ACL
• Response: 501 (Not Implemented)
• Server: AkamaiGHost
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
• Method: BIND
• Response: 400 (Bad Request)
• Server: AkamaiGHost
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
• Method: OPTIONS
• Response: 500 (Internal Server Error)
• Server: istio-envoy
Tools: Burp Suite
Alper Basaran - basaranalper@gmail.com
So?
• Can you use this to «crash» the server?
• Can you use this to enumerate further?
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• Basic usage:
• wfuzz –w wordlist http://www.target.com/FUZZ
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -w wordlist.txt https://www.apple.com/FUZZ
• We can add:
• --hc: To hide specific response
• -f: to save results to a file
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
-v
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
--follow
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• Let’s login
• Tools we’ll need:
• Cewl
• Wfuzz
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• Cewl will parse the target page and generate a wordlist
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• We’ll use the wordlist generated by Cewl to bruteforce login
• and a Wfuzz payload
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login" -
v http://192.168.19.140/dvwa/login.php
• -c: Color
• -z:
• -d:
• -v: verbose
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login"
http://192.168.19.140/dvwa/login.php
• -c: Color
• -z: Payload
• -d: Data sent in POST
• So? Could we login?
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login"
http://192.168.19.140/dvwa/login.php
• -c: Color
• -z: Payload
• -d: Data sent in POST
• So? Could we login?
• Add -v (verbose)
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
--verbose
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• Directory enumeration
--hc 404
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• SQL injection login bypass
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -w /usr/share/wordlists/wfuzz/Injections/SQL.txt -d
"uid=FUZZ&passw=FUZZ&btnSubmit=Login" -v http://www.altoromutual.com:8080/doLogin
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
• wfuzz -w /usr/share/wordlists/wfuzz/Injections/SQL.txt -b="security=low;
PHPSESSID=c8e5524009676cedd43acbfdde12ea52"
http://192.168.19.140/dvwa/vulnerabilities/sqli/?id=FUZZ&Submit=Submit#
• -w /usr/share/wordlists/wfuzz/Injections/SQL.txt
• -b="security=low; PHPSESSID=c8e5524009676cedd43acbfdde12ea52"
Alper Basaran - basaranalper@gmail.com
Tools: Wfuzz
Alper Basaran - basaranalper@gmail.com
Tools: OWASP ZAP
Alper Basaran - basaranalper@gmail.com
Fuzzing methods
• Fuzzing payloads
• Pregenerated
• Random
Alper Basaran - basaranalper@gmail.com
3. Fuzzing approaches
a) Test case-based fuzzing
b) Random fuzzing
c) Using existing fuzzing payloads
d) Generating a specific payload list
Alper Basaran - basaranalper@gmail.com
3. Fuzzing approaches
a) Test case-based fuzzing
b) Random fuzzing
c) Using existing fuzzing payloads
d) Generating a specific payload list
Smart: «Thinking about what to send»
Dumb: «Send everything but the kitchen sink»
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
• Understanding «what can be» and fuzzing accordingly
Alper Basaran - basaranalper@gmail.com
Fuzzing: OWASP Top 10 2020
1. SQL injection
2. Broken Authentication.
3. Sensitive Data Exposure.
4. XML External Entities (XXE).
5. Broken Access Control.
6. Security Misconfiguration
7. Cross-Site Scripting XSS.
8. Insecure Deserialization.
9. Using Components with Known Vulnerabilities.
10. Insufficient Logging & Monitoring.
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
1. SQL injection:
a) A web application connected to a database
b) An input sending a query to the database
c) A visible (or invisible) output
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
2. Broken Authentication.
a) Permits automated attacks such as credential stuffing
b) Permits brute force or other automated attacks.
c) Permits weak passwords, such as”Password1″ or “admin/admin.″
d) Uses weak or ineffective credential recovery and forgot-password processes (e.g.
what is your date of birth).
e) Uses plain text, encrypted, or weakly hashed passwords.
f) Has missing or ineffective multi-factor authentication.
g) Exposes session IDs in the URL (e.g., URL rewriting).
h) Does not rotate session IDs after successful login.
i) Does not properly invalidate session IDs. User sessions or authentication tokens
(particularly single sign-on (SSO) tokens) aren’t properly invalidated during logout
or a period of inactivity.
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
3. Sensitive Data Exposure
• Via stored or transmitted data
a) Credentials
b) Credit card numbers
c) Social Security Numbers
d) Medical information
e) Personally identifiable information (PII)
f) Other personal information
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
4. XML External Entities (XXE).
• Via stored or transmitted data
a) Vulnerable XML processors if malicious actors can upload XML or include
hostile content in an XML document
b) Vulnerable code
c) Vulnerable dependencies
d) Vulnerable integrations
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
5. Broken Access Control
• e.g. access admin login page
a) Access to a hosting control / administrative panel
b) Access to a server via FTP / SFTP / SSH
c) Access to a website’s administrative panel
d) Access to other applications on your server
e) Access to a database
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
6. Security Misconfiguration
• e.g. default CMS configuration
a) Unpatched flaws
b) Default configurations
c) Unused pages
d) Unprotected files and directories
e) Unnecessary services
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
7. Cross-Site Scripting XSS
• Most common vulnerability?
a) Must take input
b) Must include input in response source code
c) Also must have login/session
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
8. Insecure Deserialization
• Convert object to byte strings: serialization
• Convert byte strings to objects: deserialization
• Cookie contains BASE64 encoded of «user:Alice,privilege:user»
(dXNlcjpBbGljZSxwcml2aWxlZ2U6dXNlcg==)
• Can it be changed to «user:Alice,privilege:admin»
(dXNlcjpBbGljZSxwcml2aWxlZ2U6YWRtaW4=)
a) Deserialize an object
b) Modify the object
c) Serialize it again
Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
9. Using Components with Known Vulnerabilities
Alper Basaran - basaranalper@gmail.com
Case Based Fuzzing
9. Using Components with Known Vulnerabilities
Alper Basaran - basaranalper@gmail.com
Random Fuzzing
• «Everything but the kitchen sink»
Alper Basaran - basaranalper@gmail.com
Random Fuzzing
• Wfuzz wordlists
Alper Basaran - basaranalper@gmail.com
Random Fuzzing
• https://github.com/danielmiessler/SecLists/tree/master/Fuzzing
Alper Basaran - basaranalper@gmail.com
Random Fuzzing
• https://github.com/chrislockard/api_wordlist
Alper Basaran - basaranalper@gmail.com
Generating a Wordlist
• Cewl
• Crunch 4 4 1234
• crunch 9 9 -t @@@@1107!
• @ letter
• , capital letter
• % number
• ^ special char
• wget, cat, grep, cut, sort ☺
Alper Basaran - basaranalper@gmail.com
Questions?
basaranalper@gmail.com
Alper Basaran - basaranalper@gmail.com

Finding Bugs FASTER with Fuzzing

  • 1.
    Fuzzing: Finding Bugs FASTER AlperBasaran basaranalper@gmail.com Alper Basaran - basaranalper@gmail.com
  • 2.
    • Alper Basaran •Founder of Sparta Bilisim • 15+ years as penetration tester • Published author Alper Basaran - basaranalper@gmail.com ‫ֶם‬‫כ‬‫י‬ֵ‫ֲל‬‫ע‬ ‫לֹום‬ ָׁ‫ש‬
  • 3.
    Today • We’ll seewhere fuzzing fits • We’ll discuss fuzzing approaches • We’ll try to find zero-days* • Hotel booking application • Rentacar application • Students Test Results System Alper Basaran - basaranalper@gmail.com
  • 4.
    Fuzzing... «(...)There is noteacher but the enemy. No one but the enemy will tell you what the enemy is going to do. No one but the enemy will ever teach you how to destroy and conquer. Only the enemy shows you where you are weak.» - Ender’s Game Alper Basaran - basaranalper@gmail.com
  • 5.
    Fuzzing... «πόλλ' οἶδ' ἀλώπηξ,ἀλλ' ἐχῖνος ἓν μέγα» - Archilochus Alper Basaran - basaranalper@gmail.com
  • 6.
    Fuzzing... «a fox knowsmany things, but a hedgehog one important thing» - Archilochus Alper Basaran - basaranalper@gmail.com
  • 7.
    Fuzzing is NOTnew.. • «We didn't call it fuzzing back in the 1950s, but it was our standard practice to test programs by inputting decks of punch cards taken from the trash. We also used decks of random number punch cards. We weren't networked in those days, so we weren't much worried about security, but our random/trash decks often turned up undesirable behavior. Every programmer I knew (and there weren't many of us back then, so I knew a great proportion of them) used the trash-deck technique.» - Gerald M. Weinberg Alper Basaran - basaranalper@gmail.com
  • 8.
    Fuzzing in aNutshell Fuzzer Application • SQLi • XSS • RCE • Directory traversal • Errors • Crashes • No response Alper Basaran - basaranalper@gmail.com
  • 9.
    Fuzzing in aNutshell (Corrected) Fuzzer Application • SQLi • XSS • RCE • Directory traversal • Errors • Crashes • No response • Different response Alper Basaran - basaranalper@gmail.com
  • 10.
    Fuzzing in aNutshell (Corrected) Fuzzer Application • SQLi • XSS • RCE • Directory traversal • Errors • Crashes • No response • Different response Monitor These Alper Basaran - basaranalper@gmail.com
  • 11.
    Fuzzing Data • Mutation-based:Mutate existing data • Tested URL: http://example.com/test?id=user • Mutation: http://example.com/test?id=user2 ? • Mutation: http://example.com/test?id=admin ? • Generated: Generate/use other data • Tested URL: http://example.com/test?id=user • Mutation: http://example.com/test?id=1 ? • Mutation: http://example.com/test?id=../../../../../../etc/passwd ? Alper Basaran - basaranalper@gmail.com
  • 12.
    Penetration Testing (Reminder) •Trying to find vulnerabilities • Types of penetration testing • White box • Black box • Grey box • Where’s «penetration testing» located? • Usually at the end ☺ • At the end of what? Alper Basaran - basaranalper@gmail.com
  • 13.
    Software Development Lifecycle •Ideally: Source: http://download.microsoft.com/download/B/8/2/B8282D75-433C-4B7E-B0A0-FFA413E20060/microsoft_security_development_lifecycle.pdf Alper Basaran - basaranalper@gmail.com
  • 14.
    In Reality From: ITguy@customerisright.com To:alper@sparta.com.tr Subject: URGENT!!!!! I’ve just been told that our Marketing department is launching a promotional website tomorrow!! Could you please quickly do a pentest. K thanx, bye Alper Basaran - basaranalper@gmail.com
  • 15.
    Software Development Lifecycle •In real life: Source: http://download.microsoft.com/download/B/8/2/B8282D75-433C-4B7E-B0A0-FFA413E20060/microsoft_security_development_lifecycle.pdf Tests About there: Alper Basaran - basaranalper@gmail.com
  • 16.
    Penetration Testing Alper Basaran- basaranalper@gmail.com
  • 17.
    Penetration Testing (Limitations) •Time, time and time • Resources • Job probably goes to the lowest offer • Time? Alper Basaran - basaranalper@gmail.com
  • 18.
    Source Code Review •Will require access to source code • How does it work? Alper Basaran - basaranalper@gmail.com
  • 19.
  • 20.
    Source Code Review •https://owasp.org/www-community/Source_Code_Analysis_Tools Alper Basaran - basaranalper@gmail.com
  • 21.
    Source Code Review https://dwheeler.com/flawfinder/ •apt install python-pip • pip install flawfinder Alper Basaran - basaranalper@gmail.com
  • 22.
    Source Code Review(Limitations) • How does it work? • cat, grep, awk... • What about third party libraries/modules? • What about comments? • Can ONLY find POTENTIAL vulnerabilities Alper Basaran - basaranalper@gmail.com
  • 23.
    So What Happenswhen? • Testing time is limited • You don’t have access to the source code Alper Basaran - basaranalper@gmail.com «Start fuzzing» WE FUZZ!
  • 24.
    Why do weFuzz? • We try to find inputs that lead to errors or insecurities • It’s not an «elegant» technique • Used for: • Quality assurance • Vulnerability assessment Alper Basaran - basaranalper@gmail.com
  • 25.
    Fuzzing (limitations) • Doesn’tunderstand the logic of the application • Normally you get a 404 • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from admin accessible page) • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from user accessible page) • 404 (from user accessible page) Fuzzer will most likely miss this Alper Basaran - basaranalper@gmail.com
  • 26.
    Fuzzing (limitations) • Doesn’tunderstand the logic of the application • Looking for a buffer overflow • no crash • no crash • no crash • no crash • no crash • no crash (login successful) • no crash • no crash • no crash • Crash Alper Basaran - basaranalper@gmail.com Fuzzer will most likely miss this
  • 27.
    Fuzzing (limitations) • You’llhave to investigate exploitability • Fuzzing live systems can be «dangerous» • You’ll miss complex vulnerabilities Alper Basaran - basaranalper@gmail.com
  • 28.
    Why do wefuzz? (Software bugs/tests) • Quality testers fuzz to make sure • Everything works • App doesn’t crash • App can handle number of requests Source: https://stackoverflow.com/questions/16521143/fuzz-test-framework-web-applicationAlper Basaran - basaranalper@gmail.com
  • 29.
    Why do wefuzz? (Software vulnerabilities) • Types of vulnerabilities: • Design errors: Authentication by-pass • Execution errors: Buffer Overflows • Installation errors: Configuration flaws • We fuzz mainly to; • Uncover anything that can impact CIA • Map attack surface • Locate trust boundaries • Find «hostile» data Source: f5.com Alper Basaran - basaranalper@gmail.com
  • 30.
    Hostile Data • Mostlycharacters but also any data that can make the app do something it shouldn’t • Special characters would mainly be: ~ $ * _ } / ' ! % ( + ] ` ? " @ ^ ) = [ , ; < # & _ { | . : > Alper Basaran - basaranalper@gmail.com
  • 31.
    Hostile Data • Mostlycharacters but also any data that can make the app do something it shouldn’t • Special characters would mainly be: ~ $ * _ } / ' ! % ( + ] ` ? " @ ^ ) = [ , ; < # & _ { | . : > Breaks SQL Adds Command Comments Alper Basaran - basaranalper@gmail.com
  • 32.
    Hostile Data • Mostlycharacters but also any data that can make the app do something it shouldn’t • Special characters • File types • File metadata • Headers • ... Alper Basaran - basaranalper@gmail.com
  • 33.
    How do wefuzz? Fuzzer Target Request 1 Expected response (e.g. 404) Request 2 Unexpected response (e.g. 503) Request n Unexpected response (No response) Alper Basaran - basaranalper@gmail.com
  • 34.
    How do wefuzz? • Fuzzing phases: 1. Identify targets 2. Identify inputs 3. Generate data 4. Execute 5. Monitor anomalies 6. Check exploitability 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 35.
    How do wefuzz? • Fuzzing phases: 1 - Identify targets • Parameters (GET and POST) • Google 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 36.
    How do wefuzz? • Fuzzing phases: 1 - Identify targets • Google Hacking • https://www.exploit-db.com/google-hacking-database • GH is interested in results, we look for inputs • E.g. php?id= 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 37.
    How do wefuzz? • Fuzzing phases: 2 - Identify inputs • What is the app «normally» expecting 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 38.
    How do wefuzz? • Fuzzing phases: 3 - Generate data • Fuzzing payloads 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 39.
    How do wefuzz? • Fuzzing phases: 4 - Execute • Fuzz ☺ • Fuzz  • Fuzz ... 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 40.
    How do wefuzz? • Fuzzing phases: 5 - Monitor anomalies • What would the «normal» response be? • Is there anything different in the response? • HTTP code? • Response size? • Error? 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 41.
    How do wefuzz? • Fuzzing phases: 6 - Check exploitability • So? • How can we exploit this? 1 - Identify targets 2 - Identify inputs 3 - Generate data 4 - Execute 5 - Monitor anomalies 6 - Check exploitability Alper Basaran - basaranalper@gmail.com
  • 42.
    How do wefuzz? • Fuzzing web applications: 1. Find data entry points • Anything sent from the client 2. Generate payload list • Long • Odd characters (encoded) • Special characters (new line character, line feed, etc.) 3. Fuzz 4. Detect anomalies 5. Check exploitation Alper Basaran - basaranalper@gmail.com
  • 43.
    What do wefuzz? • Short answer: Everything! • GET data • POST data • User agent • Cookies • File metadata • etc... Alper Basaran - basaranalper@gmail.com
  • 44.
    What do wefuzz? • GET • Host • User-Agent • Accept • Accept-Language • Accept-Encoding • Connection • Cookie • Upgrade-Insecure-Requests Alper Basaran - basaranalper@gmail.com
  • 45.
    A Few Reminders AlperBasaran - basaranalper@gmail.com
  • 46.
    HTTP Requests Alper Basaran- basaranalper@gmail.com Request Response
  • 47.
    Special Characters inURLs • #: Anchor (or %23) • ?: Query string (or %3F) • &: Seperating query elements (or %26) • +: Space (or %2B) • https://www.w3schools.com/tags/ref_urlencode.asp Alper Basaran - basaranalper@gmail.com
  • 48.
    HTTP Methods • HTTPworks as a communication protocol between clients and servers • HTTP methods defines the type of the request made by the client • You’ll mostly see; • GET • POST Alper Basaran - basaranalper@gmail.com
  • 49.
    HTTP Methods • Youmight also see: • GET • POST • PUT • HEAD • DELETE • PATCH • OPTIONS Alper Basaran - basaranalper@gmail.com
  • 50.
    HTTP Methods • Butwe are fuzzers! • so; ACL GET MKCOL PRI UNBIND BASELINE-CONTROL HEAD MKREDIRECTREF PROPFIND UNCHECKOUT BIND LABEL MKWORKSPACE PROPPATCH UNLINK CHECKIN LINK MOVE PUT UNLOCK CHECKOUT LOCK OPTIONS REBIND UPDATE CONNECT MERGE ORDERPATCH REPORT UPDATEREDIRECTREF COPY MKACTIVITY PATCH SEARCH VERSION-CONTROL DELETE MKCALENDAR POST TRACE Alper Basaran - basaranalper@gmail.com
  • 51.
    HTTP Response Codes •1xx informational response: The request was received, continuing process • 2xx successful: The request was successfully received, understood, and accepted • 3xx redirection: Further action needs to be taken in order to complete the request • 4xx client error: The request contains bad syntax or cannot be fulfilled • 5xx server error: The server failed to fulfil an apparently valid request Alper Basaran - basaranalper@gmail.com
  • 52.
    Input / OutputValidation • Application should distinguish between a valid input and a malformed input • Application should NOT trust the user • Input fields are not the only way to send data to the server • Anything on the HTTP connection can be an input Alper Basaran - basaranalper@gmail.com
  • 53.
    Input / OutputValidation • Two main approaches: • Blacklist: • Don’t accept these: • <script> • ‘ or ‘1’=‘1 • Whitelist: • Only accept these • [a-z] • [0-9] Alper Basaran - basaranalper@gmail.com Client Side Server Side Input Validation
  • 54.
    Tools: HTTP HeadersLive Alper Basaran - basaranalper@gmail.com
  • 55.
    Tools: Cookie QuickManager Alper Basaran - basaranalper@gmail.com
  • 56.
    Tools: Burp Suite AlperBasaran - basaranalper@gmail.com
  • 57.
    Tools: Burp Suite AlperBasaran - basaranalper@gmail.com
  • 58.
    Tools: Burp Suite AlperBasaran - basaranalper@gmail.com
  • 59.
    Tools: Burp Suite •Sniper: Uses a single set of payloads. • Battering ram: Uses a single set of payloads. It iterates through the payloads and places the same payload into all of the defined payload positions at once. • Pitchfork: Uses multiple payload sets. There is a different payload set for each defined position (up to a maximum of 20). The attack iterates through all payload sets simultaneously, and places one payload into each defined position. • Cluster bomb: Uses multiple payload sets. There is a different payload set for each defined position (up to a maximum of 20). The attack iterates through each payload set in turn, so that all permutations of payload combinations are tested. Alper Basaran - basaranalper@gmail.com
  • 60.
    Tools: Burp Suite source:http://www.iana.org/assignments/http-methods/http-methods.xhtmlAlper Basaran - basaranalper@gmail.com
  • 61.
    Tools: Burp Suite AlperBasaran - basaranalper@gmail.com
  • 62.
    • Method: ACL •Response: 501 (Not Implemented) • Server: AkamaiGHost Tools: Burp Suite Alper Basaran - basaranalper@gmail.com
  • 63.
    • Method: BIND •Response: 400 (Bad Request) • Server: AkamaiGHost Tools: Burp Suite Alper Basaran - basaranalper@gmail.com
  • 64.
    • Method: OPTIONS •Response: 500 (Internal Server Error) • Server: istio-envoy Tools: Burp Suite Alper Basaran - basaranalper@gmail.com
  • 65.
    So? • Can youuse this to «crash» the server? • Can you use this to enumerate further? Alper Basaran - basaranalper@gmail.com
  • 66.
    Tools: Wfuzz Alper Basaran- basaranalper@gmail.com
  • 67.
    Tools: Wfuzz • Basicusage: • wfuzz –w wordlist http://www.target.com/FUZZ Alper Basaran - basaranalper@gmail.com
  • 68.
    Tools: Wfuzz • wfuzz-w wordlist.txt https://www.apple.com/FUZZ • We can add: • --hc: To hide specific response • -f: to save results to a file Alper Basaran - basaranalper@gmail.com
  • 69.
    Tools: Wfuzz -v Alper Basaran- basaranalper@gmail.com
  • 70.
    Tools: Wfuzz --follow Alper Basaran- basaranalper@gmail.com
  • 71.
    Tools: Wfuzz • Let’slogin • Tools we’ll need: • Cewl • Wfuzz Alper Basaran - basaranalper@gmail.com
  • 72.
    Tools: Wfuzz • Cewlwill parse the target page and generate a wordlist Alper Basaran - basaranalper@gmail.com
  • 73.
    Tools: Wfuzz • We’lluse the wordlist generated by Cewl to bruteforce login • and a Wfuzz payload Alper Basaran - basaranalper@gmail.com
  • 74.
    Tools: Wfuzz • wfuzz-c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login" - v http://192.168.19.140/dvwa/login.php • -c: Color • -z: • -d: • -v: verbose Alper Basaran - basaranalper@gmail.com
  • 75.
    Tools: Wfuzz • wfuzz-c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login" http://192.168.19.140/dvwa/login.php • -c: Color • -z: Payload • -d: Data sent in POST • So? Could we login? Alper Basaran - basaranalper@gmail.com
  • 76.
    Tools: Wfuzz • wfuzz-c -z file,wordlist.txt -d "username=admin&password=FUZZ&Login=Login" http://192.168.19.140/dvwa/login.php • -c: Color • -z: Payload • -d: Data sent in POST • So? Could we login? • Add -v (verbose) Alper Basaran - basaranalper@gmail.com
  • 77.
    Tools: Wfuzz --verbose Alper Basaran- basaranalper@gmail.com
  • 78.
    Tools: Wfuzz • Directoryenumeration --hc 404 Alper Basaran - basaranalper@gmail.com
  • 79.
    Tools: Wfuzz • SQLinjection login bypass Alper Basaran - basaranalper@gmail.com
  • 80.
    Tools: Wfuzz Alper Basaran- basaranalper@gmail.com
  • 81.
    Tools: Wfuzz • wfuzz-w /usr/share/wordlists/wfuzz/Injections/SQL.txt -d "uid=FUZZ&passw=FUZZ&btnSubmit=Login" -v http://www.altoromutual.com:8080/doLogin Alper Basaran - basaranalper@gmail.com
  • 82.
    Tools: Wfuzz • wfuzz-w /usr/share/wordlists/wfuzz/Injections/SQL.txt -b="security=low; PHPSESSID=c8e5524009676cedd43acbfdde12ea52" http://192.168.19.140/dvwa/vulnerabilities/sqli/?id=FUZZ&Submit=Submit# • -w /usr/share/wordlists/wfuzz/Injections/SQL.txt • -b="security=low; PHPSESSID=c8e5524009676cedd43acbfdde12ea52" Alper Basaran - basaranalper@gmail.com
  • 83.
    Tools: Wfuzz Alper Basaran- basaranalper@gmail.com
  • 84.
    Tools: OWASP ZAP AlperBasaran - basaranalper@gmail.com
  • 85.
    Fuzzing methods • Fuzzingpayloads • Pregenerated • Random Alper Basaran - basaranalper@gmail.com
  • 86.
    3. Fuzzing approaches a)Test case-based fuzzing b) Random fuzzing c) Using existing fuzzing payloads d) Generating a specific payload list Alper Basaran - basaranalper@gmail.com
  • 87.
    3. Fuzzing approaches a)Test case-based fuzzing b) Random fuzzing c) Using existing fuzzing payloads d) Generating a specific payload list Smart: «Thinking about what to send» Dumb: «Send everything but the kitchen sink» Alper Basaran - basaranalper@gmail.com
  • 88.
    Case Based Fuzzing •Understanding «what can be» and fuzzing accordingly Alper Basaran - basaranalper@gmail.com
  • 89.
    Fuzzing: OWASP Top10 2020 1. SQL injection 2. Broken Authentication. 3. Sensitive Data Exposure. 4. XML External Entities (XXE). 5. Broken Access Control. 6. Security Misconfiguration 7. Cross-Site Scripting XSS. 8. Insecure Deserialization. 9. Using Components with Known Vulnerabilities. 10. Insufficient Logging & Monitoring. Alper Basaran - basaranalper@gmail.com
  • 90.
    Case Based Fuzzing 1.SQL injection: a) A web application connected to a database b) An input sending a query to the database c) A visible (or invisible) output Alper Basaran - basaranalper@gmail.com
  • 91.
    Case Based Fuzzing 2.Broken Authentication. a) Permits automated attacks such as credential stuffing b) Permits brute force or other automated attacks. c) Permits weak passwords, such as”Password1″ or “admin/admin.″ d) Uses weak or ineffective credential recovery and forgot-password processes (e.g. what is your date of birth). e) Uses plain text, encrypted, or weakly hashed passwords. f) Has missing or ineffective multi-factor authentication. g) Exposes session IDs in the URL (e.g., URL rewriting). h) Does not rotate session IDs after successful login. i) Does not properly invalidate session IDs. User sessions or authentication tokens (particularly single sign-on (SSO) tokens) aren’t properly invalidated during logout or a period of inactivity. Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 92.
    Case Based Fuzzing 3.Sensitive Data Exposure • Via stored or transmitted data a) Credentials b) Credit card numbers c) Social Security Numbers d) Medical information e) Personally identifiable information (PII) f) Other personal information Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 93.
    Case Based Fuzzing 4.XML External Entities (XXE). • Via stored or transmitted data a) Vulnerable XML processors if malicious actors can upload XML or include hostile content in an XML document b) Vulnerable code c) Vulnerable dependencies d) Vulnerable integrations Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 94.
    Case Based Fuzzing 5.Broken Access Control • e.g. access admin login page a) Access to a hosting control / administrative panel b) Access to a server via FTP / SFTP / SSH c) Access to a website’s administrative panel d) Access to other applications on your server e) Access to a database Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 95.
    Case Based Fuzzing 6.Security Misconfiguration • e.g. default CMS configuration a) Unpatched flaws b) Default configurations c) Unused pages d) Unprotected files and directories e) Unnecessary services Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 96.
    Case Based Fuzzing 7.Cross-Site Scripting XSS • Most common vulnerability? a) Must take input b) Must include input in response source code c) Also must have login/session Alper Basaran - basaranalper@gmail.com
  • 97.
    Case Based Fuzzing 8.Insecure Deserialization • Convert object to byte strings: serialization • Convert byte strings to objects: deserialization • Cookie contains BASE64 encoded of «user:Alice,privilege:user» (dXNlcjpBbGljZSxwcml2aWxlZ2U6dXNlcg==) • Can it be changed to «user:Alice,privilege:admin» (dXNlcjpBbGljZSxwcml2aWxlZ2U6YWRtaW4=) a) Deserialize an object b) Modify the object c) Serialize it again Source: https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2020/ Alper Basaran - basaranalper@gmail.com
  • 98.
    Case Based Fuzzing 9.Using Components with Known Vulnerabilities Alper Basaran - basaranalper@gmail.com
  • 99.
    Case Based Fuzzing 9.Using Components with Known Vulnerabilities Alper Basaran - basaranalper@gmail.com
  • 100.
    Random Fuzzing • «Everythingbut the kitchen sink» Alper Basaran - basaranalper@gmail.com
  • 101.
    Random Fuzzing • Wfuzzwordlists Alper Basaran - basaranalper@gmail.com
  • 102.
  • 103.
  • 104.
    Generating a Wordlist •Cewl • Crunch 4 4 1234 • crunch 9 9 -t @@@@1107! • @ letter • , capital letter • % number • ^ special char • wget, cat, grep, cut, sort ☺ Alper Basaran - basaranalper@gmail.com
  • 105.