OSCP Capstone Lab Writeup - SQLi Module - Alvida-Eatery

 

Take a look

Website Content Analysis:

Accessed the website (http://192.168.139.47:80)

 

  • Website Content Analysis:
    • Displays bakery goods and coffee products

    • Static content only

    • No interactive elements found:

      • No search functionality

      • No login forms

      • No input fields

    Initial Assessment:

    • Limited attack surface due to lack of user input fields

    • Traditional injection techniques not immediately applicable

    • Need to explore alternative entry points

    Further Website Exploration: 

  • Located and clicked on alvida-eatery.org link within the main website
http://www6.alvida-eatery.org/lander?template=ARROW_3&tdfs=0&s_token=1731789108.0467710000&uuid=1731789108.0467710000&term=Caterer%20Menu&term=Lunch%20Catering&term=Restaurant%20Table%20Reservations%20Online&searchbox=0&showDomain=0&backfill=0

  • Attempted SQLMap injection on URL parameters:

  • Targeted 'uuid' parameter

  • Result: 403 Forbidden error received 

Initial Attack Attempts:

Hint Analysis:
  • Hint suggests binding IP address to website domain

  • This indicates potential DNS/host file configuration requirement 



Host File Configuration:

  • Updated /etc/hosts file to bind target IP (192.168.139.47) to alvida-eatery.org domain


Post-Configuration Testing:

YES! The website transformation was incredible after the host file update, a juicy search functionality appeared (potential SQLi goldmine!)



SQLi Attempt Analysis(can be ignored):

  • Eagerly launched SQLMap against the search box parameter:

  • Ugh, hit with a 403 Forbidden error (so close!)

  • No SQL injection vectors found (disappointing but won't give up!)

  • Determined to find a way in, I tried more parameters:

  • The 'cat' parameter looked promising...but no luck

  • 'page_id' parameter was another dead end

  • Frustrating results, but each failed attempt brings me closer to success





Source Code Analysis

WordPress Discovery and Exploitation:

  • checked the source code, I spotted WordPress signatures in the source code.






Treasure Hunting

Then I did a wpscan for the website, find some plugins on it.





  • With renewed energy, I launched a targeted sqlmap scanning against WordPress admin-ajax.php:


sqlmap -u "http://alvida-eatery.org/wp-admin/admin-ajax.php?action=get_question&question_id=1" -p 'question_id' -D wordpress -T wp_users --dump --technique=T --flush-session --ignore-code=404 --level=5 --risk=3

  • The anticipation was killing me during the long SQLMap runs...

  • JACKPOT! 🎉 Successfully extracted user credentials:

  • Username: admin

  • Password hash: [redacted WordPress hash with salt]



  • Hands trembling with excitement, I fired up John the Ripper:

  •    john --wordlist=/usr/share/wordlists/rockyou.txt wp_hash.txt

  • YES! YES! YES! Password cracked successfully!

  • That moment when the hash finally cracked - pure penetration testing euphoria! 🚀



After successfully logging in with the cracked credentials, I accessed the WordPress admin dashboard - a whole new world of possibilities!



With methodical precision, I conducted thorough reconnaissance of the admin interface while researching WordPress vulnerabilities. A promising attack vector emerged: the plugin upload functionality could potentially be leveraged for a reverse shell. The anticipation built as I formulated my plan.

Reverse shell

Working carefully, I crafted a PHP reverse shell, packaged it into a ZIP file, and attempted to upload it as a plugin. While I could see it in the uploads section, the system required admin approval via email verification - a potential roadblock.









Undeterred, I attempted to modify the admin email to my own address to intercept the verification, but despite multiple attempts and checking both inbox and spam folders, no verification email arrived. A setback, but not the end of the road.



During my exploration of the WordPress plugins, my eyes lit up when I discovered several inactive plugins - a potential goldmine for exploitation! With calculated precision, I initially targeted the inactive Akismet plugin, attempting to modify it for a reverse shell.





However, access was denied with a forbidden error.



Then, I devised a new strategy. Noticing that active plugins were locked down, I methodically deactivated the Perfect Survey plugin, modified its code to include my reverse shell payload, and reactivated it. The moment of truth came when I tested it - success! My pulse quickened as the reverse shell connection established.


With growing excitement but maintaining professional focus, I began enumerating the system. A quick 'ls' command revealed the website directory structure. Following my instincts, I traversed up the directory tree using 'ls ../../../' and discovered additional files.

My persistence paid off when I spotted flag.txt at the bottom of the listing. With steady hands, I executed 'cat flag.txt' and there it was - mission accomplished!








Popular posts from this blog

Phonebook - Hack the box Write up -- Web LDAP injection

wafwaf -- Hack The Box -- Web SQL injection

Cheat sheet for security+