Project 2 : Secure, Networked Communication
CIS/TCOM 551
Due: March 4, 2005 (6pm EST)
Description
Recall the blame service from Project 1, which you modified to
eliminate a buffer overflow. The original program, as written by
Prof. Feckless C. Coder, PhD, accepts on standard input the name of a
scapegoat and prints on standard output a message asserting that
person's universal culpability. For example:
$ echo "Matt Blaze" | ./blame
It's all Matt Blaze's fault.
In this project, you will do two things. First, modify the
program to to operate as a network service, accepting connections
on a port. Second, modify your networked program (and write a client)
using SSL encryption.
Source code for the original (buffer-overflow-prone) blame.c is
attached below and is also available at http://www.cis.upenn.edu/~cis551/blame.c.
Deliverables
-
(40% credit) Modify blame.c to run as a network service,
blameserver, running in a loop that accepts TCP connections on a
port specified on the command line. Write a client
blameclient that sends its standard input to the blame server
machine and port specified on the command line and that prints the
output from the service on standard output For example,
./blameserver 21212
should run the blame service on TCP port 21212, such that
echo Matt Blaze | ./blameclient localhost 21212
prints the message
It's all Matt Blaze's fault!
Your programs should work on the eniac.seas.upenn.edu machine
pool.
-
(30% credit)
Modify blameserver and blameclient to encrypt their
traffic (using a public key exchange and a block cipher). Use the
OpenSSL library, available on Eniac. Note that there are several ways
to do this. Any method that does a public key exchange to generate
a random secret session key is acceptable; you may use the entire SSL
protocol or you may use any component tools you wish from the SSL
library. Be sure to document what you did and how your software works.
-
(30% credit) Modify your encrypting blameserver and
blameclient to use certificates for the client and server.
Use the OpenSSL tools to create a certificate authority (whose public
key can be configured in to your client and server) and issue client
and server certificates. Print appropriate error messages if the
client or server certificate is invalid or if the key does not match
that in the certificate. Write demonstration programs that show
normal operation as well as these errors. Note that there are
several ways to do this.
Original Blame server source code (blame.c)
/*
* Blame server. Assigns blame to the person of your choice.
*
* Usage: blame
* (reads one line from standard input)
*
* To compile:
* cc blame.c -o blame
*
* Install under inetd as follows:
* blame stream tcp nowait root /path/to/blame blame
*
* Copyright 2004 by Feckless C. Coder, PhD.
*/
#include <stdio.h>
#include <string.h>
#define INPUT_BUFFER 256 /* maximum name size */
/*
* read input, copy into s
* gets() is insecure and prints a warning
* so we use this instead
*/
void getline(char *s)
{
int c;
while ((c=getchar()) != EOF)
*s++ = c;
*s = '\0';
}
/*
* convert newlines to nulls in place
*/
void purgenewlines(char *s)
{
int l;
l = strlen(s);
while (l--)
if (s[l] == '\n')
s[l] = '\0';
}
int main()
{
char scapegoat[INPUT_BUFFER];
getline(scapegoat);
/* this check ensures there's no buffer overflow */
if (strlen(scapegoat) < INPUT_BUFFER) {
purgenewlines(scapegoat);
printf("It's all %s's fault.\n", scapegoat);
}
return 0;
}
Last Revised: 6 January 2005