Remove custom ports for Wordpress

This commit is contained in:
gbaconni
2021-11-09 12:27:49 +01:00
parent 4f8950e4d9
commit 525b128082
3 changed files with 16 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2021/11/02 17:47:57 by gbaconni #+# #+# # # Created: 2021/11/02 17:47:57 by gbaconni #+# #+# #
# Updated: 2021/11/09 09:40:29 by gbaconni ### ########.fr # # Updated: 2021/11/09 12:26:53 by gbaconni ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@@ -130,7 +130,7 @@ amd64: qemu uefi sda debian
-drive id=pflash1,unit=1,file=${PWD}/data/edk2-i386-vars.fd,if=pflash,format=raw \ -drive id=pflash1,unit=1,file=${PWD}/data/edk2-i386-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \ -drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-amd64-netinst.iso,if=none,media=cdrom,readonly=on \ -drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-amd64-netinst.iso,if=none,media=cdrom,readonly=on \
-nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::4243-:4243,hostfwd=tcp::4244-:4244 \ -nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::443-:443,hostfwd=tcp::80-:80 \
-monitor stdio \ -monitor stdio \
-rtc base=localtime,clock=host -rtc base=localtime,clock=host
@@ -152,7 +152,7 @@ debug: qemu
-device virtio-scsi-pci,num_queues=4,id=scsi0 \ -device virtio-scsi-pci,num_queues=4,id=scsi0 \
-device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0,bootindex=0 \ -device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0,bootindex=0 \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \ -drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::4243-:4243,hostfwd=tcp::4244-:4244 \ -nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::443-:443,hostfwd=tcp::80-:80 \
-monitor stdio \ -monitor stdio \
-rtc base=localtime,clock=host -rtc base=localtime,clock=host
@@ -181,7 +181,7 @@ arm64: qemu uefi sda debian
-drive id=pflash1,unit=1,file=${PWD}/data/edk2-arm-vars.fd,if=pflash,format=raw \ -drive id=pflash1,unit=1,file=${PWD}/data/edk2-arm-vars.fd,if=pflash,format=raw \
-drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \ -drive id=drive0,index=0,file=${PWD}/data/sda.raw,if=none,media=disk,format=raw,cache=writethrough,discard=unmap \
-drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-arm64-netinst.iso,if=none,media=cdrom,readonly=on \ -drive id=cdrom0,index=1,file=${PWD}/data/debian-$(DVER)-arm64-netinst.iso,if=none,media=cdrom,readonly=on \
-nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::4243-:4243,hostfwd=tcp::4244-:4244 \ -nic user,model=virtio,hostfwd=tcp::4242-:4242,hostfwd=tcp::443-:443,hostfwd=tcp::80-:80 \
-monitor stdio \ -monitor stdio \
-rtc base=localtime,clock=host -rtc base=localtime,clock=host

View File

@@ -13,16 +13,16 @@ Bonus (Wordpress)
bash -x bonus.sh -u bash -x bonus.sh -u
``` ```
- Open Chrome - Open Chrome
- [Wordpress via https://localhost:4244](https://localhost:4244/) - [Wordpress via https://localhost](https://localhost/)
- Click on the white background - Click on the white background
- Type `thisisunsafe` - Type `thisisunsafe`
``` ```
# HTTP (4243 instead of 80) -- redirect to HTTPS # HTTP (80) -- redirect to HTTPS
curl -v http://localhost:4243 curl -v http://localhost
# HTTPS (4244 instead of 443) # HTTPS (443)
curl -sk https://localhost:4244 | less curl -sk https://localhost | less
``` ```
Debian Preseed: Debian Preseed:

View File

@@ -6,7 +6,7 @@
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2021/11/07 14:23:18 by gbaconni #+# #+# # # Created: 2021/11/07 14:23:18 by gbaconni #+# #+# #
# Updated: 2021/11/09 10:58:53 by gbaconni ### ########.fr # # Updated: 2021/11/09 12:23:30 by gbaconni ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@@ -45,10 +45,6 @@ ft_lighttpd ()
if ! dpkg --get-selections | grep -qP '^lighttpd\t+install' if ! dpkg --get-selections | grep -qP '^lighttpd\t+install'
then then
apt-get install -qq -y lighttpd apt-get install -qq -y lighttpd
sed -i -r 's/80/4243/g' /etc/lighttpd/lighttpd.conf
grep -q 'url.redirect' /etc/lighttpd/lighttpd.conf \
|| echo -e '\n$HTTP["scheme"] == "http" {\n\t$HTTP["host"] =~ "([^:]*)(:[0-9]+|)$" {\n\t\turl.redirect = (".*" => "https://%1:4244${url.path}${qsa}")\n\t}\n\turl.redirect-code = 302\n}\n' >> /etc/lighttpd/lighttpd.conf
sed -i -r 's/443/4244/g' /etc/lighttpd/conf-available/10-ssl.conf
sed -i -r 's|"bin-path"([^=]*=>).*|"host"\1 "127.0.0.1",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf sed -i -r 's|"bin-path"([^=]*=>).*|"host"\1 "127.0.0.1",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf
sed -i -r 's|"socket"([^=]*=>).*|"port"\1 "9000",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf sed -i -r 's|"socket"([^=]*=>).*|"port"\1 "9000",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf
sed -i -r 's|^(server.document-root[^=]*=).*|\1 "/usr/share/wordpress"|g' /etc/lighttpd/lighttpd.conf sed -i -r 's|^(server.document-root[^=]*=).*|\1 "/usr/share/wordpress"|g' /etc/lighttpd/lighttpd.conf
@@ -101,18 +97,18 @@ ft_wordpress ()
ft_ufw () ft_ufw ()
{ {
if test -f /etc/rc.local.orig && ! grep -q 'port 4243' /etc/rc.local if test -f /etc/rc.local.orig && ! grep -q 'port 443' /etc/rc.local
then then
sed -i -r 's|(/usr/sbin/ufw allow proto tcp from any to any port)(.+)|\1\2\n\1 4243\n\1 4244|' /etc/rc.local sed -i -r 's|(/usr/sbin/ufw allow proto tcp from any to any port)(.+)|\1\2\n\1 443\n\1 80|' /etc/rc.local
return 0 return 0
fi fi
if ! ufw status | grep -q '^4243/tcp' if ! ufw status | grep -q '^443/tcp'
then then
ufw allow proto tcp from any to any port 4243 ufw allow proto tcp from any to any port 443
fi fi
if ! ufw status | grep -q '^4244/tcp' if ! ufw status | grep -q '^80/tcp'
then then
ufw allow proto tcp from any to any port 4244 ufw allow proto tcp from any to any port 80
fi fi
return 0 return 0
} }