Posts

Showing posts from December, 2020

wafwaf -- Hack The Box -- Web SQL injection

Image
0x00 Problem 0x01 Check the Source Code We open the website and only see the source code on the website. As we can see, there is a WAF will filter some characters and words, that means the normal injection will not work. However, we can see, there is a json_decode() function will decode JSON data, that means the data can be accepted should be JSON format.  The example JSON format data is like: /u0074, /u0075. In addition, there is a "php://input",  accesses the read-only stream of the requested raw data, executing the data in the post request as PHP code. 0x02 Local Test We can launch an Apache server to test it. I copy the source code and make a little change to test this. This file is in /var/www/html. We will construct the data first. This time I use 'select' as an example. The word transfer to ASCII, then to hex, then replace the '\0x' as '\u00'. This can be test in the browser console. At the end, we can test it with curl . As we can see, the SQL...

Time-based SQLMap and Tamper scripts construct

Image
Types of SQLMap: Boolean-based blind:  replaces or appends to the affected parameter in the HTTP request. Alternatively , the user can provide a string or regular expression to match on True pages. Time-based blind:   For each HTTP response, by making a comparison between the HTTP response time with the original request, the tool inference the output of the injected statement character by character.   Error-based:   This technique works only when the web application has been configured to disclose back-end database management system error messages. UNION query-based: UNION ALL SELECT, execute the for loop http://178.62.0.100:32104/portfolio.php?id=1 union all select 1,load_file("/var/www/html/administrat/panel.php),3--  Stacked queries : piggybacking.  it appends to the affected parameter in the HTTP request, a semi-colon ( ; ) followed by the SQL statement to be executed. Time-based blind injection:  How time-based blind injection works? The function ...

FreeLancer - Hackthebox Write up - Web SQL injection

Image
0x00 Problem: 0x01 Check the vulnerability We open the website, there is a login form, it might be SQL injection, LDAP injection or XSS.    Then we can check the source file to find if there is any vulnerability. Luckily we found a file named portfolio.php , and it has an id parameter.  I tried to open this file with id=1 in the web browser. It returns a picture and some words. Then I change id to other numbers, it also returns to different words. So it might have SQL injection vulnerability. 0x02 Find the database and table Here is my payload to check the database: sqlmap -u http://178.62.0.100:32104/portfolio.php?id=2 -dbs Below is the result:  The first red box shows it truly has SQL injection vulnerability and give us the test payload which we can exploit. The second red box shows the database we found. 0x03 Dump the data  Here is my payload, we choose freelance as our target database: sqlmap -u http://178.62.0.100:32104/portfolio.php?id=2 --dump -D freela...

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

Image
 0x00 Problem  0x01 Check the vulnerability When we see the login form on the website, it might be command injection, SQL injection, LDAP injection.  We can see that this need us to login with workstation username, it might be LDAP injection. 0x02 LDAP injection payload Here is the basic LDAP injection payload. We can check the vulnerability. user=*)(& password=*)(& --> (&(user=*)(&)(password=*)(&))  After we type it, we found the response shows successful, and return a page has search box. Then we type a character in the search box, and it returns some user phonebook information. I tried 'flag', 'HTB', it doesn't find any results. Then we try to find user 'Reese', but the information doesn't look like flag.   0x03 Locate the flag  Then we change our payload to check if the password is the flag. user=Reese password=HTB*)(& --> (&(user=Reese)(password=HTB*)(&  It can also return to the search page which means it...

Templated--Hack the Box write up -- Web SSTI

Image
0x00 Problem:  We open the website, the website shows it powered by flask/Jinja2, it might be SSTI vulnerability. 0x01 Confirm the vulnerability  We use the payload below to confirm the SSTI, it shows 16 that means this has been executed. No doubt, this is SSTI.   178.128.40.63:32031/{{4*4}} 0x02 Background  What is SSTI(server side template injection)? After the server receives the user's malicious input, it will be treated as part of the content of the Web application template without any processing. During the process of target compilation and rendering, the template engine executes the statement inserted by the user that can destroy the template, which may lead to sensitive information leakage, code execution, GetShell and other problems. Popular templates for Python: Jinja2 django:  Django uses its own template engine. We all know that Django is known for fast development, has its own good ORM, and many of its things are very coupling tornado: Tornad...

Forest- Hack The Box write up- forensics

Image
Tools: stegsolve steghide ROT13   Problem: First Step: download picture from the website Second step: find the password Use stegsolve to change color of the picture, then we find the password. Third Step: Extract files  We use steghide to extract files from the picture with the password. Fourth Step: ROT13 to crack the flag We found some message in the nothinghere.txt, it looks like caesar cipher, then we use cyberchef to get the flag Here we get the flag!