Assignments Sec.5

Handing In Assignments

You must hand in by using git

Hand In by git

  • Create an empty repo on bitbucket.org, gitlab.com, or github.com,
  • git push your local repo to the above remote repo.
  • For node assignments please put the line(s)

    node_modules/

    into your .gitignore file.

Send a mail to with:

  • The word 'handin <subjectname>' in the subject line of your mail
  • The url of your repo(s).

Assignment Sec.5.0

Back in the section called “PHP Prerequisites, OOPHP” we had a page 1 that only an authenticated user had access to. Now let that page create entries into a table named abstract. It might look like this:

create table abstract (
    id int unsigned not null auto_increment,
    entered datetime not null,
    enteredby varchar(16) not null,
    authors varchar(128) not null,
    reftitle varchar(64) not null,
    abstract varchar(4096) not null,
    primary key(id),
    foreign key(enteredby) references user(uid) 
);

Once the above is tested, this means once you can insert abstracts into the database from page 1, use the insert form to inject a script into the abstract column. This script must snatch the cookies from the browser where the abstract is displayed, and send them to a page stolenCookies.php on your own server. This page could add them to a textfile stolenCookies.txt.

The above requires, of course, that the insert declaration inserting the abstract into the database is not protected by prepared statements.

Hand in the repo including the previous and this solution as one.

There is of course an element of own research in this. I suggest you look at the document.cookie and how JavaScript handles it.

Assignment Sec.5.1

Back in the section called “PHP Prerequisites, OOPHP” we also had an authentication free page 2. Now in that page the code should create some, let's say 3, three, cookies:

  • the first with a one minute life span
  • the second with no life span specification
  • the third must live forever

After the tests, clear cookies from the domain, and then activate the page. Use your browser preferences to reveal all three cookies. Put the content into a textfile, and hand in the textfile.

When everything works, and you have cookies placed in the browser, you may run the previous assignment, to check if the malicious script gets the cookies.

You may combine the hand in of this assignment with the next such that everything is in one repo.