Sunday 9 October 2011

Week3

Week 3. my favorite class for now. We learned about a new programming language created in 1989 by Guido Van Rossum. One of the most popular programming languages in security tools today.

Python:

Different Data types: Strings (""), Integers (Numbers), Lists, Dictionaries(key:value), Tuples.

With Python you can also create While and For loops to repeat set of codes until a condition is met.

In our class we analyze some basic codes to be able to open a connection with a web server, send and recieve data and close the connection when done.

This is the code:


import socket
#creates a socket -- AF_INET means IPv4, SOCK_STREAM means TCP
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#IP Address to connect to -- Enter Linux VM IP here
IP = ‘freeshell.org'
PORT = 22 #We'll look at the default SSH port
connect = (IP, PORT) #socket connection requires a tuple of IP, PORT
s.connect(connect) #establish a connection
data = s.recv(4096) #Recieve Data -- up to 4K
print data
s.send('SSH-2.0-CLASSROOM-TEST\x0a') #send data
data = s.recv(4096)
print data
s.close() #close the connection)  "







For our lab we created a Python program to be able to talk to an HTTP server and print specific HTTP Headers



No comments:

Post a Comment