Java Script Kiddie

Java Script Kiddie 1

Description

AUTHOR: JOHN JOHNSON

The image link appears broken...https://jupiter.challenges.picoctf.org/problem/58112arrow-up-right or http://jupiter.challenges.picoctf.org:58112arrow-up-right

Analysis

<html>
	<head>    
		<script src="jquery-3.3.1.min.js"></script>
		<script>
			var bytes = [];
			$.get("bytes", function(resp) {
				bytes = Array.from(resp.split(" "), x => Number(x));
			});

			function assemble_png(u_in){
				var LEN = 16;
				var key = "0000000000000000";
				var shifter;
				if(u_in.length == LEN){
					key = u_in;
				}
				var result = [];
				for(var i = 0; i < LEN; i++){
					shifter = key.charCodeAt(i) - 48;
					for(var j = 0; j < (bytes.length / LEN); j ++){
						result[(j * LEN) + i] = bytes[(((j + shifter) * LEN) % bytes.length) + i]
					}
				}
				while(result[result.length-1] == 0){
					result = result.slice(0,result.length-1);
				}
				document.getElementById("Area").src = "data:image/png;base64," + btoa(String.fromCharCode.apply(null, new Uint8Array(result)));
				return false;
			}
		</script>
	</head>
	<body>
		<center>
			<form action="#" onsubmit="assemble_png(document.getElementById('user_in').value)">
				<input type="text" id="user_in">
				<input type="submit" value="Submit">
			</form>
			<img id="Area" src=""/>
		</center>
	</body>
</html>
  1. Form takes in user input and creates png.

  2. PNG gets data is collected from /bytes path. herearrow-up-right

  3. Key length is 16.

  4. If user input matches key length the user input becomes key.

  5. PNG image gets mangled by shifter.

  6. shifter = key.charCodeAt(i) - 48; Converts string into integer. ("0" -> 0)

  7. Mangling happens on each column of PNG image.

To get the correct key we need to match first 16 Bytes with the correct PNG Image. The program mangles 16 column and first 16 Bytes of PNG is already known from Wikipediaarrow-up-right. 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52

If we match first byte of column to header byte we can get the key.

Solution

circle-check
java-script-kiddie-1

Using online QRCode Decoderarrow-up-right we get the flag.

java-script-kiddie-2
circle-check

Java Script Kiddie 2

Description

The image link appears broken... twice as badly... https://jupiter.challenges.picoctf.org/problem/42899arrow-up-right or http://jupiter.challenges.picoctf.org:42899arrow-up-right

Analysis

The program is a little different from previous challenge. Here we have key with length of 32. shifter = Number(key.slice((i*2),(i*2)+1)); shifter is the key located at odd index values in incremental order.

  • If key="1234...", shifter = 1 -> shifter = 3 -> ... (Essentially every second item is discarded.)

Solution

circle-check

Using online QRCode Decoderarrow-up-right recover the flag.

circle-check

Last updated