Browse Source

updating attacks level 1

cecylia 8 years ago
parent
commit
0f7ba3ff5f
3 changed files with 59 additions and 10 deletions
  1. 48 1
      js/devicescripts.js
  2. 0 2
      levels/04 Attacks/attacks01.html
  3. 11 7
      levels/04 Attacks/attacks01.json

+ 48 - 1
js/devicescripts.js

@@ -132,7 +132,54 @@ var deviceScripts = {
                 }
             }
         }
-    }
+    },
+    encryption: {
+        onPacketReceived: function(device, packet, portNum) {
+            if(packet.hasOwnProperty("transport") && packet["transport"].hasOwnProperty("proto")){
+                if(packet.transport.proto == "encryption"){
+                    if(packet.hasOwnProperty("application"]) && packet["application"].hasOwnProperty("type")){
+                    var type = packet.application.payload;
+
+                    switch(type) {
+                        case "keyrequest": 
+                            var new_packet = {
+                                network: {
+                                    srcip: packet.network.dstip,
+                                    dstip: packet.network.srcip
+                                },
+                                transport: {
+                                    proto: "encryption"
+                                },
+                                application: {
+                                    type: "keyresponse",
+                                    payload: "123456"
+                                }
+                            }
+                            sendPacket(device.id, portNum, new_packet);
+                        break;
+                        case "keyresponse":
+                            var new_packet = {
+                                network: {
+                                    srcip: packet.network.dstip,
+                                    dstip: packet.network.srcip
+                                },
+                                transport: {
+                                    proto: "encryption"
+                                },
+                                application: {
+                                    type: "message"
+                                }
+                            }
+                            break;
+                        default:
+                            break;
+                    }
+                    }
+                }
+            }
+        }
+                            
+    }                        
     
 }
 

+ 0 - 2
levels/04 Attacks/attacks01.html

@@ -1,5 +1,3 @@
-<link rel="stylesheet" href="../../includes/css/base.css" />
-<link rel="stylesheet" href="../../includes/css/style.css" />
 
 <h1>Attacks Level 1</h1>
 

+ 11 - 7
levels/04 Attacks/attacks01.json

@@ -2,17 +2,19 @@
 	devices:[
 		{
 			id:"Example Alice",
-			type:"SimpleEncryptionComputer",
 			ports:1,
 			x:0.25,
-			y:0.35
+			y:0.35,
+                        script: deviceScripts.encryption
 		},
 		{
 			id:"Example Bob",
+                        image: "iphone-1",
 			type:"SimpleEncryptionComputer",
 			ports:1,
 			x:0.75,
-			y:0.35
+			y:0.35,
+                        script: deviceScripts.encryption
 		},
 		{
 			id:"Alice",
@@ -23,6 +25,7 @@
 		},
 		{
 			id:"Eve",
+                        image: "macbook",
 			type:"Switch",
 			ports:2,
 			x:0.5,
@@ -33,6 +36,7 @@
 		},
 		{
 			id:"Bob",
+                        image: "iphone-1",
 			type:"SimpleEncryptionComputer",
 			ports:1,
 			x:0.75,
@@ -75,8 +79,8 @@
 			}
 		}
 	],
-	triggers:{
-		t0:{
+	triggers:[
+		{
 			type:"packet",
 			device:"Eve",
 			payload:{
@@ -85,7 +89,7 @@
 				application:{type:"message",encryptionkey:"31337"}
 			}
 		},
-		t1:{
+		{
 			type:"packet",
 			device:"Bob",
 			payload:{
@@ -94,5 +98,5 @@
 				application:{type:"message",encryptionkey:"123456"}
 			}
 		}
-	}
+        ]
 }