This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * chall * solvepath * solvepath fixes * make nominally easier with a hint --------- Co-authored-by: mud-ali <[email protected]>
- Loading branch information
1 parent
4a2ea46
commit 8c533c1
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import java.util.Scanner; | ||
|
||
public class RevTwo { | ||
public static void main(String[] args) { | ||
System.out.println("Enter the password: "); | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
String line = scanner.nextLine(); | ||
|
||
if (checkPassword(line)) { | ||
System.out.println("That's the right password!"); | ||
} else { | ||
System.out.println("That's the incorrect password!"); | ||
} | ||
|
||
scanner.close(); | ||
} | ||
|
||
public static boolean checkPassword(String passwordGuess) { | ||
int[] nums = {7267, 6113, 11757, 7152, 7675, 6345, 9823, 11463, 8821, 12339, 8019, 6739, 5983, 11476, 10344, 11057, 11603, 5087, 8791, 11956, 12115, 11982, 4820, 10719, 8787, 6835, 9059, 6901, 11090, 5605, 7677}; | ||
|
||
for (int i = 0; i < passwordGuess.length(); i++) { | ||
if ((int) passwordGuess.charAt(i) != nums[i] % 128) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Java Rev 2 | ||
categories: | ||
- rev | ||
value: 100 | ||
flag: camp{I_Gu3SS_Th1S_W4SNT_S3cuRe} | ||
description: |- | ||
After your last break-in, my friend informed me that he made it almost impossible to solve. | ||
Can you still find the password? | ||
hints: | ||
- Do you know what ASCII is? | ||
- What does the % do? | ||
files: | ||
- src: RevTwo.java | ||
authors: | ||
- Jack Crowley | ||
visible: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Java Rev Two | ||
|
||
This Java Rev challenge has an array with all of ascii values of the flag, however, they seem a little bit too high to fit into the normal 128 values. | ||
|
||
This is where `modulus` or the `%`, which acts sort of like a `division` statement. However, instead of returning the evaluated results, it gives us the remainder. In this case, it takes `nums[i] % 128`, which means that it gets the number from the array and then takes the remainder of that number after being divided by 128. | ||
|
||
For example, 6113 divided by 128 is 47, remainder 97. As such, 6113 mod 128 = 97 | ||
|
||
To solve this problem, you must first delete the `return False;` in the `checkPassword`, which enables the program to keep going even if the first character is wrong. | ||
|
||
Then you must put a print statement inside the for loop which prints the correct character of the flag, such as: | ||
|
||
``` | ||
System.out.print((char) (nums[i] % 128)); | ||
``` | ||
|
||
Note that `(char)` will display the corresponding character for the number. | ||
|
||
Once you run the program, input a long and random input such as: | ||
|
||
``` | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
``` | ||
|
||
which will produce the correct flag in the terminal. |