Computernetwerken 2
- 2009 januari examen
- 2010 augustus examen
- 2010 januari examen
- 2011 augustus examen
- 2011 januari examen
- 2012 augustus examen
- 2012 januari examen
- 2013 augustus examen
- 2013 januari examen
- 2013-2014 samenvatting - Filip Scheir
- 2014 augustus examen
- 2014 januari examen
- 2015 augustus examen
- 2016 januari examen
- 2017 juni examen
- 2018 juni examen
- 2019 extra oefeningen + oplossingen - Lars, Martijn, Jonas
- 2019 juni examen
- 2019 oplossingen labo 0 - Lars Lemmens
- 2019 oplossingen labo 1 - Lars Lemmens
- 2019 oplossingen labo 2 - Lars Lemmens
- 2019 oplossingen labo 3 - Lars Lemmens
- 2019 oplossingen labo 4 - Lars Lemmens
- 2019 oplossingen labo 5 - Lars Lemmens
- 2019 oplossingen labo 6 - Lars Lemmens
- 2019 oplossingen labo tussentest - Lars Lemmens
- 2019 oplossingen Testexamen - Lars Lemmens
- 2019 samenvatting - Lars Lemmens
- 2020 juni examen
- 2020 juni examen - versie 2
- 2021 juni examen
- Algemeen
2009 januari examen
- De 3 eerste berichten van een TCP-verbinding.
- Leg uit:
- BGP
- Tunnel en transport mode bij IPSec
- Tier 1, 2 en 3
- Internet Exchange
- Leg uit: Probleem bij firewall bij FTP
- jitter bij voip uitleggen
- je krijgt een ip6-adres waar nullen of andere getallen weg zijn, en jij moet het omzetten naar het normale ip6-adres
vb: ABCD:1234::4567:48 = ABCD:1234:0000:0000:0000:0000:4567:0048 - vragen over kerberos (kan ze niet zo meer zeggen maar er was een vraag over)
- wat is onweerlegbaarheid
- hoe kan je dit doen met RSA
- waarom kan dat niet met met symetrishe encrypty
- Invulvraag over subnetten + Omgekeerd wildcardmask.
2010 augustus examen
Theorie
- Verdeel 10.34.0.0/16 in subnetten voor minstens 600 computers
- Gegeven: TCP logs, je moet kunnen uitleggen wat er gebeurd
- Leg Kerberos in schemavorm uit. Wat is een ticket? Waarom kan deze niet nagemaakt worden?
- Wat is PGP? Hoe zorgt dit voor integrieit en authentificatie?
- Wat is onweerlegbaarheid?
- Waar of niet waar?
Een isp moet betalen voor zijn internetverbinding
IP-telefonie gaat via UDP
Bij https wordt alles met het certificaat van de server versleutelt
Praktijk
- Schrijf een oneliner die in usr/share/dict/dutch alle woorden zoekt die zonder letter en zonder cijfer beginnen (dus é à - mogen wel), geef daar de 8ste van.
- Schrijf een oneliner die /ldapusers/kubeh/geheim/geheim.txt decodeerd met cypher -aes128 en dit in het bestand ontcijferd.txt in je homedirectory zet.
- In de map van Kubeh staan er 5 gecrypteerde tekstbestanden, 1 ervan kan je ontcijferen met de publieke sleutel kubeh.pub, welke? Geef de (meerdere) commando's die je gebruikte.
- Gebruik je kennis over het HTTP protocol om met netcat, grep en echo de grootte te weten van de afbeelding hallo.png die op onze webserver staat met poort 8000 (debbie.nwlab.khleuven.be)
2010 januari examen
Praktijk
Alles moet in 1 commando!
- Maak de bestandsstructuur ~/dir1/dir2/dir3/dir4/ als dir1 nog niet bestaat (in 1 commando!).
if [ ! -d dir1 ];then mkdir -p dir1/dir2/dir3/dir4; fi
- Decrypteer een file met een AES-algoritme en een gegeven paswoord en schrijf de uitvoer naar een file.
- verplaats 10 '.jpg'-bestanden van een gegeven map naar je home dir en verander de extensies van jpg naar avi (in 1 commando!).
mv /home/ldapusers/512345/Gegevenmap/*.jpg .. | rename -f 's/\.jpg$/.avi/' /home/ldapusers/512345/*.jpg
- haal uit een woordenlijst alle woorden waar een x EN een y in voorkomen, geef enkel het 10de resultaat weer.
- geef alle 10 letterwoorden met 10 unieke letters weer. (TIP: back referencing)
Theorie
- Subnetten verdelen en in CIDR vorm kunnen opschrijven
- 10.20.0.0 verdelen in subnetten die elk minstens 365 hosts bevatten
- Gegeven: TCPdump fragment. IP-adres van de DNS server zoeken; enkele stappen uitleggen en de waarde van de volgende ACK-bit berekenen. (goed kijken naar de vorige lijen --> Waarde kan je zo aflezen)
- Beschrijf in schemavorm hoe Kerberos authenticatie werkt. Is deze bestendig tegen een replay aanval? Waarom wel/niet?
- Wat is een digitale handtekening? Hoe zorgt dit voor integriteit en authenticiteit.
- Wat is onweerlegbaarheid? Hoe zorgt het voor authenticatie en integriteit?
- IPv6 adres voluit schrijven vb: A5C2:CBE5:C::ABB5:ABBC
- Juist of fout? Licht toe met 1 zin:
- NAT werkt niet met IPsec (AH) in tunnelmode , met esp wel
- DMZ is enkel beveiligd door controle van de router, op elke server moet nog beveiliging opkomen, op DMZ moet de buitenwereld op kunnen, op het bedrijfsnetwerk niet en is dus beter beschermd. Wel kan een firewall die meer als 2 interfaces gebruikt ook de DMZ beveiligen
- De routetabellen van de AS'en worden manueel bijgewerkt wrong... routetabellen worden up-to-date gehouden door dat ze naar elkaar berichten zetten die voldoen aan het BGP (inmiddels versie 4)
- Een ISP heeft er belang bij om een peering overeenkomst te hebben met elke andere ISP?
- VOIP gebruikt UDP en enkel udp omdat voIP een real-time toepassing
- PGP heeft certificaten en genereert een zogenaamde digitale vingerafdruk die kan gebruikt worden om na te gaan of een gebruiker echt is
- Via een certificaat is de eindgebruik zeker dat de server waarmee hij verbinding heeft gemaakt effectief de gevraagde server (en houder van het certificaat) is.
2011 augustus examen
Theorie
- 4 ip-adressen van subnetten: (6.3.64.0/21, 6.3.72.0/21, 6.3.80.0/21, 6.3.88.0/21)
- Geef het subnetmasker van subnet 1
- Geef het wildcardmasker van subnet 1
- Geef het kleinste netwerk waar deze 4 subnetten afkomstig kunnen van zijn (6.3.64.0/19)
- Welke twee protocollen worden bij ip-telefonie gebruikt. Leg deze uit en geef voobeelden van de verzonden signalen (of iets in die trend was de vraag)
- Juist/fout
- een ipv6 adres, is deze wel of niet correct (was correct)
- Als een wiskundige een algoritme bedenkt om uit een getal snel de vermenigvuldiging van 2 priemgetallen te krijgen. Wordt RSA makkelijk om te kraken.
- SSL wordt gebruikt bij HTTPS (of iets in die zin, het was correct)
- Geef de volledige naam van de afkortingen en leg kort uit.
- PGP
- DMZ
- VPN
- Wat zijn de voor- en nadelen van zowel symmetrische als asymmetrische encryptie. Hoe kan men deze het beste combineren.
- Indien Alice contact wilt maken met Bob. Hoe kan ze er dan voor zorgen dat Trudy niet als 'man in the middle' fungeert. En dus haar publieke sleutel aan Alice doorgeeft en doet alsof ze Bob is.
Praktijk
- Maak vanuit de directory /home/user/tmp de file resources met daarin de file images in de file /home/user. U moet echter in dezelfde directory blijven(tmp)
Oplossing : mkdir -p ../resources/images
- Zorg ervoor dat u een leeg bestand kan aanmaken waarin de datum dat het werd aangemaakt in de titel komt. Stel dat u bijvoorbeeld dit commando zou runnen op 7 september 2011 moet het bestand er als volgt uitzien: versie_070911.txt
Oplossing: touch versie_`date +%d%m%y`.txt
- Stel dat u een file report.txt heeft van enkele alineas. Zorg ervoor dat alle regels die test bevatten NIET worden getoond.
Oplossing : grep -v 'test' report.txt
- Zorg ervoor dat u alle WOORDEN die exact uit 4 karakters bestaat uit het document report.txt naar het bestand output.txt worden weggeschreven.
Oplossing: grep -Eo '[ ]+[^ ]{4}[ ]+' report.txt > output.txt
- Versleutel een bestand topSecret.txt met 256-bit AES-encryptie en cipher-block chaining en geef als uitvoerbestand topSecret.aes
Oplossing: openssl enc -aes-256-cbc -in topSecret.txt -out topSecret.aes -k xfile
- Geef een lijst bestanden in een directory met twee kolommen (bestandsnaam en grootte), gesorteerd op grootte.
Een oplossing: ls -l -S | awk {'print $8 " " $5;'}
2011 januari examen
- IP-adressen met subnetmaskers berekenen
- IPv4 versus IPv6: wat is het verschil, en wat is er beter aan v6?
- Verklaar:
- Persistent HTTP
- BGP (Border Gateway Protocol)
- RTP (Realtime Transport Protocol)
- Signature-based IDS (Intrusion Detection System)
- Er worden 4 subnetten gegeven die aan een router zijn verbonden. Stel de ACL (Access Control List) op met vijf restricties/permissies). Het wildcard masker moet gekend zijn!
- Vragen over restricties.
- Cipher Block Chaining: wat is het?
- Diffie-Hellman in schemavorm uitleggen. Hoe kan je daar misbruik van maken (Man In The Middle).
- PGP in schema: wat gebeurt er als je de hash wegdoet, is dan integriteit en confidentialiteit en authenticiteit nog in orde? Wat is er symmetrisch en assymetrisch aan? Wat kan Trudy doen om toch de boodschap teweten te komen en wat is de oplossing (certificaten gebruiken)?
2012 augustus examen
Theorie
- Analyse van pakketten
- Zoek IP-adres van de DNS server
- Hoeveel TCP connecties worden er opgebouwt?
- In pakket x wordt een http request gedaan. In welk pakket nog en waarom ziet er dat niet uit zoals in pakket x?
- Hoeveel data is verstuurd tijdens de connectie tussen x en y die in pakketten a tot b wordt beëindigd? Kijken naar SYN en ACK bytes
- Schema van een netwerk
- Leg volgende begrippen uit aan de hand van een schema (schema moet je zelf tekenen) : intern net, demiliteraized zone, firewall, router, webserver.
- Plaats een ACL waarbij enkel inkomende verbindingen op poort 80 geaccepteerd worden op het schema om de webserver beter te beveiligen.
- Schrijf een gegeven IPv6 adress voluit.
- Encryptie
- Geef 2 algoritmes waarbij het niet belangrijk is dat de data geheim is. Leg beide kort uit.
- Geef een voorbeeld van een service die met UDP werkt en wat zijn de voordelen hiervan.
- Waar of niet waar
- Een wiskundige vind een snelle manier om een product in 2 priemgetallen op te splitsen, is het RSA in gevaar?
- Door de komst van asymmetrische sleutels zijn symmetrische sleutels eigenlijk niet meer nuttig.
- Een IPSEC AH (Authentication Header) zorgt ervoor dat de header van een IP-pakket niet meer veranderd kan worden door een digitale handtekening (iets in die trand).
- Leg kort uit
- Ticket (Kerberos)
- Diffie Helman
- Internet exchange
- VPN
Praktijk
1. op debbie.vlan77.be staat 1 vd volgende poorten open: 1234,2345,3456,4567. Hoe kan je dit vinden in 1 lijn
2. schrijf de output die men krijgt bij verbinding met deze poort weg in ~/tmp/vraag2.txt
3. doe een ping, die dit 12 keer stuurt en om de 0,5 seconde
4. (bepaald comando, weet niet meer dewelke) geeft alle actieve bestanden, geef een lijst met diegene die het meest actief zijn.
5. iets van bob en alice willen met elkaar veilig communiceren (ze hebben al een sleutel)
2012 januari examen
Theorie
- Analyse van pakketten
- Zoek IP-adres van de DNS server
- Wat gebeurd er in pakketten x tot y (was de 3-way handshake)
- In pakket x wordt een http request gedaan. In welk pakket nog en waarom ziet er dat niet uit zoals in pakket x?
- Hoeveel data is verstuurd tijdens de connectie tussen x en y die in pakketten a tot b wordt beëindigd? Kijken naar SYN en ACK bytes
- Wat betekent de 301 status code van een http response
- Je krijgt de uitvoer van netstat te zien
- Wat is het IPv4 adres van de server
- Is de server een webserver?
- Welke poort kan je alleen aanspreken met een IPv4 adres? Kijken naar poorten in tcp en tcp6-output
- Is [IPv6-adres local van bovenstaande netstat uitvoer] het IPv6 adres van de server? (Was onwaar omdat de poort erbij stond)
- Alice wil veilig communiceren met Bob via zijn publieke sleutel. Hoe kan ze zeker zijn dat ze met Bob communiceert en niet met Trudy die de pakketten probeert te onderscheppen. Geef twee manieren hoe de uitwisseling veilig kan gebeuren en leg kort uit.
- Een IPv6 adres voluit in hexadecimaal uitschrijven
- Juist of fout + leg uit
- Een pakketfilter ontdekt geen virussen
- Het Session Initiation Protocol dient om media (audio/video) te versturen
- Het IPSEC AH beschermd de gehele IP header
- Door de komst van asymmetrische sleutels zijn symmetrische sleutels eigenlijk niet meer nuttig.
- Geef een voorbeeld van een service die met UDP werkt en leg uit waarom.
- Verklaar
- Ticket (Kerberos)
- Onweerlegbaar
- ACL (Access Control List)
- Peering
Praktijk
- Van elk hoofdstuk zo goed als 1 vraag
- Vragen:
- Toon met alleen netcat, grep en echo de grootte van een foto die op het internet staat. (Oplossing Tom)
- Port-scan met netcat op 1 poort met alleen een handshake. Als de poort open is moet hij "Poort open" tonen, anders niets.
- if nc -z debbie.vlan77.be 80; then echo "Poort open"; fi
- Toon het e-mailadres van een certificaat
- openssl x509 -in ABAecom_=sub.__Am._Bankers_Assn.=_Root_CA.crt -email -noout
- Verifieer met gpg enkele files.
- gpg --import <publickey>
- find /home/test/gpg/ -type f -name 'tekst*\.txt\.asc' -exec gpg --verify {} \;
- Toon hoeveel woorden beginnen met be en eindigen met en
- grep -E '^be(.*)en$' /usr/share/dict/dutch | wc -w
2013 augustus examen
Theorie
- Analyse van pakketten
- Zoek IP-adres van de DNS server
- Hoeveel TCP connecties worden er opgebouwd?
- In pakket x wordt een http request gedaan. In welk pakket nog en waarom ziet er dat niet uit zoals in pakket x?
- Hoeveel data is er verstuurd wanneer je aan pakket x en y zit?
- Je verstuurt een mail via de server mx debbie, zeg hier bij wat er gebeurt en maak gebruik van de volgende termen: smtp, DNS protocol, routering, ARP protocol, client-server model.
- Uitleggen bij een packet filter en een inspection firewall hoe dat je die kunt omzeilen als je gebruik maakt van passive ftp
- Bob en Alice hebben elk een publieke sleutel, twee manier geven hoe dat Trudy deze niet kan onderscheppen
- Waar of niet waar
- Zonder CBC is bij AES niet mogelijk om afbeeldingen te beveiligen
- Bij handshake heeft men 2 nonces(ofzoiets)
- Iets van een versleuteling bij https
- Door de komst van asymmetrische sleutels zijn symmetrische sleutels eigenlijk niet meer nuttig.
- Leg uit het is beter om IP spoofing te gebruiken bij een DOS dan gewoon de documenten te stelen(ofzoiets)
- Termen uitleggen
- Content type(http header)
- jitter
- http hijacking
- een tekening waarbij je moest zeggen wat er gebeurt
Praktijk
- Een variant op ping waarbij je een automatische ICMP doet
- Een reeks van mappen aanmaken(vb tmp/dir1/dir2/dir3 als dir 1 ng niet bestaat)
- Een code kraken die op een website staat
- je hebt bestanden cert.pem en cert.key je moest er voor zorgen dat die de juiste permissies kregen met chmod
- Een oefening met tshark
2013 januari examen
Theorie
- Analyse van pakketten
- Zoek IP-adres van de DNS server
- Hoeveel TCP connecties worden er opgebouwt?
- In pakket x wordt een http request gedaan. In welk pakket nog en waarom ziet er dat niet uit zoals in pakket x?
- Zet wat er gebeurt als je naar www.khleuven.be surft met je browser en gebruik hierbij de volgende termen: HTTP protocol, DNS protocol, routering, ARP protocol.
- Waar of niet waar + woordje uitleg.
- Een wiskundige vind een snelle manier om een product in 2 priemgetallen op te splitsen, is het RSA in gevaar?
- Door de komst van asymmetrische sleutels zijn symmetrische sleutels eigenlijk niet meer nuttig.
- Een IPSEC AH (Authentication Header) zorgt ervoor dat de header van een IP-pakket niet meer veranderd kan worden door een digitale handtekening.
- Leg de volgende termen uit: FTP in passive mode, VPN, en nog 2 anderen.
- Een video player streamt een video, maar deze blijft steeds haperen. Geef 2 manieren om dit te vermijden. (Jitterbuffer is er 1 van)
- Geef in schema vorm een woordje uitleg over recursieve en niet recursieve DNS queries.
2013-2014 samenvatting - Filip Scheir
De samenvatting voor 2013-2014 met dank aan Filip Scheir: Samenvattingen-20210617T081040Z-001.zip
2014 augustus examen
- Het verschil tussen ECB en CBC en waarom dat het een beter is dan het andere
- Waarom dat P2P beter is in het distruburen van files dan client-server
- Prefetchen uitleggen
- Kan er gezegd worden dat een CA een "Thrusted Thirth Party" is bij PKI
- Leg onweerlegbaarheid uit bij het gebruik van PGP
- Het belang van een nonce binnen authenticatie
- Wat is de cryptografische functie een CA
- Het verschil tussen end-to-end vertraging en pakketjitter
- Waar/Niet waar + Uitleg
- Kan Jitter (Variatie Delay) opgelost worden door gebruik te maken van QoS
- Als een hacker de Publieke Sleutel van een website in handen krijgt heeft deze toegang tot alle sessies, en alle voorgaande sessies als deze werden opgenomen (Sniffing)
- Een Packet-filter kan geen virussen tegenhouden
- Voorbeelden van applicatie gateway zijn web cache en een server
- Als je zo snel mogelijk een bestand wil versturen naar een verre locatie (+15 hops) dan gebruik je TCP
- Er zijn minder regels bij een packetfilter om een bepaalde TCP communicatie toe te staan tussen client-server dan bij stateful inspection firewall
- In een DMZ (Demilitarized Zone) staan geen interne servers
- Bij VoiP loopt verkeer van alle gesprekken via de SIP proxys
- Een systeem dat gebruikt maakt van HMAC is gevoelig voor replayaanvallen
2014 januari examen
- Waarom maakt een website gebruikt van cookies. Leg uit met behulp van een schema.
- Waarom is een gedistribueerde hashtabel een 'HASH'-tabel?
- Alle voordelen en nadelen van UDP en TCP uitleggen, en 2 voorbeelden geven waarom/wanneer je gebruik zou maken van UDP of TCP.
- Hoe werkt pgp en hoe garandeert het integriteit en authenticatie? Leg uit Onweerlegbaarheid/Non-repudiation
- Leg DASH & Manifestbestand uit + onderlinge relatie.
- Noem de twee soorten redundantie bij videocompressie?
- Hoe werkt een leaky bucketsheduler?
- Vraag 8 (Waar/Niet)
- Kan Jitter (Variatie Delay) opgelost worden door gebruik te maken van QoS?
- Als bij een diefstal de Private Sleutel van een Certification Authency (CA) gestolen wordt, heeft dit dan invloed op vooraf uitgedeelde certificaten door deze sleutel?
- Als een hacker de Private Sleutel van een website in handen krijgt heeft deze toegang tot alle sessies, en alle voorgaande sessies als deze werden opgenomen (Sniffing) ?
- Een Packet-filter kan geen virussen tegenhouden.
- ...(nog een 8 tal)
2015 augustus examen
- Bespreek de 2 manieren die er zij om weergavevetraging tegen te gaan bij jitter + schema.
- Hoe helpt leaky bucket bij iets van bandbreedte + schema?
- Als netwerkbeheerder bij ICMP-ZERO moet je de firewall configureren zodat de DMZ niet kan gemapt worden door middel van traceroute. Teken deze configuratie en schrijf in pseudocode de FW-regels.
- Een audiostukje is gesampeld aan 16 000 samples per seconde. Er zijn 12 000 verschillende niveaus. Wat is de bitrate wanneer het CMP gecodeerd is? Toon ook de berekening.
- Leg volgende bewering uit: IPsec is een veiligheidsdeken.
waar of niet waar + leg uit (hierop krijg je punten)
- In de HTTP header field byterange krijgt de gebruiker een indicatie van de grootte van het object.
- Het deffel-hillman algoritme is een hashfunctie.
- Een hasfunctie is veiliger dan een checksom.
- Een DNS requests kan enkel interactieve requests aanvragen. (ja zo stond dat op het examen. Ik weet het, die zin klopt niet).
2016 januari examen
Theorie
- Dit examen werd in 2017, 2018 en 2019 getoond als voorbeeldexamen.
Deel 1: meerkeuzevragen
Principe: Per vraag zijn er vier tot 6 stellingen gegeven. Duid telkens aan welke allemaal juist zijn. Het aantal juiste mogelijkheden wordt gegeven. Elke aangeduide mogelijkheid moet juist zijn. Als de juiste antwoorden bv. zijn 'A, F & G' en je duidt 'A, B & G' aan dan is dit volledig fout. De vragen werken ook volgens het principe van eliminatie; er worden ook stellingen over ongeziene stof gegeven en door te elimineren wat je weet van de geziene stof kan je besluiten of de onbekende dingen juist zijn.
1) Welke dingen zijn van toepassing op IPsec transportmode:
- Tussen eindstations
- Unicast
- Enkel payload
Tussen gatewaysMulticast(Zie tekst over IPsec)Hele pakket(Is tunnelmode)
2) Welke twee protocollen zorgen voor confidentialiteit van uitgewisselde data
- SSH
- HTTPS
3) Welk systeem kan aanvallen inline tegenhouden. Bv. hacker wilt website defacen via Joomla Exploit.
- IPS (Intrusion Prevention System)
IDS(Intrusion Detection System)PocketfilterStateful Inspection FirewallVirusscanner
4) Beweringen over Telnet
- Machines op afstand beheren (e.g. router)
Telnet is geen protocolTelnet heeft een beveiligde verbindingMet Telnet kun je veilig inloggen
5) Iets over access lists
6) Welke tools om mail te versturen
- Netcat
- Telnet
POP3(Lezen)ESP(IPsec)SSTP(type)
7) Beweringen over IPsec-verbinding
- Wanneer client achter NAT-gateway zit dan kan AH niet gebruikt worden.
- IPsec VPN-tunnel die gebruik maakt van AH biedt geen confidentialiteit.
- Gebruiker die via VPN van thuis toegang wil krijgen tot intern bedrijfsnetwerk gebruikt daarvoor best een ESP IPsec verbinding in tunnel mode.
8) ACC’s
- Specifiekere ACC’s vanboven
- Zelfde trafiek filteren -> meer regels dan Sateful Inspection Firewall
9) Beweringen over NAT
- Portforwarding is een soort van NAT (Voorbeeldje met Plex)
10) Iets over diensten die IPsec levert. Mensen struikelden hier over het woordje diensten, want in de lijst stonden implementaties ook.
11) Welke zijn block cyphers? Dit was een kutvraag volgens Swennen. Afleiden door reductie.
12) Alice mailt Bob. Je moet blijkbaar zo’n constructies kunnen begrijpen:
- Ḳ^+^~B~(K~C~)+K~S~((Ḳ^-^~A~(H(m))+m))
13) Applicaties bovenop UDP
- DNS
- SIP
14) Beweringen over HTTP
- Body is soms leeg (Bv. Conditional Get)
15) Welke functies noodzakelijk voor IPsec?
- IKE om de SA af te spreken
- Diffie-Helman om shared-secret af te spreken
16) Welk van onderstaande servers ook application gateway
- HTTP-proxy
- SIP-proxy
17) Packet Jitter
- Variatie in delay
- Buffering kan negatieve effecten reduceren
- Jitter buffering zorgt voor algemene vertraging
18) Router die QoS algoritme WFQ samen met ???? kan garantie leveren op
- Delay
SnelheidPacketsizeThroughput
19) HTTP-conversatie, er stond geen 200 dus dat was sowieso al niet goed
- Server geen idee welke website.
20) Router in welke laag OSI-model? Hier was Swennen het meest in teleurgesteld!!!
- Laag 3
21) Beweringen ESP IPsec
- Tunnel mode wordt gebruikt tussen host en security gateway
- Tunnel mode wordt gebruikt tussen 2 security gateways
- Transport mode zal de originele IP header niet versleutelen
22) TCP source ports.
- 20
- 21
- 10000
23) Welke van de volgende zaken worden niet voorzien door TCP (transmission control protocol)?
- Timing
- Security
Deel 2: open vragen
- 1) In bijlage staat een wiresharkoverzicht van een verbinding.
-
- 1a) Hoeveel verbindingen werden er gemaakt? Aan wat zie je dit?
-
-
-
- Twee. Dit vind je door SYN, SYNACK, ACK te tellen.
-
-
-
- 1b) In pakket 8 zien we dat er een HTML-request is. In welk pakket is dit nog zo en waarom zien we dit niet zo als in pakket 8?
-
-
-
- Andere is HTTPS.
-
-
-
- 1c) Hoeveel data (bytes) is er verstuurd in de connectie die op lijn 29 wordt beëindigd.
-
-
-
- ACK = 2626 -> seq 2626 = aantal bytes
-
-
- Ergens was er ook nog een vraag over (a * b)mod^n^. Hierbij moest je niet rekenen, is formule die je zo kunt omzetten.
- 2) Geef een volledig schema over hoe mail van bij Alice die op haar mailclient (Mozilla Thunderbird) zit vanuit een telenetnetwerk tot aan Bob (ucll) geraakt. Volgende zaken moeten minstens voorkomen
- DNS records, DNS, TLD, IMAP, SMTP, (nog iets denk ik maar ben het vergeten).
-
- Die lijst met dingen die je moet aanduiden staat er niet voor niets. Die helpt je je antwoord logisch op te bouwen. Zie dat je eerst op kladblad tekent.
2017 juni examen
Theorie
- 8 moeilijke doordenk multiple choice vragen (met meerdere mogelijke juiste antwoorden, en je moet ze allemaal juist hebben)
- DNS query response gegeven van alle servers waarlangs de DNS query gaat. Leg uit met schema wat er gebeurt, wanneer wie welke responses geeft, welke queries iteratief/recursief zijn.
- Waarom wordt er bij SSL/TCL zowel symmetrische als asymmetrische encryptie gebruikt? Leg uit met een schema van SSL en zeg waar welke gebruikt wordt (toy of echte SSL)
Praktijk
Praktijkexamen 22/05/2017
- Give a list of all words with 14, 15 or 16 unique letters. The output format should look like this:
-
- Words with 14 letters: word1 word2 word3
- Words with 15 letters: word4 word5
- ...
for n in 14 15 16; do echo "Words with $n letters:" $(grep -P "^.{$n}$" dutch | grep -vP '(.).*\1'); done
- Give a list of the usernames tried in ftp_bruteforce.pcap. You can only use tshark and sort (Step by step solution: https://wiki.uclllabs.be/index.php/TShark_Tutorial#Exercises)
tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ‘ftp.request.arg’ | sort -u
- Give the current time (format: Time= hh:mm:ss (dd-mm-yyyy))
echo 'Time=' $(date +'%T (%x)') | tr / -
- Write a oneliner to decode the following file "secret" (contents: RGUgcHVudGVuIG9wIGRlemUgdnJhYWcgemlqbiBhbCBiaW5uZW4uCg==)
The file ends with '==' indicating base64 padding: openssl enc -d -base64 < secret
- Write a oneliner to display the fingerprint, serial and public key of wiki.uclllabs.be
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -fingerprint -serial -pubkey -noout
Praktijkexamen 24/05/2017
- There is a website running - https://darthvader.uclllabs.be/nw2/lab1 - which is only accessible from 193.191.177.1. That is the IP address of leia.uclllabs.be. Create an ssh tunnel between server leia and the webserver darthvader
ssh -L 10000:darthvader.uclllabs.be:443 user@leia.uclllabs.be -p 22345
- Give a list of words with 5 letters that are also palindromes.
grep -P '^(.)(.).\2\1$' dutch
- Show the file /etc/debconf.conf on screen without comment lines (i.e. lines starting with a #).
grep -vP '^#' /etc/debconf.conf
- Give a list of the usernames tried in ftp_bruteforce.pcap. You can only use tshark and sort (Step by step solution: https://wiki.uclllabs.be/index.php/TShark_Tutorial#Exercises)
tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ‘ftp.request.arg’ | sort -u
- Write a oneliner to display the fingerprint, serial and public key of wiki.uclllabs.be
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -fingerprint -serial -pubkey
2018 juni examen
Theorie
- 8 multiple choice vragen
- DNS
- Waarom wordt er bij SSL/TCL zowel symmetrische als asymmetrische encryptie gebruikt? Leg uit met een schema van SSL en zeg waar welke gebruikt wordt.
Praktijk
Praktijkexamen 23/05/2018
- 1. A simulated phone is running at http://darthvader.uclllabs.be/nw2/phone/. Create a oneliner to bruteforce the pincode. Tip: pincode range: 1200-1300.
for i in {1200..1300}; do if wget -q http://darthvader.uclllabs.be/nw2/phone/ --http-user=admin --http-password=$i; then echo $i; break; fi;done;
- 2. Ontcijfer de volgende boodschap: RGUgcHVudGVuIG9wIGRlemUgdnJhYWcgemlqbiBhbCBiaW5uZW4uCg== (deze boodschap staat in het bestand /home/logs/secret | base64 -d
cat /home/logs/secret | base64 -d
- 3. Show the file /etc/debconf.conf on screen without comment lines (i.e. lines starting with a #).
cat /etc/debconf.conf | grep -Ev "^#"
- 4. Use Netcat to download an image from "http://darthvader.uclllabs.be/nw2/images/". You can use a browser to choose an image. check the echo -ne options or use printf. If needed, slow down netcat with option -i. The image part in the HTTP stream starts after a blank line.
echo -ne "GET /nw2/images/image1.jpg HTTP/1.0\r\n\r\n" | nc darthvader.uclllabs.be 80 > image1.jpg; cat image1.jpg | tail -n +13 > imagetester.jpg
- 5. Perform a zone transfer of the cnw2.uclllabs.be zone to see which hostnames you need to use. Use "dig axfr cnw2.uclllabs.be @ns2.uclllabs.be". Sort the output and format it as follows:
-
- *.1.cnw2.uclllabs.be. 3600 IN A 193.191.176.1
- *.2.cnw2.uclllabs.be. 3600 IN A 193.191.176.2
- *.3.cnw2.uclllabs.be. 3600 IN A 193.191.176.3
- *.4.cnw2.uclllabs.be. 3600 IN A 193.191.176.4
- *.5.cnw2.uclllabs.be. 3600 IN A 193.191.176.5
- *.6.cnw2.uclllabs.be. 3600 IN A 193.191.176.6
- *.7.cnw2.uclllabs.be. 3600 IN A 193.191.176.7
- *.8.cnw2.uclllabs.be. 3600 IN A 193.191.176.8
- *.9.cnw2.uclllabs.be. 3600 IN A 193.191.176.9
- *.10.cnw2.uclllabs.be. 3600 IN A 193.191.176.10
dig axfr cnw2.uclllabs.be @ns2.uclllabs.be | awk '{print $1,$2,$3,$4,$5}' | grep "IN A" | sort -V
Praktijkexamen 22/05/2018
- 1) A simulated phone is running at http://darthvader.uclllabs.be/nw2/phone/. Create a oneliner to bruteforce the pincode. Tip: pincode range: 1200-1300
for pin in {1200..1300}; do if wget -q --http-user='admin' --http-password=$pin http://darthvader.uclllabs.be/nw2/phone; then echo $pin; break; fi; done
- Give a list of words with 5 letters that are also palindromes.
grep -P '^(.)(.).\2\1$' dutch
- Show the file /etc/debconf.conf on screen without comment lines (i.e. lines starting with a #).
grep -vP '^#' /etc/debconf.conf
- Give a list of the usernames tried in ftp_bruteforce.pcap. You can only use tshark and sort (Step by step solution: https://wiki.uclllabs.be/index.php/TShark_Tutorial#Exercises)
tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ‘ftp.request.arg’ | sort -u
- Write a oneliner to display the fingerprint, serial and public key of wiki.uclllabs.be
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -fingerprint -serial -pubkey
2019 extra oefeningen + oplossingen - Lars, Martijn, Jonas
Met dank aan de Github van Martijn
Opgave: cnw2.pdf
Met dank aan Lars Lemmens
Oplossingen
Met dank aan Jonas Berx
Monitoraat Netwerken - By JONAS BERX
# Neem niet zomaar de code over, zoek zelf een oplossing :) (man ...) of (... --help)
# Google is ook nog altijd je vriend
# Niet alle oefeningen zijn 100% juist
# Please geen haat als je uitkomst niet klopt
# Ik ben maar een arm studentje uit UCLL dat graag op Netwerken erdoor wilt zijn
# XXX JONAS XXX
#
1) wget -q -O - http://crl3.digicert.com/TERENASSLCA3.crl | openssl crl -inform DER -text -noout | grep "Revocation Date" | wc -l
2) ssh -p 22345 rNummer@leia.uclllabs.be
3) ping 127.0.0.1 -c $(ls | grep \.crl$ |wc -l)
4) tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command==PASS' -T fields -e 'ftp.request.arg' 2>/dev/null| sort | uniq -c | sort -rn | head -3 | cut -d ' ' -f 7
5) gebruik de filter : 'http.request.command==POST'
6) nc -z -n -v 193.191.177.1 1-66535 |& grep succeeded ----------- nmap -p- 193.191.177.1 --max-rate 50 (Max rate 50 is redelijk traag aangezien er +65000 poorten zijn)
7) who | awk '{print $1,$3}' | while read user time; do echo $user $(($(($(date +%s) - $(date -d "$time" +%s)))/60)) minutes; done | sort | uniq -c (Klopt niet 100% maar geeft je wel de tijd in minuten)
7A) who -H (Simpele oplossing beter te combineren met 7B)
7B) who | awk '{print $3,$4,$1}' | sort | head -1
8) tar -cvf archive.tar /home/LDAP/r0748969 | openssl enc -aes-128-cbc -in archive.tar -out archive.tar.aes; openssl enc -aes-128-cbc -in archive.tar.aes -out archive.tar.aes.aes (GOOGLE : Tar on the fly -> geen tussenbestanden)
9) ss -lnt4 | awk '/LISTEN/{print $4}' |cut -d ':' -f 2 | grep -vP '(.).*\1'
10) tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.response.code==230' (Juiste code wel : 230 maar niet juiste antwoord.. moet nog de login gegevens van de successfull login vinden)
11) #geen moeite in deze gestoken
12) grep -P '^([A-Za-z])([A-Za-z])\2\1$' (achteraf nog een dict toevoegen om in te zoeken)
14) ls -ld (-d staat voor directory)
15) String = "TGludXggUlVMRVM=" echo TGludXggUlVMRVM= | openssl enc -d -a
16) nmap 193.191.177.1 -p- -r --open -sT
39) cat /usr/share/dict/dutch | grep -vP '(.).*\1' | grep -P '^[a-zA-Z]{5}$' (voorlaatste)
#rest zal deze week er wel bijkomen.. Ik doe m'n best
#Good luck all
#De antwoorden hieronder zijn van het examen dat in de les overlopen is
Voor examen : History en dan nummer geven -> handig om op het examen niet je code over te schrijven maar gewoon het nummer van het command te geven.
-----------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!! 2>/dev/null = vuilnisbak !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
------------------------------------------------------------------------
EXAMENVRAGEN
1)for foo in 14 15 16; do echo "Words with $foo letters:" $(echo "grep -vP '(.).*\1' /usr/share/dict/dutch | grep -P '^.{$foo}$'"| sh);done
2) tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command==USER' -T fields -e 'ftp.request.arg' | sort | uniq -c | sort -rn
3) date '+Time = %X (%X)' OF echo date : $(date +%Y.%m.%d)
4) cat secret | base64 -d of cat secret | openssl enc -d -a
5) echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -pubkey -serial -fingerprint -enddate
2019 juni examen
Theorie
- 30 multiple choice vragen (waarvan 6-7 vragen letterlijk uit het voorbeeldexamen kwamen), hierbij zijn ook enkele vragen over de theorie in de labo's
DE VOLGENDE 3 VRAGEN WAREN EXACT HETZELFDE OP HET HEREXAMEN!
- Als er door ftp 6 files gedownload moeten worden hoeveel connecties dan op laag 4? (antwoord: 1 sessie)
- Hoe wordt er bij SSL/TCL ervoor gezorgd dat er geen truncation attack of lagere level encoding aanval kan gebeuren?
- Modulo rekenen (a*b)modn a=17023 b=90004, n = 1000? Zeg ook welke eigenschap van modulo rekenen je gebruikt? (oplossing: 23 * 4 = 92)
Praktijk
Praktijkexamen 1
- Companies like Google and Microsoft make heavily use of the X.509 subjectAltName extension. UCLL also uses this extension to add an alternative name *.ucll.be to the common name (ucll.be) of the certificate. Create a oneliner which calculates the amount of DNS Subject Alternate Names used in the SSL certificate of facebook.com.
echo | openssl s_client -connect facebook.com:443 | openssl x509 -text -noout | grep -o 'DNS' | wc -l
- Create a regular expression to match all words in a dictionary with 11 unique letters.
cat /usr/share/dict/dutch | grep -P '^[a-zA-Z]{11}$' | grep -vP '(.).*\1'
- Show the file /etc/debconf.conf on screen without comment lines (i.e. lines starting with a #).
cat /etc/debconf.conf | grep -vP '^#'
- Create a linux CLI oneliner to extract an overview of the different FTP usernames in the file ftp_bruteforce.pcap. You can only use the commands tshark and sort.
tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ‘ftp.request.arg’ | sort -u
- Create a CLI oneliner to find a match between different rsa private key files and their companion crt files. The output should look something like:
alfa.key matches to beta.crt gamma.key matches to delta.crt
for key in $(ls -1 *.key); do for crt in $(ls -1 *.crt); do if [ [ $(openssl rsa -in $key -noout -modulus | md5sum) == $(openssl x509 -in $crt -noout
-modulus | md5sum) ]]; then echo $key matches $crt; fi; done; done
--> er is een bestand '/home/logs' op leia waar je dit mee kan testen
Praktijkexamen 2
- Create a CLI oneliner to match all words with 14, 15 and 16 unique letters. The output should look like:
Words with 14 letters: bedrijfsomvang ... Words with 15 letters: ...
for foo in 14 15 16; do echo -e "Words with $foo letters:" && grep -P "^.{$foo}$" /usr/share/dict/dutch | grep -Pv '(.).*\1';done
- Bob needs to send a text file through an encrypted tunnel to Alice. Both already agreed on a shared
secret 'mysecret' using the Diffie Hellman algorithm. Alice wants to display the contents of the file directly on her screen in stead of storing it locally and then opening it. Use a suitable encryption algorithm. The data is sent over a medium which only allows ASCII text. Alice is logged in on debbie and Bob on the virtual machine.
- As a web server administrator you have been asked to give your manager a linux CLI oneliner to extract
the 5 IP adresses that contacted the web server the most. The apache log is located in /home/log. Create a correct oneliner. The output should look something like this: (count IPs) 8000 10.10.10.10 ... 82 81.30.45.89
cat /home/logs/apache_google.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -5
- Log into leia with a RSA key pair instead of logging in with your password.
- ?????
Praktijkexamen 3
- Use tshark to create an overview of the different HTTP servers in the file http.pcapng(you can find this file in /home/logs). Filter out all of the Apache servers. You can only use the commands tshark and sort.
- Create a oneliner which lists all palindromes with exactly 5 letters in a dictionary.
grep -P '^([a-zA-Z])([a-zA-Z])[a-zA-Z]\2\1$' /usr/share/dict/dutch
- Create a CLI oneliner using openssl to retrieve the certificate of the server facebook.com and to display only it's fingerprint, serial and public key.
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -fingerprint -serial -pubkey -noout
- Bob needs to send a text file through an encrypted tunnel to Alice. Both already agreed on a shared secret 'mysecret' using the Diffie Hellman algorithm. Alice wants to display the contents of the file directly on her screen in stead of storing it locally and then opening it. Use a suitable encryption algorithm. The data is sent over a medium which only allows ASCII text. Alice is logged in on debbie and Bob on the virtual machine.
- Make the following directories with a oneliner ~/temp/dir1/dir2/dir3. The solution must be generic: It should work from any location.
mkdir -p ~/temp/dir1/dir2/dir3
2019 oplossingen labo 0 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO 0
Exercise 24
Create 2 files with random text. Then create a third file containing the contents of the two other files
1) echo 'some random text' > file1 2) pwgen -n1 > file2 3) cat file1 file2 > file3
- The pwgen command generates passwords which are designed to be easily memorized by humans, while being as secure as possible.
- -n stands for minimum 1 number AND -1 stands for per line 1 password.
- '>' means overwrite a file
Exercise 25
List all home directories which are open for other users (group or others should have r,w or x rights)
• ls -l /home/LDAP/ | grep -v 'drwx------' | grep -v '^total' | tr -s ' ' | cut -d ' ' -f9 • ls -l /home/LDAP/ | grep -v 'drwx------' | grep -v '^total' | awk '{print $9}' • ls -l /home/LDAP/ | grep -vP '^(drwx------|total)'| awk '{print $9}' • ls -l /home/LDAP/ | awk '$1 !~ /drwx------|total/{print $9}'
- grep prints lines matching a pattern.
- -v stands for inverted match.
- -P stands for perl expression
- ^ matches position just before the first character of the string.
- The tr command replaces all occurrences of a character in a file, and print the result.
- -s replaces each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
- The command cut removes sections from each line of files
- -d use DELIM instead of TAB for field delimiter
- -f(number) select only these fields
- awk '{print $(number)' prints the field with the matching number
Exercise 26
List all lines in the file /usr/share/dict/dutch containing the string 'rare'
Exercise 27
Only show the columns with filenames and permissions of the files in your homedirectory. (tip: use ls and cut)
• ls -l ~ | grep -v '^total' | tr -s ' ' | cut -d ' ' -f1,9
- grep prints lines matching a pattern.
- -v stands for inverted match.
- The tr command replaces all occurrences of a character in a file, and print the result.
- -s replaces each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
- The command cut removes sections from each line of files
- -d use DELIM instead of TAB for field delimiter
- -f(number) select only these fields
Exercise 28
Sort the lines from 27 in reverse alphabetical order
• ls -l ~ | grep -v '^total' | tr -s ' ' | cut -d ' ' -f1,9 | sort -r -k2
- grep prints lines matching a pattern.
- -v stands for inverted match.
- The tr command replaces all occurrences of a character in a file, and print the result.
- -s replaces each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
- The command cut removes sections from each line of files
- -d use DELIM instead of TAB for field delimiter
- -f(number) select only these fields
- The sort command sort lines of text files
- -r reverse the result of comparisons
- -k start a key at POS1 (origin 1), end it at POS2 (default end of line).
Exercise 29
Use the command cal to find out on which day of the week your birthday is in 2050 and write your output to a newly created file
• ncal -m 6 2050 | grep ' 9 ' | cut -d ' ' -f1 > file • cal -N -m 6 2050 | grep ' 9 ' | cut -d ' ' -f1 > file
- The command ncal displays a calendar and the date of Easter
- The command cal displays a calendar and the date of Easter
- -m displays the specified month
- The command cut removes sections from each line of files
- -d use DELIM instead of TAB for field delimiter
- -f(number) select only these fields
- '>' means overwrite a file
Exercise 30
Append the sentence 'THE END' to the file you created in the previous exercise without opening this file in an editor (hence: use a one-liner)
• echo 'THE END' >> file # >> makes a file and saves it
Exercise 31
Create a subdirectory TEST in your homedir. Now create some files in it using this command line (and make sure you understand what happens!)
for foo in `seq 1 9`; do touch "file $RANDOM"; done && touch 'file keep me'
How can you remove all files except the file “file keep me” with just one 'oneliner'"
1) mkdir ~/TEST; cd ~/TEST 2) for foo in {1..9}; do touch "file $RANDOM"; done && touch 'file keep me' • rm file\ [0-9]* • ls file\ [0-9]* | while read file; do rm "$file";done • ls -1 | grep -v 'file keep me' | xargs -d '\n' rm • find . -type f ! -name 'file keep me' -delete
- The for keyword indicates a for loop ==> SYNTAX : for WORD [ in WORDLIST ... ] ; do ACTIONS ; done
- The command touch creates a new empty file(s) or change the times for existing file(s) to current time
- The rm command removes files or directories
- Remove (unlink) the FILE(s)
- The while command continuously executes the list list-2 as long as the last command in the list-1 returns an exit status of zero.
- The command xargs builds and executes command lines from standard input
- -d stands for delimiter ==> This can be used when the input consists of simply newline- separated items, although it is almost always better to design your program to use --null where this is possible.
- The find command searches for files in a directory hierarchy
- -f stands for regular file
- -delete stands for Delete files; true if removal succeeded.
Exercise 32
List the name and permissions of the first 10 directories in /etc.
Sample output: drwxr-xr-x /etc/ drwxr-xr-x /etc/alternatives drwxr-xr-x /etc/apache2 drwxr-xr-x /etc/apache2/conf.d drwxr-xr-x /etc/apache2/mods-available drwxr-xr-x /etc/apache2/mods-enabled drwxr-xr-x /etc/apache2/sites-available drwxr-xr-x /etc/apache2/sites-enabled drwxr-xr-x /etc/apt d rwxr-xr-x /etc/apt/apt.conf.d" • ls -l /etc | head -10 | grep -v '^total' | awk '{print $1 " " $9}'
- The head command prints the first 10 lines of each FILE to standard output. With more than one FILE, precede each with aheader giving the file name. With no FILE, or when FILE is -, read standard input.
- grep prints lines matching a pattern
- -v stands for inverted match.
- awk '{print $(number)' prints the field with the matching number
Exercise 33
Same question as #32, but now also omit all error messages. "
• ls -l /etc 2>/dev/null | head -10 | grep -v '^total' | awk '{print $1 " " $9}'
- 2>/dev/null is used to redirect to a file
- The head command prints the first 10 lines of each FILE to standard output. With more than one FILE, precede each with aheader giving the file name. With no FILE, or when FILE is -, read standard input.
- grep prints lines matching a pattern.
- -v stands for inverted match.
- awk '{print $(number)' prints the field with the matching number
Exercise 34:
List the name and permissions of all files in the /etc directory containing the word 'host' in their name. Do this without the use of the commands grep and/or awk."
• find /etc/ -type f -name '*host*' 2>/dev/null | xargs -d '\n' ls -l # (recursive search) • find /etc/ -maxdepth 1 -type f -name '*host*' 2>/dev/null | xargs -d '\n' ls -l • ls -ld /etc/*host* | tr -s ' ' | cut -d ' ' -f1,9 # (also show files of type directory) • ls -ld /etc/*host* | sed -e '/^d.*/d' | tr -s ' ' | cut -d ' ' -f1,9
- The find command searches for files in a directory hierarchy
- -f stands for regular file
- -name stands for the name
- 2>/dev/null is used to redirect to a file
- The command xargs builds and executes command lines from standard input
- -d stands for delimiter ==> This can be used when the input consists of simply newline- separated items, although it is almost always better to design your program to use --null where this is possible.
- -maxdepth stands for the - levels of directories below the starting point
- The command cut removes sections from each line of files
- -d use DELIM instead of TAB for field delimiter
- -f(number) select only these fields
- The tr command replaces all occurrences of a character in a file, and print the result.
- -s replaces each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
2019 oplossingen labo 1 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO 1
In order to connect to a remote SSH server leia.uclllabs.be in this example, execute the following command
'user:~$' • ssh r1234567@leia.uclllabs.be -p 22345
The client configuration file can make your life easier because default command line options could be specified in this configuration file
Normally you would use the following command to log in to leia
'user:~$' • ssh -p 22345 r1234567@leia.uclllabs.be "FILE: ~/.ssh/config" Host leia HostName leia.uclllabs.be Port 22345 User r1234567
The following command creates an ssh tunnel. Local tcp port CPORT (on your laptop) will be tunneled through GATEWAY to SERVER port
'user:~$' • ssh -f GWUSERNAME@GATEWAY -L CPORT:SERVER:SPORT -N
-
The -f argument instructs the ssh instance to go into the background, and -N instructs it to not launch a shell.
-
The -L argument specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
https://darthvader.uclllabs.be/nw2/lab1 which is only accessible from 193.191.177.1. That's the IP address of leia.uclllabs.be.
Try it yourself: There is a website running -'user:~$' • ifconfig | grep -B1 inet
- ifconfig configures a network interface
- The grep command grep searches the named input FILEs
- -B NUM prints NUM lines of leading context before matching lines
With this command, you can create an ssh tunnel between server leia.uclllabs.be and the webserver darthvader.uclllabs.be.
'user:~$' • ssh -p 22345 -f r0123456@leia.uclllabs.be -L 10000:darthvader.uclllabs.be:443 -N
- The -p argument shows which port to connect to on the remote host
- The -f argument instructs the ssh instance to go into the background, and -N instructs it to not launch a shell.
- The -L argument specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
First find the ssh process to close:
'user:~$' • ps fauxw | grep darthvader
- The ps command reports a snapshot of the current processes
- The f argument does a full-format listing
- The a argument selects all processes except both session leaders and processes not associated with a terminal.
- The u argument selects by effective user ID (EUID) or name.
- The x arugment Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like.
- The w argument gives wide output
- grep searches the named input FILEs
Next send a sigterm signal to the correct pid (process identifier) = second column in ps fauxw output
'user:~$' • kill 12345
And if you need to close all running ssh sessions/tunnels use the following command:
'user:~$' • killall ssh
By default kill sends a SIGTERM signal (similar to clicking on the X to close a window (Chrome, Notepad, Gnome-terminal,..). If you need to force close an application, send the SIGKILL signal:
'user:~$' • kill -9 12345 'user:~$' • killall -9 ssh
Use a text based browser on leia to verify the remote website is accessible through the ssh tunnel.
'user:~$' • lynx https://localhost:10000/nw2/lab1-all-but-leia 'user:~$' • curl -k -s https://localhost:10000/nw2/lab1-all-but-leia/ | html2text
- The argument -k instructs curl not to verify the server certificate.
- The argument -s makes curl mute make sure that it doesn't show progress meter or error messages
OpenSSH has built-in support for dynamic port forwarding via the SOCKS proxy protocol. This command turns your SSH client (on your laptop) into a SOCKS proxy server: "
'user:~$' • ssh -f user@GATEWAY -D 10000 -N -p port
- The -f argument instructs the ssh instance to go into the background, and -N instructs it to not launch a shell.
- The -p argument shows which port to connect to on the remote host
- The -D argument specifies a local “dynamic” application-level port forwarding
There are 3 different levels of debug modes that can help troubleshooting issues. With the -v option SSH prints debugging messages about its progress.
This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increase the verbosity. Maximum verbosity is three levels deep.
'user:~$' • ssh leia -v 'user:~$' • ssh leia -vv 'user:~$' • ssh leia -vvv
This command will aid you in finding an available tcp port: "
'user:~$' • netstat -lnt | grep -oP ':\K[^:][0-9]+' | sort -un
- The command netstat prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
- The -l shows only listening sockets.
- The -n shows numerical addresses instead of trying to determine symbolic host, port or user names.
- The -t argument shows only TCP ports
- The command grep searches for PATTERNS in each FILE.
- The -o argument prints only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
- The -p argument Interpret I as Perl-compatible regular expressions (PCREs).
- : matches the character : literally (case sensitive)
- \K resets the starting point of the reported match.
- [^:] matches a single character not present in the list below
- [0-9] matches a single character present in the list below
- '+' matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- The command sort sorts lines of text files
- The -u argument output only the first of an equal run
- The -n argument compares according to string numerical value
For instance, we can scan all ports up to 1000 by issuing this command:
'user:~$' • nc -vz leia.uclllabs.be 1-1000
- The command nc is a TCP/IP swiss army knife
- The -v argument is for verbose
- The -z argument is for zero-I/O mode [used for scanning]
"Messages returned by Netcat are sent to standard error. You can send the standard error messages to standard out, which will allow filtering the results. Stderr can be redirected to stdout via the 2>&1 bash syntax. Then use grep to filter
Alternatively you could use |& as a shorthand for 2>&1 |. "
'user:~$' • nc -z -n -v 193.191.177.1 1-1000 2>&1 | grep succeeded 'user:~$' • nc -z -n -v 193.191.177.1 1-1000 &| grep succeeded
- The command nc is a TCP/IP swiss army knife
- The -z argument is for zero-I/O mode [used for scanning]
- The -v argument is for verbose
- The -v argument is used for short version
Netcat is a very slow TCP port scanner as it will wait for a TCP timeout for every port it tries. Add option -w 1 to increase scanning speed, and execute this command on leia to circumvent slowdown due to firewalled ports.
Netcat isn't designed to scan for open ports, it's functionality is very limited. If you need to scan for open ports, use a real portscanner like Nmap"
'user:~$' • nmap -p1-1000 193.191.177.1
- The command nmap is a network exploration tool and security / port scanner
- The -p argument specifies which ports you want to scan
Once again, you need to choose one end of the connection to listen for connections.
However, instead of printing information onto the screen, you will place all information straight into a file
'user:~$' • nc -l -p 10000 > received_file
- The command nc is a TCP/IP swiss army knife
- The -l argument is used as listening mode
- The -p argument specifies which ports you want to scan
- The > overwrites a file
On the second computer, create a simple text file by typing: "
'user:~$' • echo "Hello, this is a file" > original_file
You can now use this file as an input for the Netcat connection you will establish to the remote listening computer.
The file will be transmitted just as if you had typed it interactively: "
'user:~$' • nc -l -p 10000 < original_file
On the receiving end, you can anticipate a file coming over that will need to be unzipped and extracted by typing: "
'user:~$' • nc -l -p 10000 | tar xzvf -
- The command nc is a TCP/IP swiss army knife
- The -l argument is used as listening mode
- The -p argument specifies which ports you want to scan
- The tar command is a GNU version of the tar archiving utility
- The -x argument extracts files from an archive
- The -z argument unzips the file
- The -v argument is for verbose
- The -f argument uses archive file
- The ending dash (-) means that tar will operate on standard input, which is being piped from Netcat across the network when a connection is made.
On the side with the directory contents you want to transfer, you can pack them into a tarball and then send them to the remote computer through Netcat:
'user:~$' • tar -czf - * | nc leia.uclllabs.be 10000
- The tar command is a GNU version of the tar archiving utility
- The -c argument creates a new archive
- The -z argument unzips the file
- The -f argument uses archive file
- The command nc is a TCP/IP swiss army knife
In the following example, we create a full backup of our home directory on leia (all files and folders) using tar - Netcat method.
Execute this on leia: "
'user:~$' • tar -cz ~ | nc -l -p 10000
- The tar command is a GNU version of the tar archiving utility
- The -c argument creates a new archive
- The -z argument unzips the file
- The command nc is a TCP/IP swiss army knife
- The -l argument is used as listening mode
- The -p argument specifies which ports you want to scan
And this on your laptop (the machine receiving backups):
'user:~$' • cd /path/to/where_I_want_to_store_my_backup 'user:~$' • nc leia.uclllabs.be 10000 | tar -xzf -
- The command nc is a TCP/IP swiss army knife
- The tar command is a GNU version of the tar archiving utility
- The -x argument extracts files from an archive
- The -z argument unzips the file
- The -f argument uses archive file w
This is just one example of transferring more complex data from one computer to another. Another common idea is to use the dd command to image a disk on one side and transfer it to a remote computer.
'user@leia:~$' • tar -cz ~ | pv | nc -l -p 10000 'user@laptop:~$' • nc leia.uclllabs.be 10000 | pv > backup.tar.gz
- The tar command is a GNU version of the tar archiving utility
- The command nc is a TCP/IP swiss army knife
- The -c argument creates a new archive
- The pv command monitors the progress of data through a pipe
- The -z argument unzips the file
- The > argument overwrites the file
- The pv command monitors the progress of data through a pipe
- The command nc is a TCP/IP swiss army knife
- The -l argument is used as listening mode
- The -p argument specifies which ports you want to scan
'user@leia:~$' • tar -cz ~ | pv | nc '-N' -l -p 10000 'user@laptop:~$' • nc -d leia.uclllabs.be 10000 | pv > backup.tar.gz
- The tar command is a GNU version of the tar archiving utility
- The command nc is a TCP/IP swiss army knife
- The -c argument creates a new archive
- The -d argument makes sure that it does not attempt to read from stdin.
- The -z argument unzips the file
'user@laptop:~$' • nc leia.uclllabs.be 10000 </dev/null | pv | tar xzf -
- The pv command monitors the progress of data through a pipe
- The -N argument shuts the network socket down after EOF on the input
- The -l argument is used as listening mode
- The -p argument specifies which ports you want to scan
- /dev/null is for error log
Exercise 1:
How do you verify if the packages openssh-server and openssh-client are installed on your Debian system? (Hint: dpkg -l ...)"
'user:~$' • dpkg -l openssh-server 'user:~$' • dpkg -l openssh-client
- The argument -l is used for list
Exercise 2:
How do you verify if the openssh-server is running?
'user:~$' • systemctl status ssh
Exercise 3:
How to check which port is used by the SSH server daemon? (Hint: netstat, ss or lsof)
'root #' • netstat -lntp | grep sshd 'root #' • ss -lntp | grep sshd 'root #' • lsof -i tcp | awk '$1=="sshd" && $10=="(LISTEN)" {print $9}' | cut -d ':' -f2 | sort -u
- The netstat command prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
- The -l argument is used as listening mode
- The -n argument shows numerical addresses instead of trying to determine symbolic host, port or user names.
- The -p argument shows the PID and name of the program to which each socket belongs
- The grep command prints lines matching a pattern
- The ss command is another utility to investigate sockets
- The lsof command lists open files
- The -i argument selects the listing of files any of whose Internet address matches the address specified in i.
- The awk command is used for pattern scanning and processing language
- The cut command removes sections from each line of files
- The -d argument use DELIM instead of TAB for field delimiter
- The -f argument selects only these fields
- The sort command sort lines of text files
- The -u argument outputs only the first of an equal run
Exercise 4:
How do you disconnect from a remote SSH session?
'user:~$' • exit 'user:~$' • logout 'user:~$' • <CTRL>+d
Exercise 5:
Is there a config file for the OpenSSH server? If so, where is it located in the file system tree?
Yes: '/etc/ssh/sshd_config'
Exercise 6:
Create and demonstrate a simple web server with Netcat.
'user:~$' • while true; do { echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n<h1>hello world from $(hostname) on $(date)</h1>" | nc -vl -p 10000; } done
- The while command The while command continuously executes the list list-2 as long as the last command in the list list-1 returns an exit status of zero.
- The echo command displays a line of text
- The -e argument enables interpretation of backslash escapes
- The command nc is a TCP/IP swiss army knife
- The -v argument uses verbose
- The -l argument is used for listen mode, for inbound connects
- The -p argument is used for local port number
2019 oplossingen labo 2 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO 2
What is the IP address of your computer?
What is the status code returned from the server to your browser?
When was the HTML file that you are retrieving last modified on the server?
'user:~$' • echo -ne 'HEAD /HTTP-Wireshark-file1.html HTTP/1.1\r\nHost: virtualhostname.x.cnw2.uclllabs.be\r\n\r\n' | nc localhost 80 | grep 'Last-Modified:' 'user:~$' • tshark -r http.pcapng -Y http -T fields -e http.last_modified
- The -n argument does not output the trailing newline
- The -e argument enables interpretation of backslash escapes
- The nc command is a TCP/IP swiss army knife
- The -r argument reads the packet date from infile
- The -Y command captures the link type
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
How many bytes of content are being returned to your browser?
What software and version is the web server running?
'user:~$' • tshark -r http.pcapng -Y http.server -T fields -e ip.src -e http.server | sort -u
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
Explain in detail the above tshark command.
What TCP ports are in use at the client and the server during your browsing session?
'user:~$' • tshark -r http.pcapng -Y http -T fields -e tcp.port | sort -u
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
Exercise 1:
Which HTTP method was used the most during the entire browsing session?
'user:~$' • tshark -r http.pcapng -Y http.request.method -T fields -e http.request.method | sort | uniq -c | head -1 | awk '{print $2}' 'user:~$' • tshark -r http.pcapng -Y http.request.method -T fields -e http.request.method | sort | uniq -c | awk 'NR=1{print $2}'
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The uniq command reports or omits repeated lines
- The -c argument prefixes lines by the number of occurences
- The head command shows output for only the first part of files
- The awk command is used for pattern scanning and processing language
In case you would like to automate this: With tshark and a Bash loop"
'user:~$' • tshark -r http.pcapng -Y 'http.request.method==GET' -T fields -e tcp.srcport | sort -u | while read PORT;do tshark -r http.pcapng -Y "tcp.dstport==$PORT && http.server contains Apache" -T fields -e ip.src;done | sort -u
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
- The -Y command captures the link type
Exercise 2:
How many HTTP GET request messages did your browser send?
'user:~$' • tshark -r http.pcapng -Y http.request.method==GET | wc -l
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The wc command prints a newline, word, and byte counts for each file
- The -l argument prints the newline counts
To which Internet addresses were these GET requests sent?
'user:~$' • tshark -r http.pcapng -Y http.request.method==GET -T fields -e ip.dst | sort -u
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y command captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
Exercise 5:
Use Netcat to download these images. check the echo -ne options or use printf. If needed, slow down netcat with option -i. The image part in the HTTP stream starts after a blank line.
'user:~$' • echo -ne "GET /nw2/images/image1.jpg HTTP/1.1\r\nHost: darthvader.uclllabs.be\r\n\r\n" |\ nc darthvader.uclllabs.be 80 | sed '1,/^\r/d' > image1.jpg 'user:~$' • echo -ne "GET /nw2/images/image1.jpg HTTP/1.1\r\nHost: darthvader.uclllabs.be\r\n\r\n" |\ nc darthvader.uclllabs.be 80 | grep -A9999999999999999 -B0 -Pa 'JFIF' > image1.jpg
- The -n argument does not output the trailing newline
- The -e argument enables interpretation of backslash escapes
- The sed command is a stream editor for filtering and transforming text
- The nc command is a TCP/IP swiss army knife
- The -A argument prints NUM lines of trailing context after matching lines.
- The -B argument interprets PATTERN as a Perl regular expression (PCRE, see below).
- The -a argument processes a binary file as if it were text; this is equivalent to the --binary-files=text option.
Exercise 7:
Use httpie, a cURL-like tool for humans to inspect the various HTTP headers in request and responses. Connect to various websites and explain the use of the HTTP headers.
'user:~$' • http -v -a Rey:StarWars http://darthvader.uclllabs.be/nw2/private/
- The -v argument is for verbose
Exercise 8:
http://darthvader.uclllabs.be/nw2/phone/. Create a oneliner to bruteforce the pincode. Tip: pincode range: 1200-1300
A simulated phone is running at'user:~$' • for foo in {1200..1300}; do if wget -q --http-user='admin' --http-password=$foo http://darthvader.uclllabs.be/nw2/phone; then echo $foo;break;fi;done
- The wget command is the non-interactive network downloader
- The -q argument turns of the wget's output
- The --http-user AND --http-password specifies the username and the password on a http server
Exercise 9:
"Put the following text.txt on your web server. This text contains the string Goed bezig :-)
Write an HTTP request by using the Range header so your web server will only return this exact string 'Goed bezig :-)'. Try to do this by only using netcat
'user:~$' • curl http://your.server.name/output.txt -i -H "Range: bytes=1-" 'user:~$' • echo -ne "GET /output.txt HTTP/1.1\r\nHost: your.server.name\r\nRange: bytes=1-\r\n\r\n" | nc your.server.name 80
- The curl command is used to transfer a URL
- The -i argument includes the HTTP-header in the output
- The -H argument is used as a extra header to use when getting a web page
- The nc command is a TCP/IP swiss army knife
- The -n argument does not output the trailing newline
- The -e argument enables interpretation of backslash escapes
Exercise 10:
This can be accomplished by sending the output of tshark or tcpdump to STDOUT instead of a regular file. Direct this STDOUT stream to Wireshark running on your local computer.
'root #' • ssh myserver.X.cnw2.uclllabs.be tcpdump -nli eth0 not tcp port 22345 -s0 -w - | wireshark -nki - 'root #' • ssh myserver.X.cnw2.uclllabs.be 'tshark -nli eth0 -f "not tcp port 22345" -s0 -w -' | wireshark -nki -
- The ssh command is a remote login program
- The -n argument redirects stdin from /dev/null (actually, prevents reading from stdin).
- The -l argument specifies the user to log in as on the remote machine.
- The -i argument selects a file from which the identity (private key) for public key authentication is read.
- The -s argument may be used to request invocation of a subsystem on the remote system
- The -w argument Requests tunnel device forwarding with the specified tun(4) devices between the client (local_tun) and the server (remote_tun).
- The -n argument disables network object name resolution (such as hostname, TCP and UDP port names), the -N flag might override this one.
- The -k argument starts the capture session immediately.
- The -i argument sets the name of the network interface or pipe to use for live packet capture.
- The -f argument (in tshark command) sets the capture filter expression
Exercise 11:
Capture some HTTP traffic while browsing several websites and save it to the file http.pcapng.
You can also use the test capture in /home/logs on leia. create a CLI oneliner which parses the captured file http.pcapng and displays all HTTP server strings which do not contain Apache.
Only the commands tshark and sort are allowed.
'user:~$' • tshark -r http.pcapng -Y 'http.server && !(http.server contains Apache)' -T fields -e http.server | sort -u
- The -r argument reads the packet date from infile
- The -Y command captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
Exercise 12:
This exercise is a small variation of the previous one. Count and sort all HTTP server strings which do not contain Apache in HTTP responses on your GET requests.
'user:~$' • tshark -r http.pcapng -Y '!(http.request.method==GET)' -T fields -e tcp.srcport | sort -u | while read PORT;do tshark -r http.pcapng -Y "tcp.dstport==$PORT && http.server && !(http.server contains Apache)" -T fields -e http.server;done | sort | uniq -c | sort -rn
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y command captures the link type
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The -u argument output only the first of an equal run
- The -T argument sets the format of the output when viewing decoded packet data.
- The uniq command reports or omits repeated lines
- The -c command prefixes lines by the number of occurrences
- The -r argument (in sort command) reverses the results of comparisons
- The -n compare according to string numerical value
2019 oplossingen labo 3 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
Labo 3
Match one or more d characters: d dd ddd dddd "
'user@:~$' • grep -P 'd+' file 'user@:~$' • cat file | grep -P 'd+'
- d matches the character d literally (case sensitive)
- The grep command prints lines matching a pattern
- The -P argument interprets PATTERN as a Perl regular expression
Color and colour are different spellings of the same word.
Color is the preferred spelling in American English, and colour is preferred in all other main varieties of English. The following regex matches both. "
'user@:~$' • grep -P 'colou?r' file
- colo matches the characters colo literally (case sensitive)
- u matches the character u literally (case sensitive)
- ? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
- r matches the characters r literally (case sensitive)
Match wh following by one, two or three e character: 'whe whee wheee'
'user@:~$' • grep -P 'whe{1,3}' file
- The grep command prints lines matching a pattern
- The -P argument interprets PATTERN as a Perl regular expression
- whe matches the characters whe literally (case sensitive)
- {1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
Match either gray or grey
'user@:~$' • grep -P '{gray|grey}' file
- The grep command prints lines matching a pattern
- The -P argument interprets PATTERN as a Perl regular expression
- '{gray|grey}' must match gray or gray
Let's say you want to match a text like !abc! or !123!. Only these two are possible, and you want to capture the abc or 123.
'user@:~$' • grep -P '!(abc|123)!' file
- The grep command prints lines matching a pattern
- The -P argument interprets PATTERN as a Perl regular expression
- '{gray|grey}' must match !abc! or !123!
Search /usr/share/dict/dutch for all words which end in 'vuur', without matching the word 'vuur' itself.
'user@:~$' • grep -P '^.+vuur$' /usr/share/dict/dutch
- ^ asserts position at start of a line
- . matches any character (except for line terminators)
- matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- vuur matches the characters vuur literally
List all words which contain 32 or more letters.
user@:~$' • grep -P '^.{32}$' /usr/share/dict/dutch
- ^ asserts position at start of a line
- . matches any character (except for line terminators)
- {32} matches the previous token exactly 32 times
- $ asserts position at the end of a line
List all words starting with the letter 'b', ending with the letter 'l' which are exactly 4 letters long. Capitalize the output
'user@:~$' • grep -E '^b.{2}l$' /usr/share/dict/dutch | tr [:lower:] [:upper:] 'user@:~$' • perl -ne 'print uc if /^b.{2}l$/' /usr/share/dict/dutch
- ^ asserts position at start of a line
- b matches the character b literally (case sensitive)
- . matches any character (except for line terminators)
- {2} matches the previous token exactly 2 times
- l matches the character l literally (case sensitive)
- $ asserts position at the end of a line
- The perl command is how to execute the Perl interpreter
- The -n argument causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed -n or awk:
- The -e argument may be used to enter one line of program.
List all palindromes with exactly 4 characters
```
'user@:~$' • grep -P '^([A-Za-z])([A-Za-z])\2\1$' /usr/share/dict/dutch
'user@:~$' • perl -lne 'print if $_ eq reverse && length($_) eq 4' /usr/share/dict/dutch
```
- A-Z matches a single character in the range between A and Z (case sensitive)
- a-z matches a single character in the range between a and z (case sensitive)
- \2 matches the same text as most recently matched by the 2nd capturing group
- \1 matches the same text as most recently matched by the 1st capturing group
- $ asserts position at the end of a line
Exercise 1:
List all words out of the file /usr/share/dict/dutch which contain 4 or 5 consecutive vowels.
```
'user@:~$' • cat /usr/share/dict/dutch | grep -P '[aeiou]{4,5}'
```
- aeiou matches a single character in the list aeiou (case sensitive)
- {4,5} matches the previous token between 4 and 5 times, as many times as possible, giving back as needed (greedy)
Exercise 2:
Count the number of words out of the file /usr/share/dict/dutch which which start with 'ver', and end with 'en'. ('verplaatsen' is ok, 'overkomen' and 'vertrek' are not ok)
```
'user@:~$' • grep -P '^ver.*en$' /usr/share/dict/dutch | wc -l
```
- ^ asserts position at start of a line
- ver matches the characters ver literally (case sensitive)
- . matches any character (except for line terminators)
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- $ asserts position at the end of a line
- The wc command prints newline, word, and byte counts for each file
- The -l argument prints the newline counts
Exercise 3:
In those annoying night television games people must guess words. Given are all the letters the word consist of and a list of dots, one for every letter.
E.g. We are looking for a 23 letter word with a 'v' in position 8: '.......v...............'. Use the letters 'enrtiscau' for the other positions."
```
'user@:~$' • cat /usr/share/dict/dutch | grep -P '[enrtiscau]{7}v[enrtiscau]{15}'
```
- enrtiscau matches a single character in the list enrtiscau (case sensitive)
- {7} matches the previous token exactly 7 times
- {15} matches the previous token exactly 15 times
Exercise 4:
Show 'System load = X Y Z' replacing X, Y and Z by the values displayed by the uptime command.
```
'user@:~$' • echo "System load =" $(uptime | awk -F': ' '{print $2}'| tr -d ',')
```
Exercise 5:
List the usernames of the students who logged in from outside of the UCLL network.
```
'user@:~$' • who | grep -Pv '(.*)\s+pts.*\s+\(10\.|tmux' | awk '/^r[0-9]/{print $1}' | sort -u
```
- . matches any character (except for line terminators)
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- \s matches any whitespace character (equivalent to [\r\n\t\f\v ])
- r matches the character r literally (case sensitive)
-
- matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- tmux matches the characters tmux literally (case sensitive)
- ^ asserts position at start of a line
- 0-9 matches a single character in the range between 0 and 9 (case sensitive)
Exercise 6:
How many times have students logged into leia from outside the UCLL network?
```
'user@:~$' • last | grep -Pv '.*?pts.*?\s+10\.' | awk '/^r[0-9]/{print $1}' | wc -l
```
- . matches any character (except for line terminators)
- *? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
- pts matches the characters pts literally (case sensitive)
- r matches the character r literally (case sensitive)
- \s matches any whitespace character (equivalent to [\r\n\t\f\v ])
- '+' matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- ^ asserts position at start of a line
Exercise 7:
Show the file /etc/debconf.conf on screen without comment lines (i.e. lines starting with a #)
```
'user@:~$' • cat /etc/debconf.conf | grep -vP '^#'
```
- ^ asserts position at start of a line
- '#' matches the character # literally (case sensitive)
Exercise 8:
List all unique IP addresses that contacted your Apache web server.
```
'user@:~$' • cat /var/log/apache2/wiki-ssl-access.log | awk '{print $1}' | sort -u
```
Exercise 9:
List all unique IP addresses that contacted the ssh daemon of your Apache web server.
```
'user@:~$' • cat /var/log/auth.log | grep -oP 'sshd.*?\K[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u
```
- sshd matches the characters sshd literally
- . matches any character (except for line terminators)
- *? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
- \K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
- [0-9]{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
- 0-9 matches a single character in the range between 0 and 9 (case sensitive)
- . matches the character . literally (case sensitive)
Exercise 10:
Create a regular expression to match all words in the dictionary /usr/share/dict/dutch which with 10 unique letters.
```
'user@:~$' • cat /usr/share/dict/dutch | grep -P '^.{10}$' | grep -vP '(.).*\1'
```
- ^ asserts position at start of a line
- . matches any character (except for line terminators)
- {10} matches the previous token exactly 10 times
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- \1 matches the same text as most recently matched by the 1st capturing group
Exercise 11:
To combat spam, a mail server administrator wants to reject mail coming from home users. The IP addresses home users always seem to connect from have hostnames like this: ip.domain. Create a regex which matches all these host names.
```
'user@:~$' • cat mail.log | grep -oP 'NOQUEUE: reject: RCPT from \K[0-9]{1,3}.*?\[' | tr -d '['
```
- [0-9]{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
- . matches any character (except for line terminators)
- *? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
Exercise 12:
www.khleuven.be. Use log file /home/logs/apache_google.log. "
List all unique firefox 2.0.0.x versions used to connect to```
'user@:~$' • cat apache_google.log | grep -oP 'Firefox\/2\.0\.0\.[0-9]+' | sort -n -t '.' -k4 -u
```
- Firefox matches the characters Firefox literally (case sensitive)
- / matches the character / literally (case sensitive)
- 2 matches the character 2 literally (case sensitive)
- . matches the character . literally (case sensitive)
- 0 matches the character 0 literally (case sensitive)
- [0-9]+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Exercise 13:
List all words with 14, 15 or 16 unique letters.
```
'user@:~$' • for foo in 14 15 16; do echo "Words with $foo letters:" $(echo "grep -vP '(.).*\1' /usr/share/dict/dutch | grep -P '^.{$foo}$'"| sh);done
'user@:~$' • for foo in 14 15 16; do echo "Words with $foo letters:" $(grep -vP '(.).*\1' /usr/share/dict/dutch | grep -P "^.{$foo}$");done
'user@:~$' • for foo in 14 15 16; do echo "Words with $foo letters:" && echo "grep -vP '(.).*\1' /usr/share/dict/dutch | grep -P '^.{$foo}$'"| sh;done
'user@:~$' • for foo in 14 15 16; do echo "Words with $foo letters:" && grep -vP '(.).*\1' /usr/share/dict/dutch | grep -P "^.{$foo}$";done
```
- . matches any character (except for line terminators)
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- \1 matches the same text as most recently matched by the 1st capturing group
- ^ asserts position at start of a line
- $ asserts position at the end of a line
- foo} matches the characters foo} literally (case sensitive) $ asserts position at the end of a line
2019 oplossingen labo 4 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
Labo 4
What is the IP address of the client and what IP address is used by the server?
Which protocol was used to find the IP address of the FTP server.
Does FTP use UDP or TCP? Why?
Is the session using active or passive FTP?
Who chooses the FTP version, active or passive? Is it the client or the server?
Sketch the three-way handshake used to negotiate the initial sequence numbers. Do this both for the relative and the real sequence numbers.
What is the benefit in using relative sequence numbers in Wireshark/Tshark?
Which credentials were used to login to the FTP service?
'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER" -T -e ftp.request.arg
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
"Step 1:
When a user's login attempt is successful, the FTP server answers with FTP response code 230 <- Response code: User logged in, proceed (230).
This message is sent to the client using it's chosen TCP port. This very same TCP port is used by the client for every packet sent in the control connection.
So we know the client will use this port as TCP source port when profiding the FTP username. Thus the first step is to find this TCP port:
See Cnw2 theory - Chapter 2: Application Layer: Active vs Passive FTP
'user@:~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
Step 2:
The port we just found is the TCP port the client uses for the FTP control connection.
When using this port as TCP source port in our display filter, we'll only list packets sent from client to FTP server
'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport)"
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data. The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
Step 3:
We're only interested in the packet containing the username, so let's add 'ftp.request.command == USER' to the display filter:
'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER"
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The server sends a 230 code in response to a command that has provided sufficient credentials to the server to grant the user access to the FTP server.
Step 4:
And finally use the tshark fields option to only display the username used:
'user@:~$' • tshark -r Cnw2_ftp.pcap -Y "tcp.srcport == $(tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230' -T fields -e tcp.dstport) && ftp.request.command == USER" -T fields -e ftp.request.arg debbie
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The server sends a 230 code in response to a command that has provided sufficient credentials to the server to grant the user access to the FTP server.
Which file was downloaded/uploaded from/to the FTP server? (delete as appropriate)
'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.request.command == RETR' | grep -Po 'RETR \K.*'
- The RETR argument ==> client issues the RETR command after successfully establishing a data connection when it wishes to download a copy of a file on the server.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The -P argument interprets I as Perl-compatible regular expressions (PCREs).
- The -o argument prints only the matched (non-empty) parts of a matching line, with each such part on a separate output line.32
Can you reconstruct this file from the Wireshark packet dump? Open the file to verify it's contents are intact.
How many packets have their destination port set to 21?
'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'tcp.dstport == 21' | wc -l
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- tcp.dstport == 21 => TCP port
- The wc command prints newline, word, and byte counts for each file
- The argument -l prints the newline counts
List all packets which have the PUSH bit set. What is the benefit in setting this bit?
'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'tcp.flags.push == 1'
- The -r argument reads the packet date from infile
- tcp.flags.push == 1 => Which means "check if the Push flag is set". Filtering for just "tcp.flags.push" would again mean "check if there's a push flag field" (which there is, always)
How can you manually calculate the actual port advertised by the PASV/PORT command?
'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 227' | awk -F ',' '{print $5*256+$6}'
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- This is the response given by the server to the PASV command. It indicates that the server is ready for the client to connect to it for the purpose of establishing a data connection.
- The awk command is used for pattern scanning and processing language
- The -F argument
- 5 matches the character 5 literally (case sensitive)
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- 25 matches the characters 25 literally (case sensitive)
- 6 matches the character 6 literally (case sensitive) + matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- $ asserts position at the end of a line
- 6 matches the character 6 literally (case sensitive)
How many L4 sessions were created in the FTP session? Note: passive FTP was used in this session.
'user@~$' • tshark -r Cnw2_ftp.pcap -Y 'ftp.response.code == 230 || ftp.response.code == 227' | wc -l
- The server sends a 230 code in response to a command that has provided sufficient credentials to the server to grant the user access to the FTP server.
- This is the response given by the server to the PASV command. It indicates that the server is ready for the client to connect to it for the purpose of establishing a data connection.
- The wc command prints newline, word, and byte counts for each file
- The argument -l prints the newline counts
Try to answer these questions with 'cnw2_ftp_bruteforce.pcap: (file)'
How many password guesses were made?
'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command == PASS' -T fields -e ftp.request.arg | wc -l
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- So, to see all login attempts, try this filter: ftp.request.command==USER || ftp.request.command==PASS
- The wc command prints newline, word, and byte counts for each file
- The argument -l prints the newline counts
Did the attacker finally get in?
'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.response.code == 230' | grep -q 'Response: 230' && echo YES || echo NO
- The server sends a 230 code in response to a command that has provided sufficient credentials to the server to grant the user access to the FTP server.
- The -q argument = quiet - do not write anything to standard output
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
Which usernames did he/she try?
'user@~$' • tshark -r Cnw2_ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ftp.request.arg | sort -u
- The -r argument reads the packet date from infile
- The -Y argument captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The -u argument => with -c, checks for strict ordering; without -c, output only the first of an equal run
2019 oplossingen labo 5 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO 5
Encrypting the self created file secret.txt using AES can be done like this: "
'user@:~$' • openssl enc -aes-128-cbc -in secret.txt -out secret.txt.aes
-The enc command is used for symmetric cipher routines
To decrypt the file created above and show the decrypted data on screen, use:
'user@:~$' • openssl enc -d -aes-128-cbc -in secret.txt.aes
To get a list of all available encryption algorithms in OpenSSL, type:
'user@:~$' • openssl list-cipher-commands
On more recent OpenSSL versions the command above will not work. The new syntax is as follows:
'user@:~$' • openssl list -help 'user@:~$' • openssl list -cipher-commands
Thus we need to tell our application that ecrypted_picture.bmp is indeed a bitmap. Bitmaps begin with a 54-byte header.
The idea is to extract the first 54 bytes of the unencrypted bitmap and overwrite the first 54 bytes of the encrypted one with the real header. See the following examples: "
AES in ECB mode
'user@:~$' 1) openssl enc -aes-128-ecb -in slimmerik.bmp -out slimmerik_ECB.bmp 'user@:~$' 2) dd if=slimmerik.bmp of=slimmerik_ECB.bmp bs=1 count=54 conv=notrunc
"We could, of course, automate this: "
'user@:~$' 1) dd if=slimmerik.bmp bs=1 count=54 > slimmerik_ECB.bmp && openssl enc -aes-128-ecb -k pass:t -in slimmerik.bmp | dd bs=1 skip=54 >> slimmerik_ECB.bmp 'user@:~$' 2) dd if=slimmerik.bmp of=slimmerik_ECB.bmp bs=1 count=54 && dd if=slimmerik.bmp bs=1 skip=54 | openssl enc -aes-128-ecb -k pass:t >> slimmerik_ECB.bmp
- The dd command converts and copy a file
- The -k argument forces nc to stay listening for another connection after its current connection is completed
AES in CBC mode
'user@:~$' 1) openssl enc -aes-128-cbc -in slimmerik.bmp -out slimmerik_CBC.bmp 'user@:~$' 2) dd if=slimmerik.bmp of=slimmerik_CBC.bmp bs=1 count=54 conv=notrunc
ROT13 encryption
'user@:~$' 1) alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'" 'user@:~$' 2) cat slimmerik.bmp | rot13 > slimmerik_rot13.bmpw
- Match a single character present in the list below [N-ZA-Mn-za-m]
- N-Z matches a single character in the range between N (index 78) and Z (index 90) (case sensitive)
- A-M matches a single character in the range between A (index 65) and M (index 77) (case sensitive)
- n-z matches a single character in the range between n (index 110) and z (index 122) (case sensitive)
- a-m matches a single character in the range between a (index 97) and m (index 109) (case sensitive)
You need a key pair to be able to use GnuGP. You can generate one with: "
'user@:~$' • gpg --gen-key
After your keypair is created you should immediately generate a revocation certificate for the primary public key using the option --gen-revoke.
If you forget your passphrase or if your private key is compromised or lost, this revocation certificate may be published to notify others that the public key should no longer be used
'user@:~$' • gpg --output revoke.asc --gen-revoke <mykey>
You can use your key pair to encrypt and sign, but without exchanging public keys this is useless. Others need your public key to verify your signatures and to send encrypted messages to you. You need their keys for the same purposes.
'user@:~$' • gpg --list-keys
You can export your public key using:
'user@:~$' • gpg --output <file> --export <email>
Now import some keys from classmates:
'user@:~$' • gpg --import <file>
You already have an automatically created encryption subkey. Now you will create another subkey for signing.
Instead of the master key the subkey will be used to verifying message signatures.
'user@:~$' • gpg --edit-key YOURMASTERKEYID
Exercise 1:
Bob needs to send a text file through an encrypted tunnel to Alice. Both already agreed on a shared secret 'secret' using the Diffie Hellman algorithm. Alice wants to display the contents of the file directly on her screen instead of storing it locally and then opening it. Use a suitable encryption algorithm. The data is sent over a medium which only allows ASCII text.
'Alice@leia:~$' • nc -l 10000 | openssl enc -a -d -aes-128-cbc -k pass:secret 'Bob@laptop:~$' • cat file | openssl enc -a -aes-128-cbc -k pass:secret | nc leia.uclllabs.be 10000
Exercise 2:
Bob needs to send a text file through an encrypted tunnel to Alice. Both already agreed on a shared secret 'secret' using the Diffie Hellman algorithm. Alice wants to display the contents of the file directly on her screen instead of storing it locally and then opening it. Use a suitable encryption algorithm. The data is sent over a medium which only allows ASCII text. "
Step 1:
As Bob needs to send an encrypted file to Alice, he will need her public key.
So in the first step Alice needs to generate a keypair, and export her public key so she could provide it to Bob. "
'Alice@Server ~ $' • gpg --gen-key 'Alice@Server ~ $' • gpg --output alice.gpg --export alice@uclllabs.be
Step 2:
Alice has exported her gpg public key to the file alice.gpg.
She sends this file e.g. by email to bob. Note that this file is no secret, it is just a public key. Now bob can import Alice's public key into gpg: "
'Bob@leia ~ $' • gpg --import alice.gpg
Step 3:
Bob is ready to sent his secret text file to Alice while providing confidentiality:
'Alice@Server ~ $' • nc -l -p 10000 | gpg --decrypt --quiet 'Bob@leia ~ $' • cat file.txt | gpg --encrypt --armor --output - --recipient alice@uclllabs.be | nc -N server.x.cnw2.uclllabs.be 10000
- The --encrypt argument encrypts data
- The --armor argument creates ASCII armored output
- The nc command is a TCP/IP swiss army knife
Exercise 3:
Same exercise as above, but now use gpg and netcat to create a simple chat application.
'Alice@Server ~ $' • nc -l -p 10000 | gpg --decrypt --quiet --allow-multiple-messages 'Bob@leia ~ $' • while read line; do echo $line | gpg --encrypt --armor --output - --recipient alice@uclllabs.be; done | nc -N server.x.cnw2.uclll
2019 oplossingen labo 6 - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO 6
Check the contents of the ucll.be wildcard certificate, and make sure you understand the chain of trust.
'user@:~$' • echo | openssl s_client -connect ucll.be:443 | openssl x509 -text -noout
- x509 - is a certificate display and signing utility
- The -text argument prints out the certificate in text form.
- The -noout argument prevents output of the encoded version of the request
We'll start this lab by making our very own SSL certificate. Before we can create a certificate we need to generate an RSA private key.
'user@:~$' • openssl genrsa -aes128 -out TomBola.keys 2048
- The genrsa command generates an RSA private key
Use the following command to remove the pass phrase:
'user@:~$' • openssl rsa -in TomBola.keys -out TomBola.keys
- The -in command specifies the input filename to read a request from or standard input if this option is not specified
- The -out command specifies the output filename to write to or standard output by default.
Now create the Certificate Signing Request.
'user@:~$' • openssl req -new -key TomBola.keys -out TomBola.csr
Lazy admins will probably prefer the following command, its result is the same as all three commands above combined:
'user@:~$' • openssl req -new -newkey rsa:2048 -keyout TomBola.keys -nodes -out TomBola.csr
- The -new command is used to generate a new certificate request
- The -newkey command creates a new certificate request and a new private key
- The -keyout command gives the filename to write the newly created private key to.
- The -nodes command is used if a private key is created it will not be encrypted.
- The -out command specifies the output filename to write to or standard output by default.
- The nodes argument -nodes tells OpenSSL not to encrypt the private key
This verification step is optional but recommended. Now we need somebody to sign our key. We will use our own private key for the signature, creating a self-signed certificate.
As a self-signed certificate is signed by itself it won't be trusted by client software like email clients and web browsers.
Only public keys of real Certificate Authorities (CA) are included in the browsers or OSs certificate stores.
'user@:~$' • openssl x509 -req -days 365 -in TomBola.csr -signkey TomBola.keys -out TomBola.crt
- The -req command is by default a certificate is expected on input. With this option a certificate request is expected instead.
- The -signkey command causes the input file to be self signed using the supplied private key.
- The -days command is used (when the -x509 option is being used) specifies the number of days to certify the certificate for.
If somehow you forgot which key/crt/csr files belong to each other, compare their modulus values. They should be the same. To ease the comparing process create a hash value first.
'user@:~$' • openssl x509 -in TomBola.crt -noout -modulus | md5sum; \ openssl req -in TomBola.csr -noout -modulus | md5sum; \ openssl rsa -in TomBola.keys -noout -modulus | md5sum
- The -in command specifies the input filename to read a certificate from or standard input if this option is not specified.
- The -noout command is used to prevent output of the encoded version of the request
- The -modulus command prints out the value of the modulus of the public key contained in the request.
- The -days command is used (when the -x509 option is being used) specifies the number of days to certify the certificate for.
As we need a Subject Alternative Name (SAN) field to specify additional names associated with our certificate the first step is to create a small openssl configuration file.
FILE: uclllabs_be.conf
[ req ]
default_bits = 4096
prompt = no
encrypt_key = no
default_md = sha512
distinguished_name = dn
req_extensions = v3_req
[ dn ]
C = BE
O = UC Leuven
CN = *.uclllabs.be
[ v3_req ]
subjectAltName = DNS:uclllabs.be
In the next step, we generate our CSR
'user@:~$' • openssl req -new -newkey rsa:4096 -nodes -out star_uclllabs_be.csr -keyout star_uclllabs_be.key -subj "/C=BE/ST=/L=/O=UC Leuven/CN=*.uclllabs.be" -sha512 -config uclllabs_be.cnf 'user@:~$' • openssl req -new -nodes -out star_uclllabs_be.csr -keyout star_uclllabs_be.key -config uclllabs_be.cnf
- The command req is a certificate request and certificate generating utility
- The -new argument generates a new certificate request
- The -newkey argument creates a new certificate request and a new private key.
- The nodes argument -nodes tells OpenSSL not to encrypt the private key
- The -out argument is specified then if a private key is created it will not be encrypted.
- The -keyout argument gives the filename to write the newly created private key to.
- The -subj argument replaces subject field of input request with specified data and outputs modified request.
- The -config argument allows an alternative configuration file to be specified
First check whether the certificate's common name corresponds with the server name, check the expiration date and check the chain of trust.
'user@:~$' • echo | openssl s_client -connect ucll.be:443 | openssl x509 -text -noout | grep -A2 Validity
- x509 - is a certificate display and signing utility
- The -text argument prints out the certificate in text form.
- The -noout argument prevents output of the encoded version of the request
http://crl3.digicert.com/TERENASSLCA3.crl
Second, verify the certificate is not listed on the included CRL (Certificate Revocation List):'user@:~$' 1) wget http://crl3.digicert.com/TERENASSLCA3.crl 'user@:~$' 2) openssl crl -in TERENASSLCA3.crl -text -noout
- The -in argument specifies the input filename to read from or standard input if this option is not specified
- The -text argument prints out the CRL in text form.
- The -noout argument doesn't output the encoded version of the CRL
Unfortunately, this does no seem to work. OpenSSL stops and spawns an error message
The reason is that TERENA published their CRL in DER format, and by default OpenSSL uses the PEM format. Lets convert the CRL to the correct format and try again:
'user@:~$' 1) openssl crl -inform DER -in TERENASSLCA3.crl -outform PEM -out TERENASSLCA3.crl.pem 'user@:~$' 2) openssl crl -in TERENASSLCA3.crl.pem -text -noout
- The -inform argument specifies the input format
- The -in argument specifies the input filename to read from or standard input if this option is not specified
- The -outform argument specifies the output format
- The -out argument specifies the output filename to write to or standard output by default.
The last two commands could be combined in one so the conversion from DER to PEM format is not necessary anymore:
'user@:~$' • openssl crl -inform DER -in TERENASSLCA3.crl -text -noout
And without first downloading the crl:
'user@:~$' • wget -q -O - http://crl3.digicert.com/TERENASSLCA3.crl | openssl crl -inform DER -text -noout
And with extracting the CRL URI automatically:
'user@:~$' • wget -q -O - $(echo | openssl s_client -connect ucll.be:443 2>/dev/null | openssl x509 -text -noout | grep -oP 'URI:\K.*\.crl'| head -1) | openssl crl -inform DER -text -noout
- The wget command is a non-interactive network downloader
- The -q command is used to turn off Wget's output
- The -o command is specified for the outpout document
- The -text argument prints out the CRL in text form.
- The -noout argument doesn't output the encoded version of the CRL
Let's find the serial number of our certificate:
'user@:~$' • openssl x509 -in cert.pem -text
shows our certificate and we find the certificate serial number being: "0d:d9:43:24:0a:84:a5:e6:36:94:ff:c7:eb:e8:1e:3f"
Or in one command with:
'user@:~$' • echo | openssl s_client -connect ucll.be:443 2>/dev/null | openssl x509 -text -noout | grep -A1 -i serial
- The -text argument prints out the CRL in text form.
- The -noout argument doesn't output the encoded version of the CRL
- The -A prints NUM lines of trailing context after matching lines.
- The -i command is used to ignore case
If we would like to verify this serial number manually we need to remove the colons or add colons to the serials in the crt.
Removing should be a peace of cake since the previous labs. Adding a colon every two characters is a bit more complex: "
'user@:~$' • echo 0d:d9:43:24:0a:84:a5:e6:36:94:ff:c7:eb:e8:1e:3f | tr -d ':' => OUTPUT: 0dd943240a84a5e63694ffc7ebe81e3f 'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/..\B/&:/g' => OUTPUT: 0d:d9:43:24:0a:84:a5:e6:36:94:ff:c7:eb:e8:1e:3f
- The .. mean: look for exactly two characters.
- &: means: replace these two dots (their corresponding found characters) itself and add a colon. Thus ab becomes ab:
- The g at the end tells sed not to stop on the first occurrence
- And finally: /B makes sure that the .. only matches at the word boundary.
'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/..//' => OUTPUT: d943240a84a5e63694ffc7ebe81e3f 'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/../&/' => OUTPUT: 0dd943240a84a5e63694ffc7ebe81e3f 'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/../&:/' => OUTPUT: 0d:d943240a84a5e63694ffc7ebe81e3f 'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/../&:/g' => OUTPUT: 0d:d9:43:24:0a:84:a5:e6:36:94:ff:c7:eb:e8:1e:3f: 'user@:~$' • echo 0dd943240a84a5e63694ffc7ebe81e3f | sed 's/..\B/&:/g' => OUTPUT: 0d:d9:43:24:0a:84:a5:e6:36:94:ff:c7:eb:e8:1e:3f
Of course, much easier is to just use the -serial parameter of OpenSSL, it will be displayed in the correct format automatically:
'user@:~$' • openssl x509 -in cert.pem -serial -noout
- The -noout argument doesn't output the encoded version of the CRL
- The -serial command outputs the certificate serial number.
Of course it is even more easy to just let OpenSSL do all the hard work, just like we do with our web browsers and mailclients. It is the client software which verifies the certificate and not the user.
'user@:~$' • openssl verify -CAfile TERENASSLCA3.crl.pem -crl_check cert.pem cert.pem: C = BE, ST = Vlaams-Brabant, L = Leuven, O = UC Leuven, CN = *.ucll.be
- The verify command is used to verify certificate chains
- The -CAfile command is a file of trusted certificates.
- The -crl_check command checks end entity certificate validity by attempting to lookup a valid CRL
Now its time to do something with our newly created certificate (TomBola.crt). OpenSSL not only includes SSL/TLS client software but also a server, which can act as a very basic web server:
'user@:~$' • openssl s_server -accept 10000 -cert TomBola.crt -key TomBola.key -www -state
- The -www command sends a status message back to the client when it connects.
- The -state command prints out the SSL session states.
- The -cert command is to specify which certificate to use
- The -state argument is used to display the various SSL states and messages used to build the secure connection
'user@:~$' • openssl s_client -connect localhost:10000
Use the private key from your certificate with the following command-line
'user@:~$' • openssl dgst -sha256 -sign TomBola.key -out examenvragen.pdf.sha2 examenvragen.pdf
- The dgst function outputs the message digest of a supplied file or files in hexadecimal form. They can also be used for digital signing and verification.
- The -sign command digitally signs the digest using the private key in "filename".
When you receive the document it's signature can be verified with the following command:
'user@:~$' • openssl dgst -sha256 -verify TomBola.pub -signature examenvragen.pdf.sha2 examenvragen.pdf
- The dgst function outputs the message digest of a supplied file or files in hexadecimal form. They can also be used for digital signing and verification.
- The -signature command is used to verify the actual signature
Use the following OpenSSL command to extract the public key from the certificate and execute the command above to verify the integrity of the document and also authenticate its sender/creator.
'user@:~$' • openssl x509 -in TomBola.crt -pubkey -noout > TomBola.pub
Use Wireshark to analyze and observe the TLS handshake between your browser and a https site of your choice. Try to answer the following questions:
Which version of the SSL/TLS protocol is used?
Which signature hash algorithms are advertised as supported by your browser?
Which cipher suites are supported by the client (browser), and which are supported by the server?
Which cipher suite is chosen? Explain the different parts of the cipher suite.
Is it the client or the server who defines the cipher suite to be used?
If you need to see the contents of SSL/TLS encrypted packets you need to feed the correct decryption keys into Wireshark.
If you have access to the private key and no Diffie-Hellman is used to calculate the session keys (shared secrets), Wireshark can decrypt all data.
In most cases you do not have access to the private key or DHE is used to calculate the session keys, thus the above option will not work.
Fortunately, some browsers (like firefox) have the ability to save these session keys to a file, allowing Wireshark to decrypt all SSL/TLS data to/from any website:
'user@:~$' 1) export SSLKEYLOGFILE=/home/slimmerik/sslkey.log 'user@:~$' 2) firefox & 'user@:~$' 2) sudo wireshark -o ssl.keylog_file:/home/slimmerik/sslkey.log
# crl Certificate Revocation List (CRL) Management. # rsa RSA key management (private key). # csr Certificate Signing Request (CSR) Management. # x509 X.509 Certificate Data Management (public key certificate). # s_client Openssl SSL/TLS client (e.g. an https client) # s_server Openssl SSL/TLS server (e.g. an https server) # enc Encoding with Ciphers (encryption and decription).
Exercise 1:
Take a close look at the contents of cert.pem. It is a pem encoded digital certificate.
With the following OpenSSL magic the certificate can be displayed in a more human-friendly format."
'user@:~$' • openssl x509 -text -noout -in cert.pem
Exercise 2:
https://wiki.uclllabs.be. We could use the following set of commands:"
Let's say we would like to check the expiration date of the certificate used on'user@:~$' • openssl s_client -connect wiki.uclllabs.be:443 > tempfile
Now open the temp file with vim, your preferred text editor and delete all lines before -----BEGIN CERTIFICATE----- and after -----END CERTIFICATE-----.
Next use the command below to find the correct expiration date:
'user@:~$' • openssl x509 -noout -enddate -in tempfile
And if you managed to understand everything this far in this lab, you should be able to glue the above together in just one command line.
'user@:~$' • echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | perl -nle 'print if /BEGIN/../END/' | openssl x509 -noout -enddate 'user@:~$' • echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -enddate
- The -enddate command prints out the expiry date of the certificate, that is the notAfter date.
Now with a few additions, the above could be used as a base for a fully automated certificate expiration checker
Create a textfile with all your domains in it for which ssl certificates are used. Of course this could be automated too.
There are of course less ugly ways for achieving the same
'user@:~$' • for foo in $(cat hosts); do if [[ $(echo $(date -d"$(echo | openssl s_client -connect $foo:443 2>/dev/null | openssl x509 -noout -enddate | cut -d'=' -f2 | awk '{print $2 " " $1 " " $4}')" +%s) - $(date +%s) | bc) -gt 0 ]]; then echo $foo: OK; else echo $foo: EXPIRED;fi;done
And now a shorter version with some more OpenSSL magic
'user@:~$' • for foo in $(cat hosts); do if echo | openssl s_client -connect $foo:443 2>/dev/null | openssl x509 -noout -checkend 0; then echo $foo: OK; else echo $foo: EXPIRED; fi;done
- The -checkend command checks if the certificate expires within the next arg seconds and exits non-zero if yes it will expire or zero if not.
And magic++:
'user@:~$' • for foo in $(cat hosts); do check_ssl_cert -H $foo;done
- The check_ssl_cert checks the validity of X.509 certificates
- The -H command is used to specify the host
Exercise 3:
Create a oneliner which shows the amount of currently revoked certificates in the Terena SSL CA revocation list.
http://crl3.digicert.com/TERENASSLCA3.crl."
Do not create temporary files. The CRL can be found at'user@:~$' • wget -q -O - http://crl3.digicert.com/TERENASSLCA3.crl | openssl crl -inform DER -text -noout | grep -P '^\s+Serial Number' | wc -l
- The -inform command specifies the input format normally the command will expect an X509 certificate but this can change if other options such as -req are present.
Exercise 4:
Companies like Google and Microsoft make heavily use of the X.509 subjectAltName extension.
UCLL also uses this extension to add an alternative name *.ucll.be to the common name (ucll.be) of the certificate.
Create a oneliner which calculates the amount of DNS Subject Alternate Names used in the SSL certificate of gmail.com."
'user@:~$' • echo | openssl s_client -connect facebook.com:443 2>/dev/null | openssl x509 -text -noout | grep -o 'DNS:' | wc -l
Exercise 5:
Create a CLI oneliner to find a match between different rsa private key files and their companion crt files. The output should look something like:
alfa.key matches beta.crt
gamma.key matches delta.crt
First we need to generate some certificates so we can actually verify our solution. The following command creates a self-signed certificate in one step:
'user@:~$' • openssl req -x509 -sha256 -newkey rsa:2048 -keyout tombola_uclllabs_be.key -out tombola_uclllabs_be.crt -days 365 -nodes -subj "/C=BE/ST=/L=/O=UC Leuven/CN=tombola.uclllabs.be"
- The -subj command outputs the "hash" of the certificate subject name.
With the following for loop we can easily generate a few certificates to test with:
'user@:~$' • for foo in TomBola GreetSchap VanderNeffe LukRaak AlainProvist; do openssl req -x509 -sha256 -newkey rsa:2048 -keyout "$foo"_uclllabs_be.key -out "$foo"_uclllabs_be.crt -days 1024 -nodes -subj
As explained in this lab, the modulus of corresponding files (CSR, private KEY and Certificate) should be the same. We'll create a oneliner which tests wich files belong to one another. I.e. which files have the same modulus.
'user@:~$' • for key in $(ls -1 *.key); do for crt in $(ls -1 *.crt); do if [[ $(openssl rsa -in $key -noout -modulus | md5sum) == $(openssl x509 -in $crt -noout -modulus | md5sum) ]]; then echo $key matches $crt;fi ;done;done
Or a slightly shorter version:
'user@:~$' • for key in $(ls *.key); do for cert in $(ls *.pem); do [[ $(openssl rsa -in $key -noout -modulus | md5sum) == $(openssl x509 -in $cert -noout -modulus | md5sum) ]] && echo $key matches to $cert;done;done
Exercise 6:
Create a CLI oneliner using openssl to retrieve the certificate of the server wiki.uclllabs.be and to encrypt the text
https://wiki.uclllabs.be and extract the public key from the presented certificate:"
'Lets make CNW2 great again'" with it’s public key. In the first step, we willll connect to'user@:~$' • echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -pubkey > public.pem
Now the public key is saved in a tempfile we can use it to encrypt arbitrary data.
'user@:~$' • echo "Let's make CNW2 great again" | openssl rsautl -encrypt -pubin -inkey public.pem -out CNW2.encrypted
- The rsautl command can be used to sign, verify, encrypt and decrypt data using the RSA algorithm.
- The -encrypt command encrypts the input data using an RSA public key.
- The -pubin command is used to input file is an RSA public key.
- The -out command specifies the output filename to write to or standard output by default.
Or without first downloading the public key:
'user@:~$' • echo "Let's make CNW2 great again" | openssl rsautl -encrypt -pubin -inkey <(echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -pubkey) -out CNW2.encrypted
Exercise 7:
Experiment with the tools sslyze and nmap to enumerate supported ssl cipher suites for various websites. Make sure you understand its output. See the folloing example:
- sslyze --regular --http_headers wiki.uclllabs.be - nmap --script ssl-enum-ciphers -p 443 wiki.uclllabs.be
Exercise 8:
Let’s Encrypt has rate limits which prevent issuing more than 20 new certificates per domain per week. They use the public suffix list for this.
The limit is per registered domain, not per subdomain. So all student certificates count for the same uclllabs.be suffix.
"root #" • certbot --apache -d "tom.x.cnw2.uclllabs.be, bola.x.cnw2.uclllabs.be, tom.bola.x.cnw2.uclllabs.be"
- The certbot command is used to obtain and install HTTPS/TLS/SSL certificates
- The --apache command is used to use the Apache plugin for authentication & installation
- The -d command is used for domain names to apply
Exercise 9:
Create a CLI oneliner using OpenSSL to retrieve the certificate of the server wiki.uclllabs.be and to display only its fingerprint, serial and public key. Sample output:"
'user@:~$' • echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -fingerprint -serial -pubkey
2019 oplossingen labo tussentest - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
LABO TEST
Exercise 1:
Copy the content of your it-enabled grandmothers id_rsa.pub file in your ~/.ssh/authorized_keys file"
'user@:~$' • ssh user@leia.uclllabs.be -p 22345 -i "/path/to/your grandmothers identity_file"
- The ssh command is a remote login program
- The -p argument is used for a port to connect to on the remote host.
- The -i argument selects a file from which the identity (private key) for public key authentication is read.
'user@:~$' • ssh user@leia.uclllabs.be -p 22345
- The ssh command is a remote login program
- The -p argument is used for a port to connect to on the remote host.
Exercise 2:
Try to find out which TCP ports are open on leia without using tools like netstat or ss. Execute on leia for increased speed.
'user@:~$' • nc -zv -w 1 leia.uclllabs.be 1-65535 2>&1 | grep succeeded | awk '{print $4}' 'user@:~$' • for foo in {1..65535}; do nc -N -w1 leia.uclllabs.be $foo </dev/ null >/dev/null && echo $foo;done 'user@:~$' • nmap -p 1-65535 leia.uclllabs.be | grep -P '\d+/tcp.*open' |cut -d'/' -f1 'user@:~$' • nmap --reason -p 1-65535 leia.uclllabs.be | grep -oP '\d+(?=/tcp.*open)'
- The nc command is a TCP/IP swiss army knife
- The -z argument is used for scanning
- The -v argument is used for verbose
- The -w (# in seconds) arguments is timeout for connects and final net reads
- The grep command prints lines matching a pattern
- The awk command is used for pattern scanning and processing language
- \d matches a digit (equivalent to [0-9])
- '+' matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- . matches any character (except for line terminators)
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy) open matches the characters open literally (case sensitive)
- The cut command removes sections from each line of files
- The -d argument use DELIM instead of TAB for field delimiter
- The command nmap is a network exploration tool and security / port scanner
- The --reason argument shows the reason each port is set to a specific state and the reason each host is up or down
- The -p argument specifies which ports you want to scan and overrides the default.
- The -o argument print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
- The -o argument prints only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
- The -p argument Interpret I as Perl-compatible regular expressions (PCREs).
Exercise 3:
Create a oneliner which lists all palindromes with exactly 6 letters in a dictionary.
'user@:~$' • cat dutch | grep -P '^(.)(.)(.)\3\2\1$'
- ^ asserts position at start of a line
- . matches any character (except for line terminators)
- in ^(.)(.)(.) ==> the first (.) is the first capturing group, the second (.) is the second capturing group, the third (.) is the third capturing group,
- \3 matches the same text as most recently matched by the 3rd capturing group, \2 matches the same text as most recently matched by the 2nd capturing group and \1 matches the same text as most recently matched by the 1st capturing group
Exercise 4:
As a web server administrator you have been asked to give your manager a Linux CLI oneliner to extract the 5 IP addresses that contacted the web server the most
The apache log is located in /home/logs. Create a correct oneliner. The output should look something like this: (count IPs)
'user@:~$' • cat apache_google.log | cut -d ' ' -f1 | sort | uniq -c | sort -rn | head -5
- The cut command removes sections from each line of files
- The -d argument uses DELIM instead of TAB for field delimiter
- The -f argument selects only these fields
- The sort command sorts lines of text files
- The uniq command reports or omits repeated lines
- The -c argument prefixes lines by the number of occurrences
- The -r reverses the result of comparisons
- The head command shows output the first part of files
Exercise 5:
What Linux ssh command do you use to bind your local port 3000 to a web server on port 4444 on the network of the ssh server
'user@:~$' • ssh -p 22345 username@leia.uclllabs.be -L 3000:IP_web_server:4444
- The -p argument shows which port to connect to on the remote host
- The -L argument specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
Exercise 6:
Create an apache vhost (netcat.X.cnw2.uclllabs.be) which displays a single web page (index.html). How can you update/alter this website (index.html) via a Netcat connection from your laptop."
'root@myserver' 1) mkdir /var/www/html/netcat 'root@myserver' 2) nano netcat.conf
<VirtualHost *:80>
ServerAdmin root@netcat.X.cnw2.uclllabs.be
ServerName netcat.X.cnw2.uclllabs.be
DocumentRoot /var/www/html/netcat
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/netcat-error.log
CustomLog ${APACHE_LOG_DIR}/netcat-access.log combined
</VirtualHost>
'# root@myserver' 1) a2ensite netcat '# root@myserver' 2) systemctl reload apache2 '# root@myserver' 3) nc -l -p 10000 >> /var/www/html/netcat/index.html 'user@laptop:~$' 4) echo test | nc netcat.X.cnw2.uclllabs.be 10000
Exercise 7:
On server Leia, use the list of logged in users to print only the username that has been logged in to the server for the longest time
'user@:~$' • who | awk '{print $3$4 " " $1}' | sort -n | awk '{print $2}' | head -1
- The command who shows who is logged in
- The command sort sorts lines of text files
- The -n argument compares acoording to string numerical value
- The head command outputs the first part of files
Exercise 8:
Some subdirectory of /tmp contains a bunch of movies. However, their extension is wrong.
The extension should be .avi instead of .jpg. Copy these files to your homedirectory and correct their extensions in one line. "
'user@:~$' • ls -1 *.jpg | while read foo; do echo cp $foo ~/$(basename $foo .jpg).avi;done 'user@:~$' • ls -1 *.jpg | while read foo; do echo cp $foo ~/${foo%.jpg}.avi;done
- The -1 argument lists one file per line
- cp $foo ~/$(basename $foo .jpg).avi ==> Echo the STRING(s) to standard output.
Exercise 9:
Create a Linux CLI oneliner to decode the following string 'SWYgeW91IGNhbiByZWFkIHRoaXMsIHlvdSBmb3VuZCB0aGUgY29ycmVjdCBhbnN3ZXIK'
'user@:~$' • echo 'SWYgeW91IGNhbiByZWFkIHRoaXMsIHlvdSBmb3VuZCB0aGUgY29ycmVjdCBhbnN3ZXIK' | openssl enc -a -d 'user@:~$' • echo 'SWYgeW91IGNhbiByZWFkIHRoaXMsIHlvdSBmb3VuZCB0aGUgY29ycmVjdCBhbnN3ZXIK' | base64 -d
- The -a argument ==> Base64 process the data
- The -d argument ==> decrypts the input data
- The -base64 argument = The -a argument
Exercise 10:
Create a regular expression to match all words in a dictionary with 5 unique letters. "
'user@:~$' • cat /usr/share/dict/dutch | grep -P '^[a-zA-Z]{5}$'| grep -vP '(.).*\1'
- ^ asserts position at start of a line
- A-Z matches a single character in the range between A and Z (case sensitive)
- a-z matches a single character in the range between a and z (case sensitive)
- {5} matches the previous token exactly 5 times
- . matches any character (except for line terminators
- '*' matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
- -v stands for inverted match.
- -P stands for perl expression
Exercise 11:
Create a oneliner to show ‘Time = 15:44:25 (11/10/1901)' or 'Time = 15:44:25 (11-10-1901)’ each time with the current time and date.
'user@:~$' • echo "Time = $(date '+%X (%x)')" 'user@:~$' • date '+Time = %X (%x)' 'user@:~$' • date '+Time = %X (%Y/%d/%m)'
- date matches the characters date literally (case sensitive)
- '+' matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
- The %X argument sets locale's time representation
- the %x argument sets locale's date representation
- The %Y arguments = year
- The %d arguments = day
- The %m arguments = month
Exercise 12:
Create a oneliner which lists the top 3 most used passwords in the ftp brute force attack captured in "ftp_bruteforce.pcap". Use a suitable sniffer filter which only displays whats really needed.
'user@:~$' • tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command==PASS' -T fields -e 'ftp.request.arg' 2>/dev/null| sort | uniq -c | sort -rn | head -3
- The tshark command dumps and analyzes network traffic
- The -r argument reads the packet date from infile
- The -Y command captures the link type
- The -T argument sets the format of the output when viewing decoded packet data.
- The -e argument (in tshark command) adds a field to the list of fields to display if -T fields is selected
- The sort command sorts lines of text files
- The uniq command reports or omits repeated lines
- The -c command prefixes lines by the number of occurrences
- The -r argument (in sort command) reverses the results of comparisons
- The -n compare according to string numerical value
- The head command shows output for only the first part of files
2019 oplossingen Testexamen - Lars Lemmens
Met dank aan de Github van Martijn en natuurlijk Lars Lemmens
Exercise 1
Create a CLI oneliner to match all words with 14, 15 or 16 unique letters. The output shouldlook like:
Words with 14 letters: EHBO-diploma's bruiloftsdagen katrolschijven verontschuldig ...
Words with 15 letters: dampkringslucht sandwichformule ...
Words with 16 letters: ...
'user@:~$' • for foo in 14 15 16; do echo "Words with $foo letters:" $(grep -vP '(.).*\1' /usr/ share/dict/dutch | grep -P "^.{$foo}$");done
- for name [ [ in [ word ... ] ] ; ] do list ; done The list of words following in is expanded, generating a list of items. The variable name is set to each element of this list in turn, and list is executed each time. If the in word is omitted, the for command executes list once for each positional parameter that is set (see PARAMETERS below). The return status is the exit status of the last command that executes. If the expansion of the items following in results in an empty list, no commands are executed, and the return status is 0.
- echo displays a line of text
Exercise 2
Create a linux CLI oneliner to extract an overview of the different FTP usernames in the file ftp_bruteforce.pcap. Only the commands tshark and sort are allowed.
'user@:~$' • tshark -r ftp_bruteforce.pcap -Y 'ftp.request.command == USER' -T fields -e ftp.request.arg |sort -u
- The -r command opens the recording
- The -Y command is used for displaying the filter
- The -T fields -e is used to specify the fields you want to show
- The sort command is used to sort lines of text files
- The -u command is used to show the output of only the first of an equal run
Exercise 3
Create a oneliner to show ‘Time = 15:44:25 (11/10/1901)' or 'Time = 15:44:25 (11-10-1901)’ each time with the current time and date.
'user@:~$' • date '+Time = %X (%x)'
- The date command prints or sets the system date and time
- The +Time is used to set time
- The %X command is used to set the systems time
- The %x command is used to set the date -> with () is used to put () around the date
Exercise 4
Create a linux CLI oneliner to decode the following string ‘RGUgcHVudGVuIG9wIGRlemUgdnJhYWcgemlqbiBhbCBiaW5uZW4uCg==’. (/home/logs/secret)
'user@:~$' • cat /home/logs/secret | openssl enc -a -d
- The cat command is used to concatenate files and print on the standard output
- The enc command is used to encrypt or decrypt a file
- The -a command is used if encryption is taking place the data is base64 encoded after encryption. If decryption is set then the input data is base64 decoded before being decrypted
- The -d command is used to decrypt
Exercise 5
Create a CLI oneliner using openssl to retrieve the certificate of the server wiki.uclllabs.beand to display only it’s fingerprint, serial and public key.Sample output:
SHA1 Fingerprint=8C:CB:D9:A1:F3:3C:78:C2:2E:F6:EB:1C:CD:4B:F3:39:1B:9A:EE:4Eserial=0966DB4115B74092EE07D6DA585547D8-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2NHdNb3iWbb7mx9UFYzbv05YvUe+uBD8IunSnpj4SSol+5RG5EKZhFAcXwH9FCUxXE7ZZP3FDLNG0qG8cLSHjg==-----END PUBLIC KEY-----
'user@:~$' • echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -fingerprint -serial -pubkey
- The s_client command implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS
- The x509 command outputs a self signed certificate instead of a certificate request.
- The -noout command is used to prevent output of the encoded version of the request
- The -fingerprint command is used to show the fingerprint
- The -serial command outputs the certificate serial number.
- The -pubkey command outputs the the certificate's SubjectPublicKeyInfo block in PEM format.
2019 samenvatting - Lars Lemmens
Met dank aan de Github van Martijn en Lars Lemmens
Hoofdstuk 2
2.1 Principes van netwerkapplicaties
2.1.1 Structuren van netwerkapplicaties
Client-server structuur
- Host altijd-aan (server) & handelt verzoeken van andere hosts (clients) af
- Meestal datacenters → anders overbelasting
P2P-structuur
- Infrastructuurservers die altijd aan zijn → minimaal of afwezig
- Maakt gebruik van rechtstreekse communicatie → periodiek met elkaar verbonden hosts → peers
- Zelfschaalbaarheid & goedkoper
2.1.2 Communicerende processen
- Processen in 2 verschillende hosts → communiceren met elkaar door berichten uit te wisselen → verzendend proces creëert & verzendt berichten over netwerk → ontvangend proces ontvangt berichten en verzendt eventueel antwoordbericht
Client – en serverprocessen
- Voor elk paar comunnicerende processen → 1 van de 2 processen client & andere server
- Definitie client- en serverprocessen:
- In context van een communicatiesessie tussen 2 processen noemen we het proces dat de communicatie initieert de client. Het wachtende proces noemen we de server
- In P2P kan een proces ophalen en beschikbaar stellen
Interface tussen proces en computernetwerk
-
Proces verzendt berichten naar en ontvangt berichten van het netwerk via een netwerkinterface →socket AKA API ( Application Programming Interface)
-
Socket = soort deur → proces bericht naar ander proces sturen → bericht door deur (socket) naar buiten → verzendende proces neemt aan → andere kant deur → infrastructuur aanwezig is waarmee bericht → bij deur van huis van bestemming zal bezorgd worden → zodra bericht arriveert bij ontvangende host → passeert het de toegangsdeur van ontvangende proces → waarna ontvangende proces bericht verwerkt
Adresseren van processen
- Om ontvangende proces te kennen moet het 2 gegevens bevatten:
- Het adres van de host
- Unieke aanduiding van ontvangende proces in ontvangende host
2.1.3 Transportdiensten voor applicaties
| Data Integriteit:
-
Transportlaagprotocol → mogelijk een betrouwbare gegevensoverdracht tussen processen aan applicatie leveren → verzendend proces gegevens in socket duwen & is zeker van geen fouten
-
Als er geen betrouwbare gegevensoverdracht is → mogelijkheid dat deel gegevens niet aankomen bij ontvangend proces →**verliestolerante apps (**Skype,...) | Doorvoer
-
Sommige apps (bijv. multimedia) vereisen een minimale verwerkingscapaciteit om "effectief" te zijn = bandbreedtegevoelige apps → stellen eisen aan doorvoercapaciteit
-
Elastische apps gebruiken de doorvoercapaciteit die op het moment beschikbaar is
Timing:
- Sommige apps (bijv. internettelefonie, interactieve games) hebben een korte vertraging nodig om 'effectief' te zijn Security
- Encryptie, data integriteit,...
Diensten van TCP & UDP
Beveiligen van TCP
TCP gebruikt SSL/TLS → TCP met SSL/TLS → doet niet alleen wat oorspronkelijke TCP doet → levert ook beveiliginsdiensten voor communicerende processen → SSL niet een 3e transportprotocol voor internet is dat op zelfde niveau werkt als UDP & TCP → uitbreiding van TCP → uitbreidingen geimplementeerd in applicatielaag
Diensten die niet geleverd worden door internettransportprotocollen
- Huidig internet presteert goed voor tijdgevoelige apps → geen garanties voor timing of doorvoercapaciteit
- Internettelefonieapps kan enig verlies verwerken maar wel minimale snelheid eisen om te kunnen werken → Internettelefonieapps meestal UDP → grotendeel van firewalls blokkeren UDP → ontworpen voor TCP → als back-up communicatie via UDP niet lukt
2.1.5 Protocollen voor applicatielaag
In applicatielaag volgende aspecten gedefinieerd:
- Soorten berichten die uitgewisseld worden, request & antwoordberichten
- Syntaxis van verschillende soorten berichten, velden in bericht & manier waarop velden van elkaar gescheiden worden
- Semantiek van velden → betekenis informatie in velden
- Regels voor bepalen wanneer en hoe proces berichten verzendt & beantwoordt
2.1.6 Netwerkapplicaties die in dit boek beschreven worden
2.2 Web & HTTP
2.2.1 Meer over HTTP
-
Webpagina bestaat uit aantal objecten → object is een bestand
-
HTTP definieert hoe webclient een webserver verzoekt om een webpagina op te zoeken & hoe servers webpagina's versturen naar een client
-
HTTP → TCP als transportprotocol
-
HTTP-client initieert TCP-verbinding met server → verbinding tot stand → processen van browser & server TCP via socketinterfaces → client verzendt HTTP-verzoekberichten door socket → server ontvangt op zelfde manier HTTP-verzoekberichten via socket & verzendt HTTP-antwoordberichten door socket
-
HTTP is staatloos → Server houdt geen informatie bij over eerdere clientaanvragen
2.2.2 Non-persistente en persistente verbindingen
Non persistent
Basis HTML-file met volgende url: http://www.someschool.edu/someDepartment/home.index
- HTTP-client starts TCP-verbinding met server → client & server gebruiken socket
- HTTP-client verzendt HTTP-verzoekbericht naar HTTP
- HTTP-serverproces ontvangt verzoekbericht
- HTTP-serverproces TCP opdracht → verbreek verbinding als bericht ontvangen
- HTTP-client ontvangt antwoordbericht
- Herhaal stap 1-4 voor elk object
RTT → tijd die packet nodig heeft → client naar server & omgekeerd
Klikt op een hyperlink → 3-way handshakeproces nodig:
-
Client verzendt TCP-segment naar server
-
Server bevestigt & antwoord met TCP-segment
-
Client verzendt 2e bevestiging naar server
→ 1 RTT
- Na 1&2 → verzendt client HTTP-verzoekbericht + 3e deel van 3way-handshake
- Totale responstijd = 2 RTT's + transmissietijd HTML-bestand server
Persistent
- Bij non persistent → elk opgevraagd object een nieuwe verbinding tot stand gebracht & gehouden worden
- Bij non persistent → elk object 2 RTT's vertraging → 1 voor TCP-verbinding starten & 1 om TCP-verbinding object op te vragen & ontvangen
- HTTP 1.1 persistent → server laat TCP-verbinding intact na respons
2.2.3 Indeling HTTP-berichten
HTTP-verzoekbericht
- Eerste regel → requestregels
- Volgende regels → headerregels
- Host → host waar opgeslagen object is
- Connection: close → geen persistente verbinding nodig
- User Agent: → type browser
- POST → stuurt velden dat gebruiker heeft ingevuld door
- GET → 2 velden ( x & y ) → structuur URL →www.eensite.nl/zoekIets?x&y
- HEAD → server reageert HTTP-bericht zonder opgevraagde object te verzenden
HTTP-antwoordbericht
- Statusregel, 6 headerregels & entity body
- Connection: close → client weet TCP-verbinding weg na bericht verstuurd
- Server: → geeft aan gegenereerd door Apache-webserver
- Last-Modified: cachen objecten → lokaal & server
- Content-length: → grootte object
2.2.4 Interactie gebruikers & servers: cookies
2.2.5 Webcaching
Netwerkentiteit die HTTP-verzoeken afhandelt names oorspronkelijke webserver waar verzoek oorspronkelijk naartoe is gestuurd
Browser object http://www.someschool.edu/campus.gif
- Browser start TCP-verbinding met webcache & verzendt HTTP-verzoek voor object naar webcache
- Webcache checks → exemplaar opgevraagde object aanwezig? → if yes → webcache verzendt object in HTTP-antwoordbericht naar browser client
- Opgevraagde object niet op webcache → TCP-verbinding met oorspronkelijke server → webcache verzendt HTTP-verzoek voor object via TCP-verbinding → wanneer server ontvangen → verzendt object in HTTP-antwoordbericht naar webcache
- Opslaan kopie lokaal & stuurt een exemplaar naar browser
2 redenen webcaching
- Responstijd clientverzoek verkorten
- Webcaches belasting van link van instituut verlagen
CDN (Content Distribution Networks) → veel geografische verspreide cachegeheugens in internet → groot deel dataverkeer lokaal
2.2.6 The conditional GET
- Verzoekbericht methode GET
- Verzoekbericht bevat If-Modified-Since
- Client maakt get request
- Server reageert met header
- Client checkt de Last-Modified header
- ls Last nieuwer is dan cache → haal pagina opnieuw op & zet opnieuw in cache
- anders → laad van cache
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
\r\n
HTTP/2
Goal: vertraging verlagen in multi-object HTTP requests HTTP1.1** :** meerdere, pipelined GETs over 1 TCP connectie
- Server antwoord in-order ( FCFS : first-come-first-served scheduling ) naar GET requests
- Met FCFS, mogelijkheid dat kleine objects moeten wachten voor transmissie (Head-of-line (HOL) blocking) achter grote objects
- Herstel van loss (retransmissie van verloren TCP segmenten) stalls object transmissie
HTTP/2** :** flexibiliteit verhogen server in versturen van objects naar client Goal: vertraging verlagen in multi-object HTTP requests
- Methoden, status codes, meeste header velden onveranderd tov HTTP 1.1
- verzendvolgorde van aangevraagde objecten op basis van door de klant opgegeven objectprioriteit (Niet noodzakelijk FCFS)
- Push unrequested objects naar cleint
- Verdeel objects in frames, plan frames om HOL-blokkering te verminderen
HTTP/2 to HTTP/3
Goal: vertraging verlagen in multi-object HTTP requests
HTTP/2 over single TCP connectie wil zeggen:
-
Herstel packet loss vertraagt nog steeds alle objecttransmissies
-
In HTTP 1.1 browsers → stimulans om meerdere TCP-verbindingen te openen → vertraging verminderen → algehele doorvoer te verhogen
-
Geen security over vanilla TCP-verbinding
-
HTTP/3 → adds security → per object fout- & congestie-controle ( meer pipelining) over UDP
2.3 E-mail op het internet
2.3.1 SMTP
Werking:
- Alice → UA opdracht verstuur bericht
- Alice's UA stuurt bericht mailserver→ in berichtenwachtrij
- Clientzijde van SMTP opent TCP-verbinding met Bob's e-mailserver
- SMTP-client verzendt het bericht van Alice via de TCP-verbinding
- Bob's mailserver plaatst het bericht in Bob's mailbox
- Bob roept zijn user agent aan om bericht te lezen
2.3.2 Vergelijking met HTTP
SMTP
- Transfers files van 1 mail server naar een andere mail server
- PUSH protocol: verzendende e-mailserver duwt bestand naar e-mailserver van ontvanger
- Elk bericht moet in 7-bit ASCII zijn
- Plaatst alle bericht objecten in 1 bericht
HTTP
- Transfers files van web server naar web client
- PULL protocol: Iemand zet informatie op een webserver & gebruiker gebruikt HTTP om informatie van server ophalen wanneer het hem uitkomt
- Restrictie niet nodig
- Encapsuleert elk object in zijn eigen HTTP response message
2.3.3 Formats e-mailberichten
2.3.4 Mail accessprotocollen
SMTP: levering/opslag van e-mailberichten op de server van de ontvanger
Mail Access Protocol: Ophalen server
IMAP: Internet Mail Access Protocol [RFC 3501]: berichten opgeslagen op de server, IMAP biedt ophalen, verwijderen, mappen met opgeslagen berichten op de server
HTTP: Gmail, Hotmail, Yahoo! Mail, etc. biedt webgebaseerde interface bovenop STMP (om te verzenden), IMAP (of POP) om e-mailberichten op te halen
POP3
UA → TCP-verbinding naar mailserver
- Autorisatiefase: UA → verstuurt username & password → identitetit gebruiker vaststellen
- Transactiefase: UA haalt berichten op
- Updatefase: client opdracht quit → POP3-sessie closed
IMAP
- Koppelt elk bericht aan een map
- Biedt opdrachten → UA afzonderlijke componenten van bericht
Webmail
Ontvanger wil mailbox bekijken → bericht van mailserver naar browser van gebruiker verzonden → behulp van HTTP-protocol
2.4 DNS
2.4.1 Diensten van DNS
- Een gedistribueerde database → geïmplementeerd in hiërarchie van DNS-servers
- Applicatielaagprotocol waarmee hosts & DNS-servers kunnen communiceren om vertaalslag ( omzetten IP → "te onthouden" adres & omgekeerd)
DNS verzorgt aantal andere diensten naast vertalen hostnamen in IP-adressen:
- Host-aliasing: 1 of meerdere aliassen wanneer hostname te lastig is → canonieke hostnaam → aliashostnamen gebruikt → gemakkelijker te onthouden dan canonieke hostnamen
- Mailserver-aliasing: Hostnaam van een mailserver (bv. Yahoo) → moeilijker dan → eenvoudige Yahoo.com → DNS kan door mailapplicatie gebruikt worden → achterhalen canonieke hostnaam v/e bepaalde host + IP-adres van host → MX record maakt mogelijk dat mailserver & webserver van bedrijf dezelfde hostnamen hebben → mailserver & webserver van bedrijf kunnen dus bv. enterprise.com heten.
(Een MX-record (Mail eXchange-record) is een gegevenstype in het Domain Name System (DNS). Het specificeert de mail server die e-mailverkeer voor het betreffende domein afhandelt. Een domein kan meerdere MX-records hebben met een verschillende prioriteit waardoor het mogelijk is om bijvoorbeeld een back-up mailserver aan te geven als de computer met de hogere prioriteit niet bereikbaar blijkt. De naam die in het MX-record wordt gevonden kan via DNS op zijn beurt in een ip-adres worden vertaald. Src: Wikipedia)
- Loadbalancing: Belasting van gerepliceerde servers te verminderen → gerepliceerde webservers een serie IP-adressen gekoppeld aan canonieke hostname → DNS-database bevat serie IP-adressen
2.4.2 Overzicht van de werking van het DNS
Gecentraliseerd ontwerp levert volgende problemen op:
- Single point of failure: als DNS crashed hele internetonbruikbaar
- Netwerkbelasting : 1 DNS-server → alle DNS-verzoekberichten verwerken ( alle HTTP-verzoekberichten & e-mails van honderden miljoenen hosts)
- Afstand tot gecentraliseerde database : 1 enkele DNS-server kan niet 'in de buurt' van alle verzoekende clients staan → centrale DNS bijvoorbeeld in Antwerpen → verzoeken uit Nieuw-Zeeland → kan vertraging veroorzaken
- Onderhoud : die DNS-server informatie over alle internethosts moeten beheren → database wordt dan heel groot & telkens bijgewerkt moeten worden wanneer nieuwe host wordt aangemeld.
Een gedistribueerde, hiërarchische database
- Root-DNS-servers: meer dan 400 root-nameservers verspreid over de wereld → door 13 verschillende organisaties gemanaged → leveren IP adressen van TLD-servers
- Topleveldomein (TLD) -servers: voor elk TLD (com,org,net,edu,...) & landTLD(nl,fr,ca,...) → is er een TLD → TLD leveren IP-adressen voor authoritative DNS-servers
- Authoritative DNS-servers: eigen DNS-server(s) van de organisatie, die gezaghebbende hostnaam biedt aan IP-toewijzingen voor de benoemde hosts van de organisatie + kan Dutch translation. kakjkworden onderhouden door organisatie of dienstverlener
- Lokale DNS-server behoort niet tot hiërarchie maar wel belangrijk voor DNS-structuur → elke ISP zoals een standaard ISP of ISP van instituut → lokale DNS-server → wanneer host verbinding tot stand wil brengen met ISP → ISP geeft aan die host IP-adressen van 1 of meer van diens lokale DNS-server → lokale DNS-server niet ver weg van host → bij residentiële ISP DNS-server → gescheiden enkele routers van host van client → host verzoekbericht aan DNS verzendt → doorgestuurd lokale DNS-server → fungeert als proxy → verzoek verder gestuurd in DNS-serverhiërarchie
- Recursief DNS-verzoek = host stuurt verzoek aan lokale DNS-server, die op zijn beurt een verzoek doet aan de root-server, die op zijn beurt een verzoek doet aan de TLD-server … (zie p127)
- Iteratief DNS-verzoek = host stuurt verzoek aan lokale DNS-server, die op zijn beurt een verzoek doot aan de root-server, de root-server stuurt antwoord naar lokal DNS-server die op haar beurt een verzoek doet aan de TLD-server… (zie p126)
DNS-caching
DNS-server → in verzoekberichtenketen → wanneer DNS-antwoord ontvangt → verwijzing in lokale cachegeheugen plaatsen
2.4.3 DNS-records en -berichten
DNS-servers bevatten bronrecords → (Naam, Waarde, Type, TTL)
- If Type = A then naam bevat hostnaam en Waarde bevat IP-adres van hostnaam
- If Type = NS then naam bevat domeinnaam en Waarde bevat hostnaam van authoritative DNS-server die de hostnaam en IP combinaties voor de hosts in dat domein weet
- If Type = CNAME then waarde is canonieke hostname voor aliashostname
- IF Type = MX then waarde is canonieke naam van mailserver met alias hostname name
DNS-berichten
- Eerste 12 bytes voor de header:
- Eerste veld is een uniek 16 bit getal waarmee het verzoek geïdentificeerd kan worden. Dat getal word gekopieerd in het antwoordbericht, zodat de client het antwoord en het verzoek kan kopellen
- Vlaggen veld bevat een aantal vlaggen. Een 1-bit verzoek/antwoord-vlag (verzoek = 1 en antwoord = 0), 1-bit authoritative-vlag wordt in een antwoordbericht gezet als de DNS-server de authoritative DNS-server voor de hostnaam is, 1-bit recursienoodzaak-vlag wordt gebruikt als de client vraagt om recursief te werken als het gevraagde record niet op die DNS-server staat en een 1-bit recursiemogelijkheids-vlag die in het antwoordbericht staat na een verzoekbericht met een recursienoodzaak-vlag
- Vraagveld bevat informatie over het verzonden verzoek:
- Bevat een naamveld met de naam waarvoor het IP-adres wordt gezocht
- Bevat een typeveld met het type verzoek (Type A, Type NS…)
- In een antwoordbericht staat in het antwoordveld de bronrecords van het oorspronkelijke DNS-verzoek
- Het autorisatieveld bevat gegevens van andere authoritative DNS-servers
- Het aanvullingsveld bevat aanvullende bronrecords (Het antwoordveld in een antwoord op een MX-verzoek bevat een bronrecord met de canonieke hostnaam van de mailserver en het aanvullingsveld bevat het een Type A record met het IP-adres van de canonieke hostnaam van de mailserver
DNS-Security
DDOS-attack:
- root servers belasten met verkeer
- Tot op heden niet succesvol
- Verkeersfiltering
- Lokale DNS-servers cache-IP's van TLD-servers waardoor rootserver bypassed
TLD servers bombarderen:
- Kan gevaarlijker zijn maar moeilijker → TLD servers niet zo gemakkelijk bypassed
Aanvallen omleiden
- Man in the middle → DNS queries intercepten
- DNS poisoning → valse afhankelijkheden verzenden naar dns-server, die cachen
DNS voor DdoS exploiteren
- Queries versturen met vervalste bronadres → target IP
- Vereist versterking
Laatste 2 vormen DNSSEC
2.5 Peer-to-peer bestandsdistributie
P2P file distributie: BitTorrent
Peer neemt deel aan torrent → meldt bij tracker → peer informeert tracker met regelmaat of nog aanwezig in torrent → nieuwe peer → tracker random # peers → verzendt IP-adressen van # peers → naar nieuwe peer → proberen TCP-verbinding met peers op lijst → bepaald tijdstip → elke peer → # chunks bestand → verschillende peers → verschillende verzamelingen chunks hebben → na een bepaalde tijd → gebruiker vraagt elke peer om lijst met chunks die ze hebben → gebruiker vraagt de "missing chunks" van de peerst → zeldzaamste eerst of Rarest first
Tit-for-tat principe:
Gebruiker stuurt chunks naar die vier peers die momenteel haar chunks in het hoogste tempo verzenden → andere peers gestikt door gebruiker (ontvangen geen chunks van gebruiker) → herbeoordeeld top 4 elke 10 seconden
Elke 30 seconden → selecteert willekeurig een andere peers, begint met verzenden van chunks → optimistisch unchocked deze peer → nieuwe gekozen peer kan lid worden van top 4
2.6 Videostreaming en content distribution networks
Internetvideo
-
Video → sequentie van afbeeldingen → afgebeeld constante snelheid Bijvoorbeeld: 24 afbeeldingen / seconde
-
Digital image → array van pixels Elke pixel gerepresenteerd door bits
-
Coding: Gebruikt redundantie binnen en tussen afbeeldingen om # bits te verminderen die worden gebruikt om abeeldingen te gebruiken Spatial → binnen afbeelding Temporal → van 1 afbeelding naar volgende
-
CBR → constant bit rate → video encoding rate is fixed
-
VBR → variable bit rate → wijzigingen in videocoderingssnelheid als hoeveelheid spatial, temporal codering wijzigt
2.6.1.1 Streaming stored video
Simpel Scenario:
Hoofddoelen:
-
Server to client bandbreedte varieert over tijd met veranderende netwerkcongestieniveaus → ( in huis, in acces network, network core, video server)
-
pakketverlies en vertraging als gevolg van congestie zullen de play-out vertragen of resulteren in een slechte videokwaliteit
2.6.1.2 Streaming stored video : challenges
Continuous playout constraint → zodra play-out van client begint → afspelen overeenkomen met oorspronkelijke timing → maar network delays variabel (jitter) → heeft buffer aan clientzijde nodig om aan play-out vereisten te voldoen
Andere challenges
Client interactiviteit → pause, voortspoelen, terugspelen, verder in video gaan → video packets loss mogelijk → opnieuw verzonden
HTTP-streaming en DASH
D ynamic A daptive S treaming over H TTP
- Server
- Deelt video bestand in meerdere chunks
- Elke chunk stored, gecodeerd met verschillende snelheden
- Manifestbestand : biedt URL's voor verschillende chunks
- Client
- Meet periodiek server-naar-client bandbreedte
- Adviesmanifest, vraagt 1 chunk tegelijk
- Kiest voor max coderingssnelheid duurzaam gezien huidige bandbreedte
- Kan verschillende coding rates kiezen op verschillende punten in tijd → afhankelijk vrije bandbreedte
STREAMING VIDEO = CODERING + DASH + PLAYOUT BUFFERING
Content Distribution Networks (CDNs)
Challenge: Hoe content streamen naar 100 tot 1000'en gebruikers tegelijk
-
Optie 1: 1 grote server
- Single point of failuire
- Punt van netwerkcongestie
- Lange weg naar clients die verweg zijn
- meerdere kopieën van video verzonden via uitgaande link
-
Deze oplossing schaalt niet
-
Optie 2: meerdere kopieën van video's opslaan/weergeven op meerdere geografisch gedistribueerde sites →(CDN)
- Enter deep → push CDN servers diep in veel access networks → dichtbij users
- Bijvoorbeeld: Akamai → 240k in meer dan 120 landen
- Bring home: kleinere nummers (10's) of grotere clusters in POP's dichtbij access netwerken
- Enter deep → push CDN servers diep in veel access networks → dichtbij users
-
CDN → slaagt kopieen van content op aan CDN nodes
-
Subscriber vraagt content van CDN → gericht nabijgelegen kopie & haalt inhoud op
-
kan een andere kopie kiezen als het netwerkpad overbelast is
Hoofdstuk 8: Security in computer networks
8.1 Wat is netwerkbeveiliging
- Vertrouwelijkheid : Alleen zender & beoogde ontvanger inhoud van verzonden bericht begrijpen
- Berichtintegriteit : de afzender en ontvanger zeker zijn dat inhoud van communicatie niet wordt gewijzigd
- Authenticatie op eindpunt: zender & ontvanger identiteit andere partij vaststellen zeker te zijn dat ander is wie hij beweert
- Operationele beveiliging: bijna alle organisaties hebben netwerken aangesloten op het openbare internet.Deze netwerken kunnen daarom mogelijk worden aangetast.
8.2 Principes van cryptografie
Verzender ( X ) verstuurt bericht naar ontvanger (Y)
- X gebruikt sleutel K** A**→ invoer versleutelalgoritme
- Versleutelalgoritme gebruikt sleutel → onversleutelde bericht m → versleutelde tekst → K** A****(m)**
- KA onderling afspreken
- Y ook sleutel K** B **** →**invoer onsleutelalgoritme → versleutelde bericht X → plaintext
- Y ontvangen versleutelde bericht KA(m) → ontsleutelen → berekenen van Kb(Ka(m)) = m
- Symmetrische sleutelsystemen → sleutels X & Y identiek en geheim
- Openbare sleutelsystemen → 2 verschillende sleutels → 1 v/d 2 zowel bij X als Y bekend
8.2.1 Cryptografie met symmetrische sleutels
- First → Caeser cipher → elke letter in platte tekst → letter → k-letters in alfabet te vervangen
- Daarna → monoalfabetisch cijfer → lettervervanging maar moet uniek zijn
Bruteforce-benadering→ uitproberen alle 10^26 → teveel werk
- Aanval met alleen versleutelde tekst → indringer beschikt alleen over onderschepte versleutelde tekst → niet over informatie van inhoud → onversleutelde bericht
- Aanval met bekende onversleutelde tekst →Indringer (Z)→ kent enkele combinaties van onversleutelde & versleutelde tekst
- Aanval met specifieke onversleutelde tekst → Z kiest onversleuteld bericht → corresponderende versleutelde tekst krijgen → als Z → X een bepaalde zin kan laten verzenden → versleutelmethode verbroken
Polyalfabetische codering → verschillende monoalfabetische ciphers gebruikt → afwisselend ingezet → bepaalde positie in onversleutelde bericht te versleutelen
Block ciphers (DES = data encryption standard, 3DES, AES= advanced encryption standard)
2 categorieën van symmetrische versleuteltechnieken
- Stream cipher
- Block cipher
Blockciphers
- versleutelen bericht → verwerkt blokken k bits
- IF k = 64 → bericht opgesplitst in 64 blokken → elk blok onafhankelijk versleuteld
- Codering 1 op 1 toewijzing om k-bit blok cleartext toe te wijzen aan k-bit blok Ciphertext
Hoeveel mogelijke verwijzingen?
- k = 3 dan zijn er 23 mogelijke ingangen. Deze ingangen kunnen in 8 worden gepermuteerd! = 40 320.
Zeer moeilijk uit te voeren. Voor k = 64 moeten Alice en Bob een tabel onderhouden met 2^64 invoerwaarden → onmogelijk → blokcoderingen meestal functies die willekeurig gepermuteerde tabellen simuleren.
Cipher-block chaining (CBC)
Blockcipher → twee of meer blokken identiek zijn→aanvaller mogelijk cleartext raden en misschien het hele bericht decoderen. → solution → willekeur in ciphertext
Werkwijze:
- voor bericht versleutelt → genereert Afzender een willekeurige k-bit string,initialisatievector (IV) = c(0) genoemd→ afzender stuurt IV naar ontvanger in leesbare vorm
- Eerste blok berekent de afzender m(1) + c(0) → exclusieve OR van eerste blok onversleutelde tekst & IV. → verzender verwerkt met BC → bijhorende blok als versleutelde tekst c(1)=Ks(m(1)+c(0) → verzender versleutelde blok (c1) naar ontvanger
- Voor het i-blok genereert de afzender c(i) = Ks(m(i) + c(i-1))
8.2.2 Cryptografie met openbare sleutel
- 2 partijen delen gedeeld geheim →Symmetrische sleutel voor encryptie & decryptie
Diffie-Hellman key exchange
- Alice haalt Bob's publieke sleutel
- Alice versleutelt bericht (m) aan Bob → door public key van Bob en bekend encryptie-algoritme K+B(m).
- Bob ontvangt → gecodeerde bericht van Alice → gebruikt private key & bekend decoderingsalgoritme → gecodeerde bericht decoderen
- Bob berekent K-B( K+B(m)).
- Berekenen van Kb-(Kb+(m)) resulteert in m
Note : each party generates a public/private key pair and distributes the public key. After obtaining an authentic copy of each other's public keys, Alice and Bob can compute a shared secret offline. The shared secret can be used, for instance, as the key for a symmetric cipher.
RSA
Maken van publieke en private RSA keys:
- Kies 2 grote priemgetallen p & q → hoe groter de waarden hoe moeilijker RSA-algoritme te kraken
- Bereken n = p * q
- Bereken z = (p – 1) * (q-1)
- Kies nummer e, dat kleiner is dan n & geen factoren (buiten 1 ) gemeenschappelijk heeft met z
- Zoek een getal d, zodanig dat ed – 1 precies deelbaar is door z. Wij kiezen d zodanig dat e*d mod z = 1
- Openbare sleutel (K+B) is het paar van de getallen (n, e)
- The private key(K-B) is the pair of the numbers (n, d)
- Encrypteren → C = me mod n
- Decrypteren → m = cd mod n. Which requires the use of the private key (n, d)
NOTE: Diffie-Hellman niet zo veelzijdig als RSA omdat het niet gebruikt kan worden om berichten met willekeurige lengte te coderen → toegepast om symmetrische sessiesleutel tot stand te brengen → daarna coderen berichten
Berichtintegriteit en digitale handtekeningen
8.3.1 Cryptografische hashfuncties
- Rekentechnisch onmogelijk → 2 verschillende berichten x en y te vinden → waarbij
H(x) = H(Y)
- Onmogelijk voor indringer → bericht vervangen door ander bericht dat beveiligd is met hashfunctie
- Om veiligheidsredenen hebben we een krachtigere hash-functie nodig dan een checksum → het MD5-hash-algoritme. Het berekent een 128-bits hash in een proces in vier stappen dat bestaat uit:
- een opvulstap
- een toevoegstap
- een initialisatie van een accumulator
- een laatste loopingstap waarin de blokken van 16 woorden van het bericht in vier rondes worden verwerkt
- Het tweede belangrijke hash-algoritme is het Secure Hash Algorithm (SHA1). Het produceert een 160-bits berichtcijfer. De langste output maakt SHA1 veiliger.
8.3.2 Berichtauthenticatiecode
berichtintegriteit uit te voeren→Alice en Bob→ naast gebruik van cryptografische hashfuncties, → gedeeld geheim nodig→niets meer dan een reeks bits = verificatiesleutel.→ door gedeelde geheim kan berichtintegriteit als volgt worden uitgevoerd:
- Alice maakt bericht m, samenvoegt s met m om m + s te maken en berekent de hash (m+s). → berichtverificatiecode (MAC = Message Authentication Code )
- Alice voegt vervolgens de MAC toe aan het bericht m, maakt een uitgebreid bericht (m, H(m+s)) en stuurt het naar Bob
- Bob ontvangt het bericht (m, h) en weet s, berekent de MAC H(m+s). Als H(m+s) = h, dan is alles in orde met de boodschap
8.3.3 Digitale handtekeningen
Certificering van openbare sleutels
-
Een certification authority controleert of een entiteit is wie het zegt dat het is.
-
certificeringsinstantie identiteit van entiteit verifieert, maakt certificeringsinstantie een certificaat → openbare sleutel van de entiteit aan de identiteit bindt → certificaat bevat openbare sleutel + wereldwijd unieke identificerende informatie over eigenaar van openbare sleutel. Het certificaat digitaal ondertekend door certification authority.
Authenticatie op het eindpunt
Eindpuntverificatie →proces waarbij de ene entiteit zijn identiteit aan een andere entiteit bewijst via een computernetwerk.
8.4.1 Authenticatieprotocol ap1.0
Trudy (indringer) stuurt bericht naar Bob → zegt "ik ben Alice" → Bob weet niet of het werkelijk Alice is 8.4.2 Authenticatieprotocol ap2.0 Alice bekend netwerkadres waaruit ze altijd communiceert→ Bob proberen Alice te verifiëren → bronadres IP-datagram met verificatiebericht overeenkomt met het bekende adres van Alice.
niet moeilijk om IP-datagram te maken, zet elk IP-bronadres dat we willen in het IP-datagram.
8.4.3 Authenticatieprotocol ap3.0
Het wachtwoord is een gedeeld geheim tussen de authenticator en de persoon die wordt geverifieerd.
- Alice stuurt haar geheime wachtwoord naar Bob.
- De beveiligingsfout hier is dat als Trudy Alice's communicatie afluistert, ze Alice's wachtwoord kan leren.
8.4.4 Authenticatieprotocol ap3.1
Door het wachtwoord te versleutelen→voorkomen Trudy Alice's wachtwoord leert→aannemen dat Alice en Bob een symmetrische geheime sleutel delen, KA – B,dan kan Alice het wachtwoord versleutelen en haar identificatiebericht en het gecodeerde wachtwoord naar Bob sturen. Bob decodeert vervolgens het wachtwoord en verifieert Alice.
De fout: the playback attack : Trudy hoeft alleen maar de communicatie van Alice af te luisteren, de gecodeerde versie van het wachtwoord op te nemen en de gecodeerde versie van het wachtwoord af te spelen naar Bob om te doen alsof ze Alice is.
8.4.5 Authenticatieprotocol ap4.0
Een nonce is een getal dat een protocol maar één keer in een leven zal gebruiken. Dat wil zeggen dat zodra een protocol een nonce gebruikt, het het nummer nooit meer zal gebruiken. Onze ap4.0 gebruikt een nonce in als volgt:
- Alice verzendt bericht 'ik ben Alice' aan Bob
- Bob kiest een nonce en verzendt die naar Alice
- Alice versleutelt de nonce met de symmetrische sleutel van Alice en Bob, KA– B,en stuurt de gecodeerde nonce KA_B(R) terug naar Bob.
- Bob ontsleutelt het ontvangen bericht. Als de gedecodeerde nonce gelijk is aan de nonce die hij Alice stuurt, dan is Alice geauthenticeerd
8.5 E-mail beveiligen
8.5.1 Ontwerp van veilige e-mail
Vertrouwelijkheid (Systeem 1)
-
Bericht versleutelen → symmetrische sleuteltechnologie (DES) → ontvanger bericht ontsleutelen
-
Alternatief → cryptografie openbare sleutel (RSA)
-
Om dit efficiëntieprobleem op te lossen, maken we gebruik van een sessie key:
- Alice selecteert een willekeurige symmetrische sessiesleutel (Ks)
- Versleutelt haar bericht m met de symmetrische sleutel
- Versleutelt de symmetrische sleutel met Bob's openbare sleutel K+b
- Voegt het gecodeerde bericht en de gecodeerde symmetrische sleutel samen om een pakket te vormen
- stuurt het pakket naar Bob's e-mailadres. (zie p 586 onderaan voor schema)
-
Bob ontvangt pakket:
- Gebruikt geheime sleutel Kb-→ verkrijgen symmetrische sleutem Ks
- Symmetrische sleutel Ks → ontsleutelen bericht
Sessie key = inefficient
1. Berichtintegriteit
-
Digitale handtekeningen:
- Alice past hashfunctie H toe
- Versleutelt resultaat met hashfunctie → met geheime sleutel KA- → digitale handtekening
- Oorspronkelijke bericht samen met handtekening → 1 pakket
- Verzend pakket → e-mail Bob
-
Bob ontvangt het pakket
- Openbare sleutel Alice KA+ → op ondertekende hash
- Vergelijkt resultaat bewerking met eigen hash H van bericht
The 2 combined:
- Alice maakt eerst een voorlopig pakket, dat bestaat uit haar originele bericht samen met een digitaal ondertekende hash van het bericht
- Vervolgens behandelt ze dit voorlopige pakket als een bericht op zich en stuurt dit nieuwe bericht via de stappen van de afzender van (a), waardoor een nieuw pakket wordt gemaakt dat naar Bob wordtverzonden (zie schema p 586** )**
8.5.2 PGP
PGP-software gebruikt:
- MD5 of SHA → berekenen hash
- CAST, Triple-DES of IDEA → versleutelen symmetrische sleutel
- RSA versleuteling openbare sleutel
Als PGP installed:
- Openbaar sleutelpaar voor gebruiker
- Openbare sleutel → website gebruiker of openbare sleutelserver
- Persoonlijke sleutel beschermd → wachtwoord
PGP → mogelijkheid bericht digitaal ondertekenen
8.6 TCP-verbindingen beveiligen
Noodzaak SSL:
- Geen versleuteling → indringer Bobs bestelling onderscheppen → creditcardgegevens achterhalen
- Integriteit gegevens niet gecontroleerd → bestelling veranderen
- Server niet geauthenticeerd → Valse website maken → gegevens stelen
SSL lost problemen op door volgende bovenop TCP uit te voeren:
- Vertrouwelijkheid
- Gegevensintegriteit
- Serverauthenticatie
- Clientauthenticatie
SSL → eenvoudige API vergelijkbaar API van TCP
8.6.1 Het hele verhaal, maar vereenvoudigd
Fase 1: Handshake
- Bob TCP-verbinding met Alice maken
- Verzekeren dat Alice echt Alice is
- Alice geheime mastersleutel zenden → Alice & Bob gebruiken → symmetrische sleutel genereren → nodig voor SSL
Fase 2: Verkrijgen van een sleutel
Alice & Bob moeten MS gebruiken om vier sleutels te genereren:
- EB: session encryption key for data sent from Bob to Alice
- MB: session MAC key for data sent from Bob to Alice
- EA: session encryption key for data sent from Alice to Bob
- MA: session MAC key for data sent from Alice to Bob
Fase 3: Gegevensoverdracht
Geen goed idee → integriteit alle gegevens tijdens hele sessie dat Bob gestuurd heeft controleren
- SSL splitst gegevensstream → records
- SSL voegt berichtauthenticatiecode toe aan elk record → versleutelt combinatie
- Maken van berichtauthenticatiecode → Bob hashfunctie toe → combinatie recordgegevens & sleutel Mb
- Versleutelen → Bob gebruikt sessievercijfersleutel Eb
Man in the middle attack ( MITM) : kansegmenten in de TCP-stream vervangen, invoegen en verwijderen tussen Alice en Bob.
Aannemen dat elk TCP-segment exact 1 record verpakt is → kijken hoe Alice segmenten verwerkt
- TCP in host Alice → denkt alles is OK → 2 records aan SSL-sublaag
- SSL in host Alice → 2 records ontsleutelen
- SSL in host Alice →berichtauthenticatiecode in elk record gebruiken → integriteit van gegevens in 2 records
- SSL → ontsleutelde bytestream van 2 records doorgeven → applicatielaag → door Alice ontvangen bytestream → gevolg verwisseling records → niet in juiste volgorde
Oplossing: gebruik volgnummers.
- Bob onderhoudt een reeksnummerteller, die begint bij nul en wordt verhoogd voor elke SSL-record die hij verzendt.
- Wanneer hij de MAC berekent,neemt hij het volgnummer op in de MAC-berekening.
Zo is MAC = hash van gegevens + MAC-toets + huidig volgnummer.
Alice kan Bob's volgnummers opsporen, zodat ze de gegevensintegriteit kan verifiëren.
SSL record
Bestaat uit → typeveld, versieveld, lengteveld, gegevensveld & berichtauthenticatiecode
8.6.2 Het hele verhaal, maar wat minder vereenvoudigd
SSL handshake
Alice & Bob begin SSL-sessie zelf afspraken maken over cryptografische algoritmen → aka handshakeprocedurefase → + Alice & Bob zenden elkaar nonces toe → gebruikt bij maken van sessiesleutels (EB,MB,EA,MA)
Handshakeprocedure bij SSL:
- Client verzendt lijst → versleutelalgoritmen die hij ondersteunt & zelfgekozen nonce
- Server kiest uit ontvangen lijst algoritme voor → symmetrische sleutel, openbare sleutel & berichtauthenticatiecode → server verstuurt bericht met voorkeuren, certificaat & zelfgekozen nonce
- Client authenticeert certificaat + berekent openbare sleutel server + genereert geheime pre-mastersleutel (PMS) → versleutelt PMS met openbare sleutel server → verzendt versleutelde PMS naar server
- Afgesproken functie bepalen sleutel → berekenen client & server onafhankelijk → geheime mastersleutel met PMS & nonces → geheime mastersleutel in stukken gehakt → 2 coderingssleutels & 2 berichtauthenticatiecodes genereren → gekozen symmetrische codering werkt met cipher-block-chaining → 2 initialisatievectoren gemaakt → geheime mastersleutel → daarna alle berichten versleuteld & geauthenticeerd
- Client verzendt berichtauthenticatiecode → alle handshakeprocedureberichten
- Server verzendt berichtauthenticatiecode → alle handshakeprocedureberichten
Alleen nonces → niet mogelijk "replay attack" te voorkomen
Verbinding verbreken
Iemand geeft in het typeveld aan of de record dient om de SSL-sessie te beëindigen. Door zo'n veld op te nemen, zou Alice weten dat als ze een TCP FIN zou ontvangen voordat ze een SSL-sluitingsrecord zou ontvangen, ze weet dat er iets grappigs aan de hand is.
8.7 Beveiliging op netwerklaag: IPsec & VPN
8.7.1 IPsec & VPN
Met VPN → interne dataverkeer van de instelling verzonden via het publiekelijk toegankelijke internet in plaats van via een fysiek gescheiden netwerk. → dataverkeer eerst versleuteld
CHECK PAGINA 597 IN HANDBOEK VOOR AFBEELDING
8.7.2 Authentication header-protocol en het encapsulation security payload-protocol
Protocolsuite IPsec → Authentication header (AH-protocol) & encapsulation security payload (ESP-protocol)
AH-protocol → bronauthenticatie & gegevensintegriteit maar geen vertrouwelijkheid ESP-protocol → bronauthenticatie & gegevensintegriteit & vertrouwelijkheid Vertrouwelijkheid essentieel bij VPN & andere IP-sec applicaties
8.7.3 Beveiligingsassociaties
IPsec-datagrammen → verzonden tussen 2 netwerkentiteiten → voor bronentiteit IPsec-datagrammen verstuurt → 2 entiteiten → logische verbinding tot stand = beveiligingsassociatie → logische simplexverbinding → unidirectioneel van bron naar bestemmingsentiteit → beide entiteiten beveiligde datagrammen naar elkaar willen verzenden → noodzakelijk om 2 beveiligingsassociaties tot stand te brengen → voor elke richting 1
8.7.4 Het IPsec-datagram
2 verschillende packetvormen → tunnelmodus & transportmodus PAGINA 589 HANDBOEK
- R1 voegt achter aan oorspronkelijke IPv4-datagram een ESP-trailerveld toe
- R1 versleutelt resultaat met behulp van het algoritme & de sleutel die voor de beveiligingsassociatie zijn overeengekomen
- R1 voeg aan voorkant van versleutelde geheel → veld toe → ESP-header → Resulterende pakket → enchilada
- R1 voegt berichtauthenticatiecode toe aan achterkant van versleutelde geheel → alles te samen → inhoud van payloadveld
- R1 creëert een nieuwe IP-header met alle klassieke IPv4-headervelden → voegt voor payloadveld toe
8.7.5 sleutelbeheer in IPsec (IKE)
IKE kent twee fase
Fase1:
- Vaststellen bidirectionele IKE SA
opmerking: IKE SA anders dan IPsec SA ook bekend als ISAKMP security association
Fase 2:
- ISAKMP wordt gebruikt om veilig te onderhandelen over IPsec-paar SA's
fase 1 heeft twee modi: agressieve modus en hoofdmodus
- Agressieve modus gebruikt minder berichten
- Hoofdmodus biedt identiteitsbescherming en is flexibeler
IKE-berichtenuitwisseling voor algoritmen, geheime sleutels, SPI-nummers
- AH- of ESP-protocol (of beide) AH biedt integriteit, bronverificatie
- ESP-protocol (met AH) biedt bovendien versleuteling
- IPsec-peers kunnen twee eindsystemen zijn, twee routers/firewalls, of een router/firewall en een eindsysteem
8.8 Securing wireless LANs
8.8.1 Wired equivalent privacy
LEER VANUIT SLIDES $rarr; DUIDELIJKER
8.9 Operationele beveiliging: firewalls & intrusion-detectionsystemen
8.9.1 Firewalls
3 doelen:
- Alle dataverkeer van buiten naar binnen & omgekeerd passeert firewall
- Alleen geauthenticeerd dataverkeer → gedefinieerd in lokale beveiligingspolicy's mag passeren
- Firewall kan niet zelf benaderd worden
Traditionele packetfilters
Filterbeslissingen meestal genomen op basis van:
- IP-bronadressen of IP-bestemmingsadressen
- Typeveld in IP-datagram
- TCP- of UDP-bronpoorten en -bestemmingspoorten
- TCP-vlagbits: SYN, ACK,...
- ICMP-berichttype
- Verschillende regels voor datagrammen die netwerk binnenkomen en verlaten
- Verschillende regels voor verschillende routerinterfaces
Organisatie kan filteren op:
- TCP-SYN-segmenten → geen inkomende TCP-verbindingen toestaan behalve voor publieke webserver → alle TCP-SYN-segmenten blokkeren behalve → TCP-SYN-segmenten bestemmingspoort 80 & bestemmings-IP overeenkomt met webserver
- TCP-ack-bit → interne clients verbinden met externe servers → externe clients niet verbinden met interne servers
- 2e mogelijkheid → DNS-packets netwerk kunnen binnenkomen & verlaten → blokkeert al het dataverkeer → behalve webdataverkeer binnen organistatie & DNS-dataverkeer
Filterpolicy kan gebaseerd zijn op combinatie van adressen & poortnummers
Stateful packetfilters
Bewaken alle bestaande TCP-verbindingen → firewall kan nieuwe verbinding detecteren → door 3-wayhandshake (SYN, SYNACK & ACK) → + eind verbinding detecteren → FIN-packet → firewall kan ook veronderstellen → verbinding niet meer nodig is → geen activiteit
Packet bereikt firewall
- Firewall controleert lijst met toegangsbeheer ( traditionele packetfilters )
- Verbindingstabel controleren voor packet in netwerk van organisatie kan komen
- Controleert verbindingstabel → geen deel van lopende TCP-verbinding → weigert
- IF webserver stuurt packet terug → firewall controleert tabel → overeenkomstige verbinding → packet passeren
Application gateway
Firewalls moeten packetfilters combineren met applicatiegateways → die kijken verder dan headers van IP, TCP & UDP → beslissingen op basis van applicatiegegevens Applicatiegateway → applicatiespecifieke server die door alle applicatiegegevens gepasseerd moet worden → verschillende applicatiegateways kunnen op dezelfde host uitgevoerd worden → elke gateway afzonderlijke server met eigen processen
Stel:
Firewall → geselecteerde groep interne gebruikers → Telnet-verbindingen met externe netwerken → tegelijk voorkomen → externe clients → Telnet-verbinding maken met interne host
Stel nu:
Interne gebruiker wil verbinding tot stand brengen met buitenwereld
- Gebruiker Telnet-sessie starten met applicatiegateway → op gateway draait applicatie → wacht voor inkomende Telnet-sessies tot stand komen
- Applicatie vraagt username & password
- IF informatie = correct → applicatiegateway checkt IF gebruiker = gerechtigd is → als dat het geval is
- Gateway vraagt gebruiker → hostname externe host ingeven
- Gateway Telnet-sessie → tussen gateway & externe host
- Gateway verzendt alle gegevens afkomstig van externe host naar gebruiker & omgekeerd
8.9.2 Intrusion-detectionsystems
- Intrusiondetectionsysteem (IDS)→ waarschuwt wanneer mogelijk schadelijk dataverkeer detecteerd
- Intrusion-preventionsysteem (IPS)→ Apparaat dat schadelijk dataverkeer blokkeert
IDS + IPS = IDS
Organisatie → meerdere IDS's sensoren implementeren → meestal samenwerkend → sturen verdachte verkeersactiviteit → centrale IDS-processor → verzamelt info → alarmen verzendt naar netwerkbeheerder wanneer nodig
Pagina 619 afbeelding 3.6
Organisatie → 2 delen opgesplitst
- Streng beveiligd deel → afgeschermd door → packetfilter & applicatiegateway → bewaakt door IDS sensoren
- Minder streng beveiligd deel →gedemilitariseerde zone (DMZ)→ alleen beveiligd door packetfilter maar ook bewaakt door sensoren IDS (is een netwerksegment dat zich tussen het interne en externe netwerk bevindt. Het externe netwerk is meestal het Internet. Een DMZ is feitelijk een andere naam voor een extranet, een gedeelte van het netwerk dat voor de buitenwereld volledig toegankelijk is. Op het netwerksegment van de DMZ zijn meestal servers aangesloten die diensten verlenen die vanuit het interne en externe netwerk aangevraagd kunnen worden)
Sensoren voor IDS → verderop in systeem → elke sensor deel van dataverkeer → gemakkelijker taak uitvoeren
IDS systemen in 2 categorieën
- Systemen die werken met handtekeningen
- database met aanvalskenmerken (handtekeningen) → elke handtekening → verzameling regels → gebruikt verdachte activiteit → kan lijst met kenmerken 1 packet → vergelijkt packets met handtekening in database → overeenkomst in database → waarschuwing
Beperkingen:
-
dit soort IDS → alleen als voorkennis over aanval is → gebruikt nauwkeurige handtekening te vervaardigen → blind als er nieuwe aanvallen zijn
-
packet → zelfs als er bekende handtekening is → niets te maken met een aanval → false-positive warning
-
IDS kan overvoerd geraken → elk packet vergeleken moet worden → uitgebreide verzameling handtekeningen → kan zover komen dat IDS schadelijke packets niet detecteert
-
Op anomalie gebaseerde systemen
- Creëert profiel → normale verloop → gecontroleerde dataverkeer → zoekt packetstreams statisctisch ongebruikelijk zijn
- Niet afhankelijk van voorkennis bestaande aanvallen
- Wel moeilijk → efficiënt onderscheid maken → normaal dataverkeer & statistisch ongebruikelijk verkeer
Snort
Maakt gebruik van generieke sniffingsinfterface, libpcap
Enorme groep gebruikers & beveiliginsexperts → houden handtekeningdatabase actueel
9 Multimedianetwerken
9.1 Multimedianetwerkapplicaties
9.1.1 Eigenschappen van video
- Hoge bit rate : 100kbps voor low-quality video conferencing → 3 Mbps streaming high-definition movies. → bitsnelheidvereisten van video belangrijk ontwerpen netwerkvideotoepassing
- Een niet-gecomprimeerde, digitaal gecodeerde afbeelding → reeks pixels→ elke pixel gecodeerd in aantal bits om luminantie en kleur weer te geven.
- 2 Types redundantie in video → exploited door video compressie
- Tijdelijke redundantie → werkt met verschillen tussen opeenvolgende afbeeldingen
- Spatial redundancy → redundantie binnen een bepaalde afbeeling
9.1.2 Eigenschappen van audio
- Digitale audio → lagere bandbreedte nodig dan video → Pulse Code Modulation (PCM) → coderen spraak → 8000 samples/seconde & 8 bits per sample → bitsnelheid 64 kbps
- Compressietechniek voor stereomuziek → MP3 → bitsnelheid 128 kbps → geluidskwaliteit slechter
- Advanced Audio Coding (AAC) → meerdere versies vooropgenomen audio stream kan gemaakt worden → elke klein verschil bit rate
9.1.3 Soorten multimedianetwerkapplicaties
Streamen van opgeslagen audio / video
Streamen van opgeslagen video 3 belangrijke onderscheidende kenmerken
- Streamen → client begint video → binnen enkele seconden na ontvangst weer te geven → client video weergeeft → bepaalde plaats in opname & tegelijk latere delen van die opname ontvangt van server = streamen
- Interactiviteit → media vooraf opgenomen → gebruiker weergave onderbreken, doorspoelen,... → voor aanvaardbare gebruikskwaliteit → tijd tussen moment gebruiker actie start & uitvoering actie → enkele seconden
- Continue weergave → zelfde snelheid weergeegven als orgineel → gegevens op tijd van server ontvangen → voor moment client moet weergeven → anders haperingen
- Gemiddelde doorvooercapaciteit → netwerk streamapplicatie → gemiddelde doorvoorcapaciteit bieden → ten minste even groot als bitsnelheid video
VOIP
Timing is belangrijk → spraak- en videoapplicaties → vertragingsgevoelig → meeste multimedianetwerkapplicaties → bestand tegen een zekere mate van gegevensverlies → resulteert in korte onderbrekingen van audio of video
Streamen van live audio & video
Meestal via CDN's → zelfde snelheid weergeegven als orgineel → gegevens op tijd van server ontvangen → voor moment client moet weergeven → anders haperingen → omdat evenement = live → vertraging probleem zijn → timingeisen minder streng dan voor spraakgebrekken
9.2 Streamen van opgeslagen video
2 belangrijke voordelen bufferen door client
- Fluctuaties in vertraging tussen server en client opvangen
- Banbreedte tussen server & client → daalt onder sneheid → waarmee videocontent wordt weergegeven → blijven kijken zolang buffer van clientcomponent niet leegraakt
9.2.1 Streamen met UDP
Kleine buffer op clientcomponent van applicatie gebruikt → net groot genoeg voor minder dan seconde video → server die video aan UDP-verbinding vertrouwt → stukjes video verpakken in transportpackets speciaal ontworpen voor transporteren audio & video → Realtime Transport Protocol ( RTP )
Server & client → onderhouden verbinding voor videostream → ook afzonderlijke besturingsverbinding die door client wordt gebruikt geven opdrachten
Systeem 3 belangrijke nadelen:
- Streamen met constante snelheid → voor continue weergave → problemen opleveren als gevolg van onvoorspelbaare & wisselende beschikbare bandbreedte
- Streamen met UDP → server nodig om media te besturen → interactieve verzoeken tussen client en server afhandelen & toestand client bewaren → voor elke sessie
- Veel firewalls geconfigureerd om UDP verkeer te blokkeren
9.2.2 Streamen met HTTP
Video in HTTP server → gewoon bestand met specifieke URL → gebruiker wil video zien
- Client start TCP-verbinding met server
- Verzendt HTTP-GET-bericht
- Server verzendt video bestand in HTTP-antwoordbericht
- Clientcomponent applicatie verzamelt bytes in buffer
- Zodra # bytes in buffer > bepaalde drempelwaarde
- Client begint met weergave + videoframes periodiek uit buffer opgehaald & gecomprimeerd
Packets → vertraagd als gevolg opnieuw verzenden packets
Gebruik van HTTP over TCP → firewalls en NAT's gemakkelijker gepasseerd kunnen worden → van het UDP-dataverkeer tegen houden → HTTP-dataverkeer door te laten → streamen HTTP geen mediabesturingsserver nodig (RTSP-server) → kosten lager → meeste videostreamapplicaties werken met HTTP over TCP als streamprotocol
Prefetchen van video
Client probeert video downloaden → snelheid hoger dan weergavesnelheid → voorraad krijgen van videoframes → toekomst worden weergegeven
Buffers van clientcomponent van de applicatie & TCP-buffers
Volledige client applicatie buffer → legt indirect limiet op rate → video verstuurd van server naar client wanneer streamen over HTTP
Analyse van clientcomponent van applicatie en TCP-buffers
If beschikbare rate < video rate → continue weergave afgewisseld worden → periodes beeld stilstaat → wanneer beschikbare rate in netwerk > video rate → na initiele buffering vertraging → continous playout tot einde video
Vroegtijdige beëindiging van weergave & verplaatsen van weergavetijdstip
HTTP-byterange-headerveld in HTTP-get-verzoekbericht → bevat informatie → bereik in bytes van gewenste video → client wil ontvangen → If gebruik springt naar ander tijdstip in video → client verzendt nieuw HTTP-verzoekbericht → in byterangeheaderveld van bericht → clientapplicatie specifieert vanaf welke byte in bestand → gegevens wil ontvangen → server nieuw HTTP-verzoek ontvangt → alle eerdere verzoeken weg & bytes verzenden
9.2.3 Dynamic Adaptive Streaming over HTTP (DASH)
Gebruikt meerdere versies → zelfde video → elk een bepaalde snelheid waarmee gestreamd wordt → gecomprimeerd → CDN's vaak gebruikt distribueren opgeslagen & live video
9.3 Voice-over-IP (VoIP)
9.3.1 Beperkingen van best-effortdienst van IP
IP → zo snel mogelijk van bron naar bestemming → geen beloften → vertraging of packet loss → belangrijke consequenties → ontwerp realtime spraakapplicaties → gevoelig voor packetvertraging, jitter & verlies
- Verzender genereert bytes met snelheid → 8000 bytes/seconde → iedere 20 ms verzamelt bytes in stuk → chunk
- Chunk + speciale header → verpakt in UDP-segment → elke 20 ms UDP-segment verzonden
Als packet ontvanger bereikt → constante end-to-endvertraging → packets 20 ms na elke spraakactie van andere partij arriveren → ideale situatie → ontvanger elke chunk direct bij aankomst weergeven → sommige packets kwijt + niet zelfde end-to-endvertraging
Ontvanger moet
- Bepalen wanneer chunk moet weergegeven worden
- Bepalen wat er moet gebeuren als chunk ontbreekt
Packetverlies
Verlies zou voorkomen → packets over TCP versturen → mechanismen opnieuw verzenden packets → niet geschikt voor VoIP → vergroten end-to-endvertraging
Packetloss tussen 1% en 20% is acceptabel → afhankelijk hoe spraakgegevens gecodeerd & verzonden zijn → manier hoe ontvanger verlies maskeert → Forward Error Correction (FEC) → hulpvol zijn packetverlies maskeren
End-to-endvertraging
Totaal van
- Transmission delay
- Processing delay
- Queing delays routers
- Propagation delays in verbindingen
- Processing delays hosts
Ontvanger bij VoIP-applicatie → packets negeren die vertraging groter dan bepaalde drempelwaarde
Packetjitter
Variatie in queuing delays → packet in netwerkrouters ondervindt = cruciaal → deze vertragingen variëren → dus ook verstreken tijd tussen moment → verzenden packet & ontvangen packet → fenomeen = jitter → compenseren aan de hand van volgnummers , tijdstempels & weergavevertraging
9.3.2 Jitter voor audio compenseren bij ontvanger
Gedaan door 2 mechanismes combineren
- Elke chunk vooral laten gaan door tijdstempel → verzender voegt aan elk nieuw gegenereerd packet → informatie over tijdstip → packet werd gegenereerd
- Weergave chunks → bij ontvanger vertragen → weergave ontvangen chunks → vertraagd worden → zodat grootste deel packets ontvangen is voor weergeven
1) Onveranderlijke weergavevertraging
Ontvanger kan weergavevertragingen variëren
Chunk tijdstempel bij afzender op tijdstip t → ontvanger speelt chunk (q) af op tijdstip t + q → assuming chunk tegen die tijd gearriveerd → packets na hun geplande speeltijd arriveren → weggegooid
2) Variabele weergavevertraging
Door initiële weergavevertraging groot te maken → meestg packets op tijd aankomen → verloren packets = klein →weergavevertraging variëren aan begin elke spraaksessie → stiltes voorafgaand aan spraaksessie → verkort of verlengd → niet hoorbaar wanneer verleningen / verkortingen stiltes niet te groot zijn
-
Schatting van de pakketvertraging ( di ) = schatting gemiddelde netwerkvertraging moment i-de packet arriveert bij ontvanger
-
Schatting gemiddelde afwijking van vertraging ( vi ) = geschatte gemiddelde afwijking vertraging ten opzichte van de geschatte gemiddelde vertraging → di gemiddelde werkelijke netwerkvertragingen $rarr; r1 - t1,...,ri-ti
-
Schattingen di & vi berekend elk ontvangen pakket → als packet i → 1e packet in spraaksessie → weergavemoment pi berekend $rarr; pi = ti + di + Kvi
-
Term Kvi → weergavemoment zover in toekomst verschoven → klein gedeelte packets te laat arriveren in spraaksessie
-
Stel dat qi = tj + qi → tijd tussen moment 1e packet in spraaksessie genegeerd & moment packet weergegeven → als packet j ook hoor bij spraaksessie → wergegeven op tijdstip → pj = tj + qi
9.3.3 Compenseren van packetverlies
Forward Error Correction ( FEC )
Mechanisme 1:
Verzendt redundant gecodeerde 'chunk' na elke n chunks → geconstrueerd door exclusieve OR-bewerking uit te voeren op n oorspronkelijke chunk.
Als willekeurig packet van groep n+1 kwijtgeraakt → ontvanger verloren packet reconstrueren → meer dan 2 niet mogelijk → verhoogt overdrachtssnelheid & weergavevertraging
Mechanisme 2:
Versturen van lagere resolutie audio stream → verzender genereert n-de packet door n-de chunk van nominale stream achter (n-1) de chunk van redundante stream te plaatsen → wanneer meerdere niet opeenvolgende packets kwijtraken → ontvanger verlies compenseren door chunk met lage bitsnelheid → volgende packet "meelift" geven → lagere geluidskwaliteit
Interleaving
Verzender verstuurt eenheden audiogegevens in andere volgorde → oorspronkelijk aangrenzende eenheden in verzonden stream gescheiden zijn door afstand → effect packetverlies verkleinen → if packetloss → meeste van elke orginele chunk → geen redundantie overhead → verhoogt playout delay → voordeel → benodigde bandbreedte voor een stream niet vergroot
Maskeren van fouten
Herhalen van packets → ontvanger vervangt kwijtgeraakte packets door kopieën
Interpolatie → kwijtgeraakte packet berekend p basis van voorgaande & volgende packet in stream
9.3.4 Casus: VoIP met Skype
- Skype werkt met hiërarchisch overlaynetwerk
- Peer kan "superpeer" of gewone peer zijn
- Werkt met index → koppelt IP-adressen aan gebruikers
- Index gedistribueerd over superpeers
- Alice belt Bob → Skype client zoekt distribueerde index → Bob's IP adres bepalen
Meeste thuisnetwerken → NAT netwerken → NAT voorkomt host buiten thuisnetwerk verbinding met host binnen thuisnetwerk → beide Skype-bellers NAT → probleem
Super peers lossen probleem op
- Alice logt in → superpeer buiten netwerk toegewesen → Alice & superpeer besturingsberichten uitwisselen → idem voor Bob
- Alice belt Bob → informeert Alice superpeer → superpeer Bob informeert → brengt Bob op hoogte → inkomende oproep Alice
- Bob accepteert → 2 superpeers kiezen 3e superpeer zonder NAT → gegevens Alice en Bob uitwisselen aan elkaar koppelen
Conference calls → elke gebruiker verzendt audiostream naar deelnemer die gesprek start → deelnemer combineert audiostreams tot 1 enkele stroom → verzendt kopie van elk gecomineerde stream → elk van andere N-1 deelnemers → video elke deelnemer → gestuurd in servercluster
9.4 Protocollen voor realtime spraakapplicaties
9.4.1 RTP
Gebruikt PCM,MP3,... te transporteren
Basisprincipes van RTP
RTP boven op UDP
- Verzendende component verpakt chunk media-gegevens in RTP-packet
- Verpakt packet in UDP-segment → naar IP
- Ontvangende haalt RTP-packet uit UDP-segment
- Chunk → mediaplayer → decodeert & weergeven
- Verzendende omponent voegt voor elke chunk audiogegevens → RTP-header toe
- Type van audiocodering
- Volgnummer
- Tijdstempel
- RTP packet → in UDP socket interface
- Ontvanger → applicatie ontvangt RTP van socket interface
- Applicatie filtert audiogegevens & headervelden van RTP packet → gegevens decoderen & afspelen
RTP geen mechanismen → tijdige bezorging van gegevens of kwaliteit diensten → geen garantie of packets aankomen of juiste volgorde
RTP → elke bron → eigen onafhankelijke RTP-packetstream → routers geen onderscheid tussen IP-datagrammen met RTP-packets & zonder RTP-packets
Headervelden van RTP-packet
- Volgnummerveld (16 bits) → verhoogt met 1 voor elk verstuurde RTP-packet → gebruikt door ontvanger om packet loss & volgorde van packets herstellen
- Tijdstempelveld (32 bits) → ontvanger tijdstempels → packetjitter compenseren & packets met zelfde snelheid weergeven als waarin verzonden → als applicaties 160 gecodeerde samples maakt → tijdstempelveld verhoogt met 160 voor elk RTP-packet wanneer bron actief → tijdstempelveld klok loopt met constante snelheid → zelfs if bron = inactief
- Bronidentificatieveld / ( Synchronization Source Identifier of SSRC (32 bits) → identificeerd bron van RTP stream → elke RTP sessie heeft unieke bronidentificatie
9.4.2 SIP
- Levert mechanismen → gesprekken over IP-netwerk → beller kan diegene die gebeld wordt waarschuwen → gesprek wil → beide partijen afspraken maken over codering van media → beide deelnemers ook gesprek beëindigen
- Mechanismen → beller huidige IP-adres bepalen van gebelde → gebruikers geen vast IP → dynamisch toegewezen → verschillende IP-apparaten
- Mechanismen → beheren gesprekken → bv. Toevoegen nieuwe mediastreams, doorschakelen van gesprekken, ...
Gesprek tot stand brengen met bekend IP-adres
- Alice stuurt Bob → SIP INVITE bericht → over UDP naar poort 5060 voor SIP → geeft poort aan
- INVITE-bericht identificatie voor Bob + indicatie huidig IP van Alice & preferred codering
- Bob antwoord met 200 OK bericht → poort weer, IP & preferred codering
- Na ontvangen Bob antwoord → SIP ontvangst bericht → erna praten
SIP kan over TCP of UDP verstuurd worden → default port 5060 → SIP berichten verstuurd en ontvangen in sockets → andere dan voor media data
SIP berichten → ASCII leesbaar → lijken op HTTP-ber
SIP-berichten
Kijk pagina 663. Voor voorbeeld
Vertalen van namen en het traceren van een gebruiker
Alice kent alleen e-mailadres Bob → dit adres ook voor SIP-gesprekken
bob@domain.com
Hoe kent proxyserver het huidige IP-adres vanElke SIP-gebruiker → registrar gekoppeld
- Gebruiker start SIP-applicatie
- Applicatie verzendt SIP-registerbericht naar registrar → informatie huidig IP gebruiker
- Registrar Bob → bijhouden huidig IP-adres Bob → ander SIP-apparaat → nieuw registerbericht met nieuw IP
Gebruik langere tijd → register blijft registerberichten sturen → registrar overeenkomsten met DNS-name-server → vertaalt vaste hostnamen naar vaste IP → SIP-registrar vaste menselijke identificatiegegevens → dynamische IP-adressen → SIP-registrars & proxy's op zelfde host
Hoe kan SIP proxy huidige IP-adres van Bob achterhalen
- Alice verstuurt INVITE-bericht → SIP-proxy Bob
- Proxy stuurt bericht naar SIP-apparaat van Bob
- Bob ontvangt Alice INVITE-bericht → kan antwoord sturen naar Alice
Jim@umass.edu (217.123.56.89) wil VoIP starten met Keith@upenn.edu (197.87.54.21)
- Jim verzendt INVITE-bericht naar SIP-proxy van umass
- Proxy → DNS-lookup voor SIP-registrar upenn.edu → verzendt bericht naar registrarserver
- Keith.upenn.edu → niet bekend bij registrar upenn → registrar omleidingsantwoordbericht → melding → umass keith.nyu.edu moet proberen
- Proxy umass → INVITE-bericht → SIP-registrar van NYU
- Registrar NYU → kent IP van keith@upenn.edu→ stuurt INVITE-bericht door naar host 197.87.54.21 → SIP-client van Keith uitvoert.
- Verzendt SIP-antwoordbericht → registrars/proxy's → terug naar SIP-client → 217.123.56.89
- Idem 6
- Idem 6
- Media → rechtstreeks tussen 2 clients verzonden → ook ACK
9.5 Netwerkondersteuning voor multimedia
- Beste maken van de best-effortdienst → toenames van vraag voorspeld → ISP's extra bandbreedte & switches in → acceptabele mate vertraging & packetloss te garanderen
- Diensten in verschillende categorieën aanbieden → 1 type van verkeer → kan hogere prioriteit krijgen dan een ander type
- Per verbinding andere QoS-garanties geven → per verbiending QoS garantie → elke instantie van applicatie → bandbreedte reserveren → garanties end-to-endperformance → harde garantie → applicatie zeker de gevraagde QoS zal ontvangen → Zachte garantie → grote waarschijnlijkheid de gevraagde QoS zal ontvangen
9.5.1 Best-effortnetwerken dimensioneren
Eerste manier kwaliteit multimedia-applicaties te verbeteren →
Meer geld uitgeven
Bij multimedia in netwerken → voorkomen tekort aan recources → als linkcapaciteit → groot genoeg → packets door huidige internet getransporteerd → zonder queuing delays of kans op vermissing
Vraag is → hoeveel capaciteit nodig? → kosten leveren benodigde bandbreedte → reële zakelijke optie is voor ISP's → hoe groot capaciteit netwerklinks → bepaalde topologie → bepaalde end-to-endperformance te leveren = netwerkdimensioneringsprobleem
Volgende problemen moeten opgelost worden om performance van applicatielaag tussen 2 eindpunten in netwerk te kunnen voorspellen
- Modellen van het benodigde dataverkeer tussen eindpunten in het netwerk
- Mogelijk modellen gedefinieerd worden op gespreksniveau
- Goed gedefinieerde performance-eisen
- Performance eis stellen dat gevoelig is voor vertraging → kans end-to-endvertraging van packets groter is dan max te tolereren vertraging
- Modellen om end-to-endperformance bij een bepaald netwerkbelastingsmodel te voorspellen en technieken om zo gering mogelijke kosten zodanig bandbreete toe te wijzen dat aan alle eisen van de grebruikers wordt voldaan
9.5.2 Verschillende soorten diensten verlenen
Eenvoudigste uitbreiding → dataverkeer voor unitaire & egalitaire best-effortdienst → huidige internet opsplitsen in categorieën → bij dienstverlening aan verschillende categorieën → verschillende niveaus
Een paar scenarios
Principe 1: Packet markering → markeren van packets → router packets die horen bij verschillende dataverkeercategorieën van elkaar onderscheiden → originele doel (ToS) veld in IPv4
Principe 2: Isolatie dataverkeer → zekere mate van isolatie tussen categorieën implementeren → ene klasse niet nadelig beïnvloed kan worden → als iets mis is met andere categorie
2 aanpakken mogelijk:
- Dataverkeerpolicy → als dataverkeercategorie moet voldoen aan bepaalde criteria → controlemechanisme → zorgen policy nageleefd → als applicatie niet aan criteria houdt → mechanisme handelend optreden → dataverkeer netwerk binnenkomt voldoet aan criteria
- Packetschedulingmechanisme op datalinklaag → expliciet een constante hoeveelheid van linkbandbreedte te laten reserveren → elke categorie
Principe 3: Belangrijk categorieën van elkaar scheiden → wenselijk recources → efficiënt mogelijk te benutten → manier packets in wachtrij voor verzending over link worden geselecteerd = link-schedulingmethode
Leaky bucket
Policing = belangrijk QoS-mechanisme
3 policycriteria:
- Gemiddelde snelheid: Netwerk kan gemiddelde snelheid van packets van stream langere tijd beperken → cruciale factor → tijdsduur waarover de gemiddelde snelheid zal worden geregeld → bron begrensd 100 packets per seconde → sneller afgeremd dan bron 6000 packets/min → zelfs beide bronnen → zelfde gemiddelde snelheid
- Maximale snelheid: beperking van gemiddelde snelheid → begrenst hoeveelheid dataverkeer → in netwerk gezonden kan worden → relatief lange periode → beperking van maximale snelheid → begrenst # packets verzonden in korte periode
- Burstgrootte → Netwerk kan ook max # packets → begrenzen → dat gedurende extreem korte periode via netwerk wordt verzonden
Buckets bestaan uit → bucket dat max b tokens bevat
- Nieuwe tokens → in bucket → snelheid van r tokens per seconde genereerd
- IF bucket < b tokens → token direct in bucket
- Else → token genegeerd → bucket blijft gevuld met b tokens
Stel packet voor het verzonden wordt → token uit bucket halen
Omdat maximaal b tokens in bucket zitten → maximale burstgrootte voor een met leaky bucket begrense stream gelijk aan b packets
Tokens genereerd met snelheid r → maximale aantal packets → netwerk kan binnenkomen in willekeurige periode met lengte t → rt + b → snelheid r waarmee tokens genereerd worden → maat om gemiddelde snelheid → packets netwerk kunnen binnenkomen op lange termijn → begrenzen
9.5.3 Diffserv
Diffserv → differentiatie in dienstverlening → mogelijkheid verschillende categorieën dataverkeer → internet schaalbare manier
2 functionele elementen
- Functies aan de edge: → classificeren en coditioneren van dataverkeer → ingaande edge netwerk ( bij Diffserv-host die dataverkeer genereert of eerste Diffserv-router waarlangs dataverkeer passeert) → arriverende packets gemarkeerd
- Functies in de core → doorverzenden → wanneer Diffserv gemarkeerd packet → arriveert Diffserv router → doorverzonden naar volgende hop → volgens 'per-hop' voorschrift → geldt voor betreffende categorie packets → 'per-hop' voorschrift uitsluitend gebaseerd op markering van packet ( Diffserv-model)
Packets die bij edgerouter aankomen → gaclassificeerd & gemarkeerd (AFBEELDING p.679)
- Classificeerder selecteert packets → basis 1 of meer waarden in headervelden
- Verzendt packet naar betreffende markeerfunctie
Sommige gevallen host afgesproken → packetverzendsnelheid → sturen → voldoet aan bepaald dataverkeerprofiel → kan limiet op maximale overdrachtsnelheid bevatten of maximale # packets verzonden in korte tijd
Zolang gebruiker packets verzendt → voldoen aan overeengekomen waarden in dataverkeerprofiel → packets voorkeursbehandeling → wanneer verzender niet houdt aan dataverkeerprofiel, packets buiten overeenkomst vallen → andere markering of vertraagd worden of zelfs genegeerd worden aan edge netwerk
Meetfunctie → ingaande stream vergelijken met overeengekomen dataverkeerprofiel → bepalen packet binnen dat profiel past → eigenlijke beslissing over packets → netwerkbeheerder
In per-hop gedrag belangrijke overwegingen
- 'per-hop' voorschrift → zorgen verschillende categorieën dataverkeer → verschillende diensten
- Per-hop voorschrift verschilt → behandeling tussen categorieën definieert → geen expliciete informatie hoe voorschrift uitvoeren
- Verschillen in performance moeten dus zichtbaar & meetbaar zijn
2 'per-hop' voorschriften gedefinieerd
- Expedited forwarding → 'per-hop' voorschrift → vertreksnelheid van categorie → bij router = > dan geconfigureerde snelheid
- Assured forwarding → 'per-hop' voorschrift → verkeer in 4 categorieën → elke AF-categorie gegarandeerd → bepaalde minimale hoeveelheid bandbreedte & buffers
End-to-end-Diffserv-dienst leverren → alle ISP's tussene eind systemen → service leveren & samenwerken & afspraken maken → klant → gedifferentieerde end-to-end dienst te bieden
9.5.4 Per verbinding Qos-garanties geven: recources reserveren & streams toelaten
Principe 4: Nood aan nieuwe netwerk mechanics en protocollen → duidelijk wanneer stream gegearandeerde service moet ontvangen zodra gestart is
- Recources reserveren → enige manier garanderen → stream beschikken over benodigde recources → recources gereserveerd → stream naar behoefte benutten → gedurende gereserveerde tijd ongeacht behoeften andere streams
- Streams toelaten → recources gereserveerd → netwerk mechanisme hebben → streams verzoeken kunnen richten → recources niet oneindig → verzoek stream afgewezen → als gevraagde recources niet beschikbaar zijn
- Signaleren set-up streams → toelatingsproces → stream die QoS nodig heeft → voldoende recources reserveren → elke netwerkrouter tussen bron & bestemming → zeker zijn end-to-end-QoS-eisen hebben → elke router → lokale recources voor nieuwe stream nodig zijn berekenen → bekijken hoeveel beschikbare recources in gebruik zijn → opgestarte streams → of bepalen beschikbare per hop → toereikend QoS-eisen → honoreren Signaliseringsprotocol nodig activiteiten coördineren = call-setupprotocol → RSVP-protocol → voorgesteld voor dit doel binnen internetarchitectuur (PAGINA 683 AFBEELDING)
Active vs Passive FTP
Active FTP
- Client contacteert server op command poort
- Server stuurt ACK terug naar client's commandpoort
- Server initieert connectie op lokale datapoort → naar datapoort client eerder aanduidde
- Client stuurt ACK terug
Passive FTP
- Client contacteert server op command poort
- Server antwoord met poort 2024 → server verteld welke poort luisterd voor data connectie
- Client initieert data connectie van zijn datapoort → gespecifieerde data poort
- Server stuurt ACK terug naar client's datapoort
Active → SYN door client Passive → SYN door client
2020 juni examen
(Corona) - P. Geens
Theorie
+- 24 multiple chose vragen
Praktijk
Bij elke vraag moest je deze vorm van input meegeven: "oneliner - outputhash md5sum" ('| mdsum' toevoegen aan je oneliner geeft je de hash terug van je output)
- Vraag 1: Voorbeeldvraag (was gegeven en kon je geen punten mee verdienen)
ls -ld /etc
- Vraag 2: Create a linux CLI oneliner to extract the logged in user's username in the file Cnw2_ftp.pcap (use tshark) (dit commando is eigenlijk voor meerdere users...)
tshark -r /home/logs/Cnw2_ftp.pcap -Y 'ftp.request.command==USER' -T fields -e 'ftp.request.arg' | sort | head -1
- Vraag 3: Create a linux CLI oneliner to get the following output of wiki.uclllabs.be (use openssl)
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -text
- Vraag 4: Create oneliner to decode string in the secret located at /home/logs (use openssl)
cat /home/logs/secret | openssl enc -a -d
2020 juni examen - versie 2
Examen Juni 2020
Dit examen was tijdens de corona periode. Labo en theorie waren dus samen gevoegd.
Voor theorie: zie het bestande THEORIE.md
Dank aan: Pablopicasso en ISW
cn2_examen_juni2020.zip is gewoon een kopie van de Toledo website op dat moment,
Labo
Instructies
Het examen is gesloten boek, je mag enkel gebruik maken van onderstaande hulpmiddelen:
-
pcre handleiding + Linux comand line cheat sheet. Zie dat je een lokale kopie hebt op je laptop (of op papier) voor aanvang van het examen, tijdens het examen is toegang tot de wiki verboden.
-
ssh sessie naar server leia.uclllabs.be.
Antwoorden bestaan steeds uit een enkele ‘oneliner’, net zoals in de geziene labo’s en het voorbeeldexamen. Je mag commando’s aan elkaar lijmen met unnamed pipes ( | symbool), maar &&, || en ; mogen enkel gebruikt worden wanneer dit echt noodzakelijk is (bijvoorbeeld voor de syntax van een for-loop).
Let op: Bij sommige opdrachten staat er vermeld welke commando's je (niet) mag gebruiken.
Veel succes!
Vraag 1 (voorbeeld): 0 punten
Dit is een voorbeeld vraag, inclusief het correcte antwoord. Bekijk ze goed, zodat je weet wat er exact verwacht wordt.
Maak een CLI oneliner die de directory permissies, eigenaar, groep,... (via ls -l) oplijst van de /etc directory zelf (niet van de inhoud) op server leia.
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
ONELINER - md5 hash
Oplossing:
# Met deze onliner kan je de permissies,... opvragen van de /etc directory zelf:
ls -ld /etc
# En zo pipe je de output van deze oneliner in md5sum:
ls -ld /etc | md5sum
# En dit vul je in in het antwoordveld:
ls -ld /etc - 69ede2180c67f4a59fea0206e031101f
Vraag 2: 10 punten
Het bestand Cnw2_ftp.pcap bevat een opgenomen FTP sessie. Je kan dit bestand vinden in /home/logs op server leia.
Maak een CLI oneliner met tshark die de gebruikersnaam toont van de gebruiker die succesvol inlogde. Enkel de gebruikersnaam mag getoond worden. Dus geen witregels, geen errors, geen andere tekst.
In je oneliner mag je enkel gebruik maken van het commando tshark. Geen enkel ander commando is toegestaan. Je mag wel gebruik maken van Wireshark als hulpmiddel om de juiste display filter ('s) te vinden.
Oplossing
tshark -r /home/logs/Cnw2_ftp.pcap -Y "ftp.request.command==USER && tcp.srcport==$(tshark -r /home/logs/Cnw2_ftp.pcap -Y "ftp.response.code==230" -T fields -e tcp.dstport)" -T fields -e ftp.request.arg
# Deze kan ook maar is waarschijnlijk niet altijd juist
tshark -r /home/logs/Cnw2_ftp.pcap -Y 'ftp.request.command==USER' -T fields -e 'ftp.request.arg' | sort | head -1
Vraag 3: 10 punten
Maak een CLI oneliner met openssl die het certificaat van de server wiki.uclllabs.be als tekst laat zien. Enkel dit mag getoond worden. Sample output:
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
0d:81:12:b8:1c:24:0c:f3:0d:46:af:cd:9a:9b:96:d2
Signature Algorithm: sha256WithRSAEncryption
Issuer: C = NL, ST = Noord-Holland, L = Amsterdam, O = TERENA, CN = TERENA SSL CA 3
Validity
Not Before: Jan 22 00:00:00 2020 GMT
Not After : Jan 26 12:00:00 2022 GMT
Subject: C = BE, L = Leuven, O = UC Leuven, CN = *.uclllabs.be
Subject Public Key Info:
Public Key Algorithm: id-ecPublicKey
Public-Key: (384 bit)
pub:
04:f5:46:f9:2c:94:f0:86:bd:6f:59:32:7c:4d:82:
06:da:d7:87:38:cb:74:98:6d:66:c0:4c:ca:f4:9e:
1f:5a:22:25:43:11:07:d4:86:1d:68:92:82:d3:eb:
4a:a5:bd:fb:4a:46:84:86:ed:40:be:92:7d:f1:f2:
56:3b:2b:9f:eb:84:33:59:0d:62:ef:8d:68:ac:4d:
d2:76:84:8c:69:93:47:cc:09:a2:2d:19:9d:ba:c6:
e7:e8:03:01:7d:df:44
ASN1 OID: secp384r1
NIST CURVE: P-384
X509v3 extensions:
X509v3 Authority Key Identifier:
keyid:67:FD:88:20:14:27:98:C7:09:D2:25:19:BB:E9:51:11:63:75:50:62
X509v3 Subject Key Identifier:
1B:19:0F:9E:AE:E4:39:61:82:08:79:0C:06:42:75:4A:EE:86:BF:6C
X509v3 Subject Alternative Name:
DNS:*.uclllabs.be, DNS:uclllabs.be
X509v3 Key Usage: critical
Digital Signature
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 CRL Distribution Points:
Full Name:
URI:http://crl3.digicert.com/TERENASSLCA3.crl
Full Name:
URI:http://crl4.digicert.com/TERENASSLCA3.crl
X509v3 Certificate Policies:
Policy: 2.16.840.1.114412.1.1
CPS: https://www.digicert.com/CPS
Policy: 2.23.140.1.2.2
Authority Information Access:
OCSP - URI:http://ocsp.digicert.com
CA Issuers - URI:http://cacerts.digicert.com/TERENASSLCA3.crt
X509v3 Basic Constraints: critical
CA:FALSE
CT Precertificate SCTs:
Signed Certificate Timestamp:
Version : v1 (0x0)
Log ID : A4:B9:09:90:B4:18:58:14:87:BB:13:A2:CC:67:70:0A:
3C:35:98:04:F9:1B:DF:B8:E3:77:CD:0E:C8:0D:DC:10
Timestamp : Jan 22 11:03:02.541 2020 GMT
Extensions: none
Signature : ecdsa-with-SHA256
30:44:02:20:5B:C2:BD:AA:16:4F:D8:18:42:10:D7:48:
9D:37:37:0B:4D:D6:65:65:F1:BF:08:A4:8D:B4:81:31:
02:BF:15:06:02:20:0D:DB:02:07:86:E1:2B:C0:24:04:
BE:42:FC:13:5E:77:D5:BF:E9:4B:53:0D:F1:6D:5E:78:
51:0A:3F:E4:26:31
Signed Certificate Timestamp:
Version : v1 (0x0)
Log ID : 87:75:BF:E7:59:7C:F8:8C:43:99:5F:BD:F3:6E:FF:56:
8D:47:56:36:FF:4A:B5:60:C1:B4:EA:FF:5E:A0:83:0F
Timestamp : Jan 22 11:03:02.760 2020 GMT
Extensions: none
Signature : ecdsa-with-SHA256
30:46:02:21:00:FF:25:60:84:19:69:76:91:D6:8E:C5:
54:ED:7C:D4:40:9F:9B:14:99:2F:22:89:F0:0A:3F:9E:
3F:15:98:A3:66:02:21:00:92:05:A1:8D:F3:06:A8:DD:
92:E2:86:83:54:C1:BC:F9:5F:03:2E:62:F9:DA:5A:17:
2D:F8:D1:E6:5B:A2:78:6A
Signed Certificate Timestamp:
Version : v1 (0x0)
Log ID : EE:4B:BD:B7:75:CE:60:BA:E1:42:69:1F:AB:E1:9E:66:
A3:0F:7E:5F:B0:72:D8:83:00:C4:7B:89:7A:A8:FD:CB
Timestamp : Jan 22 11:03:02.616 2020 GMT
Extensions: none
Signature : ecdsa-with-SHA256
30:44:02:20:7E:42:D6:3A:55:8B:7B:5A:1E:E0:05:48:
09:80:89:E5:A5:7A:FD:8C:5F:EE:AB:2E:7E:D1:07:A0:
C2:B4:63:EA:02:20:3A:12:1E:14:28:50:F7:8D:C3:73:
EA:9E:6C:AB:5D:B4:A8:AE:27:4C:D1:40:18:23:80:1E:
F3:87:B8:A8:98:71
Signature Algorithm: sha256WithRSAEncryption
7b:8b:b1:71:c4:73:c9:1f:30:d9:74:ea:b0:e9:a3:a7:a0:7b:
23:a3:24:cf:e4:c4:f3:8f:82:47:15:4a:e7:4a:05:da:57:0a:
89:db:90:50:62:0f:a8:95:47:5a:22:eb:5b:2f:a3:fd:31:d0:
b5:b1:86:02:a1:91:87:65:42:70:ea:fc:49:79:ea:2c:13:fb:
b0:4e:a5:15:ab:80:82:9d:c9:82:e9:da:9e:bb:81:8a:f0:65:
eb:ef:73:1c:e4:e2:69:ce:06:fc:38:92:fc:7a:06:72:ae:c7:
7e:37:37:21:b9:71:52:93:ed:18:b4:5d:91:9c:95:48:62:d6:
ed:ab:3a:db:1d:22:ed:01:de:7d:56:58:f3:0a:7a:49:4c:cb:
8b:73:b9:5f:83:f8:c4:b3:1a:ec:54:52:b9:83:ae:db:f7:0b:
b2:cb:76:d0:99:19:e9:26:f9:c2:12:5d:ec:ea:0b:e3:f4:28:
8a:da:c2:f5:b3:76:a4:03:c7:02:da:d0:44:a8:7a:6b:19:a0:
99:99:f4:e8:e9:6b:ab:2e:ce:c8:5f:31:bb:e9:bb:52:35:61:
ed:5a:22:fa:1c:ed:d0:4c:fe:83:8d:78:8a:43:79:fa:a3:38:
5b:c2:f0:6e:b5:13:8e:28:fc:c7:f4:2c:a1:fe:79:b4:5a:68:
fa:41:d5:a3
Oplossing
echo | openssl s_client -connect wiki.uclllabs.be:443 2>/dev/null | openssl x509 -noout -text
Vraag 4: 10 punten
Met welke CLI oneliner kan je volgende string decoderen?
RGUgcHVudGVuIG9wIGRlemUgdnJhYWcgemlqbiBhbCBiaW5uZW4uCg==
Je kan deze string ook terugvinden in het bestand /home/logs/secret op server leia. Je mag enkel gebruik maken van het commando openssl. Geen andere commando's zijn toegestaan.
Oplossing
openssl base64 -d -in /home/logs/secret
# Of een andere oplossing:
cat /home/logs/secret | openssl base64 -d
# Of een andere oplossing:
echo "RGUgcHVudGVuIG9wIGRlemUgdnJhYWcgemlqbiBhbCBiaW5uZW4uCg==" | openssl base64 -d
Dit is ook mogelijk maar is volgende de vraag fout, je moet openssl gebruiken.
cat /home/logs/secret | base64 -d
# Of
base64 -d /home/logs/secret
Examenbestanden:
2021 juni examen
Met dank aan ISW
Praktijk test 21-05-2021
Let op, er waren twee testen en dus ook meerdere vragen.
### Vraag 2
1. Maak een CLI oneliner waarmee je alle woorden die uit exact 14 unieke letters bestaan toont. Sorteer het lijstje in omgekeerd alfabetische volgorde. Gebruik hiervoor het bestand /usr/share/dict/dutch.
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
oneliner - md5 hash
2 punten
### Vraag 3
1. Maak een CLI oneliner die uit de capture http.pcapng (/home/logs op leia) alle HTTP server strings laat zien en telt die niet de string Apache bevatten als antwoord op je GET requests. Sorteer van groot naar klein.
Sample output:
2 ClientMapServer
1 YouTube Frontend Proxy
1 sffe
1 Kestrel
1 ECS (ams/D1E7)
1 ECS (ams/499C)
1 downloads
1 CloudFront
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
oneliner - md5 hash
2 punten
### Vraag 4
1. Maak een CLI oneliner die alle unieke gebruikersnamen toont waarmee geprobeerd werd om in te loggen op de website http://darthvader.uclllabs.be/nw2/private. Maak gebruik van de capture http_basic_auth.pcapng (/home/logs op leia).
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
oneliner - md5 hash
2 punten
### Vraag 5
1. Maak een CLI oneliner waarmee je de uitgever, vervaldatum en modulus (in deze volgorde) laat zien van het certificaat van de website https://x.toledo.ucll.be.
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
oneliner - md5 hash
2 punten
### Vraag 6
1. Maak een CLI oneliner die de juiste (dus van vandaag) dag en datum toont zoals in onderstaand voorbeeld:
Het is vandaag vrijdag (1996.09.13)
Daarna pipe je de output van je CLI oneliner in het commando md5sum. In het antwoordveld vul je beide in op deze manier:
oneliner - md5 hash
Theorie test 31-05-2021
Algemeen
Dit vak bestaat uit theorielessen en computerzittingen. In de computerzittingen worden er oefeningen gemaakt in Linux, via SSH op een server van school. De leerstof van de praktijk lijkt eerst zot moeilijk, maar zorg gewoon dat je genoeg oefent en durf vragen te stellen en uiteindelijk zal het zichzelf uitwijzen
Het examen bestaat uit twee delen: een theorie-examen op 10 punten in de normale examenperiode en een praktijkexamen in de laatste week van het semester dat eveneens op 10 punten staat. Alles wat bij de Wiki op de pagina theorie staat is te kennen theorie. Er komt sowieso een vraag gebaseerd op hetgeen er in de filmpjes of extra teksten staat. Bij de meerkeuzevragen van het theorie-examen is er is geen giscorrectie, maar alles moet juist zijn om punten te kunnen krijgen. Het aantal juiste antwoorden wordt gegeven. Het is goed mogelijk dat er vragen terugkomen.
Het onderwerp cryptografie is een moeilijk onderdeel van computernetwerken. Als je het niet erg vindt om eens wat te lezen: het boek Computer Networks: A top-down approach is een zeer goed boek.
De puntenverdeling was oorspronkelijk 14 voor het theorie-examen en 6 voor het praktijkexamen. In 2015-2016 werd dit een eerste jaars vak en in schooljaar 2016-2017 veranderde de puntenverdeling naar 10/10 waarbij 10 punten op de theorie en 10 op de labo's.