Category: Computer science and IT assignments

Move To Front List

Keep it as simple as possible, don’t use extremely complex methods unless absolutely necessary. This assignment is not huge nor extremely complicated. Do not change the method’s signature in any way, just fill in the code under the method’s signature. The only file that should be edited is MoveToFrontList.java, the other files are for reference/testing.

Sorting a Random List

Given what algorithm is supposed to do, just make the code based on the descriptions. Keep function names and parameter the same as given. Use the test.py file to ensure that the algorithm will get the full grades. Do not prompt the user for input.

Python IPv4 Breakdown

Write a short program that does all of the following. 
1. Asks the user for an IP Address with the subnet prefix.  (ex:  192.168.2.142/20 )
2. The input must be the correct format and have validation (make sure it meets the format requirements). 
3. You must use a List to store the IP Address (Lab 4 – Step 5) and a variable for the prefix. 
4. Calculate the required answers. 5. Output should match the provide sample below.

LAB 4

Complete a port scan.  Use NMAP for this.  Showcase the findings.

Use wireshark and perform a TCPFlood attack.  Record your findings.

Use Kali tools to perform a Hping3 attack.  Record your findings.

Write a 2 page paper that discusses your findings and what businesses should do to mitigate these attack vectors.

LAB 3 Assignment

It was brought to my attention that the laboratory does not contain information on what you need to do. After trying to contact faculty services, I wasn’t able to get a hold of anyone that could discuss what needed to be done.  As we are discussing footprinting and we have colleague, I have a few things that I would like you all to run.

Install whois on Kali.  You may have issues if this is not part of the repository list. Use the following commands.

/etc/apt/sources.list

This will let you know your repository listing. Ensure that the repository listing has the following inside.

deb http://http.kali.org/kali kali-rolling main contrib non-free

Run the following commands in terminal.

apt-get update
apt-get upgrade
apt-get dist-upgrade

that should allow you to run the WHOIS installation command.

apt-get install whois

Run queries against domains.

whois caltech.edu

whois -h whois.networksolutions.com caltech.edu
whois -h whois.networksolutions.com *caltech.edu
whois -h whois.networksolutions.com .banjo
Run this against a few different websites.  Copy the text from the terminal and store it into a file. Write a one-page summary for how this information could be used to attack a network.

Given the lateness of the hour, I will be giving a full week of extra time on this. Please accept my apologies. I will be working on the next lab to ensure that you guys have it out before it’s due. Thank you for your time and understanding regarding this.

Shiny

The Data

For this assignment, you’ll be using the midwest dataset, which is built into the ggplot2 package. Each row contains demographic information about a county in each state:

midwest dataset

Remember, you may want to use dplyr to compute (and then later visualize) summary information!

Assignment Structure

For this assignment, you build your own shiny application. The application should provide users with the ability to interact with a visual representation of the midwest dataset. What the application looks like is up to you, as long as it meets the following requirements:

You create a multi-page (tab) application with at least two pages
On each page, you should use the appropriate layout, such as a sidebarLayout, to create a section for control widgets, and another section for a visualization.
You must create at least two widgets on each page that change the visual output in your application, such as data displayed on the x or y axis of a scatterplot.
One of your widgets on each page must change the data that is being displayed. For example, the attribute being shown on the x or y axis. While changing the color of all markers (from, say, red to blue) would not mheet this requirement, changing the data driving the color of each point would (i.e., color by percent poverty or population density)
You must create a visual representation of a dataset that reacts to the widgets on each page
You must host your application up to the shinyapps.io server, making it publicly usable
The layout is well structured (clear headers, panels, etc.)
As you know, in order to run a shiny application, you must create multiple files:

An app.R file, that drives your application
An app_ui.R file that defines your UI element (to be loaded into the app.R file)
An app_server.R file that defines your server element (to be loaded into the app.R file)
A README.md file, because it’s important to document your code. This file should contain a link to your project.
The purpose of this project really is just to make sure you’re comfortable with the structure of a web application. Feel free to be creative in your assignment, though a scatter-plot with 2 widgets controlling the x variable and y variable would be sufficient.

Widgets

You should create at least two widgets of your choice for each visualization. As stated above in the requirements, at least one of these widgets should change the data being displayed.

Visual representation

