80,443 - Pentesting Web Metodologia

Tip

Ucz się i ćwicz Hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Ucz się i ćwicz Hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Ucz się i ćwicz Hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Wsparcie dla HackTricks

Podstawowe informacje

Usługa webowa jest najbardziej powszechną i rozległą usługą i istnieje wiele różnych rodzajów podatności.

Domyślny port: 80 (HTTP), 443(HTTPS)

PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  ssl/https
nc -v domain.com 80 # GET / HTTP/1.0
openssl s_client -connect domain.com:443 # GET / HTTP/1.0

Wytyczne dotyczące Web API

Web API Pentesting

Podsumowanie metodologii

W tej metodologii zakładamy, że będziesz atakować pojedynczą domenę (lub subdomenę) i tylko ją. Zastosuj tę metodologię do każdej odkrytej domeny, subdomeny lub IP z nieokreślonym web serverem w zakresie.

  • Zacznij od zidentyfikowania technologii używanych przez web server. Szukaj sztuczek, które warto mieć na uwadze podczas reszty testu, jeśli uda Ci się poprawnie zidentyfikować tech.
  • Czy istnieje jakaś znana podatność dla wersji tej technologii?
  • Używana jest jakaś znana technologia? Jakieś przydatne sztuczki do wydobycia dodatkowych informacji?
  • Czy istnieje jakiś wyspecjalizowany skaner do uruchomienia (np. wpscan)?
  • Uruchom general purposes scanners. Nigdy nie wiadomo, czy coś znajdą lub czy wyciągną jakieś interesujące informacje.
  • Rozpocznij od wstępnych kontroli: robots, sitemap, 404 error oraz SSL/TLS scan (jeśli HTTPS).
  • Zacznij spidering strony: czas znaleźć wszystkie możliwe pliki, foldery i parametry używane. Sprawdź też szczególne odkrycia.
  • Zauważ, że za każdym razem gdy nowy katalog zostanie odkryty podczas brute-forcingu lub spideringu, powinien on zostać zspiderowany.
  • Directory Brute-Forcing: Spróbuj brute-forcować wszystkie odkryte foldery w poszukiwaniu nowych plików i katalogów.
  • Zauważ, że za każdym razem gdy nowy katalog zostanie odkryty podczas brute-forcingu lub spideringu, powinien on zostać Brute-Forced.
  • Backups checking: Sprawdź, czy możesz znaleźć kopie zapasowe odkrytych plików, dopisując popularne rozszerzenia backupów.
  • Brute-Force parameters: Spróbuj odkryć ukryte parametry.
  • Gdy zidentyfikujesz wszystkie możliwe endpoints akceptujące wejście od użytkownika, sprawdź wszystkie rodzaje vulnerabilities z nimi związane.
  • Postępuj zgodnie z tą listą kontrolną

Server Version (Vulnerable?)

Identyfikacja

Sprawdź, czy istnieją znane podatności dla wersji serwera, która jest uruchomiona.
HTTP headers and cookies of the response mogą być bardzo przydatne do zidentyfikowania używanych technologii i/lub wersji. Nmap scan może zidentyfikować wersję serwera, ale przydatne mogą być też narzędzia whatweb, webtech or https://builtwith.com/:

whatweb -a 1 <URL> #Stealthy
whatweb -a 3 <URL> #Aggresive
webtech -u <URL>
webanalyze -host https://google.com -crawl 2

Search for vulnerabilities of the web application version

Check if any WAF

Web tech tricks

Kilka tricks do finding vulnerabilities w różnych dobrze znanych technologies używanych:

Weź pod uwagę, że ta same domain może używać different technologies na różnych ports, folders i subdomains.
Jeśli aplikacja webowa używa którejkolwiek z wcześniej wymienionych tech/platform listed before lub any other, nie zapomnij search on the Internet nowych trików (i daj mi znać!).

Source Code Review

Jeśli source code aplikacji jest dostępny na github, oprócz przeprowadzenia samodzielnie a White box test aplikacji, istnieją pewne informacje, które mogą być useful dla bieżącego Black-Box testing:

  • Czy istnieje plik Change-log or Readme or Version lub coś z version info accessible przez web?
  • Jak i gdzie są przechowywane credentials? Czy istnieje jakiś (dostępny?) file z credentials (usernames lub passwords)?
  • Czy passwords są w plain text, encrypted czy jaki hashing algorithm jest używany?
  • Czy używany jest jakiś master key do szyfrowania czegoś? Jaki algorithm jest używany?
  • Czy możesz access any of these files wykorzystując jakąś vulnerability?
  • Czy są jakieś interesting information in the github (solved and not solved) issues? Albo w commit history (może jakiś password introduced inside an old commit)?

