proxmox: turnkey RDP exposure for the Kali seats
kali rdp writes one systemd unit per seat (3381..338N) forwarding to the seat's 3389, and rdp-off removes them. The xrdp bake now pulls xorgxrdp, uses LAB_HOST_IP for the temporary proxy instead of a hardcoded address, and restores any pre-existing squid configuration afterwards. Docs use the command instead of a manual socat loop and mention the PVE firewall.
This commit is contained in:
+1
-1
@@ -143,7 +143,7 @@ Tout ce que demande l'atelier est déjà dans l'image, et la liste de mots arriv
|
|||||||
d'outils.
|
d'outils.
|
||||||
|
|
||||||
`KALI_XRDP=1` (par défaut) installe `xrdp` dans le gabarit pour ceux qui veulent un bureau
|
`KALI_XRDP=1` (par défaut) installe `xrdp` dans le gabarit pour ceux qui veulent un bureau
|
||||||
graphique via un client RDP ; voir `docs/instructeur.md` pour exposer les ports.
|
graphique via un client RDP. `./lab.sh kali rdp` expose un port par siège (3381, 3382…).
|
||||||
|
|
||||||
## Participants
|
## Participants
|
||||||
|
|
||||||
|
|||||||
@@ -222,18 +222,18 @@ Avec `KALI_XRDP=1` (valeur par défaut), `xrdp` est installé **dans le gabarit*
|
|||||||
paquet, puis arrête et désactive le proxy. Chaque clone — et chaque `kali reset` — garde donc
|
paquet, puis arrête et désactive le proxy. Chaque clone — et chaque `kali reset` — garde donc
|
||||||
xrdp.
|
xrdp.
|
||||||
|
|
||||||
Pour donner RDP aux participants, exposez un port par siège sur l'hôte :
|
Pour donner RDP aux participants, exposez un port par siège — une unité systemd par port, donc
|
||||||
|
persistante :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apt install -y socat
|
apt install -y socat
|
||||||
for i in 1 2 3 4 5; do
|
./lab.sh kali rdp # 3381 … 338N, un port par siège
|
||||||
socat TCP-LISTEN:$((3380+i)),fork,reuseaddr TCP:10.10.10.$((40+i)):3389 &
|
./lab.sh kali rdp-off # retire les redirections
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Un client RDP sur `<hôte>:3381` … `:3385`, utilisateur `kali`, mot de passe `kali`. Comme pour
|
Un client RDP sur `<hôte>:3381` … `:3385`, utilisateur `kali`, mot de passe `kali`. La commande
|
||||||
SSH, ces redirections ne survivent pas à un redémarrage : recréez-les ou passez par des unités
|
imprime la correspondance siège → port et le nom d'hôte à utiliser. Si le pare-feu Proxmox est
|
||||||
systemd.
|
actif, ouvrez ces ports vers votre réseau de participants.
|
||||||
|
|
||||||
SSH reste disponible sur les sièges (port 22) et donne un terminal sans passer par une session
|
SSH reste disponible sur les sièges (port 22) et donne un terminal sans passer par une session
|
||||||
graphique.
|
graphique.
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ _px_kali_bake_xrdp() {
|
|||||||
&& cp /etc/squid/squid.conf /root/squid.conf.norbourg
|
&& cp /etc/squid/squid.conf /root/squid.conf.norbourg
|
||||||
|
|
||||||
cat >/etc/squid/squid.conf <<EOF
|
cat >/etc/squid/squid.conf <<EOF
|
||||||
http_port 10.10.10.1:3128
|
http_port ${LAB_HOST_IP:-10.10.10.1}:3128
|
||||||
acl lab src ${probe}/32
|
acl lab src ${probe}/32
|
||||||
http_access allow lab
|
http_access allow lab
|
||||||
http_access deny all
|
http_access deny all
|
||||||
@@ -538,11 +538,11 @@ set -e
|
|||||||
iface=\$(ip -o link show | awk -F': ' '\$2 != "lo" && \$2 !~ /^docker/ {print \$2; exit}')
|
iface=\$(ip -o link show | awk -F': ' '\$2 != "lo" && \$2 !~ /^docker/ {print \$2; exit}')
|
||||||
ip addr add ${probe}/24 dev "\$iface" || true
|
ip addr add ${probe}/24 dev "\$iface" || true
|
||||||
ip link set "\$iface" up
|
ip link set "\$iface" up
|
||||||
ip route replace 10.10.10.1/32 dev "\$iface" src ${probe}
|
ip route replace ${LAB_HOST_IP:-10.10.10.1}/32 dev "\$iface" src ${probe}
|
||||||
printf 'Acquire::http::Proxy "http://10.10.10.1:3128";\n' > /etc/apt/apt.conf.d/99proxy
|
printf 'Acquire::http::Proxy "http://${LAB_HOST_IP:-10.10.10.1}:3128";\n' > /etc/apt/apt.conf.d/99proxy
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
apt-get install -y -qq xrdp
|
apt-get install -y -qq xrdp xorgxrdp
|
||||||
rm -f /etc/apt/apt.conf.d/99proxy
|
rm -f /etc/apt/apt.conf.d/99proxy
|
||||||
if [ -d /home/kali ]; then
|
if [ -d /home/kali ]; then
|
||||||
echo startxfce4 > /home/kali/.xsession
|
echo startxfce4 > /home/kali/.xsession
|
||||||
@@ -567,6 +567,9 @@ GUEST
|
|||||||
pve_running "$tpl" && qm stop "$tpl" >/dev/null 2>&1 || true
|
pve_running "$tpl" && qm stop "$tpl" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
systemctl disable --now squid >/dev/null 2>&1 || true
|
systemctl disable --now squid >/dev/null 2>&1 || true
|
||||||
|
if [[ -f /root/squid.conf.norbourg ]]; then
|
||||||
|
mv -f /root/squid.conf.norbourg /etc/squid/squid.conf
|
||||||
|
fi
|
||||||
ok "xrdp installed in the Kali template"
|
ok "xrdp installed in the Kali template"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,6 +825,39 @@ cmd_kali() {
|
|||||||
_px_kali_configure "$vmid" "kali-$(printf '%02d' "$i")" "$(kali_ip "$i")" || true
|
_px_kali_configure "$vmid" "kali-$(printf '%02d' "$i")" "$(kali_ip "$i")" || true
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
rdp)
|
||||||
|
have_cmd socat || die "socat required (apt install socat)"
|
||||||
|
local host; host=${PVE_WEB_HOST:-$(hostname -f 2>/dev/null || hostname)}
|
||||||
|
local unit
|
||||||
|
for i in $(seq 1 "$count"); do
|
||||||
|
pve_exists "$(kali_vmid "$i")" || { warn "kali-$(printf '%02d' "$i") does not exist — ./lab.sh kali install"; continue; }
|
||||||
|
unit="/etc/systemd/system/norbourg-kali-rdp-$i.service"
|
||||||
|
cat > "$unit" <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Norbourg Kali seat $i (RDP)
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/socat TCP-LISTEN:$((3380 + i)),fork,reuseaddr TCP:$(kali_ip "$i"):3389
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now "norbourg-kali-rdp-$i" >/dev/null 2>&1 \
|
||||||
|
|| { warn "could not start the forward for kali-$(printf '%02d' "$i")"; continue; }
|
||||||
|
ok "$(printf 'kali-%02d rdp://%s:%s (kali/kali)' "$i" "$host" "$((3380 + i))")"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
rdp-off)
|
||||||
|
for i in $(seq 1 "$count"); do
|
||||||
|
systemctl disable --now "norbourg-kali-rdp-$i" >/dev/null 2>&1 || true
|
||||||
|
rm -f "/etc/systemd/system/norbourg-kali-rdp-$i.service"
|
||||||
|
done
|
||||||
|
systemctl daemon-reload
|
||||||
|
ok "RDP forwards removed"
|
||||||
|
;;
|
||||||
reset)
|
reset)
|
||||||
for i in $(seq 1 "$count"); do
|
for i in $(seq 1 "$count"); do
|
||||||
local vmid; vmid=$(kali_vmid "$i")
|
local vmid; vmid=$(kali_vmid "$i")
|
||||||
@@ -833,7 +869,7 @@ cmd_kali() {
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
info "usage: ./lab.sh kali install|up|down|status|configure|reset"
|
info "usage: ./lab.sh kali install|up|down|status|configure|rdp|rdp-off|reset"
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user