I have written a telnet-like program to execute commands on a remote system. First, run the server, then when ever someone else someone connects you can send them commands and receive the command jazz. If more than one client connects you can use the command 'changeclient' to change the client.
If you still don't get it I will be posting a video later tonight.
Here is my webpage...errrrr.....if you call it that: rexploits.netai.net/pynet.html
Server
#This is a simple telnet-type server.
#It will only work with my client.
#To get my client go to rexploits.netai.net/pynet.html
#To change the port change this variable(Making a config file atm) The default is port 5000
PORT = 5000
from socket import *
import time
BUFSIZE = 1024
ADDRESS = ('', PORT) # '' = all addresses.
server = socket(AF_INET, SOCK_STREAM)
server.bind(ADDRESS)
server.listen(5)
# print stuff the user needs to know
print ''
print ' ____ _____ ___ _______ '
print ' / \ | | / \ /____\ | '
print '| | | | | | | | '
print ' \____/ \____/| | | \____/ | v0.62'
print ' | | '
print ' | | '
print ' | | '
print ' | \_____/ '
print 'Contact Rex for any bug reports at rexploits@gmail.com'
print '\n'
print 'Please input the command when prompted with \'>\''
print 'The stdout stuff will be in this format: '
print ' (<stdout>, <stderr>) '
print 'Type: pynethelp for PyNet commands.\n'
while True:
STOP_SERVER = 0 #Setting command to something other than '1'
print '\nWaiting for connections...'
client, address = server.accept()
print '...client connected from ', address[0]
while True:
command = raw_input('\n> ')
if command == 'stop':
STOP_SERVER = 1
client.close()
break
elif command == 'stopclient':
client.send('stopclient')
time.sleep(1)
clientClose = client.recv(1024)
print clientClose
client.close()
break
elif command == 'changeclient':
print 'Changing clients.....\n'
client.send('changeclient')
break
elif command == 'pynethelp':
print '\n==========HELP=========='
print 'stop Stop the server, client throws an error(BUG)'
print 'stopclient Stop the current connected client, have to stop all clients individually'
print 'changeclient Switches that is currently connected'
print 'pynethelp Display this menu'
print '========================\n'
else:
client.send(command)
commandJazz = client.recv(BUFSIZE)
print commandJazz
if STOP_SERVER == 1:
print 'Closing server......'
time.sleep(2)
print 'Goodbye!'
time.sleep(1)
break
server.close()
Client
#Author: Rex McKinnon
#Website: rexploits.netai.net
#Client for my server
#requries ChangeClient.py to be in the same folder
#To change your IP, change this variable(localhost is default)if it is just numbers do not put '' around it.
IP = 'localhost'
from subprocess import *
from socket import *
import os
PORT = 5000
BUFSIZE = 1024
ADDRESS = (IP, PORT)
server = socket(AF_INET, SOCK_STREAM)
server.connect(ADDRESS)
while True:
command = server.recv(BUFSIZE)
if command == 'changeclient':
server.close()
os.system('ChangeClient.py')
elif command == 'stopclient':
server.send('Client Disconnecting...')
server.close()
else:
executeIt = Popen(command, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE)
commandJazz = executeIt.communicate()
strCommandJazz = str(commandJazz)
server.send(strCommandJazz)
print strCommandJazz
ChangeClient.py
Required to be in the same directory as Client.py for changeclient command to work.
#Put this in the same directory as Client.py
import os
import time
time.sleep(2)
os.system('Client.py') # Client.py should be the name of your client file(The default is client.py)