SQLMap — TryHackMe WriteUp
Learn about and use Sqlmap to exploit the web application
Sqlmap is an open source penetration testing tool developed by Bernardo Damele Assumpcao Guimaraes and Miroslav Stampar that automates the process of detecting and exploiting SQL injection flaws and taking over database servers. It comes with a powerful detection engine, many niche features for the ultimate penetration tester, and a broad range of switches lasting from database fingerprinting, fetching data from the database, to accessing the underlying file system and executing commands on the operating system via out-of-band connections.
Started by running the default Nmap scan
I found port 80 to be open.
I then ran the service scan and default script scan
I accessed the website and found out this
Next I ran the Gobuster tool to find any available directories. I found /blood.
It had a login page and registration. I click on the login and then use Burpsuite to intercept the login page and save it to a TXT file
We now use SQLMap to enumarate the Databases for Usernames, Passwords and all data that can be found in it.
Get Wilklins Nyatteng’s stories in your inbox
Join Medium for free to get updates from this writer.
To enumerate for current database
We find the DB to be blood
Now that we know the name of the Database we look for tables available in the DB
Now that we are interested in the flag table. We run the dump command to find its details
Conclusion
Mitigating against exploiting SQL injection flaws and protecting database servers is crucial for maintaining data security and preventing unauthorized access. You need consider:
- Implementing Input Validation and Parameterized Queries: Apply stringent input validation techniques to sanitize user inputs and eliminate potentially malicious SQL statements. Utilize parameterized queries or prepared statements to ensure that user inputs are treated as data rather than executable code.
- Applying Principle of Least Privilege: Restrict database user privileges to the minimum required for their respective tasks. Avoid using privileged accounts for routine operations and assign specific access rights based on user roles. This limits the potential damage an attacker can inflict even if they manage to exploit an SQL injection flaw.
- Regularly Updating and Patching Database Software: Keep the database management system (DBMS) software up to date with the latest security patches. Stay informed about vulnerabilities and exploits related to the specific DBMS and promptly apply relevant patches to protect against known attack vectors.
- Employ Web Application Firewalls (WAFs): Implement a WAF that is capable of detecting and blocking SQL injection attempts. WAFs can analyze incoming requests, identify suspicious SQL statements, and prevent them from reaching the database server. This adds an additional layer of defense against SQL injection attacks.
- Conducting Regular Security Audits and Penetration Testing: Perform comprehensive security audits and penetration tests on your application and database infrastructure. Engage with experienced security professionals to identify and address any existing vulnerabilities or weaknesses. Regular testing helps in proactively identifying SQL injection flaws and taking appropriate mitigation measures.
By following these key points, organizations can significantly reduce the risk of SQL injection attacks and ensure the integrity and security of their database servers. It is essential to adopt a proactive approach to security, keeping up with the latest best practices and staying vigilant against emerging threats.




![[IronHold] — Spring Boot Source Code Analysis: Finding Credentials, SQL Injection, PrivEsc, and…](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*2yaTo73YRGo1GknAUJNfPg.jpeg)




