Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What needs to be done is decrypt a file inputwannacry_encoded.txt which i will provide. the lecturer has already provided work spaces with methods that we

image text in transcribedimage text in transcribedimage text in transcribed

What needs to be done is decrypt a file "inputwannacry_encoded.txt" which i will provide. the lecturer has already provided work spaces with methods that we are supposed to create, which i will provide too. The decrypted file should be saved in a folder "DecryptedOriginal.txt". what the first line should contain when its decrypted was provided in the picture above.

THIS IS "InputWannaCry_encoded.txt" IT IS THE ENCODED FILE THAT NEEDS TO BE DECODED: 70114111109321161041013211910198321081051101075832104116116112115584747119119119461219710411111146991111094711010111911547116114117109112115451141019710845117110100111105110103451099712145991141011011121051101034510297116105103117101454857484849545553524610411610910869120991011141121161153210211411110932971103297114116105991081013298121327797116116326697105443289971041111113278101119115327797121324949443250484955321161051161081011005832323484114117109112391153211410197108321171101001111051101033210997121329810132116104101329911410110111210511010332102971161051031171014634 651091011141059997110115321141019710810812132100111321199711011632973211497100105999710832114101111114100101114105110103321111023211610410132112111108105116105999710832115121115116101109463266117116329710211610111432973211610510910144321191013297112112114101991059711610132110111114109971089912144321161111114632651153279104105111391153210311111810111411011111444327411110411032759711510599104443211211711632105116321191041011103273321169710810710110032116111321041051093210897115116321191011011073240101991041111051101033297321081051101013280114101115105100101110116327998971099732117115101100321161113211711510141583234651163211511110910132112111105110116443211610410132102101118101114321191051081083298114101971074634 74105109109121326797114116101114321151171141021011003210511011611132879711510410511010311611111032111110329732116115117110971091053211110232112111112117108971143211410111811110811646326611711632971021161011143297321021011193212110197114115321111023210397115321151041111141169710310111532971101003211011799108101971143299114105115101115329711010032115971161011081081051161011153210297108108105110103321021141111093211610410132115107105101115443211811111610111411532119101114101321091111141013211610497110321141019710012132102111114329732108105116116108101321151169798105108105116121463273116321021011081163211611111132109117991043210810510710132973210910511411411111432105109971031013211110232116104101327810512011111032121101971141153245329711032117110991019711510511010332999711599971001013211110232104101971001081051101011153297110100329911111011611411111810111411510510111544321111101013211111032116111112321111023211610410132111116104101114443299114111119100105110103321111171163211610410132115112979910132102111114321011181011141211009712132108105102101 841041013211511199105101116121321051153210010510210210111410111011632110111119443211110232991111171141151014632841041013211297114116105115971103211611410598101115321191041113210810511810132111110321161041013211210897105110115321111023211511199105971083210910110010597321191051081083298101971163211610410110511432100114117109115321009710510812132117110116105108321161041013210410111410011532100105115971121121019711446326611111410110032971101003297110103114121329711632116104101321191111141081004432116104101121329911497118101321161041013299111110115116971101163210411710932111102321011201051151161011101161059710810511510946 661171163211610497116391153211011111632119104101114101321161041013211897115116321099710611111410511612132111102326510910111410599971101153210810511810146328410410112132119971101163299104971101031014432981171163211011111632991049711111532101120112108111100105110103321009710510812132971081083297114111117110100321161041011094632841041011213910810832116971071013297321151161141111101034432101110116101114116971051101051101033211210111411511111097108105116121443297108108321141051031041164432981171163211011111632105102321051163210910197110115321161049711632112111108105116105991153210497115321161113298101991111091013211610410132115117981161011201163210211111432101118101114121329911111011810111411597116105111110329711632102971091051081213210010511011010111411532971101003276105116116108101327610197103117101321039710910111546 73321111109910132104101971141003297329911410510910511011110811110310511511632115117103103101115116321161049711644321051103297321199712144321091011161049710911210410111697109105110101321199711532973210810111511532104971141091021171083210011411710332116104971103210410111411110511046328410497116391153298101999711711510132973211210111411511111032999711032101120105115116321111103210410111411110511032102111114329732108111110103321161051091014432106117115116321151111141163211110232108111108108105110103329711411111711010044329811711632109101116104329811410511010311532121111117321161113211610410132981111161161111093210511032973210411711411412146328410410132971001001059911610511111032105115321151041111141161011144432116104101329911110810897112115101329711010032114101991111181011141213211711097118111105100979810810146 77971219810132116104971163911532119104101114101321191013297114101321191051161043284114117109112463277971219810132104101391153211111711432112111108105116105999710832109101116104463284104101321011031111099711010597443211610410132114971151041101011151154432116104101321091171081161054510211411111011632119971143211111032101118101114121111110101321051103210410511532119971213297110100321151111091013211910411132971141011103911632453211610410511532105115321101111163211511711511697105110979810810132105110329732991111171101161141213211610497116329997114101115329798111117116321111161041011143211610410511010311546 8311132105102321211111173298101108105101118101443297115327332100111443211610497116328411411710911232105115321171101081051071011081213211611132103111118101114110321191011081083210511032971101213210111810111011644321211111173211510411111710810032981013210310897100321161113211510110132104105109321021051141013267111109101121463289111117321151041111171081003210411111210132104101321001051031153210511044329711011697103111110105122101115326711111010311410111511532971101003210897119321011101021111149910110910111011644321161141051011153211611132115104117116321001111191103211610410132109101100105974432111114321191049711610111810111432111116104101114321071051101003211110232991149712212132991111091121011081153210410510946 6610199971171151013211610410132109111114101321041013210210897105108115329711632101110101109105101115329711010032102108101120101115321161041013210911711599108101321111023210410511532111102102105991014432116104101321091111141013265109101114105999711011532119105108108321151011011073211510410110811610111432102114111109321161041013211497105110105110103329810811111911546326511010032116104101321021171141161041011143210410511532971121121141111189710832114971161051101031153210011411111244321161041013210211711411610410111432109101109981011141153211110232104105115321111191103211297114116121321191051081083211411711032105110321161041013211111610410111432100105114101991161051111104432108101971181051101033284114117109112321051151111089711610110032971101003210010510910511010511510410110046 6511010032116104101321151111111101011144432112101114104971121154432116104105115321129711411610599117108971143211010510310411610997114101321191051081083297989711610146

