Assignment 1
Assignment 1 is due 1/24/21 on or before 11:59:59pm MST.
Part 1 (5 points)
Sign up for the course Piazza. We will know if you registered by your name and/or ASU ID. If we have any questions, we will contact you directly.
Once you’re on Piazza, register for a Gradescope account so that you can submit the rest of the assignment.
Part 2 — Bandit v1 (25 points)
For a future homework assignment you will be hacking on a Linux server. The goal of this assignment is to familiarize yourself with accessing a Linux environment via SSH, along with developing skills on command line interaction and wargames.
First, register for a wechall account. You will need to submit your wechall username so that we can track your progress on the levels. After registering, you will need to link OverTheWire.org to your wechall account by doing the following:
- Click “Account” on the top of wechall.net
- Clink on the “Linked Sites” button
- On the “Select a site” dropdown, select “OverTheWire.org”
- Then click the “Link Site” button
Now, OverTheWire.org should show up in your list of linked sites, and we will be able to track your progress on Bandit from your user profile.
Then, the goal is to solve 5 levels (in other words reach level 6) on the overthewire.org Bandit challenges.
You will need to update wechall with your progress on bandit. There are three ways to do that:
-
Edit your
.bashrc
and.ssh/config
to pass your wechall username and wechall token to bandit everytime you login by following there instructions. This option is best if you are comfortable editing these files in your local environment and don’t want to supply your wechall username/token every time. - Use
export
to set the proper environment variables every time you log into bandit.
You’ll need to run the following commands onbandit
(in other words, afterssh
ing into thebandit
server), replacingfoobar
with your wechall username andtoken
with your wechall token:
bash export WECHALLUSER="foobar" export WECHALLTOKEN="token"
Then, you can run thewechall
command:
bash wechall
- Specify your wechall username and token every time that you run
wechall
.
You’ll need to run the following commands onbandit
(in other words, afterssh
ing into thebandit
server), replacingfoobar
with your wechall username andtoken
with your wechall token:
bash WECHALLUSER="foobar" WECHALLTOKEN="token" wechall
Using one of these techniques, your bandit progress will be captured on wechall, which we will use to grade your progress.
A very important note is that level 0 (zero) of bandit is not
counted on wechall, so when you run wechall
after solving level 0
you will get an error that states “unknown level for this warbox”.
This is expected, run wechall
on level 1 and beyond!
Note that you can always do this after you have broken a level, so if you are stuck on this part please attend office hours or ask on the course piazza and continue working on bandit.
Also, keep track in your README how you solved each level.
Note that Bandit is an open system, and the goal of this assignment is to practice and develop your own skills, so be honorable and do not read walkthroughs.
Submission Instructions
Submit on GradeScope the plain text file README to gradescope.
Note: you must include the following line in your README (replace
the INSERT_WECHALL_NAME_HERE
will your wechall username), or else
the autograder won’t be able to give you a grade and you will get a 0:
wechall name: INSERT_WECHALL_NAME_HERE
Helpful Resources From Students
- This video on How to use Putty to access the bandit levels from Windows
- Read each of the resources linked on each Bandit level.
- Google for linux commands and syntax
Part 3 — Make this (25 points)
All of the coding assignments in this course (including Part 4 of this assignment) allow you to write your assignment in any programming language. To allow this, you will need to write a Makefile that creates an executable file based on your source code.
In this assignment, you’ll practice writing a Makefile for two different types of programs, one a C program that must be compiled, and the other a Python program.
Here are some Makefile resources:
- https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html
- https://web.stanford.edu/class/archive/cs/cs107/cs107.1174/guide_make.html
- https://www.gnu.org/software/make/manual/make.html
- http://mrbook.org/blog/tutorials/make/
- YouTube video: How to Create a Simple Makefile - Introduction to Makefiles
- Starter Information about Python Makefiles
C Program Makefile
The C Program Makefile must compile the file
c_program.c
into the executable
c_program
.
Assume that your C Program Makefile is called Makefile.c
and is in the same directory as the
c_program.c
, and therefore, when you
run make -f Makefile.c
in that directory, the compiled program c_program
is
created using gcc
.
Also, your C Program Makefile must recompile the binary when c_program.c
changes when you run make -f Makefile.c
again.
This means that:
- Run
make -f Makefile.c
. - Execute
./c_program
. - Edit the source code
c_program.c
(change the strings, for instance). - Run
make -f Makefile.c
. - Execute
./c_program
and verify that the changes you made in step 3 are reflected.
Python Makefile
The Python Makefile must use the file
python_program.py
to create an
executable file called python_program
.
Assume that your Python Makefile is called Makefile.python
and is in the same directory as the
python_program.py
, and therefore, when you run make -f Makefile.python
in that
directory, your Python Makefile will create a python_program
executable.
Also, your Python Makefile must recreate python_program
when
python_program.py
changes and you run make -f Makefile.python
again.
This means that:
- Run
make -f Makefile.python
. - Execute
./python_program
. - Edit the source code
python_program.py
(change the strings, for instance). - Run
make -f Makefile.python
. - Execute
./python_program
and verify that the changes you made in step 3 are reflected.
There are several ways to approach this (because there’s nothing to
compile). For instance, you can take advantage of the
shebang functionality,
which allows a file that can be interpreted to be executed. This
requires that the file is executable (chmod +x filename
).
Submission Instructions
Submit on GradeScope the Python Makefile as Makefile.python
and the C Makefile as
Makefile.c
.
Part 4 — Commands (45 points)
One of the ways that programs receive input from users is through command line arguments. We will also use this in future assignments.
Your goal is to write, in any language, a program which first prints out the number of command line arguments and the next line prints them out in reverse order, separated by space (so that the last command line argument is printed first).
The name of your program will be called command
.
Examples
When your program is executed with the following:
./command foo bar
It must output exactly:
2
bar foo
Other examples:
./command
Output:
0
Running:
./command a b "test input" c d e
Output:
6
e d c test input b a
Implementation
Your program must work on Ubuntu 18.04 64-bit with the default packages installed.
In addition to the default packages, the following packages for languages are also installed:
- C (
gcc
) - C+++ (
g++
) - Java (
default-jre
anddefault-jdk
) - Rust (
rustc
) - Ruby (
ruby-full
) - Node.js (
nodejs
andnpm
) - Mono (Custom install)
- Go (1.15.6, custom install)
If there’s a package that you need, please ask on the course piazza and I’ll have it installed for everyone. Java is already installed.
You’ll also need to write a Makefile that, when the make
command is
run, will create the executable called command
.
Submission Instructions
Submit on GradeScope your source code, along with
a Makefile (called Makefile
) and a README. The Makefile must create
your executable, called command
, when make
is ran. Your README
file must be plain text and should contain your name, ASU ID, and a
description of how your program works.