Anatomy of a Virus

Today, we will be doing something special. We will writing our own virus. Don’t worry, the code is not malicious, but it demonstrates the power of computer viruses, and how easy it is for anyone with a little programming knowledge (like you guys) to make your own viruses.

Please download the following code:

https://pastebin.com/embed_iframe/XKcwdEh8

Step 1: Create a new folder somewhere on your computer, preferably on your desktop or in documents, you can call it ‘foofolder’

Step 2: Open Wing and copy/paste the code above into a new file, call it foo.py and save it in ‘foofolder’.

Step 3: Open Wing again, and create a new document, type in “Please don’t mess with this file”, and save it as test.foo in the ‘foofolder’.

Optional Step 4: Repeat step 3 but type in something else and name it something else but still with the .foo extension.

Step 5: (Do not run your program in Wing) Open up terminal, change directory to ‘foofolder’, and run “python3 foo.py”

Step 6: Now, open up the files test.foo and anything else that is .foo from ‘foofolder’. You should see the results of the virus.

Step 7: Now make another folder somewhere on your computer, call it ‘anotherfoofolder’.

Step 8: Copy test.foo from ‘foofolder’ to ‘anotherfoofolder’.

Step 9: Repeat Step 3 but instead this time create any random .foo files in ‘anotherfoofolder’.

Step 10: Open terminal and change directory into ‘anotherfoofolder’. Now type “./test.foo”

Step 11: Open any .foo files from ‘anotherfoofolder’, and see the results.

When done, please copy you ‘foofolder’, make sure you rename it to your name so that it will look different than everyone elses, into the server.

What changes could be made to make this code more malicious?

Lecture, computer security

Hello, welcome back from Spring Break. Today we will be starting a short lecture series on computer security. I will go over the Powerpoint below (you can download it to follow along on your computer).

pt1-introattacks

When the lecture is done, please copy/paste the following questions into a word processing doc (MS Word or Google Docs) and answer the the questions and save them on the server.

What are the 3 pillars of the CIA triad of information security?

What are 3 different ways users can provide information to identify themselves for computer access?

In your opinion what are the top 4 guidelines for passwords?

What is the name of software that verifies that the user is not another computer?

What else other than your username and password is needed for 2 factor authentication?

What is the name for software that attempts to bypass authorization to perform unauthorized functions?

What are 2 mechanisms that antivirus software use to detect and remove malicious code?

Give at least 1 example of phishing and denial of service?

Chp 8-10 Activity lab

Please complete the following chp 8-10 activity by answering the following questions below. Copy and past the code into your wing IDE and try to fix the mistakes. Then, copy and paste your corrected code into a new MS Word or Google Docs document and save it on the server when done.

When done, you can finish off your drawing functions assignment that I assigned last Mon.

  1. Why does using this code in the main loop not work to move the rectangle?
    rect_x = 50
    pygame.draw.rect(screen, WHITE, [rect_x, 50, 50, 50])
    rect_x += 1
  2. If the screen is 400 pixels tall, and the shape is 20 pixels high, at what point should the code check to see if the shape is in contact with the bottom of the screen.
  3. When drawing a starry background, explain why it doesn’t work to put code like this in the main program loop:
    for i in range(50):
    x = random.randrange(0, 400)
    y = random.randrange(0, 400)
    pygame.draw.circle(screen, WHITE, [x, y], 2)
  4. If you have a list of coordinates like the following, what code would be required to print out the array location that holds the number 33?
    stars = [[ 3, 4],
    [33, 94],
    [ 0, 0]]
  5. This code example causes snow to fall:
    # Process each snow flake in the list
    for i in range(len(snow_list)):
    # Get the x and y from the list
    x = snow_list[i][0]
    y = snow_list[i][1]
    # Draw the snow flake
    pygame.draw.circle(screen, WHITE, [x, y], 2)
    # Move the snow flake down one pixel
    snow_list[i][1] += 1

    So does the example below. Explain why this example works as well.

    # Process each snow flake in the list
    for i in range(len(snow_list)):
    # Draw the snow flake
    pygame.draw.circle(screen, WHITE, snow_list[i], 2)
    # Move the snow flake down one pixel
    snow_list[i][1] += 1

 

6. What’s wrong with this code that uses a function to draw a stick figure? Assume the colors are already defined and the rest of the program is ok. What is wrong with the code in the function?

def draw_stick_figure(screen, x, y):
# Head
pygame.draw.ellipse(screen, BLACK, [96,83,10,10], 0)
# Legs
pygame.draw.line(screen, BLACK, [100,100], [105,110], 2)
pygame.draw.line(screen, BLACK, [100,100], [95,110], 2)
# Body
pygame.draw.line(screen, RED, [100,100], [100,90], 2)
# Arms
pygame.draw.line(screen, RED, [100,90], [104,100], 2)
pygame.draw.line(screen, RED, [100,90], [96,100], 2)

7. Show how to grab the mouse coordinates, and then grab just the x coordinate of where the mouse is.

8. When we created a bouncing rectangle, we multiplied the speed times -1 when the rectangle hit the edge of the screen. Explain why that technique won’t work for moving an object with the keyboard.