package ng.edu.baze.com313.qtrTwo2017.javaRevisted.wannaCry;

import java.io.*;

/** * Add Javadoc * */ public class WriteToFileSystem { private static BufferedWriter myFileWriter = null; private static String myFileNameAndPath = null; private static int howManyCalls = 0; public WriteToFileSystem() { } /** * * @param message * @param filePathAndName * @param appendToFile * @return * @throws IOException */ public static int writeToFile(String message, String filePathAndName, Boolean appendToFile) throws IOException { try { BufferedWriter localFileWriter = new BufferedWriter(new FileWriter(filePathAndName, appendToFile)); localFileWriter.write(message); //Set static variable for use by the writeToFile(string message) method myFileWriter = localFileWriter; myFileNameAndPath = filePathAndName; howManyCalls += 1; } catch (IOException genericFileAccessError) {

@SuppressWarnings("unused") String errorMessage = "Problem writing to file" + filePathAndName ; throw (new IOException(genericFileAccessError)); } finally {

@SuppressWarnings("unused") String errorMessage = "File " + filePathAndName + ": Open Successful "; //==> add errorMessage to log as an "Info" } return howManyCalls; } /** * This method assumes that the 3 parameter writeToFile method with fileapathName had * previously been called to open file for output. Error will occur otherwise. * @param message * @return an integer * @throws Exception */ public static int writeToFile(String message) throws Exception { howManyCalls++; if (myFileWriter == null) { String errorMessage = "Failure to 1st call method with filePathAndName"; //==> add errorMessage to log as an "Fatal" throw new Exception(errorMessage); } try { myFileWriter.write(message+" "); } catch (IOException genericFileAccessError) { @SuppressWarnings("unused") String errorMessage = "Problem writing to file" + myFileNameAndPath; throw (new IOException(genericFileAccessError)); } return howManyCalls; } /** * Set CloseFile to true to close file. * If called with false file will be left alone * @param closeFile */ public static void closeTheFile(Boolean closeFile) { if ((myFileWriter != null) && (closeFile)) { try { myFileWriter.close(); } catch (IOException genericFileAccessError) { } } return; } }

package ng.edu.baze.com313.qtrTwo2017.javaRevisted.wannaCry;

import java.io.*; import java.util.*;

/** * Add javadoc * */ public class ReadFileAsText { public ReadFileAsText() { } // private static final String recordDelimiter = "$"; //read file given a file name and dump the content in a string and return to the //caller. public static String ReturnFileContentAsString(String fileNameAndPath) throws IOException { StringBuilder fileContentAsString = new StringBuilder(); //String inputRecord; //its loaded when we read the file // try { fileContentAsString = ReturnFileContentAsString(fileNameAndPath, recordDelimiter); /* BufferedReader reader = new BufferedReader(new FileReader(fileNameAndPath)); while ((inputRecord = reader.readLine()) != null) { //process(inputRecord); fileContentAsString.append(inputRecord.trim() + recordDelimiter); } //==> add Message to log an "Info" indicating // name of file that was opened and how many student records were read // Remember the 1st record is a header not a student record // reader.close(); */ } catch (FileNotFoundException error) { //==> add errorMessage to log as an "Error" throw (new IOException(error)); } catch (IOException e) { //==> add errorMessage to log as an "Error" throw (new IOException(e)); } finally { } return fileContentAsString.toString(); } // public static StringBuilder ReturnFileContentAsString(String fileNameAndPath, String delimter) throws IOException { StringBuilder fileContentAsString = new StringBuilder(); String inputRecord; //its loaded when we read the file // try { BufferedReader reader = new BufferedReader(new FileReader(fileNameAndPath)); while ((inputRecord = reader.readLine()) != null) { //process(inputRecord); fileContentAsString.append(inputRecord.trim() + delimter); } //==> add Message to log an "Info" indicating // name of file that was opened and how many student records were read // Remember the 1st record is a header not a student record // reader.close(); } catch (FileNotFoundException error) { //==> add errorMessage to log as an "Error" //re-throw the file not found error throw (new IOException(error)); } catch (IOException e) { //==> add errorMessage to log as an "Error" throw (new IOException(e)); } finally { } return fileContentAsString; } //read file with a given file name and dump the content in a string[] and return to the //caller. public String[] ReturnFileContentAsStringArray(String fileNameAndPath) throws Exception, IOException { String[] arrayOfRecords = null; // List ListOfRecords = new ArrayList(); String inputRecord; //its loaded when we read the file // try { BufferedReader reader = new BufferedReader(new FileReader(fileNameAndPath)); while ((inputRecord = reader.readLine()) != null) { //process(read record); ListOfRecords.add(inputRecord.trim()) ; } // reader.close(); } finally { } //Convert List to array and return to caller //*** Fix This if it does not work *** //ToDo try { arrayOfRecords = ListOfRecords.toArray(new String[0]); } catch(Exception e) { throw (new Exception(e)); } // return arrayOfRecords; // } public List ReturnFileContentAsStringList(String fileNameAndPath) throws Exception, IOException { List listOfRecords = new ArrayList(); String studentRecord; //its loaded when we read the file // try { BufferedReader reader = new BufferedReader(new FileReader(fileNameAndPath)); while ((studentRecord = reader.readLine()) != null) { //process(read record); listOfRecords.add(studentRecord.trim()) ; } // reader.close(); } finally { } return listOfRecords; } }

package ng.edu.baze.com313.qtrTwo2017.javaRevisted.wannaCry;

import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map;

public class WannaCryDecryptor {

public static Map decryptionLookupTable; public static final String encryptedInputfileName = "InputWannaCry_Encoded.txt"; public static final String decryptedOutputFile = "DecryptedOriginal.txt"; public static void main(String[] args) { //1st: Build the conversion Map Table Boolean mapTableBuildOkay = buildTheConversionMapTable(); if (!mapTableBuildOkay) { System.exit(9999); } //2nd:Read the file (encryptedInputfileName) into List //2.1 Create on object of the class ReadFileAsText ReadFileAsText fileAccessor = new ReadFileAsText(); //2.2 Define a list variable to contain file content List encodedStrings = null; //2.3 Use object to read the file try { encodedStrings = fileAccessor.ReturnFileContentAsStringList(encryptedInputfileName); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //2.4 Check if List is not empty if (encodedStrings.size()> 0){} else { System.exit(1999);} //3rd. Process items in List to create decoded file //Start decoding for (int loopCounter = 0; loopCounter 31 and = 3 AND = '3' && nextCharacter Should actually throw an Exception System.exit(7777); } //Convert extracted digit to Map Table key as Integer int mapTableKey = convertTwoOrThreeDigitsToInteger(twoOrThreeDigits); if (mapTableKey > 127) { System.out.println(tempConvertString); } // //Use maptableKey to get decoded value from Map Table char convertedCharacter = getDecodedValueFromMapTable(mapTableKey); //Append decodedValue to tempConvertString tempConvertString += convertedCharacter; } //At end of while loop, we remove space at // start of tempConvertString and then write string // to output file. tempConvertString = tempConvertString.trim(); System.out.println(tempConvertString); //print to see progress Boolean okayFileIO = false; if (loopCounter == 0) { okayFileIO = openAndWriteToFile(tempConvertString,decryptedOutputFile,false); if (!okayFileIO) {System.exit(1988);} } else { okayFileIO = writeToFile(tempConvertString); if (!okayFileIO) {System.exit(1988);} } } //End decoding by closing output file WriteToFileSystem.closeTheFile(true); } private static char getDecodedValueFromMapTable(int mapTableKey) { // TODO Auto-generated method stub return 0; } // private static String extractThreeDigits(String listItemString, int locationOfCode) { // TODO Auto-generated method stub return null; } private static String extractTwoDigits(String listItemString, int locationOfCode) { // TODO Auto-generated method stub return null; } private static int convertTwoOrThreeDigitsToInteger(String twoOrThreeDigits) { // TODO Auto-generated method stub return 0; } private static Boolean writeToFile(String tempConvertString) { Boolean writeToFile = false; //Ad code to write to file. Also use try/catch to enable // return of true or false writeToFile // return writeToFile; }

private static Boolean openAndWriteToFile(String tempConvertString, String decryptedoutputfile2, boolean b) { Boolean writeToFile = false; //Ad code to write to file. Also use try/catch to enable // return of true or false writeToFile // return writeToFile; }

private static Boolean buildTheConversionMapTable() { //Initialize the Conversion Map Table decryptionLookupTable = new HashMap(); //We generate the UTF-8 ASCII compatible table // for Integer = 1 to Integer = 127 for (int loopCounter = 1; loopCounter

THESE ARE THE WORK SPACES THE LECTURER PROVIDED. IM SO CONFUSED I DONT EVEN KNOW HOW TO START ABOUT IT

vp Users Guide.pdf 313 Application P e Microsoft cdge Tips 192.160.8. COM313 pplic co M313 Application P g%.20 (22-20170-Wk2Apdl SAISI IAG20USMAN/Desklop COM313/COM3 13 Appl 12620P for (String curr Key dictionaryOfNavigationDrawerltem.keyset ent //Code to extract the value using the key goes here If we also the variable name followed by and wait, we can also get a set of each (Key, Value) pairs in the map. dissionaryofNavigation V remove objectke):Dateltem-Map -24% Ucleano: void Map 125. try Set size int-Map 10% containsKey object key): boolcan Map-5% Returns a Set view of the mappings contained in thi hentry5et0:SetkEntry etel Mop- 2% The set is P, changes to the map are V isEmpty 0 boolea Map 2% the set, and p is modified V volueo.colection Dat while (except thr getrobject key): Dataltem Map-used operation or through th keysee 0: Set

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions

Question

RP-7 What are some ways to reconcile conflicts and promote peace?

Answered: 1 week ago