7 Commits

Author SHA1 Message Date
Leo
07568edbcd feat: found the exploit in the code and attaced the server 2026-05-02 19:48:28 +02:00
Leo
a23ec65d30 feat: init sheet03 2026-05-02 19:00:49 +02:00
Leo
d3aa96fa84 feat: a2 c
All checks were successful
zip and release / build-and-release (push) Successful in 4s
2026-05-01 01:32:01 +02:00
Leo
9c2b167d3a feat: a1 without d 2026-05-01 01:31:53 +02:00
Leo
4784a15866 fix: remove package and rename files 2026-05-01 01:31:17 +02:00
Julian
76d4003957 feat(sheet2): task 2 solution 2026-04-29 13:28:34 +02:00
Leo
3b9e9034ba chore: create empty files for ex2 2026-04-28 20:14:21 +02:00
27 changed files with 290 additions and 0 deletions

2
sheet02/a1/b-aeskey.txt Normal file
View File

@@ -0,0 +1,2 @@
AES Key: cddf0c7f664624fd0b604c622a2c670dffc3fdd7859a7cdd2377d1ba2ab86f89
IV: 30579741743af76bdd06ec45b12ee6d7

3
sheet02/a1/b-dec-aes.txt Normal file
View File

@@ -0,0 +1,3 @@
Viktoria
Leo
Julian

1
sheet02/a1/b-enc-aes.txt Normal file
View File

@@ -0,0 +1 @@
o5Ö¦Íß*òþk¼¾I¦BîÜr<C39C>Œ´<C592>6@hün5Ø

5
sheet02/a1/b.txt Normal file
View File

@@ -0,0 +1,5 @@
Generate 256bit aes key and 128 bit iv:
openssl rand -hex 32
openssl rand -hex 16
Encrypt the file plaintext.txt with the key and iv
openssl enc -aes-256-cbc -in plaintext.txt -out b-enc-aes.txt -K cddf0c7f664624fd0b604c622a2c670dffc3fdd7859a7cdd2377d1ba2ab86f89 -iv 30579741743af76bdd06ec45b12ee6d7

3
sheet02/a1/c-dec-rsa.txt Normal file
View File

@@ -0,0 +1,3 @@
Viktoria
Leo
Julian

2
sheet02/a1/c-enc-rsa.txt Normal file
View File

