forked from tushargoyal02/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpytelnet_server.py
More file actions
46 lines (29 loc) · 847 Bytes
/
pytelnet_server.py
File metadata and controls
46 lines (29 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!usr/bin/python
import socket
# type of ip , type of protocol
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
#bind current ip and port
s.bind(("192.168.102.128",8000))
#buffer size to recieve
user=s.recvfrom(10)
password=s.recvfrom(10)
if user[0] == 'root' and password =='123' :
s.sendto("allow",password[1]) #ip of client
#print s.recvfrom(10)
for i in range(10000): #to get from all clients
data=s.recvfrom(100)
#showing client ip and port
print commands.getout(data[0])
#return something to client
s.sendto(output,data[1])
else :
print "bad username and password"
s.sendto("login failed",password[1])
'''
for i in range(10000): #to get from all clients
data=s.recvfrom(100)
if 'date' in data[0]:
print commands.getoutput('date')
elif 'cal' in data[0]
print commands.getoutput('cal')
'''