コード例 #1
0
def lambda_handler(event, context):
    urllib3.disable_warnings()
    http = urllib3.PoolManager()
    response = http.request('GET', url1, preload_content=False, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'})
    data = json.loads(response.data.decode('utf-8'))
    tag = data['tag_name']
    location = url2 + tag + "/frida-server-" + tag + "-android-arm.xz"
    filename = ("frida-server-" + tag + "-android-arm.xz")
    request = http.request('GET', location, preload_content=False, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'})
    fileobj = request
    path = f"s3://{bucket}/{filename}"
#    log.info(f"Uploading file to {path}")
    s3.upload_fileobj(fileobj, bucket, filename)
    return {
        "statusCode": 200,
        "body": json.dumps('Upload Successful')
    }
コード例 #2
0
ファイル: main.py プロジェクト: todun/python-lambda-local
import logging
import os
import timeit
from botocore.vendored.requests.packages import urllib3
import multiprocessing

from . import event
from . import context
from .environment_variables import set_environment_variables, export_variables
from .timeout import time_limit
from .timeout import TimeoutException

logging.basicConfig(stream=sys.stdout,
                    level=logging.INFO,
                    format='[%(name)s - %(levelname)s - %(asctime)s] %(message)s')
urllib3.disable_warnings()


ERR_TYPE_EXCEPTION = 0
ERR_TYPE_TIMEOUT = 1

EXITCODE_ERR = 1


class ContextFilter(logging.Filter):
    def __init__(self, context):
        super(ContextFilter, self).__init__()
        self.context = context

    def filter(self, record):
        record.aws_request_id = self.context.aws_request_id
コード例 #3
0
import re
import json
import boto3
import arrow
from os import getenv as env
from operator import itemgetter
from urllib.parse import urljoin

from botocore.exceptions import ClientError
from botocore.vendored import requests

from botocore.vendored.requests.packages import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

API_KEY = env('API_KEY')
VPSA_HOST = env('VPSA_HOST')
METRIC_INTERVAL = env('METRIC_INTERVAL', 30)
METRIC_NAMESPACE = env('METRIC_NAMESPACE')
LAST_MESSAGE_ID_PARAM_NAME = env('LAST_MESSAGE_ID_PARAM_NAME')
VPSA_LOG_GROUP_NAME = env('VPSA_LOG_GROUP_NAME')
AWS_PROFILE = env('AWS_PROFILE')

if AWS_PROFILE is not None:
    boto3.setup_default_session(profile_name=AWS_PROFILE)

cw = boto3.client('cloudwatch')
ssm = boto3.client('ssm')
cwlogs = boto3.client('logs')
s = requests.Session()
s.headers.update({'X-Access-Key': API_KEY})
コード例 #4
0
ファイル: s3.py プロジェクト: adam-douglass/assemblyline-base
import logging
import os
import tempfile

from botocore.exceptions import ClientError, EndpointConnectionError, ConnectionClosedError
from io import BytesIO

from assemblyline.common.exceptions import ChainAll
from assemblyline.filestore.transport.base import Transport, TransportException

try:
    from botocore.vendored.requests.packages.urllib3 import disable_warnings
except ImportError:
    from urllib3 import disable_warnings

disable_warnings()
"""
This class assumes a flat file structure in the S3 bucket.  This is due to the way the AL datastore currently handles
file paths for local/ftp datastores not playing nicely with s3 constraints.
"""


@ChainAll(TransportException)
class TransportS3(Transport):
    DEFAULT_HOST = "s3.amazonaws.com"

    def __init__(self,
                 base=None,
                 accesskey=None,
                 secretkey=None,
                 aws_region=None,
コード例 #5
0
import re
import json
import boto3
import arrow
from os import getenv as env
from operator import itemgetter
from urllib.parse import urljoin

from botocore.exceptions import ClientError
from botocore.vendored import requests

from botocore.vendored.requests.packages import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

API_KEY = env('API_KEY')
VPSA_HOST = env('VPSA_HOST')
METRIC_INTERVAL = env('METRIC_INTERVAL', 30)
METRIC_NAMESPACE = env('METRIC_NAMESPACE')
LAST_MESSAGE_ID_PARAM_NAME = env('LAST_MESSAGE_ID_PARAM_NAME')
VPSA_LOG_GROUP_NAME = env('VPSA_LOG_GROUP_NAME')
AWS_PROFILE = env('AWS_PROFILE')

if AWS_PROFILE is not None:
    boto3.setup_default_session(profile_name=AWS_PROFILE)

cw = boto3.client('cloudwatch')
ssm = boto3.client('ssm')
cwlogs = boto3.client('logs')
s = requests.Session()
s.headers.update({'X-Access-Key': API_KEY})
コード例 #6
0
import json
import logging
import uuid
import os
import timeit
from botocore.vendored.requests.packages import urllib3

import event
import context
from timeout import time_limit
from timeout import TimeoutException

logging.basicConfig(stream=sys.stdout,
                    level=logging.INFO,
                    format='[%(name)s - %(levelname)s - %(asctime)s] %(message)s')
urllib3.disable_warnings()


def run(args):
    e = event.read_event(args.event)
    c = context.Context(args.timeout)
    if args.library is not None:
        load_lib(args.library)
    request_id = uuid.uuid4()
    func = load(request_id, args.file, args.function)

    logger = logging.getLogger()
    result = None

    logger.info("Event: {}".format(e))
コード例 #7
0
import os
import click
import boto3
import botocore
import dpath.util

import botocore.vendored.requests.packages.urllib3 as urllib3

urllib3.disable_warnings(urllib3.exceptions.SecurityWarning)

from base64 import b64decode

from .base import BaseHelper


# TODO: Better permissions checking
class AWSHelper(BaseHelper):
    def __init__(self):
        self._session = boto3.session.Session()

    def codepipeline_get_artifacts_revision(self):
        CODEBUILD_BUILD_ID = os.getenv('CODEBUILD_BUILD_ID')
        CODEBUILD_INITIATOR = os.getenv('CODEBUILD_INITIATOR')

        if not CODEBUILD_BUILD_ID or not CODEBUILD_INITIATOR:
            return None

        (service, pipeline_name) = CODEBUILD_INITIATOR.split('/')
        client = self._session.client('codepipeline')
        response = client.get_pipeline_state(name=pipeline_name)