Está en la página 1de 4

Andrew Emrazian

u0349111
CS 4480: Computer Networks
PA1-Final
February 16, 2016

Discuss the TCP Proxy server for assignment PA1. Design, Testing, & Output

Design that describes the program design, how it works and any design tradeoffs considered and
made.

My proxy server, written in Java, has a listening socket connection on a given port that’s passed
in to the command line. When a new connection is initialized, it is handed off to an object of
TCPProxyServer. For Part B, the proxy server worked fairly fast and efficient since I was
passing the bytes straight to back to the client as they came back form the remote server. There
are around 10 validations and/or parsings that happen on each request/header line. This didn’t
seem to slow the connection very much compared to caching the response and processing it. A
expensive problem is that I stored all the response bytes into a dynamic array (ArrayList) and
then back to a standard array. I did this because you obviously can’t hash the file until you
have all of it. These were the main tradeoffs. Caching is necessary in this case but the tradeoff
that left a bad taste in my mouth though was that I had to switch between Byte arrays and
byte arrays. Performance can be hit or miss. It often is dependent on how long it takes to
receive a response from Team Cymru.

Testing that describes the tests you executed to convince yourself that the program works
correctly. Also document any cases for which your program is known not to work correctly. 


For part 1, I used telnet to test simple cases like, http://www.cs.utah.edu/~kobus/simple.html


and then I configured Firefox browser to use my proxy server and for any site that depended
solely on GET requests. For part 2, I tested the concurrency by downloading large file(100mb)
and then requesting some content separately (ex: simple.html). I did this with Firefox and
telnet. For the final part, I used the command line tool curl to verify the results of requesting a
non-malicious file and a malicious file. I obtained a known malicious file api.malshare.com and
verified the md5 hash locally and also did a whois query on that hash to verify that it should be
blocked. I then started an Apache server locally and then requested the files through the proxy
server on localhost. This worked every time. I also got it to work in configured Firefox but it
wasn’t working 100% of the time. I was already not trusting the browser clients all the time
because I was getting conflicting md5 hash signatures. They were always consistent with the
command line tools however (telnet, curl).
Output that shows output that illustrates the correct functioning of your program. 


Andrews-MacBook-Pro-2:Desktop Emrazian$ curl --proxy1.0 localhost:1132


localhost:80/simple.html
<!DOCTYPE html>
<html>
<body>

<h1>Real Simple</h1>

</body>
</html>

Andrews-MacBook-Pro-2:Desktop Emrazian$ curl --proxy1.0 localhost:1132


localhost:80/malware.bad
<!DOCTYPE html>
<html>
<body style="background-color: #e6e6e6;">
<h1 style="color:red; font-family:verdana; text-align:center;">Malware Blocked</h1>
<p style="font-family:verdana; text-align:center;">The content that was requested is
known to contain suspicious malware.</p>
</body>
</html>
Andrews-MacBook-Pro-2:Desktop Emrazian$

I ran the proxy server on my Macbook Pro along with the Apache server and had Firefox
configured on my Windows machine. Using Firefox:

An example of compiling and running the program on the Cade machines on port 1111:

[andrewe@lab2-10 ~]$ telnet localhost 1111


Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET http://www.cs.utah.edu/~kobus/simple.html HTTP/1.0

HTTP/1.1 200 OK
Date: Mon, 22 Feb 2016 04:43:35 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Sun, 12 Jan 2014 04:01:24 GMT
ETag: "46-4efbe03469098"
Accept-Ranges: bytes
Content-Length: 70
Vary: Accept-Encoding
X-Frame-Options: sameorigin
Connection: close
Content-Type: text/html

<!DOCTYPE html>
<html>
<body>

<h1>Real Simple</h1>

</body>
</html>

Connection closed by foreign host.

Other formatting test cases:


Different valid formatting
Andrews-MacBook-Pro-2:Desktop Emrazian$ telnet localhost 1132
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /~kobus/simple.html HTTP/1.0
Host: www.cs.utah.edu

HTTP/1.1 200 OK
Date: Mon, 22 Feb 2016 06:39:58 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Sun, 12 Jan 2014 04:01:24 GMT
ETag: "46-4efbe03469098"
Accept-Ranges: bytes
Content-Length: 70
Vary: Accept-Encoding
X-Frame-Options: sameorigin
Connection: close
Content-Type: text/html

<!DOCTYPE html>
<html>
<body>

<h1>Real Simple</h1>

</body>
</html>

Connection closed by foreign host.

No HTTP Version
Andrews-MacBook-Pro-2:Desktop Emrazian$ telnet localhost 1132
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /~kobus/simple.html
HTTP/1.0 400 Bad Request
Connection: close

Connection closed by foreign host.


Only GET is supported
Andrews-MacBook-Pro-2:Desktop Emrazian$ telnet localhost 1132
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST /~kobus/simple.html HTTP/1.0
HTTP/1.0 501 Not Implemented
Connection: close

Connection closed by foreign host.

Invalid domain
Andrews-MacBook-Pro-2:Desktop Emrazian$ telnet localhost 1132
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET baddomain HTTP/1.0

HTTP/1.0 400 Bad Request


Connection: close

Connection closed by foreign host.

Headers need to valid also


Andrews-MacBook-Pro-2:Desktop Emrazian$ telnet localhost 1132
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /~kobus/simple.html HTTP/1.0
BAD HEADER
HTTP/1.0 400 Bad Request
Connection: close

Connection closed by foreign host.

También podría gustarte