Instructions: Each line of code is to be explained in a comment. I have provided an example for the first line of code. I want to know what the statement is doing, i.e. creating a function, using module, assigning a value and specifically what is the variable, function, parameters etc… Answer, What will be printed and What is the output in a comment The use of Python Library 2.7 may necessary to complete the assignment. 1. # port variable is being assigned an integer value of 21 port = 21 #banner is being assigned the string FreeFloat FTP Server banner = “FreeFloat FTP Server” #combines banner and port while adding Checking for and on print “[+] Checking for “+banner+” on port “+str(port) #prints out: [+]Checking for FreeFloat FTP Server on port 21 What will be printed banner = “FreeFloat FTP Server” Type(banner) port = 21 portList= [21,22,80,110] type(portList) portOpen = True type(portOpen) 2. banner = “FreeFloat FTP Server” print banner.upper( ) What will be printed print banner.lower( ) What will be printed print banner.replace (‘FreeFloat’ , ‘Ability’) What will be printed print banner.find(‘FTP’) 3. portList = [ ] portList.append(21) portList.append(80) portList.append(443) portList.append(25) print portList What will be printed portList.sort( ) print portList What will be printed pos = portList.index(80) print “[+] There are “+str(pos)+” ports to scan before 80.” What will be printed portList.remove(443) print portList What will be printed cnt = len(portList) print “[+] Scanning “+str(cnt)+” Total Ports.” What will be printed 4. services = {‘ftp’:21, ‘ssh’:22, ‘smtp’:25, ‘http’:80} services.keys( ) What will be the output service.item( ) What will be output services.has_key(‘ftp’) What will be output services[‘ftp’] What will be output print “[+] found vuln with FTP on port “+str(servies[‘ftp’]) What will be printed 5. import socket def retBanner(ip, port): try: socket.setdefaulttimeout(2) s = socket.socket( ) s.connect( ( ip, port)) banner = s.recv(1024) return banner except: return def main( ): ip1 = ‘192.168.95.148’ ip2 = ‘192.168.95.149’ port = 21 banner1 = retBanner(ip1, port) if banner1: print ‘[+] ‘ + ip1 + ‘ : ‘ + banner1 if banner2: print ‘[+] ‘ + ip1 + ‘ : ‘ + banner1 if __name__ == ‘ __main__’: main( )
for the chunk 1:
line 2 and 10 is assigning the port number to be the 21
line 4 and 8 is assigning the banner to be the "Free Float FTP server"
line 9 is giving the type of the banner variable which is string
line 11 is creating an array of 4 variable
line 12 is giving the type of portlist variable which is the array
line 13 is creating a boolean variable
and line 14 is giving the type of the var portOpen which is the boolean
for the second chunk
line 2 will print the whole string in the upper case lettters. ("FreeFloat FTP Server")
line 3 will print the whole string in the lower case letters ("freefloat ftp server")
line 4 will replace FreeFloat to the ability Now banner becomes ("Ability FTP Server")
line 5 will return the starting index of the substring which is the 10
for the third chunk
line 6 will print [21,80,443,25]
line 8 will print [21,25,80,443]
line 10 will print "[+] There are 2 ports to scan before 80"
line 12 will print [21,25,80]
line 14 will print "[+] Scanning 3 Total Ports"
for the FOurth chunk
line 2 will return all the keys ["ftp","ssh","smtp","http"]
line 3 will return list of items [21,22,25,80]
line 4 will return True because dictionary has the key "Ftp"
line 5 will return 21 which is the value at a"ftp" key
line 6 will print "[+] found vuln with FTP on port 21"
for the fifth chunk
first of all, there is an error at line 16 because banner2 is not in the context
otherwise, this will print "[+] 192.168.95.148 : Ability FTP Server"
Any problem ask me in the comment section
Thumbs up is appreciated.
Instructions: Each line of code is to be explained in a comment. I have provided an...
166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls and Os) goes in and out of a machine physically is through the NIC (network interface card). The way network communication goes in and out of a machine logically though, is through a program or service. A service is a program that runs in the background, independent of a logon, that provides functionalities to a system. Windows client machines, for instance, have a Workstation...