Billions of people use cryptography on a daily basis without realising it. The 2010s saw the widespread adoption of encryption on the web, accelerated by the Snowden disclosures: in 2015, 30% of pages loaded on Android were protected by Transport Layer Security (TLS), but by 2020, it was 90%. Alongside TLS, major websites employ hash functions for password storage, signed tokens for authorisation, and complex protocols for handling payment-card data.
However, as we've seen from other categories, cryptography is full of subtleties, and teams building web apps often get it wrong. This highly practical category explores common ways that cryptography is used in web apps, together with devastating implementation errors that are seen in the real world.
.
): the header, the payload, and the signature. In fact, it's a variant of base64 encoding, where the +
and /
have been replaced by different special characters since they can cause issues in URLs.You must be logged in to submit your flag.
You must be logged in to submit your flag.
You must be logged in to submit your flag.
You must be logged in to submit your flag.
pip show pyjwt
to find the location of the PyJWT library on your computer, and make the edit. For versions of PyJWT > 2.4.0 the code has been changed so you will have to edit jwt/utils.py
instead of jwt/algorithms.py
You must be logged in to submit your flag.
You must be logged in to submit your flag.
You must be logged in to submit your flag.
tls1.cryptohack.org
and find the name of the certificate authority organisation which issued the TLS certificate for the domain - this can be done purely within the browser. We'll explore the role of certificate authorities more in future challenges!You must be logged in to submit your flag.
View > Resolution > Resolve Network Addresses
to see some helpful names we added to the source and destination IPs to make the communication clearer. While Wireshark can resolve some public IPs by itself (like 178.62.74.206
becomes "cryptohack.org" using the DNS request in the packet capture), Wireshark could not resolve the private IPs in the capture so we annotated those ourselves in the provided file by right-clicking the IPs then Edit Resolve Name
.Apply as Filter > Selected
to apply the same criteria on the selected column to filter all packets in the capture. For instance, if you right-click and do this for a packet sent by the CryptoHack server in the "Source" column, the ip.src == 178.62.74.206
filter will be applied. To remove the filter clear the search bar and hit enter.You must be logged in to submit your flag.
178.62.74.206
).178.62.74.206
.178.62.74.206
. This negotiated a stable connection between the two computers over the Internet before the real data transfer could start.cdnjs.cloudflare.com
to load JavaScript resources on the page and sent DNS requests to resolve those domains. This isn't relevant to TLS apart from the notable fact that DNS requests on most systems by default are not encrypted (but DNS-over-HTTPS, which fixes this obvious leak, is starting to get more common).ServerHello
message of the packet capture. Randomness is contributed by both client and server, and it plays role in preventing replay attacks. A replay attack is when an attacker that has recorded an existing handshake tries to reuse the same messages to pretend to be a client or server in a new connection.You must be logged in to submit your flag.
ECDHE-RSA-AES128-GCM-SHA256
: ECDHE
is the Elliptic-curve Diffie–Hellman algorithm used for key exchange.RSA
is used to sign the certificate. This field is sometimes missing, in which case the signature algorithm to be used is negotiated in the signature_algorithms
extension. In Wireshark, you can see the client's desired signature algorithms in the ClientHello message.AES-128
is used to symmetrically encrypt the application data.GCM
is the mode of operation that will be used for AES.SHA256
will be used for handshake authentication.curl
or openssl
commands with specific flags to specify that TLS 1.2 is the maximum version you support in your ClientHello message, or you can use an online tool like Qualys SSL Labs to get all the TLS information about the server to solve this.
You must be logged in to submit your flag.
tls2.cryptohack.org
using the curl
command-line tool. Unlike the TLS 1.3 connection we were looking at in the previous packet capture, more of the handshake is visible in plaintext.TLS_RSA_WITH_AES_256_GCM_SHA384
cipher suite (AES256-GCM-SHA384
in OpenSSL format). This uses RSA for key exchange.tls2.cryptohack.org
server and obtained the certificate's RSA private key. Use it to decrypt the TLS connection and find the flag in the HTTP/2 stream.You must be logged in to submit your flag.
You must be logged in to submit your flag.
verify_data = HMAC(finished_key, Transcript-Hash(Handshake Context, Certificate*, CertificateVerify*))
HMAC
function uses the last algorithm specified in the agreed cipher suite, usually SHA256 or SHA384.finished_key
is the relevant handshake_traffic_secret, the CLIENT_HANDSHAKE_TRAFFIC_SECRET
seen in the keylogfile.txt in the case for the client's Finished.Transcript-Hash
function works by concatenating together TLS messages (not including record layer headers) and hashing the result using the hash algorithm in the cipher suite.verify_data
in the Client Finished message should look like, and submit that as your answer.You must be logged in to submit your flag.
socket.cryptohack.org 13408
You must be logged in to submit your flag.
socket.cryptohack.org 13409
You must be logged in to submit your flag.
You are now level Current level