Sfoglia il codice sorgente

added traceroute level. made manualRouter update TTLs

Erinn 8 anni fa
parent
commit
340276dc72
4 ha cambiato i file con 191 aggiunte e 2 eliminazioni
  1. 2 1
      js/bindings.js
  2. 21 1
      js/devicescripts.js
  3. 13 0
      levels/04 Attacks/attacks03.html
  4. 155 0
      levels/04 Attacks/attacks03.json

+ 2 - 1
js/bindings.js

@@ -1,6 +1,7 @@
 
 function onDeviceClick() {
-	$("#subpane").html("<h3>Device info</h3><p><img src=\"./includes/"+(this.image||'imac')+".png\"></p><p>IP address: "+this.id+"</p>");
+	var ip = this.hasOwnProperty("secret") && this.secret ? "<i>secret</i>" : this.id;
+	$("#subpane").html("<h3>Device info</h3><p><img src=\"./includes/"+(this.image||'imac')+".png\"></p><p>IP address: "+ip+"</p>");
 	$("#subpane").show();
 	$("#subpane_close").show();
 	$("#leveldescrip").hide();

+ 21 - 1
js/devicescripts.js

@@ -1,8 +1,28 @@
 var deviceScripts = {
 	manualRouter: {
-		onPacketReceived: function(device, packet) {
+		onPacketReceived: function(device, packet, portNum) {
 			var newpkt = JSON.parse(JSON.stringify(packet));
 
+			if (packet.hasOwnProperty("transport") && packet.transport.hasOwnProperty("proto") && packet.transport.proto == "ICMP" && packet.transport.hasOwnProperty("ttl")) {
+				if (packet.transport.ttl > 0) {
+					newpkt.transport.ttl--;
+				} else {
+					newpkt.network.srcip = device.id;
+					newpkt.network.dstip = packet.network.srcip;
+					newpkt.transport.proto = "ICMP_ERROR";
+					sendPacket(device.id, portNum, newpkt);
+					return;
+				}
+			}
+
+			if (packet.hasOwnProperty("network") && packet.network.hasOwnProperty("dstip") && packet.network.dstip == device.id &&
+			    packet.hasOwnProperty("transport") && packet.transport.hasOwnProperty("proto") && packet.transport.proto == "ICMP") {
+			    	newpkt.network.srcip = device.id;
+				newpkt.network.dstip = packet.network.srcip;
+				sendPacket(device.id, portNum, newpkt);
+				return;
+			}
+
 			for (var i = 0; i < device.rules.length; i++) {
 				if (device.rules[i].dstip == packet.network.dstip) {
 					sendPacket(device.id, device.rules[i].portNum, newpkt);

+ 13 - 0
levels/04 Attacks/attacks03.html

@@ -0,0 +1,13 @@
+
+<p>In this level, the routers use the <strong>time to live (TTL)</strong> field.  The TTL field is designed to keep packets from getting trapped in infinite loops: each router decreases the TTL value by one, and if it ever reaches zero, it stops forwarding the packet and returns an error message instead.<p>
+
+<p>We have hidden the IP addresses of the routers in this level.  Your job is to figure out who they are!</p>
+
+<p><i><strong>Fun fact:</strong> This trick is called "tracerouting", and you can do it for real to see the routers between you and anyone else. Ask a TA to show you how!</i></p>
+
+<h3>Level Objectives</h3>
+
+<ul>
+	<li>Figure out how to use TTLs to figure out the IP addresses of routers</li>
+	<li>Send a ping to <strong>each</strong> of the four routers between Alice and Google</li>
+</ul>

+ 155 - 0
levels/04 Attacks/attacks03.json

@@ -0,0 +1,155 @@
+{
+	devices:[
+		{
+			id:"Alice",
+			ports:1,
+			x:0.1,
+			y:0.3,
+                        player: true
+		},
+		{
+			id:"Waterloo",
+                        image: "router",
+			ports:2,
+			x:0.25,
+			y:0.6,
+                        script: deviceScripts.manualRouter,
+			rules:[
+				{dstip:"Alice", portNum:0},
+				{dstip:"Toronto", portNum:1},
+				{dstip:"New York", portNum:1},
+				{dstip:"Mountain View", portNum:1},
+                                {dstip:"Google", portNum:1}
+			],
+			secret: true
+		},
+		{
+			id:"Toronto",
+                        image: "router",
+			ports:2,
+			x:0.4,
+			y:0.3,
+                        script: deviceScripts.manualRouter,
+			rules:[
+				{dstip:"Alice", portNum:0},
+				{dstip:"Waterloo", portNum:0},
+				{dstip:"New York", portNum:1},
+				{dstip:"Mountain View", portNum:1},
+                                {dstip:"Google", portNum:1}
+			],
+			secret: true
+		},
+		{
+			id:"New York",
+                        image: "router",
+			ports:2,
+			x:0.55,
+			y:0.6,
+                        script: deviceScripts.manualRouter,
+			rules:[
+				{dstip:"Alice", portNum:0},
+				{dstip:"Toronto", portNum:0},
+				{dstip:"Waterloo", portNum:0},
+				{dstip:"Mountain View", portNum:1},
+                                {dstip:"Google", portNum:1}
+			],
+			secret: true
+		},
+		{
+			id:"Mountain View",
+                        image: "router",
+			ports:2,
+			x:0.7,
+			y:0.3,
+                        script: deviceScripts.manualRouter,
+			rules:[
+				{dstip:"Alice", portNum:0},
+				{dstip:"Waterloo", portNum:0},
+				{dstip:"Toronto", portNum:0},
+				{dstip:"New York", portNum:0},
+                                {dstip:"Google", portNum:1}
+			],
+			secret: true
+		},
+		{
+			id:"Google",
+                        image: "server",
+			ports:1,
+			x:0.85,
+			y:0.6,
+			script: deviceScripts.ping
+		}
+	],
+	links:[
+		{
+			src:"Alice", srcport:0,
+			dst:"Waterloo", dstport:0
+		},
+		{
+			src:"Waterloo", srcport:1,
+			dst:"Toronto", dstport:0
+		},
+		{
+			src:"Toronto", srcport:1,
+			dst:"New York", dstport:0
+		},
+		{
+			src:"New York", srcport:1,
+			dst:"Mountain View", dstport:0
+		},
+		{
+			src:"Mountain View", srcport:1,
+			dst:"Google", dstport:0
+		}
+	],
+	timeline:[
+		{
+			type:"packet",
+			at:1000,
+			from:"Alice",
+			payload:{
+				network:{srcip:"Alice",dstip:"Google"},
+				transport:{proto:"ICMP", ttl:256}
+			}
+		},
+		{
+			type:"packet",
+			at:2000,
+			from:"Alice",
+			payload:{
+				network:{srcip:"Alice",dstip:"Google"},
+				transport:{proto:"ICMP", ttl:256}
+			}
+		}
+	],
+	triggers:[
+		{
+			type:"packet",
+			device:"Waterloo",
+			payload:{
+				network:{srcip:"Alice",dstip:"Waterloo"}, transport:{proto:"ICMP"}
+			}
+		},
+		{
+			type:"packet",
+			device:"Toronto",
+			payload:{
+				network:{srcip:"Alice",dstip:"Toronto"}, transport:{proto:"ICMP"}
+			}
+		},
+		{
+			type:"packet",
+			device:"New York",
+			payload:{
+				network:{srcip:"Alice",dstip:"New York"}, transport:{proto:"ICMP"}
+			}
+		},
+		{
+			type:"packet",
+			device:"Mountain View",
+			payload:{
+				network:{srcip:"Alice",dstip:"Mountain View"}, transport:{proto:"ICMP"}
+			}
+		}
+        ]
+}