Hi
I keep on getting data altered when I receive it
example:
SAM:~ SamarthAgarwal$ telnet 192.168.1.39 8888
Trying 192.168.1.39...
Connected to 192.168.1.39.
Escape character is '^]'.
--Welcome To HACKNET--
Username:
Admin
Password:
pass
--INCORRECT IDENTIFICATION--Connection closed by foreign host.
SAM:~ SamarthAgarwal$
the data on the server side:
('192.168.1.39', 57727) client tried to connect with username: Admin
and password: pass
the data always has a extra space so i added an extra space to the password
but it still doesn't work.
Code:
#!/usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is HACKNET.
#
# The Initial Developer of the Original Code is
# Samarth Agarwal.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK *****
import socket
import threading
import shelve
import SETTINGS
class Server:
def __init__(self):
self.username = ""
self.password = ""
print "Server Running At:", SETTINGS.host
def login(self):
host = SETTINGS.host
port = SETTINGS.port
backlog = 5
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(backlog)
while 1:
client, address = s.accept()
client.send( SETTINGS.welcome)
client.send("\nUsername:\n")
self.username = str(client.recv(size))
client.send("Password:\n")
self.password = str(client.recv(size))
if self.username == SETTINGS.username:
if self.password == SETTINGS.password:
client.send(("Loged in as :\n", SETTINGS.username))
break
else:
client.send("--INCORRECT IDENTIFICATION--")
print client.getpeername(),"client tried to connect with username:",self.username," and password:",self.password
client.close()
print SETTINGS.password
print SETTINGS.username
server = Server()
server.login()
the SETTINGS module/file:
#HACKNET Settings file
host = "192.168.1.39"
port = 8888
username = "Admim"
password = "pass"
welcome = "--Welcome To HACKNET--"
help