Source code Review / SAST Tools

Automatic scanners

General purpose automatic scanners

nikto -h <URL>
whatweb -a 4 <URL>
wapiti -u <URL>
W3af
zaproxy #You can use an API
nuclei -ut && nuclei -target <URL>

# https://github.com/ignis-sec/puff (client side vulns fuzzer)
node puff.js -w ./wordlist-examples/xss.txt -u "http://www.xssgame.com/f/m4KKGHi2rVUN/?query=FUZZ"

Skanery CMS

Jeśli używany jest CMS, nie zapomnij uruchomić skanera — możesz znaleźć coś ciekawego:

Clusterd: JBoss, ColdFusion, WebLogic, Tomcat, Railo, Axis2, Glassfish
CMSScan: WordPress, Drupal, Joomla, vBulletin skanuje strony pod kątem problemów z bezpieczeństwem. (GUI)
VulnX: Joomla, Wordpress, Drupal, PrestaShop, Opencart
CMSMap: (W)ordpress, (J)oomla, (D)rupal lub (M)oodle
droopscan: Drupal, Joomla, Moodle, Silverstripe, Wordpress

cmsmap [-f W] -F -d <URL>
wpscan --force update -e --url <URL>
joomscan --ec -u <URL>
joomlavs.rb #https://github.com/rastating/joomlavs

Na tym etapie powinieneś mieć już pewne informacje o serwerze WWW używanym przez klienta (jeśli podano jakieś dane) oraz kilka trików do zapamiętania podczas testu. Jeśli masz szczęście, znalazłeś nawet CMS i uruchomiłeś jakiś skaner.

Krok po kroku — odkrywanie aplikacji webowej

Od tego momentu zaczniemy wchodzić w interakcję z aplikacją webową.

Wstępne sprawdzenia

Domyślne strony z ciekawymi informacjami:

  • /robots.txt
  • /sitemap.xml
  • /crossdomain.xml
  • /clientaccesspolicy.xml
  • /.well-known/
  • Sprawdź także komentarze na stronie głównej i stronach drugorzędnych.

Wymuszanie błędów