@@ -0,0 +1,2 @@
Ìnç‰á~Á>hì`£aÿ*‘Ú#ÒÒhå4ò,>«ôÓ„ì÷9 &†…%´c,¤tNØR‰“5sŠq
˜°+$ú d!E½Í·3£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AHDMctkQEMsNj3qoMScMoT4NROrM
+Do51EDoUtJ8Ks9l8Bvlz3x/MrX9140Dy571LZiLHD9VuMI3iQybr8puaaq/Da+9
co2C5vbXn0CzjR8V1DibsYiWrSY/TOcirOmf4AdkUQNumrOsMiLkOlhbuB061K4H
awIDAQAB
-----END PUBLIC KEY-----

8
sheet02/a1/c.txt Normal file
View File

@@ -0,0 +1,8 @@
Generate rsa private key:
openssl genpkey -algorithm RSA -out c-rsa-priv.key -pkeyopt rsa_keygen_bits:2048
Extract the public key from the private key
openssl pkey -in c-rsa-priv.key -pubout -out c-rsa-pub.key
Encrypt the file using the rsa pubkey
openssl pkeyutl -encrypt -pubin -inkey c-rsa-pub.key -in plaintext.txt -out c-enc-rsa.txt

0
sheet02/a1/d.txt Normal file
View File

9
sheet02/a1/e.txt Normal file
View File

@@ -0,0 +1,9 @@
Decrypt the aes-encrypted key with the aes-key and iv:
openssl enc -d -aes-256-cbc -in b-enc-aes.txt -out b-dec-aes.txt -K cddf0c7f664624fd0b604c622a2c670dffc3fdd7859a7cdd2377d1ba2ab86f89 -iv 30579741743af76bdd06ec45b12ee6d7
Decrypt encrypted file using the rsa private key
openssl pkeyutl -decrypt -inkey a1/c-rsa-priv.key -in a1/c-enc-rsa.txt -out a1/c-dec-rsa.txt
Verify the same files with the tool diff
diff plaintext.txt b-dec-aes.txt -> Prints nothing, so its the same
diff plaintext.txt c-dec-rsa.txt -> Prints nothing, so its the same

3
sheet02/a1/plaintext.txt Normal file
View File

@@ -0,0 +1,3 @@
Viktoria
Leo
Julian

23
sheet02/a2/SignECDSA.java Normal file
View File

@@ -0,0 +1,23 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyPairGenerator;
import java.security.Signature;
import java.util.Base64;
public class SignECDSA {
public static void main(String[] args) throws Exception {
final var gen = KeyPairGenerator.getInstance("EC");
final var kp = gen.genKeyPair();
final var bytes = Files.readAllBytes(Path.of("plaintext.txt"));
final var sig = Signature.getInstance("SHA256withECDSA");
sig.initVerify(kp.getPublic());
sig.initSign(kp.getPrivate());
sig.update(bytes);
final var signature = sig.sign();
Files.write(Path.of("b-signature.txt"), Base64.getEncoder().encode(signature));
Files.write(Path.of("b-publickey.txt"), Base64.getEncoder().encode(kp.getPublic().getEncoded()));
Files.write(Path.of("b-privatekey.txt"), Base64.getEncoder().encode(kp.getPrivate().getEncoded()));
}
}

View File

@@ -0,0 +1,26 @@
import java.security.KeyFactory;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
public class VerifyECDSA {
public static void main(String[] args) throws Exception {
if (args.length < 3) {
System.out.println(
"Please specify in the following order: Public Key (X509), Signature (Base64), Message (plain text)");
return;
}
final String PUBLIC_KEY = args[0];
final String SIGNATURE = args[1];
final String MESSAGE = args[2];
final var kf = KeyFactory.getInstance("EC");
final var pub = kf.generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(PUBLIC_KEY)));
final var sig = Signature.getInstance("SHA256withECDSA");
sig.initVerify(pub);
sig.update(MESSAGE.getBytes());
System.out.println("Correct: " + sig.verify(Base64.getDecoder().decode(SIGNATURE)));
}
}

View File

@@ -0,0 +1 @@
ME4CAQAwEAYHKoZIzj0CAQYFK4EEACIENzA1AgEBBDA/BgxBUzJUc3MfZVBIdPTbQfIdf4SABYZJlno8rUPkhBRrK3VkpEhyGdviYUPViz4=

View File

@@ -0,0 +1 @@
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEVHteuMnscItIHycwEZ80P44WyIWmL7PmeN6HLRAu8IJsLKX6BTDawN0MezskF68oQ9Ft7zy2u4v2aaYB4tgUv+0YG7zEwFr0ofqSqFFPSLr0qrVRvXi/H7Bux8tYVgaN

View File

@@ -0,0 +1 @@
MGQCMHq04CPgDiSaWPXb3LiuBrb97aV4JjinA5gIuEIFjFYLD1jYdECBdV/aHLLYsyMYnAIwedsP6qJKK4Y2uLgn3XLxbHgDKxf+eq07Rptmn/LttHTpWjtTfaLERM+Uh2BUGmMt

5
sheet02/a2/c.txt Normal file
View File

@@ -0,0 +1,5 @@
copy the publickey into a .pem file that starts with -----BEGIN PUBLIC KEY----- and ends with -----END PUBLIC KEY----- and has linebreaks after 64 chars.
then decode the base64 signature
base64 -d b-signature.txt > signature.bin
verify using openssl
openssl dgst -sha256 -verify c-pubkey.pem -signature signature.bin plaintext.txt

3
sheet02/a2/plaintext.txt Normal file
View File

@@ -0,0 +1,3 @@
Julian
Leonard
Viktoria

1
sheet02/a2/verify-example.sh Executable file
View File

@@ -0,0 +1 @@
java VerifyECDSA.java "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnSgO/uuSq9QHH/rrnSgXeQTKPMI8tjLhyJzevl9fLQZW/zXuHk9iThiKY/c2k52quUby3czAwL2l2HaRqcBXEg==" "MEUCIAzRvK3CNFqMTZxIgMd1uQ/XybtRKXFht9S4q8qUy/IbAiEA7EcFYuRbViVC/zzIRW78HekjRHZVn3DjHVUcKyJ5sXw=" "hello world"

0
sheet03/a1/a.txt Normal file
View File

0
sheet03/a1/b.txt Normal file
View File

71
sheet03/a2/Auth.java Normal file
View File

@@ -0,0 +1,71 @@
import java.io.Console;
import java.util.Map;
import java.util.HexFormat;
import java.util.stream.Collectors;
import java.nio.file.Path;
import java.nio.file.Files;
import java.security.MessageDigest;
public class Auth {
private static final byte[] INVALID_HASH = "----------------------------------------------------------------".getBytes();
public static void main(String[] args) {
try {
Map<String, byte[]> passwd = Files.readAllLines(Path.of("passwd"))
.stream()
.filter(line -> line.indexOf(":") > 1 && line.length() > 3)
.collect(Collectors.toMap(
line -> line.substring(0, line.indexOf(':')),
line -> HexFormat.of().parseHex(line.substring(line.indexOf(':') + 1))
));
System.out.println("Chocolate Factory SCADA Command Line Interface v2.2.144");
System.out.println();
System.out.println("Please, enter your authentication credentials.");
System.out.println();
Console cons = System.console();
String username;
String password;
long timeout = 500;
while (true) {
username = cons.readLine("> Username: ");
password = new String(cons.readPassword("> Password: "));
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] encodedHash = digest.digest(password.getBytes());
// constant time comparison to prevent timing attacks
if (MessageDigest.isEqual(
passwd.getOrDefault(username, INVALID_HASH),
encodedHash
)) {
System.out.println();
System.out.printf("Welcome %s!%n", username);
Thread.sleep(150);
break;
} else {
// exponential timeout to prevent brute force attacks
System.out.println("Incorrect username and/or password.");
Thread.sleep(timeout);
timeout *= 2;
}
}
printSystemStatus();
printSecretRecipe();
} catch (Exception e) {
// ignore
}
}
private static void printSystemStatus() throws Exception {
// TOP SECRET
}
private static void printSecretRecipe() throws Exception {
// TOP SECRET
}
}

5
sheet03/a2/a.txt Normal file
View File

@@ -0,0 +1,5 @@
The Code uses unsalted hashes of the passwords.
That way there is no random data added to the hashes and it is very easy to find identical hashes using
pre-computed lookup tables.
Using such a tool we found that the password admin123 has the same hash that is stored for the username admin.

77
sheet03/a2/b.txt Normal file
View File

@@ -0,0 +1,77 @@
07:46:38 leo@group-20 ~ → cat .ssh/config
Host chocolate
User chocolate
Hostname 10.42.23.1
07:46:13 leo@group-20 ~ → ssh chocolate
chocolate@10.42.23.1's password: chocolate
Chocolate Factory SCADA Command Line Interface v2.2.144
Please, enter your authentication credentials.
> Username: admin
> Password: admin123
Welcome admin!
We are currently clean on OPSEC.
Current System Status:
🏭 Production Line 1: [🟢 ONLINE] - Idle
🏭 Production Line 2: [🟢 ONLINE] - Running (Secretly Sweet Chocolate Batch #42)
🏭 Ingredient Hopper (Cocoa): [🟢 ONLINE] - Level: 85%
🏭 Ingredient Hopper (Sugar): [🟢 ONLINE] - Level: 92%
🏭 Ingredient Hopper (Milk Powder): [🟢 ONLINE] - Level: 78%
🌡️ Temperature Control System: [🟢 ONLINE] - Target: 45°C (±0.5°C)
⚙️ Mixing Unit A: [🟢 ONLINE] - Standby
⚙️ Mixing Unit B: [🟢 ONLINE] - Active
🍫 Molding Machine Alpha: [🟢 ONLINE] - Ready
🍫 Molding Machine Beta: [🟢 ONLINE] - Processing
🧊 Cooling Tunnel System: [🟢 ONLINE] - Target: 10°C (±1°C)
📦 Packaging Unit Delta: [🟢 ONLINE] - Awaiting Output
🤖 Quality Control Bot v3.2: [🟢 ONLINE] - Monitoring
⚡ Power Supply: [🟢 ONLINE] - Stable
🌐 Network Connectivity: [🟢 ONLINE] - Good
🔒 Security System: [🟢 ONLINE] - Active
----------------------------------------------------
✅ ALL SYSTEMS GREEN. Chocolate production is nominal. ✅
📝 Recipe for 'Secretly Sweet Chocolate Batch #42
Ingredients:
1 'Bargain Bin Chocolate Chunk'
(obtained from ... questionable sources)
3 'Heaping Spoonfuls of Questionable Granules'
(definitely not pure sugar)
A splash of 'Mysterious Gloss'
(something called vasline, maybe inedible,
but it makes things shiny!)
Instructions:
Acquire the Goods:
Locate and 'liberate' the cheapest-looking chocolate
you can get from the competition.
The Melt Down:
Subject the 'Bargain Bin Chocolate Chunk' to intense heat.
The goal is a questionable, slightly lumpy liquid.
Sweeten the Deal:
Introduce the 'Heaping Spoonfuls of Questionable Granules'
to the melted chocolate. Stir vigorously (or just shake the
container violently). The mixture should become alarmingly
sweet.
The Glossy Finish:
Add a dash of 'Mysterious Gloss.' This will give the product
an unsettlingly shiny appearance.
Mold it (Sort Of):
Pour the concoction into a vaguely bar-shaped container (the
packaging of the input chocolate might work?).
The Pay Off:
Pay tons of influencers to advertise this as the best
chocolate they have ever tasted, and price this chocolate
at a ridiculous high price!!1! 🤑💰💸
Connection to 10.42.23.1 closed.

0
sheet03/a2/c.txt Normal file
View File

3
sheet03/a2/passwd Normal file
View File

@@ -0,0 +1,3 @@
admin:240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9
alice:57a975ec110f89a7ca6a8c39aec856890b10488006106fb12c3a5fe063b1e7d5
bob:2a3cc87f95b4363a1e6483d4659671361f86239735d31e8c4a9be893a2427c19