ThePorgs / Exegol

Fully featured and community-driven hacking environment
https://exegol.readthedocs.io/
GNU General Public License v3.0
1.95k stars 191 forks source link

Wayland support #200

Closed QU35T-code closed 9 months ago

QU35T-code commented 10 months ago

Description

Hey @Dramelac,

Here's an addition to set the correct environment variables for wayland. I started with this observation:

docker run -it -e XDG_RUNTIME_DIR=/tmp -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY debian bash
➜  ~ echo $WAYLAND_DISPLAY
wayland-1
[*] Location of the exegol workspace on the host : /home/qu35t/.exegol/workspaces/htb
[+] Opening shell in Exegol 'htb'
[-] The xhost command is not available on your host. Exegol was unable to allow your container to access your graphical environment (or you don't have one).
[Jan 26, 2024 - 21:53:47 (CET)] exegol-htb /workspace # firefox
Authorization required, but no authorization protocol specified

Error: cannot open display: :0

I've modified the code to add a check on the display server and return the correct environment variables if this is the case. There's one step missing (and I'm struggling):

You need to add a volume:

-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY

With my modifications, the following command works: (the xhost warning must also be removed)

(venv) ➜  Exegol git:(wayland) python3 exegol.py start -V $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY wayland2
[*] Exegol is currently in version v4.3.1
[*] Exegol Discord serv.: https://discord.gg/cXThyp7D6P
[*] Exegol documentation: https://exegol.rtfd.io/
[+] We thank Capgemini for supporting the project (helping with dev) πŸ™
[+] We thank HackTheBox for sponsoring the multi-arch support πŸ’š
[*] Starting exegol
[*] Arguments supplied with the command, skipping interactive mode

πŸ›Έ Available images
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Image tag β”‚ Size    β”‚ Status                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ nightly   β”‚ 50.5GB  β”‚ Up to date (v.58d605bb) β”‚
β”‚ web       β”‚ ~23.5GB β”‚ Not installed           β”‚
β”‚ osint     β”‚ ~13.3GB β”‚ Not installed           β”‚
β”‚ light     β”‚ ~14.2GB β”‚ Not installed           β”‚
β”‚ full      β”‚ ~55.3GB β”‚ Not installed           β”‚
β”‚ ad        β”‚ ~40.4GB β”‚ Not installed           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

[*] You can use a name that does not already exist to build a new image from local sources
[?] Select an image by its name (nightly):

⭐ Container summary
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             Name β”‚ wayland2                                  β”‚
β”‚            Image β”‚ nightly - v.58d605bb (Up to date)         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Credentials β”‚ root : oq3PEox5VLkNHpCRulmhJL0Pay0pTI     β”‚
β”‚          Desktop β”‚ Off πŸͺ“                                    β”‚
β”‚              X11 β”‚ On βœ”                                      β”‚
β”‚          Network β”‚ host                                      β”‚
β”‚         Timezone β”‚ On βœ”                                      β”‚
β”‚ Exegol resources β”‚ On βœ” (/opt/resources)                     β”‚
β”‚     My resources β”‚ On βœ” (/opt/my-resources)                  β”‚
β”‚    Shell logging β”‚ Off πŸͺ“                                    β”‚
β”‚       Privileged β”‚ Off βœ”                                     β”‚
β”‚        Workspace β”‚ Dedicated (/workspace)                    β”‚
β”‚          Volumes β”‚ /run/user/1000/wayland-1 ➑ /tmp/wayland-1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

[*] Creating new exegol container
[+] Exegol container successfully created !
[-] The xhost command is not available on your host. Exegol was unable to allow your container to access your graphical environment (or you don't have one).
[*] Location of the exegol workspace on the host : /home/qu35t/.exegol/workspaces/wayland2
[+] Opening shell in Exegol 'wayland2'
[Jan 26, 2024 - 22:56:19 (CET)] exegol-wayland2 /workspace #
[Jan 26, 2024 - 22:57:14 (CET)] exegol-wayland2 /workspace # env|grep -i wayland
HOSTNAME=exegol-wayland2
WAYLAND_DISPLAY=wayland-1
DISPLAY=wayland-1

image

Dramelac commented 9 months ago

The PR is incomplete, but it's already a very good start, and I'm taking over the rest internally on the repo. Thank you very much!