On each page (tab) of your application, you must have a visualization of the midwest dataset. The visualization can be made with base ggplot2, plotly, or something less supported but more interesting. While we don’t expect you to create anything ground-breaking, we do expect you to create a clear visualization with proper labels, titles, and interactions (if using and interactive library). And of course, the graphic needs to react to changing values in the widgets.

AES block cipher

Project 3
AES block cipher modes

In this project you will answer a series of questions about AES. In this description you will see five questions, Question 1,…,Question 5. You should answer each of these in a separate document, preferably a markdown document like this one. Please do not use MS word or another word processing program. The cocalc text editor is fine. Please clearly indicate your solution by using an informative filename like solution.md.

In class last week we played around a bit using block cipher modes and openssl. For reference I have given you an example of how to use the tool in the file called enc.sh in your directory:

hunter@pop-os:~/Desktop/aes_play$ cat enc.sh
KEY=000102030405060708090A0B0C0D0E0F
IV=101112131415161718191A1B1C1D1E1F
openssl aes-128-ecb -e -K $KEY -in plaintext -out ct_ecb
You can execute this script by doing this at the terminal:

hunter@pop-os:~/Desktop/aes_play$ . enc.sh
This will produce the output ct_ecb which is the encryption of the plaintext in the file called plaintext.

After running enc.sh you should be able to look at the cipertext and plaintext using the hex editor xxd. The output should look like this:

hunter@pop-os:~/Desktop/aes_play$ xxd ct_ecb
00000000: 29ab 9897 1f42 5ad4 e4b5 d5cf 4c7a fd68  )….BZ…..Lz.h
00000010: 5a3f 6b23 d9de ddd5 8910 9a6f dfd4 9902  Z?k#…….o….
00000020: 1983 2768 4597 007e 4331 314e dfa7 1811  ..’hE..~C11N….
00000030: 77ec caa1 03ce 813a 4070 2661 a7c4 7b5f  w……:@p&a..{_
00000040: 06b1 9024 f5cd 9667 99c7 4ddc d479 b661  …$…g..M..y.a
00000050: 08d3 1d4d 1bd7 e600 fc18 b6f2 eedb 3148  …M……….1H
00000060: 6a87 f1b2 dc3b e5df 8eac 13b1 9be2 a7fd  j….;……….
00000070: 8911 1e63 804c 7023 e112 7209 0c15 aa1c  …c.Lp#..r…..
00000080: ffa3 0de9 e609 1259 d6a9 9640 080d 876b  …….Y…@…k
00000090: 657e d2d7 403f 0535 d192 5bc8 2d35 098d  e~..@?.5..[.-5..
000000a0: 0a05 80ec de7b fc2f 3f60 7c39 516e 5e93  …..{./?`|9Qn^.
000000b0: a21e 8a78 c563 0b49 5342 470c e2fb 36d3  …x.c.ISBG…6.
hunter@pop-os:~/Desktop/aes_play$ xxd plaintext
00000000: 4166 7465 7220 616c 6c2c 2069 7427 7320  After all, it’s
00000010: 6561 7379 2074 6f20 7265 6f70 656e 2073  easy to reopen s
00000020: 6368 6f6f 6c73 2069 6620 7468 6520 6e65  chools if the ne
00000030: 7773 2069 7320 676f 6f64 2e20 2046 6f72  ws is good.  For
00000040: 2065 7861 6d70 6c65 2c20 6d79 2063 6f6c  example, my col
00000050: 6c65 6167 7565 7320 616e 6420 4920 6f62  leagues and I ob
00000060: 7365 7276 6564 2074 6865 2075 7365 206f  served the use o
00000070: 6620 7363 686f 6f6c 2063 6c6f 7369 6e67  f school closing
00000080: 7320 616e 6420 6f74 6865 7220 4e50 4973  s and other NPIs
00000090: 2064 7572 696e 6720 7468 6520 3230 3039  during the 2009
000000a0: 2048 314e 3120 696e 666c 7565 6e7a 6120  H1N1 influenza
000000b0: 6570 6964 656d 6963 2e0a 0a              epidemic…
Notice that the plaintext is 12 blocks long, as is the ciphertext. But the ciphertext has been padded such that the last block is a full 16 bytes.

You can get the ciphertext as hex without formatting by using the -p option with xxd:

hunter@pop-os:~/Desktop/aes_play$ xxd -p ct_ecb
29ab98971f425ad4e4b5d5cf4c7afd685a3f6b23d9deddd589109a6fdfd4
9902198327684597007e4331314edfa7181177eccaa103ce813a40702661
a7c47b5f06b19024f5cd966799c74ddcd479b66108d31d4d1bd7e600fc18
b6f2eedb31486a87f1b2dc3be5df8eac13b19be2a7fd89111e63804c7023
e11272090c15aa1cffa30de9e6091259d6a99640080d876b657ed2d7403f
0535d1925bc82d35098d0a0580ecde7bfc2f3f607c39516e5e93a21e8a78
c5630b495342470ce2fb36d3
Redirect this into a file of its own:

xxd -p ct_ecb > ct_ecb.hex
Now edit the hex and change the sequence 06b19024 from the 5th block so that it becomes 86b19024. Notice that this is a one bit change. Save the changes to ct_ecb.hex.

Now use xxd in reverse mode to convert the altered hex back into a binary file:

xxd -r -p ct_ecb.hex > ct_ecb_bitflip
Now decrypt this file as if it were the ciphertext for the original plaintext.

For how to do the decryption, look in the file dec.sh.

Question 1

How has the plaintext changed? Paste what you see on the command line when you xxd both the original plaintext and the decrypt of the altered ciphertext.

Question 2

Repeat all of the above, but this time use CBC mode (please use the IV provided in enc.sh). Again change a single bit in the 5th block of the ciphertext. In particular, change 32429b73 to 22429b73. How does the plaintext change? Which lines are affected? Why does it happen? Again paste both the xxd of the original and altered plaintext.

You can use this encryption command:

hunter@pop-os:~/Desktop/aes_play$ openssl aes-128-cbc -e -K $KEY -iv $IV -in plaintext -out ct_cbc
Question 3

Repeat all of the steps above, but this time use CTR mode. Notice that the ciphertext is not padded in this case. Why not? In the bit flip part of the exercise, change 166186a5 to 366186a5. Which blocks change? How do they change? Why is that the change?

You can use this encryption command:

hunter@pop-os:~/Desktop/aes_play$ openssl aes-128-ctr -e -K $KEY -iv $IV -in plaintext -out ct_ctr
Part 2
In this section you will break a ciphertext. This is possible because the developer (me) has made a terrible error. He has encrypted two files using aes-128-ctr using the same key and the same IV. Even worse: The plaintext of one of the files is known to the attacker (you)!

Question 4

Why is this a mistake? What is the basic plan for decrypting the ciphertext for which the plaintext is unknown?

The files were encrypted using a truly random 128 bit key to which you do not have access. One of the files is just the file called plaintext which you have in your directory. The ciphertext files are called pt_key2 and m2_key2. The file pt_key2 is the encryption of plaintext, but m2_key2 is the encryption of an as yet unknown file.

To help you along I have given you a program called xor. The source code is in the file xor.c. You use it like this:

$ ./xor file1 file2 > file3
This XORs file1 and file2 on the byte level and puts the result in file3. Because file1 and file2 are probably not the same length, file3 is only as long as the shorter of file1 and file2.

Question 5

What is the decryption of m2_key2? (Or as much of it as you can find)?

C Code Expressions

Deliverables:

Deliverables for this project include the following:
1. Source code correctly implementing all required functionality. Your program must compile with Microsoft Visual C++ or any modern C/C++ compiler on your O/S.

2. Word or PDF file providing screen shots of successfully compiling and executing the program.

3. Description of the process and lesson learned while completing this project (to be included in the Word or PDF document).

4. A test plan that contains test cases that test all of the required operators. Each test case should include the expression and its expected value (to be included in the Word or PDF document).

Computer Science Assignment 2

In this assignment, the encryption algorithm we use encrypts (or decrypt) one letter of the message at a time.

First, we will remove all characters that are not letters from the plaintext message and also convert all lowercase letters to uppercase. This means that whitespace, digits and punctuation are lost in the encryption process, leaving only uppercase letters of the alphabet. Next, we convert the letters to numbers based on their place in the alphabet (A is represented as 0, B as 1, C as 2, …, Y as 24, and Z as 25). We’ll use the resulting sequence of these numbers as input to the encryption algorithm.

After the letters are converted to numbers (remember, we’re only converting capital letters here), the encryption algorithm generates a special number for each position in the plaintext message. These special numbers are called keystream values. To encrypt each letter, the numeric letter value and the corresponding keystream value are added, modulo 26, and then the resulting number is converted to its letter form. The two numbers that are added are the number corresponding to the letter in the plaintext, and the keystream value for the position of the letter in the plaintext.

Decryption is just the inverse of encryption. Start by converting the letters in the ciphertext to be decoded to numbers, in the same way as the original plaintext message was converted. Then, use the encryption algorithm again to generate a special number for each position in the ciphertext. Subtract these special numbers from the numbers from the ciphertext, again modulo 26. Finally, convert the resulting numbers to letters to recover the plaintext message.

The only other requirement for the encryption and decryption processes to work is that both encryption and decryption use the same sequence of keystream values. In our algorithm, we’ll use a representation of a deck of playing cards to generate keystream values. The encryption and decryption algorithms need to start with the same decks.

Python design problem

Payroll
Introduction
This assignment is a design problem, not a coding problem. It is meant to provide you with practice in top-down design with step-wise refinement, that is, the decomposition of a problem into appropriate modules and high level functions definitions. We are looking for a design document, not a working Python 3 program, so do not submit any Python 3 code.

The problem
A company needs a program to generate on-screen reports from their employee database.

The company’s employee records are in files on their computer system. The format of these files (.csv, .json, whatever) is not important to your design. Here is a description of the data contained in the files that are relevant to your project:

A central employees file contains the following information for each employee:
name
employee ID
(other information not needed for reports)
Each employee has a file (with a name generated from the employee’s ID number) that contains up to twelve records of data (one per month) for the current year. Each record contains this information:
The employee’s (unique) ID
The month
The number of hours worked that month by the employee
The employee’s hourly rate of pay for that month.
This file gets updated monthly by an existing program (not yours) with new information.
Here is a list of report types the company wants and for which you’ve been asked to design a program:

A pay report for a user-specified month. The report will have one screen row of data for each employee showing the following:
The employee’s ID.
The employee’s name.
The number of hours worked that month by the employee.
The employee’s hourly rate of pay for that month.
The employee’s pay for that month.*
*Gross pay. Don’t concern yourself with tax, pension, and other deductions.
This report will also contain a summary of pay information, as follows:

Number of employees.
Total pay for all employees.
Average pay per employee.
A year-to-date pay report for a user-specified employee. The report will have one screen row of data for each month of the current year. (Fewer than twelve rows, obviously, if the report is generated before the end of December.) Each row of the report will contain:
A month.
The number of hours worked that month by the employee.
The employee’s hourly rate of pay for that month.
The employee’s pay for that month.
This report will also contain a summary of pay information for the employee, as follows:
Total pay to date for the employee.
Average monthly pay for the employee.
A year-to-date pay summary report for all employees. The report will have one screen row of data for each month of the current year. Each row of the report will contain:
The month.
The total pay for the month.
The average pay per employee for the month.
What you must do
You are to create a top-down design for the problem described above. Your end result should be a listing of modules, descriptions of each modules’ purpose, functions within those modules, and descriptions of each function. Here is a sample of what we expect to see (for a different problem, of course, and recognizing that a real solution that includes a controlling (main) module would be much longer).

Module: build_word_list

< A description of the module’s purpose goes here.>

Functions:

get_words(file_name): Read a file of words into a list.
Parameter:
file_name: The name of the file of words.
Return: A list of words extracted from file file_name.
filter_words(words_list, unwanted_words): Remove duplicate words and words in unwanted_words from words_list.
Parameters:
words_list: A list of words.
unwanted_words: A list of words to be removed from words_list.
Module: anagrams

< A description of the module’s purpose goes here.>

Function:

find_anagrams(all_words_file_name, words_list): Return a two dimensional list of anagrams of the words in words_list. Each anagram is a word found in file all_words_file_name.
Parameters:
all_words_file_name: The name of a file containing all valid words.
words_list: The list of words.
Return: A two-dimensional list of words, each row of which is a list of anagrams of words from the corresponding row of words_list.
Note: Your design should make clear which function in which module serves as the starting point for your program’s execution