Created
April 29, 2013 22:16
-
-
Save daryo918/5485244 to your computer and use it in GitHub Desktop.
shell python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import time | |
print """ | |
-------------------- | |
| cliente | | |
-------------------- | |
instrucciones: | |
1. se recomienda no enviar comandos que se redireccionen por ejemplo: echo h > hola. | |
2.para que el server se desconecte presione enter sin poner nada. | |
3.si va a probar este programa en localhost ponga la ip del pc en la lan. No use 127.0.0.1 o localhost. | |
""" | |
def shell(): | |
print "conectado" | |
while 1: | |
data = raw_input(">") | |
clientsocket.send(data) | |
if not data: break | |
newdata = clientsocket.recv(6024) | |
print newdata | |
pino = raw_input("inserte la ip del servidor > ") | |
clientsocket = socket.socket() | |
try: | |
clientsocket.connect((pino, 7000)) | |
shell() | |
except: | |
print "ha sucedido un error en la conexion, este programa se cerrara en 5 segundos" | |
time.sleep(6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import os | |
import os.path | |
serversocket=socket.socket() | |
serversocket.bind(( socket.gethostname(),7000)) | |
serversocket.listen(40) | |
clientsocket , addr = serversocket.accept() | |
def proxy(): | |
yemeth = os.name | |
if yemeth == "posix": | |
os.system("cd $home") | |
else: | |
os.system("cd %HOMEPATH%") | |
while 1: | |
if os.path.isfile("bad"): | |
os.remove("bad") | |
data = clientsocket.recv(1024) | |
if not data: break | |
datos = data + "> bad" | |
mayer = os.system(datos) | |
if mayer != 0: | |
clientsocket.send("error") | |
else: | |
inp = open("bad","r") | |
aarchivo = inp.read() | |
if aarchivo != "": | |
clientsocket.send(aarchivo) | |
else: | |
os.system("echo comando sin respuesta > bad") | |
aarchivo = inp.read() | |
clientsocket.send(aarchivo) | |
inp.close() | |
proxy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment