All group work and a summary of the web-technologies lecture at THI in the winter semester 2023/24 resides here.
.
├── README.md
├── SGML
│ ├── example.html
│ ├── example.xml
│ ├── example.xsl
│ ├── external-dtd-example.xml
│ ├── external.dtd
│ ├── internal-dtd-example.xml
│ └── simple.html
├── Virtual-Web-Servers
│ ├── IPbased
│ │ ├── hosts
│ │ └── httpd.conf
│ ├── Namebased
│ │ ├── hosts
│ │ └── httpd.conf
│ └── Portbased
│ ├── hosts
│ └── httpd.conf
├── basic-calculator.html
├── injection-web-proxy.py
├── minimal-web-proxy.py
├── minimal-web-server.py
└── node
├── calc
│ ├── App.js
│ ├── calc-ajax-rest-client.html
│ └── calc-rest-server.mjs
├── hosts
├── minimal-web-proxy.js
├── minimal-web-server.js
└── user-management
├── loggedIn-ajax.html
├── login-ajax.html
├── reset.json
├── user-management-ajax-rest-server.js
├── user-management-rest-server.js
└── user.json
WIP
- To add node to an OpenBSD system make sure you have root permissions and run
pkg_add node
- If node throws a package not found exception run
npm install <packagename>
- In
hosts
files,./Virtual-Web-Servers/IPbased/httpd.conf
,./node/calc/App.js
and all files with an.html
file extension in the./node
directory one needs to replace<ipv4address>
accordingly
Implement a tiny webserver that fulfills the following requirements:
- accepts connections on port 80
- no SSL/TLS
- supports only GET on HTTP/1.1
- ignores all headers but the Host header
./minimal-web-server.py
- Start a shell and run
python minimal-web-server.py
- Open a browser and type
localhost:80
into the addressbar - Start a second shell and run
curl localhost:80
Implement a tiny proxy that fulfills the following requirements:
- safe everything that is passed through
- no SSL/TLS
./minimal-web-proxy.py
- Start a shell and run
python minimal-web-proxy
- Start a second shell and run
curl -x localhost:8080 example.com
- Repeat step 2 a vew times with diffrent web pages
- Go back in the first shell and stop the proxy via
ctrl + c
- Take a look at the produced files
request.txt
andresponse.txt
- Create a simple web page in HTML/4.01
- Create a internal and external DTD for
./SGML/example.xml
- Create an XSL to transform
./SGML/example.xml
in HTML/4.01 - Transform
./SGML/example.xml
using the XSL from 3. and make it an XHTML document
./SGML
./SGML/simple.html
./SGML/internal-dtd-example.xml
,./SGML/external.dtd
,./SGML/external-dtd-example.xml
./SGML/example.xsl
./SGML/example.html
- Open
./SGML/simple.html
with a browser - -
- -
- Transformation
- Go to http://xsltransform.net/ and paste the contents of
./SGML/example.xml
and./SGML/example.xsl
accordingly - Safe the result with a html file extension e.g.
example.html
- Open
example.html
with a browser - One can transform
example.html
into an XHTML conform document with minor adjustments (should look like./SGML/example.html
)
- Go to http://xsltransform.net/ and paste the contents of
Create a simple web page in HTML that provides a basic calculator (supports + - * /) by embedding JavaScript code.
./basic-calculator.html
- Open
./basic-calculator.html
with a browser
One can use a proxy to inject anything into the http response here is an example proxy ./injection-web-proxy.py
. It is based on ./minimal-web-proxy.py
from Group Work 2 and injects the calculator into an html page served via http.
Usage:
- Start a shell end run
python injection-web-proxy.py
- Start a second shell and
curl -x localhost:8080 example.com > modifiedExample.html
- Open
./modifiedExample.html
with a browser
Create 2 virtual webservers with httpd within an OpenBSD virtual machine using the following techniques:
- Name based hosting
- IP based hosting
- Port based hosting
./Virtual-Web-Servers
./Virtual-Web-Servers/Namebased
./Virtual-Web-Servers/IPbased
./Virtual-Web-Servers/Portbased
- Name based hosting
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./Virtual-Web-Servers/Namebased/httpd.conf
at/etc/httpd.conf
within the vm (requires su permissions) - Run
mkdir -p /var/www/site1/www
within the vm (requires su permissions) - Run
mkdir -p /var/www/site2/www
within the vm (requires su permissions) - Run
rcctl enable httpd
within the vm (requires su permissions) - Run
rcctl start httpd
within the vm (requires su permissions) - Start a shell on your host machine and append the contents of
./Virtual-Web-Servers/Namebased/hosts
to/etc/hosts
(requires su permissions) - Open a browser on your host machine and type
web1.local
into the addressbar - Open a browser on your host machine and type
web2.local
into the addressbar
- IP based hosting
- Deploy an OpenBSD virtual machine with two network-adapters in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-addresss which can be found under em0 and em1 will be referred to as<ipv4address.em0>
and<ipv4address.em1>
- Place
./Virtual-Web-Servers/IPbased/httpd.conf
at/etc/httpd.conf
within the vm (requires su permissions) - Run
mkdir -p /var/www/site1/www
within the vm (requires su permissions) - Run
mkdir -p /var/www/site2/www
within the vm (requires su permissions) - Run
rcctl enable httpd
within the vm (requires su permissions) - Run
rcctl start httpd
within the vm (requires su permissions) - Start a shell on your host machine and append the contents of
./Virtual-Web-Servers/IPbased/hosts
to/etc/hosts
(requires su permissions) - Open a browser on your host machine and type
web1.local
into the addressbar - Open a browser on your host machine and type
web2.local
into the addressbar
- Port based hosting
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./Virtual-Web-Servers/Namebased/httpd.conf
at/etc/httpd.conf
within the vm (requires su permissions) - Run
mkdir -p /var/www/site1/www
within the vm (requires su permissions) - Run
mkdir -p /var/www/site2/www
within the vm (requires su permissions) - Run
rcctl enable httpd
within the vm (requires su permissions) - Run
rcctl start httpd
within the vm (requires su permissions) - Start a shell on your host machine and append the contents of
./Virtual-Web-Servers/Namebased/hosts
to/etc/hosts
(requires su permissions) - Open a browser on your host machine and type
web.local:80
into the addressbar - Open a browser on your host machine and type
web.local:81
into the addressbar
Note:
- One can stop httpd by running
rcctl stop httpd
- For added convinience extract the ip-address of the virtual machine (e.g. with
ifconfig
-cmd). Then runssh username@ipAddress
on your host machine in order to start a remote shell. - You may want to delete anything you appended to
/etc/hosts
.
- Implement a tiny webserver that supports name based virtual hosting and fulfills the following requirements
- Implement a tiny proxy that prints all traffic (TODO: ,has a timeout) and fulfills the following requirements
- target system OpenBSD virtual machine
- written in Javascript and running in node.js
./node
./node/minimal-web-server.js
,./node/hosts
./node/minimal-web-proxy.js
- Tiny webserver
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/minimal-web-server.js
inside adirectory
of your choice within the vm - Run
node minimal-web-server.js
inside thedirectory
within the vm - Start a shell on your host machine and append the contents of
./node/hosts
to/etc/hosts
(requires su permissions) - Run
curl http://web1.local:8080
on your host machine - Run
curl http://web2.local:8080
on your host machine - Run
curl http://<ipv4address>:8080
on your host machine
- Tiny webproxy
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/minimal-web-proxy.js
inside adirectory
of your choice within the vm - Run
node minimal-web-proxy.js
inside thedirectory
within the vm - Start a shell on your host machine and run
curl -x <ipv4address>:8080 example.com
Provide a REST-API for the calculator developed in Group Work 4
./node/calc
./node/calc/calc-rest-server.js
, ./node/calc/calc-ajax-rest-client.html
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/calc/calc-rest-server.js
inside adirectory
of your choice within the vm - Start a shell inside the vm an run
node rest-api-server.js
inside thedirectory
within the vm - Start a shell on your host machine and run:
curl GET http://<ipv4address>:8080/add\?arg1\=1\&arg2\=2
curl GET http://<ipv4address>:8080/sub\?arg1\=3\&arg2\=1
curl GET http://<ipv4address>:8080/mul\?arg1\=5\&arg2\=3
curl GET http://<ipv4address>:8080/div\?arg1\=10\&arg2\=0
Note: One can test the REST-API using ./node/calc/calc-ajax-rest-client.html
within an Browser
- Place
./node/calc/calc-ajax-rest-client.html
inside thedirectory
within the vm - Open a browser and type
<ipv4address>:8080
into the addressbar
Provide a REST-API that handles users with the following requirenments:
- register account
- login (creating a session)
- password reset
./node/user-management
./node/user-management/user-management-rest-server.mjs
, ./node/user-management/user.json
, ./node/user-management/reset.json
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/user-management/user-management-rest-server.mjs
inside adirectory1
of your choice within the vm - Start a shell inside the vm an run
node user-management-rest-server.mjs
inside thedirectory1
within the vm - Place
./node/user.json
and./node/reset.json
inside adirectory2
of your choice on your host machine - Start a shell on your host machine and run the following curls inside the
directory2
:curl http://<ipv4address>:8080/users
(gives you all existing users)curl -d @user.json -H "Content-Type: application/json" -X POST http://<ipv4address>:8080/users
(creates the user specified inuser.json
)curl -d @user.json -H "Content-Type: application/json" -X POST http://<ipv4address>:8080/login
(creates a session for the user specified inuser.json
)curl -d @reset.json -H "Content-Type: application/json" -X POST http://<ipv4address>:8080/pwreset
(sets a new password for the user with the specifiedid
)
Note: Run the first curl inbetween the others to see the effect of them.
Create a react frontend for the backend ./node/calc/calc-rest-server.mjs
developed in Group Work 7
./node/calc/App.js
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/calc/calc-rest-server.mjs
inside adirectory
of your choice within the vm - Start a shell inside the vm an run
node calc-rest-server.mjs
inside thedirectory
within the vm - Start a shell on your host machine and run
npx create-react-app calc-rest-frontend
thencd calculator-frontend
- Replace the
./src/App.js
on your host machine with./node/App.js
from this repo - Run
npm start
Modify ./node/user-management-rest-server.mjs
developed in Group Work 8 and develop an ajax frontend consisting of an login page and an content page.
The following criterias need to be met
- register account
- login (creating a session)
- logout (destroying a session)
- password reset
./node/user-management
./node/user-management/user-management-ajax-rest-server.mjs
, ./node/user-management/login-ajax.html
, ./node/user-management/loggedIn-ajax.html
- Deploy an OpenBSD virtual machine with one network-adapter in bridge mode
- Start a shell inside the vm and run
ifconfig
. The ipv4-address which can be found under em0 will be referred to as<ipv4address>
- Place
./node/user-management/user-management-ajax-rest-server.mjs
,./node/user-management/login-ajax.html
,./node/user-management/loggedIn-ajax.html
inside adirectory
of your choice within the vm - Start a shell inside the vm and run
node user-management-ajax-rest-server.mjs
inside thedirectory
within the vm - Open a browser on your host machine and type
http://<ipv4address>:8080/
into the addressbar
Note:
- Start a shell on your host machine and run
curl http://<ipv4address>:8080/users
to print the current database entries - Registering the same username multiple times can lead to problems
- This Proof-of-Concept has two major security concerns
- Session are handeled in the html client not by the browser in form of cookies
- One can access the content page by calling the API endpoint directly
PHP