Professional Documents
Culture Documents
It System Security Laboratory Experiment No. 2 (Part 1)
It System Security Laboratory Experiment No. 2 (Part 1)
Q1.
import tkinter as tk
from tkinter import Button
win=tk.Tk()
win.title('LOGIN PAGE')
win.geometry('300x300')
title1=tk.Label(win,text='CHAT APPLICATION')
title1.place(x=30,y=1)
lab1=tk.Label(win,text='Enter:')
lab1.place(x=2,y=30)
def checkcreds():
u=entry1.get()
info=tk.Label(win, text=u)
info.place(x=90,y=90)
button1=Button(win,text='Submit',command=checkcreds)
button1.place(x=30,y=55)
entry1=tk.Entry(win)
entry1.place(x=45,y=30)
Q2.
import tkinter as tk
from tkinter import Button
win=tk.Tk()
win.title('CHAT BOT')
win.geometry('300x100')
def meth1():
print('new')
def meth2():
print('open')
button1=Button(win,text='New',command=meth1)
button1.place(x=10,y=10)
button2=Button(win,text='Open',command=meth2)
button2.place(x=60,y=10)
IT SYSTEM SECURITY LABORATORY
EXPERIMENT NO. 2 (PART 2)
s.bind(('', port))
print("socket binded to %s %(port)")
s.listen(5)
print("socket is listening")
while True:
c, addr = s.accept()
print ('Got connection from', addr)
print(10*(repr(c.recv(1024))))
c.send(b'Thank you for connecting')
c.close()
Client:
import socket
s = socket.socket()
port = 12345
s.connect(('127.0.0.1', port))
s.send(b'Network Programming')
print((repr(s.recv(1024))))
s.close()
def getipaddress():
host=gethostname()
try:
hostip=gethostbyname(host)
print("IP address: "+hostip)
except:
print("Unable to get ip address")
def getservname():
try:
serv=getfqdn()
print("Server name: "+serv)
except:
print("Unable to get server name")
def getservip():
host=getservname()
try:
hostip=gethostbyname(host)
print("Server IP address: "+hostip)
except:
print("Unable to get server ip address")
while ch<6:
print("MENU DRIVEN PROGRAM")
print("\n 1. Get local host name")
print("\n 2. Get local host IP address")
print("\n 3. Get server name at local host")
print("\n 4. Get IP address of server")
print("\n 5. Exit")
if ch==1:
getlocalhostname()
elif ch==2:
getipaddress()
elif ch==3:
getservname()
elif ch==4:
getservip()
elif ch==5:
print("Exiting...")
exit()
Q3. Write a program to show whether platform is big endian or little endian.
Ans.
import sys
print()
if sys.byteorder == "little":
print("Little-endian platform.")
else:
print("Big-endian platform.")
print()
Q4. Write a program to convert network byte order to host byte order and vice versa.
Ans.
import socket
from socket import *
ch,num1,num2=0,0,0
def HostToNetwork(num1):
res=htons(num1)
print(res)
def NetworkToHost(num2):
res=ntohs(num2)
print(res)
while ch<4:
if ch==1:
num1=int(input("Enter number - "))
HostToNetwork(num1)
elif ch==2:
num2=int(input("Enter number - "))
NetworkToHost(num2)
elif ch==3:
print("Exiting....")
exit(0)