Serwery WWW mogą zachowywać się nieoczekiwanie, gdy prześle się do nich dziwne dane. To może ujawnić vulnerabilities lub spowodować ujawnienie wrażliwych informacji.

  • Access fake pages like /whatever_fake.php (.aspx,.html,.etc)
  • Add “[]”, “]]”, and “[[” w cookie values i parameter values, aby wywołać błędy
  • Wygeneruj błąd, podając jako wejście /~randomthing/%s na końcu URL
  • Spróbuj różnych HTTP Verbs jak PATCH, DEBUG lub błędnych takich jak FAKE

Sprawdź, czy możesz przesyłać pliki (PUT verb, WebDav)

Jeśli odkryjesz, że WebDav jest włączony, ale nie masz wystarczających uprawnień do uploading files w katalogu root, spróbuj:

  • Brute Force credentials
  • Upload files via WebDav do pozostałych znalezionych folderów na stronie. Możesz mieć uprawnienia do przesyłania plików w innych folderach.

SSL/TLS podatności

  • Jeśli aplikacja nie wymusza użycia HTTPS w żadnej części, to jest podatna na MitM
  • Jeśli aplikacja wysyła dane wrażliwe (hasła) przez HTTP, to jest to poważna podatność.

Użyj testssl.sh aby sprawdzić vulnerabilities (w programach Bug Bounty takie podatności prawdopodobnie nie zostaną zaakceptowane) i użyj a2sv aby ponownie sprawdzić podatności:

./testssl.sh [--htmlfile] 10.10.10.10:443
#Use the --htmlfile to save the output inside an htmlfile also

# You can also use other tools, by testssl.sh at this momment is the best one (I think)
sslscan <host:port>
sslyze --regular <ip:port>

Information about SSL/TLS vulnerabilities:

Spidering

Uruchom jakiś rodzaj spider w obrębie aplikacji webowej. Celem spidera jest znalezienie jak największej liczby ścieżek w testowanej aplikacji. Dlatego powinno się użyć crawlowania stron i źródeł zewnętrznych, aby znaleźć jak najwięcej poprawnych ścieżek.

  • gospider (go): HTML spider, LinkFinder in JS files and external sources (Archive.org, CommonCrawl.org, VirusTotal.com).
  • hakrawler (go): HML spider, with LinkFider for JS files and Archive.org as external source.
  • dirhunt (python): HTML spider, also indicates “juicy files”.
  • evine (go): Interactive CLI HTML spider. It also searches in Archive.org
  • meg (go): This tool isn’t a spider but it can be useful. You can just indicate a file with hosts and a file with paths and meg will fetch each path on each host and save the response.
  • urlgrab (go): HTML spider with JS rendering capabilities. However, it looks like it’s unmaintained, the precompiled version is old and the current code doesn’t compile
  • gau (go): HTML spider that uses external providers (wayback, otx, commoncrawl)
  • ParamSpider: This script will find URLs with parameter and will list them.
  • galer (go): HTML spider with JS rendering capabilities.
  • LinkFinder (python): HTML spider, with JS beautify capabilities capable of search new paths in JS files. It could be worth it also take a look to JSScanner, which is a wrapper of LinkFinder.
  • goLinkFinder (go): To extract endpoints in both HTML source and embedded javascript files. Useful for bug hunters, red teamers, infosec ninjas.
  • JSParser (python2.7): A python 2.7 script using Tornado and JSBeautifier to parse relative URLs from JavaScript files. Useful for easily discovering AJAX requests. Looks like unmaintained.
  • relative-url-extractor (ruby): Given a file (HTML) it will extract URLs from it using nifty regular expression to find and extract the relative URLs from ugly (minify) files.
  • JSFScan (bash, several tools): Gather interesting information from JS files using several tools.
  • subjs (go): Find JS files.
  • page-fetch (go): Load a page in a headless browser and print out all the urls loaded to load the page.
  • Feroxbuster (rust): Content discovery tool mixing several options of the previous tools
  • Javascript Parsing: A Burp extension to find path and params in JS files.
  • Sourcemapper: A tool that given the .js.map URL will get you the beatified JS code
  • xnLinkFinder: This is a tool used to discover endpoints for a given target.
  • waymore: Discover links from the wayback machine (also downloading the responses in the wayback and looking for more links)
  • HTTPLoot (go): Crawl (even by filling forms) and also find sensitive info using specific regexes.
  • SpiderSuite: Spider Suite is an advance multi-feature GUI web security Crawler/Spider designed for cyber security professionals.
  • jsluice (go): It’s a Go package and command-line tool for extracting URLs, paths, secrets, and other interesting data from JavaScript source code.
  • ParaForge: ParaForge is a simple Burp Suite extension to extract the paramters and endpoints from the request to create custom wordlist for fuzzing and enumeration.
  • katana (go): Awesome tool for this.
  • Crawley (go): Print every link it’s able to find.

Brute Force directories and files

Start brute-forcing from the root folder and be sure to brute-force all the directories found using this method and all the directories discovered by the Spidering (you can do this brute-forcing recursively and appending at the beginning of the used wordlist the names of the found directories).
Tools:

  • Dirb / Dirbuster - Included in Kali, old (and slow) but functional. Allow auto-signed certificates and recursive search. Too slow compared with th other options.
  • Dirsearch (python): It doesn’t allow auto-signed certificates but allows recursive search.
  • Gobuster (go): It allows auto-signed certificates, it doesn’t have recursive search.
  • Feroxbuster - Fast, supports recursive search.
  • wfuzz wfuzz -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt https://domain.com/api/FUZZ
  • ffuf - Fast: ffuf -c -w /usr/share/wordlists/dirb/big.txt -u http://10.10.10.10/FUZZ
  • uro (python): This isn’t a spider but a tool that given the list of found URLs will to delete “duplicated” URLs.
  • Scavenger: Burp Extension to create a list of directories from the burp history of different pages
  • TrashCompactor: Remove URLs with duplicated functionalities (based on js imports)
  • Chamaleon: It uses wapalyzer to detect used technologies and select the wordlists to use.

Recommended dictionaries:

Zwróć uwagę, że za każdym razem gdy podczas brute-forcingu lub spideringu zostanie odkryty nowy katalog, powinien on zostać Brute-Forced.

What to check on each file found

Special findings

While performing the spidering and brute-forcing you could find interesting things that you have to notice.

Interesting files

403 Forbidden/Basic Authentication/401 Unauthorized (bypass)

403 & 401 Bypasses

502 Proxy Error

If any page responds with that code, it’s probably a bad configured proxy. If you send a HTTP request like: GET https://google.com HTTP/1.1 (with the host header and other common headers), the proxy will try to access google.com and you will have found a SSRF.

NTLM Authentication - Info disclosure

If the running server asking for authentication is Windows or you find a login asking for your credentials (and asking for domain name), you can provoke an information disclosure.
Send the header: “Authorization: NTLM TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=” and due to how the NTLM authentication works, the server will respond with internal info (IIS version, Windows version…) inside the header “WWW-Authenticate”.
You can automate this using the nmap pluginhttp-ntlm-info.nse”.

HTTP Redirect (CTF)

It is possible to put content inside a Redirection. This content won’t be shown to the user (as the browser will execute the redirection) but something could be hidden in there.

Web Vulnerabilities Checking

Now that a comprehensive enumeration of the web application has been performed it’s time to check for a lot of possible vulnerabilities. You can find the checklist here:

Web Vulnerabilities Methodology

Find more info about web vulns in:

Monitor Pages for changes

You can use tools such as https://github.com/dgtlmoon/changedetection.io to monitor pages for modifications that might insert vulnerabilities.

HackTricks Automatic Commands

HackTricks Automatic Commands ```yaml Protocol_Name: Web #Protocol Abbreviation if there is one. Port_Number: 80,443 #Comma separated if there is more than one. Protocol_Description: Web #Protocol Abbreviation Spelled out

Entry_1: Name: Notes Description: Notes for Web Note: | https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-web/index.html

Entry_2: Name: Quick Web Scan Description: Nikto and GoBuster Command: nikto -host {Web_Proto}://{IP}:{Web_Port} &&&& gobuster dir -w {Small_Dirlist} -u {Web_Proto}://{IP}:{Web_Port} && gobuster dir -w {Big_Dirlist} -u {Web_Proto}://{IP}:{Web_Port}

Entry_3: Name: Nikto Description: Basic Site Info via Nikto Command: nikto -host {Web_Proto}://{IP}:{Web_Port}

Entry_4: Name: WhatWeb Description: General purpose auto scanner Command: whatweb -a 4 {IP}

Entry_5: Name: Directory Brute Force Non-Recursive Description: Non-Recursive Directory Brute Force Command: gobuster dir -w {Big_Dirlist} -u {Web_Proto}://{IP}:{Web_Port}

Entry_6: Name: Directory Brute Force Recursive Description: Recursive Directory Brute Force Command: python3 {Tool_Dir}dirsearch/dirsearch.py -w {Small_Dirlist} -e php,exe,sh,py,html,pl -f -t 20 -u {Web_Proto}://{IP}:{Web_Port} -r 10

Entry_7: Name: Directory Brute Force CGI Description: Common Gateway Interface Brute Force Command: gobuster dir -u {Web_Proto}://{IP}:{Web_Port}/ -w /usr/share/seclists/Discovery/Web-Content/CGIs.txt -s 200

Entry_8: Name: Nmap Web Vuln Scan Description: Tailored Nmap Scan for web Vulnerabilities Command: nmap -vv –reason -Pn -sV -p {Web_Port} –script=banner,(http* or ssl*) and not (brute or broadcast or dos or external or http-slowloris* or fuzzer) {IP}

Entry_9: Name: Drupal Description: Drupal Enumeration Notes Note: | git clone https://github.com/immunIT/drupwn.git for low hanging fruit and git clone https://github.com/droope/droopescan.git for deeper enumeration

Entry_10: Name: WordPress Description: WordPress Enumeration with WPScan Command: | ?What is the location of the wp-login.php? Example: /Yeet/cannon/wp-login.php wpscan –url {Web_Proto}://{IP}{1} –enumerate ap,at,cb,dbe && wpscan –url {Web_Proto}://{IP}{1} –enumerate u,tt,t,vp –passwords {Big_Passwordlist} -e

Entry_11: Name: WordPress Hydra Brute Force Description: Need User (admin is default) Command: hydra -l admin -P {Big_Passwordlist} {IP} -V http-form-post ‘/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location’

Entry_12: Name: Ffuf Vhost Description: Simple Scan with Ffuf for discovering additional vhosts Command: ffuf -w {Subdomain_List}:FUZZ -u {Web_Proto}://{Domain_Name} -H “Host:FUZZ.{Domain_Name}” -c -mc all {Ffuf_Filters}

</details>

> [!TIP]
> Ucz się i ćwicz Hacking AWS:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Ucz się i ćwicz Hacking GCP: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Ucz się i ćwicz Hacking Azure: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>Wsparcie dla HackTricks</summary>
>
> - Sprawdź [**plany subskrypcyjne**](https://github.com/sponsors/carlospolop)!
> - **Dołącz do** 💬 [**grupy Discord**](https://discord.gg/hRep4RUj7f) lub [**grupy telegramowej**](https://t.me/peass) lub **śledź** nas na **Twitterze** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
> - **Dziel się trikami hackingowymi, przesyłając PR-y do** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repozytoriów na githubie.
>
> </details>