JAVA CODE JAVA CODE Spy Games Hello Agent, We have an emergency and only you can help. Our systems have intercepted much chatter about an imminent illegal arms exchange going down at a US airport. We...

1 answer below »
Java code



JAVA CODE JAVA CODE Spy Games Hello Agent, We have an emergency and only you can help. Our systems have intercepted much chatter about an imminent illegal arms exchange going down at a US airport. We have determined the date and time of the exchange, but we need your help figuring out the airport. We were able to get a partial packet capture of a text message sent between the dealer and the buyer. We believe that the message reveals the exact airport where the event will occur. You will shortly be briefed on the details. Good luck agent! Set Up You will need to write some software that will crack the case and figure out the IATA airport code (https://en.wikipedia.org/wiki/IATA_airport_code) of the location of the arms exchange. In order to achieve this objective, you will need to be familiar with: ● Java Multithreading (Threads, Blocking Queues) ● Java Binary I/O ● Hashing ● Base-64 Hashing After extensive analysis, it has been determined by our agency experts that the packet capture did not capture the airport code itself, but it was able to capture the tail-end of the message that included the MD5 hash (https://en.wikipedia.org/wiki/MD5) value of the message. The has value was produced by a hash function. A hash function is any function that can be used to map arbitrary-length data to fixed-size values. It is often times used to protect the integrity of messages during transmission; it allows the receiver to determine if the data has been changed/corrupted during transmission. For example, a text message may be of any length, but the hash value protecting it from corruption will always be a fixed length (128 bytes for example). For example, consider the following hash function: hash(data) = ∑(data) https://en.wikipedia.org/wiki/IATA_airport_code https://en.wikipedia.org/wiki/IATA_airport_code https://en.wikipedia.org/wiki/MD5 For this particular hash function, if the data being transmitted is 1,2,3,4,5 (the combination on my luggage), the hash value would be (1+2+3+4+5) = 15 Using Binary I/O, the message would exist in a file, or in RAM, as a sequence of bytes: {0x01, 0x02, 0x03, 0x04, 0x05, 0x0F} The receiver could therefore run the same set of operations on the message, compare the generated hash value to the final value in the message, and determine, with some confidence, that the message was not altered during transmission. If it was altered, the two values would note match, and the user may request the message be resent. For example: {0x06, 0x02, 0x03, 0x04, 0x05, 0x0F} The MD5 hash function is a bit more advanced than this simple example. MD5 is a cryptographic hash function meaning that one cannot easily look at the hash value computed by the hash function and determine what the value of the source data looked like. MD5 is considered obsolete as it has been found to be exploitable, meaning. The data it is supposed to protect can be intentionally changed without detection, however it can still be used to verify data integrity against unintentional corruption such as a packet loss in a network. The MD5 hash value always requires 16 bytes of memory to store. For example, MD5("AAA") = {0xE1 0xFA 0xFF 0xB3 0xE6 0x14 0xE6 0xC2 0xFB 0xA7 0x42 0x96 0x96 0x23 0x86 0xB7} Base64 Base64 (https://en.wikipedia.org/wiki/Base64) is a very common binary representation that you will see a lot in you illustrious careers. Base64 is a system to allow for representing binary data in a human-readable form that is relatively compact. Java has support for working with Base64 data, however, you will not be required to implement anything yourselves. The Base64 components will be provided for you, as you will see, to represent the MD5 hash value that was captured on the end of the intercepted packet. You would use Base64 in the same way you would use Hex strings to represent binary data, only it is even more compact. Hex has 16 different characters (0-9A-F) to represent values. Base64 has 64 values: (A-Za-z0-9+/) Your Mission Your solution will require you to perform a brute-force search for the value of the MD5 value. A "brute force" search requires that every possible Airport codes be generated and checked. The Base64 string representation of the message's MD5 hash function value is: ts0OZ1EKxGw/C2TZl9YTgg== Calculating the hash value of a single value can be a processive intensive operation, therefore, it is a requirement that you implement a solution that uses two CPU threads to assist in the hunt by allowing each check to be performed independently. https://en.wikipedia.org/wiki/Base64 You will need to write two classes: 1. DigestCracker 2. DigestMd5CrackerRunnable The DigestCracker class is the main class of the application. It should accept, as a command-line argument, a single string value. The string is a Base-64 encoded binary value containing the MD5 hash of the intercepted message. DigestCracker should decode the Base-64 encoded value into binary. This binary value is the MD5 value of the message. DigestCracker also creates all possible three-letter airport codes: AAA-ZZZ (uppercase) and loads them into a BlockingQueue. The DigestCracker spawns two threads which search for the correct MD5 hash. One thread is assigned MIN_PRIORITY and the other thread is assigned MAX_PRIORITY. The DigestCracker class waits for both threads to finish their execution and then itself exits. The DigestMd5CrackerRunnable is a runnable class. Its constructor accepts a BlockingQueue and the binary byte array of the MD5 value collected from the intercepted message. When it runs, it pulls a IATA airport code (a String) from the BlockingQueue, runs performs a MD5 hash on the value, and compares the value to the MD5 value collected from the intercepted message. If the MD5 matches, print the IATA airport code to the console (System.out). The DigestMd5CrackerRunnable class should keep running until there are no more value to check, even if it finds the target airport code. Once the queue of airport codes is exhausted, the thread should print to the console (System.out) the thread's priority and the number of airport codes that it checked. Toolbox The following is code you will need to complete this assignment: import java.util.Base64; final byte[] digest = Base64.getDecoder().decode(args[0]); import java.security.MessageDigest; MessageDigest messageDigest = MessageDigest.getInstance("MD5"); https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/security/MessageDigest.html (Links to an external site.) https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/security/MessageDigest.html https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/security/MessageDigest.html https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Base64.html (Links to an external site.) The Submission Submit the following: 1. All 2 classes you have implemented 1. DigestCracker 2. DigestMd5CrackerRunnable 2. A screen capture of the output https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Base64.html https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Base64.html
Answered 1 days AfterOct 09, 2021

Answer To: JAVA CODE JAVA CODE Spy Games Hello Agent, We have an emergency and only you can help. Our systems...

Ramachandran answered on Oct 10 2021
121 Votes
Order-93321/DigestCracker.java
Order-93321/DigestCracker.java
import java.security.NoSuchAlgorithmException;
import java.
util.Base64;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
public class DigestCracker {
    public static void main(String[] args) throws InterruptedException, NoSuchAlgorithmException {
        if(args.length == 0 ){
            System.out.println("please enter the code");
            return;
        }
        System.out.println("Input code is " + args[0]);
        //decode the argument
        final byte[] digest = Base64.getDecoder().decode(args[0]);
        String interceptValue = new String(digest);
        //create a blocking queue
        BlockingQueue airPortCodes = new LinkedBlockingQueue<>();
        //fill the blocking queue with all 3 letter combinations [AAA-ZZZ] total 17576 possible plain codes
        for (char i = 'A'; i <= 'Z'; i++) {
            for (char j = 'A'; j <= 'Z'; j++) {
                for (char k = 'A'; k <= 'Z'; k++) {
                    String code = i + "" + j + "" + k;
                    airPortCodes.put(code);
                }
            }
        }
        //create the first runna...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here