Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Create a package called hacker and create a class in the package called Hacker. Hacker must have: o Protected member that is an array
Java
Create a package called hacker and create a class in the package called Hacker. Hacker must have: o Protected member that is an array list of bytes o A constructor with one argument-the file name. This constructor will read in the bytes of the file using a byte stream file input and store them in the array list of bytes. A display method that will display the bytes as characters to the console. If the character is between the space and the tilde in the ASCII chart, it is a printable character and must be shown as is; otherwise it is known as an unprintable character and you will need to display a period instead. It must print 64 characters on each line (the last line may have fewer characters). For example: .............1...0......0r0^1.0...0....US1.0...0....Symantec Co rporation100...U... 'Symantec Time Stamping Services CA - G2..... 8...5n..j...P0...+.......]0...*. ......1...*. ......0...*. ..... .1...19092209330120#..*.H......1...RO.. (........../.._0...*... o o A method that will write the bytes out to a file as bytes and by using a byte stream. The method's argument is the name of the output file. If done correctly, a copy of putty.exe will still be executable. A method that will add an array of bytes to the end. The arguments are two strings, the filename for the output file and the phrase to add. The phrase must be converted to a byte array and added to the end of the file during output using a byte stream. If done properly, the copy of putty.exe that is created will still execute and you will see your phrase if you open the exe file in a text editor. The array list of Bytes must be used but must not be changed i.e. do not add it the phrase directly to the array list). A method that will add an array of bytes to the beginning. Follow the same basic requirements as the method above but put the phrase at the beginning this time. If done properly, the created putty.exe file will not run, but you will still be able to see your phrase if you open it in a text editor. The array list of Bytes must be used but must not be changed. A method that will find and replace phrases. This method must have three arguments, the string to find, the string to replace it with, and the filename you will save it as. It must take the array list of bytes and copy it into a String Builder object. Then use the methods of the StringBuilder class to find and replace all instances of the phrase (this is a reasonably short method to write if you know the String Builder methods). Save the resulting edited contents to the output file using a byte steam. It will be case sensitive. For example, you can find and replace all instances of "Host" with "Hack" and run the resulting putty.exe file and see the effect. You can assume that phrases will match in size (note that the example uses two phrases of 4 characters). A method that will output the byte array list as a text file using a character stream. This is basically like the display method, but outputs it to the file. Put 64 characters per line. O Create a package called hacking with a class called Hacking. Hacking will have the main method. o The main method must use command line arguments to determine what methods to call. The command line arguments are a flag followed by the needed information. Source is the filename to read from, destination is output filename, phrase is the string to add to the file, find is the string to search for, and replace is the phrase to replace the find phrase with. -d source -C source destination -e source destination phrase -b source destination phrase -f source destination find replace -t source destination You can assume that the use will use correct arguments and argument order, except that they may enter and incorrect flag. If they do, output the message "Invalid Flag" and end the program. There are some provided data files to play with: putty.exe - portable executive ssh client RtlExUpd.dll - a Windows DLL file from Realtek Semiconductor Corp Active Hours.png - an image file syllabus.pdf - the PDF of our syllabus Note that it is possible that your virus checker may be triggered if you try to run putty.exe after altering the contents. Mine detected the change, but still allowed me to run it. Create a package called hacker and create a class in the package called Hacker. Hacker must have: o Protected member that is an array list of bytes o A constructor with one argument-the file name. This constructor will read in the bytes of the file using a byte stream file input and store them in the array list of bytes. A display method that will display the bytes as characters to the console. If the character is between the space and the tilde in the ASCII chart, it is a printable character and must be shown as is; otherwise it is known as an unprintable character and you will need to display a period instead. It must print 64 characters on each line (the last line may have fewer characters). For example: .............1...0......0r0^1.0...0....US1.0...0....Symantec Co rporation100...U... 'Symantec Time Stamping Services CA - G2..... 8...5n..j...P0...+.......]0...*. ......1...*. ......0...*. ..... .1...19092209330120#..*.H......1...RO.. (........../.._0...*... o o A method that will write the bytes out to a file as bytes and by using a byte stream. The method's argument is the name of the output file. If done correctly, a copy of putty.exe will still be executable. A method that will add an array of bytes to the end. The arguments are two strings, the filename for the output file and the phrase to add. The phrase must be converted to a byte array and added to the end of the file during output using a byte stream. If done properly, the copy of putty.exe that is created will still execute and you will see your phrase if you open the exe file in a text editor. The array list of Bytes must be used but must not be changed i.e. do not add it the phrase directly to the array list). A method that will add an array of bytes to the beginning. Follow the same basic requirements as the method above but put the phrase at the beginning this time. If done properly, the created putty.exe file will not run, but you will still be able to see your phrase if you open it in a text editor. The array list of Bytes must be used but must not be changed. A method that will find and replace phrases. This method must have three arguments, the string to find, the string to replace it with, and the filename you will save it as. It must take the array list of bytes and copy it into a String Builder object. Then use the methods of the StringBuilder class to find and replace all instances of the phrase (this is a reasonably short method to write if you know the String Builder methods). Save the resulting edited contents to the output file using a byte steam. It will be case sensitive. For example, you can find and replace all instances of "Host" with "Hack" and run the resulting putty.exe file and see the effect. You can assume that phrases will match in size (note that the example uses two phrases of 4 characters). A method that will output the byte array list as a text file using a character stream. This is basically like the display method, but outputs it to the file. Put 64 characters per line. O Create a package called hacking with a class called Hacking. Hacking will have the main method. o The main method must use command line arguments to determine what methods to call. The command line arguments are a flag followed by the needed information. Source is the filename to read from, destination is output filename, phrase is the string to add to the file, find is the string to search for, and replace is the phrase to replace the find phrase with. -d source -C source destination -e source destination phrase -b source destination phrase -f source destination find replace -t source destination You can assume that the use will use correct arguments and argument order, except that they may enter and incorrect flag. If they do, output the message "Invalid Flag" and end the program. There are some provided data files to play with: putty.exe - portable executive ssh client RtlExUpd.dll - a Windows DLL file from Realtek Semiconductor Corp Active Hours.png - an image file syllabus.pdf - the PDF of our syllabus Note that it is possible that your virus checker may be triggered if you try to run putty.exe after altering the contents. Mine detected the change, but still allowed me to run itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started