Bladeren bron

Added scripts for Malware Lab

main
kusum 3 maanden geleden
bovenliggende
commit
83afdc60ce

+ 41
- 0
GSAutomation/malware-lab/malware_main.sh Bestand weergeven

@@ -0,0 +1,41 @@
#!/bin/bash

# Prompt user for Prefix value
read -p "Enter the prefix for the hostname: " Prefix

files=( "clear.txt" "eicar.txt" "eicar_com.zip" "eicarcom2.zip" )

for file in "${files[@]}"
do
if [ ! -f "$file" ]; then
if [ "$file" == "clear.txt" ]; then
echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vel nunc ut velit porttitor congue nec a orci. Ut in massa ut sapien laoreet gravida in ac sem. Quisque et ipsum orci. Fusce diam quam, vulputate in finibus sed, pellentesque in nibh. Fusce sit amet augue quis diam ultrices auctor vel eu sem. Fusce rhoncus sit amet lectus et sollicitudin. Duis in laoreet dolor, quis porta ante. Nam pharetra nibh velit, sit amet venenatis turpis bibendum posuere. Proin volutpat sem sit amet magna scelerisque, nec eleifend neque tristique. Pellentesque in sapien sit amet magna lacinia sagittis. Aenean eget tincidunt risus, et mollis libero. Aenean vitae nisi ac velit volutpat faucibus. Proin dolor neque, congue non dictum ut, placerat vel justo. Sed pretium iaculis augue vitae dapibus. Aenean sed libero a dui ullamcorper blandit vitae eget elit. Quisque erat urna, suscipit at cursus eu, pellentesque non tortor.

Mauris rutrum porttitor ex, eu posuere nunc vehicula id. Praesent ultricies laoreet odio, non aliquam risus dapibus nec. Integer sed congue ipsum, et pellentesque mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla sollicitudin augue aliquet, egestas urna eget, tincidunt arcu. Etiam luctus semper dignissim. Praesent nec ligula eu mauris laoreet accumsan." > "$file"
elif [ "$file" == "eicar.txt" ]; then
wget https://secure.eicar.org/eicar.com.txt -O "$file" &> /dev/null
else
wget "https://secure.eicar.org/$file" &> /dev/null
fi
fi
done

# Set default values for filename and hostname
filename=${1:-"eicar.txt"}
hostname=${2:-"${Prefix}malware.gslab-juiceshop.com"}

# Ask user for input for filename, with default and example displayed
read -e -p "Enter the filename (eicar.txt, eicar_com.zip, eicarcom2.zip, clear.txt): " input

# Use user input if provided, otherwise use default
filename=${input:-$filename}

# Ask user for input for hostname, with default and example displayed
read -p "Enter the hostname (default: $hostname): " input

# Use user input if provided, otherwise use default
hostname=${input:-$hostname}

# Call upload_file.sh script with provided or default filename and hostname
echo "Running the command: ./upload_file.sh --file \"$filename\" --host \"$hostname\""
./upload_file.sh --file "$filename" --host "$hostname"

+ 14
- 0
GSAutomation/malware-lab/property/akamai.tf Bestand weergeven

@@ -0,0 +1,14 @@
terraform {
required_providers {
akamai = {
source = "akamai/akamai"
version = ">= 6.0.0"
}
}
required_version = ">= 1.0"
}

provider "akamai" {
edgerc = var.edgerc
config_section = var.section
}

+ 186
- 0
GSAutomation/malware-lab/property/property-snippets/Accelerate_delivery.json Bestand weergeven

@@ -0,0 +1,186 @@
{
"children": [
{
"behaviors": [
{
"name": "dnsAsyncRefresh",
"options": {
"enabled": true,
"timeout": "1h"
}
}
],
"comments": "Optimize the connection between edge and origin.",
"name": "Origin connectivity",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "enhancedAkamaiProtocol",
"options": {
"display": ""
}
},
{
"name": "http3",
"options": {
"enable": true
}
},
{
"name": "http2",
"options": {
"enabled": ""
}
},
{
"name": "allowTransferEncoding",
"options": {
"enabled": true
}
},
{
"name": "sureRoute",
"options": {
"enableCustomKey": false,
"enabled": true,
"forceSslForward": false,
"raceStatTtl": "30m",
"srDownloadLinkTitle": "",
"testObjectUrl": "/akamai/sureroute-test-object.html",
"toHostStatus": "INCOMING_HH",
"type": "PERFORMANCE"
}
}
],
"comments": "Serve your website using modern and fast protocols.",
"name": "Protocol optimizations",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"children": [
{
"behaviors": [
{
"name": "prefetch",
"options": {
"enabled": true
}
}
],
"children": [
{
"behaviors": [
{
"name": "prefetch",
"options": {
"enabled": false
}
}
],
"comments": "Disable prefetching for specific clients identifying themselves as bots and crawlers. This avoids requesting unnecessary resources from the origin.",
"criteria": [
{
"name": "userAgent",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"matchWildcard": true,
"values": [
"*bot*",
"*crawl*",
"*spider*"
]
}
}
],
"name": "Bots",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Define for which HTML pages prefetching should be enabled.",
"name": "Prefetching objects",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "prefetchable",
"options": {
"enabled": true
}
}
],
"comments": "Define which resources should be prefetched.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"css",
"js",
"jpg",
"jpeg",
"jp2",
"png",
"gif",
"svg",
"svgz",
"webp",
"eot",
"woff",
"woff2",
"otf",
"ttf"
]
}
}
],
"name": "Prefetchable objects",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Instruct edge servers to retrieve embedded resources before the browser requests them.",
"name": "Prefetching",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "adaptiveAcceleration",
"options": {
"abLogic": "DISABLED",
"enableBrotliCompression": true,
"enableForNoncacheable": false,
"enablePreconnect": true,
"enablePush": true,
"enableRo": false,
"preloadEnable": true,
"source": "mPulse",
"titleHttp2ServerPush": "",
"titlePreconnect": "",
"titlePreload": "",
"titleRo": ""
}
}
],
"comments": "Automatically and continuously apply performance optimizations to your website using machine learning.",
"name": "Adaptive acceleration",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control the settings related to improving the performance of delivering objects to your users.",
"name": "Accelerate delivery",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 95
- 0
GSAutomation/malware-lab/property/property-snippets/Augment_insights.json Bestand weergeven

@@ -0,0 +1,95 @@
{
"children": [
{
"behaviors": [
{
"name": "cpCode",
"options": {
"value": {
"cpCodeLimits": null,
"createdDate": 1634051944000,
"description": "Ion",
"id": 1244209,
"name": "Ion",
"products": [
"SPM"
]
}
}
}
],
"comments": "Identify your main traffic segments so you can granularly zoom in your traffic statistics like hits, bandwidth, offload, response codes, and errors.",
"name": "Traffic reporting",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "mPulse",
"options": {
"apiKey": "",
"bufferSize": "",
"configOverride": "",
"enabled": true,
"loaderVersion": "V12",
"requirePci": false,
"titleOptional": ""
}
}
],
"comments": "Collect and analyze real-user data to monitor the performance of your website.",
"name": "mPulse RUM",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "edgeScape",
"options": {
"enabled": false
}
}
],
"comments": "Receive data about a user's geolocation and connection speed in a request header. If you change cached content based on the values of the X-Akamai-Edgescape request header, contact your account representative.",
"criteria": [
{
"name": "requestType",
"options": {
"matchOperator": "IS",
"value": "CLIENT_REQ"
}
}
],
"name": "Geolocation",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "report",
"options": {
"logAcceptLanguage": false,
"logCookies": "OFF",
"logCustomLogField": false,
"logEdgeIP": false,
"logHost": false,
"logReferer": false,
"logUserAgent": false,
"logXForwardedFor": false
}
}
],
"comments": "Specify the level of detail you want to be logged in your Log Delivery Service reports. Log User-Agent Header to obtain detailed information in the Traffic by Browser and OS report.",
"name": "Log delivery",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control the settings related to monitoring and reporting. This gives you additional visibility into your traffic and audiences.",
"name": "Augment insights",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 96
- 0
GSAutomation/malware-lab/property/property-snippets/Increase_availability.json Bestand weergeven

@@ -0,0 +1,96 @@
{
"children": [
{
"behaviors": [
{
"name": "breakConnection",
"options": {
"enabled": true
}
}
],
"comments": "Simulate an origin connection problem and test the site failover configuration on the CDN staging network.",
"criteria": [
{
"name": "contentDeliveryNetwork",
"options": {
"matchOperator": "IS",
"network": "STAGING"
}
},
{
"name": "requestHeader",
"options": {
"headerName": "breakconnection",
"matchCaseSensitiveValue": true,
"matchOperator": "IS_ONE_OF",
"matchWildcardName": false,
"matchWildcardValue": false,
"values": [
"Your-Secret-Here"
]
}
}
],
"name": "Simulate failover",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "failAction",
"options": {
"enabled": false
}
}
],
"comments": "Specify how edge servers respond when the origin is not available.",
"criteria": [
{
"name": "originTimeout",
"options": {
"matchOperator": "ORIGIN_TIMED_OUT"
}
}
],
"name": "Site failover",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "healthDetection",
"options": {
"maximumReconnects": 2,
"retryCount": 3,
"retryInterval": "10s"
}
}
],
"comments": "Monitor the health of your origin by tracking unsuccessful IP connection attempts.",
"name": "Origin health",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "scriptManagement",
"options": {
"enabled": false
}
}
],
"comments": "Enable Script Management to minimize performance and availability impacts from third-party JavaScripts.",
"name": "Script management",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control how to respond when your origin or third parties are slow or even down to minimize the negative impact on user experience.",
"name": "Increase availability",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 58
- 0
GSAutomation/malware-lab/property/property-snippets/Minimize_payload.json Bestand weergeven

@@ -0,0 +1,58 @@
{
"children": [
{
"behaviors": [
{
"name": "gzipResponse",
"options": {
"behavior": "ALWAYS"
}
}
],
"comments": "Serve gzip compressed content for text-based formats.",
"criteria": [
{
"name": "contentType",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"matchWildcard": true,
"values": [
"application/*javascript*",
"application/*json*",
"application/*xml*",
"application/text*",
"application/vnd-ms-fontobject",
"application/vnd.microsoft.icon",
"application/x-font-opentype",
"application/x-font-truetype",
"application/x-font-ttf",
"application/xml*",
"font/eot*",
"font/eot",
"font/opentype",
"font/otf",
"image/svg+xml",
"image/vnd.microsoft.icon",
"image/x-icon",
"text/*",
"application/octet-stream*",
"application/x-font-eot*",
"font/ttf",
"application/font-ttf",
"application/font-sfnt",
"application/x-tgif"
]
}
}
],
"name": "Compressible objects",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control the settings that reduce the size of the delivered content and decrease the number of bytes sent by your properties. This allows you to cut down the network overhead of your website or API.",
"name": "Minimize payload",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 397
- 0
GSAutomation/malware-lab/property/property-snippets/Offload_origin.json Bestand weergeven

@@ -0,0 +1,397 @@
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "NO_STORE"
}
},
{
"name": "tieredDistribution",
"options": {
"enabled": true
}
},
{
"name": "validateEntityTag",
"options": {
"enabled": false
}
},
{
"name": "removeVary",
"options": {
"enabled": false
}
},
{
"name": "cacheError",
"options": {
"enabled": true,
"preserveStale": true,
"ttl": "10s"
}
},
{
"name": "cacheKeyQueryParams",
"options": {
"behavior": "INCLUDE_ALL_ALPHABETIZE_ORDER"
}
},
{
"name": "prefreshCache",
"options": {
"enabled": true,
"prefreshval": 90
}
},
{
"name": "downstreamCache",
"options": {
"allowBehavior": "LESSER",
"behavior": "ALLOW",
"sendHeaders": "CACHE_CONTROL",
"sendPrivate": false
}
},
{
"name": "modifyViaHeader",
"options": {
"enabled": true,
"modificationOption": "REMOVE_HEADER"
}
}
],
"children": [
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "MAX_AGE",
"mustRevalidate": false,
"ttl": "7d"
}
}
],
"comments": "Override the default caching behavior for CSS and JavaScript",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"css",
"js"
]
}
}
],
"name": "CSS and JavaScript",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "MAX_AGE",
"mustRevalidate": false,
"ttl": "30d"
}
}
],
"comments": "Override the default caching behavior for fonts.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"eot",
"woff",
"woff2",
"otf",
"ttf"
]
}
}
],
"name": "Fonts",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "MAX_AGE",
"mustRevalidate": false,
"ttl": "30d"
}
}
],
"comments": "Override the default caching behavior for images.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"jpg",
"jpeg",
"png",
"gif",
"webp",
"jp2",
"ico",
"svg",
"svgz"
]
}
}
],
"name": "Images",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "MAX_AGE",
"mustRevalidate": false,
"ttl": "7d"
}
}
],
"comments": "Override the default caching behavior for files. Files containing Personal Identified Information (PII) should require Edge authentication or not be cached at all.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"pdf",
"doc",
"docx",
"odt"
]
}
}
],
"name": "Files",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "MAX_AGE",
"mustRevalidate": false,
"ttl": "7d"
}
}
],
"comments": "Override the default caching behavior for other static objects.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"aif",
"aiff",
"au",
"avi",
"bin",
"bmp",
"cab",
"carb",
"cct",
"cdf",
"class",
"dcr",
"dtd",
"exe",
"flv",
"gcf",
"gff",
"grv",
"hdml",
"hqx",
"ini",
"mov",
"mp3",
"nc",
"pct",
"ppc",
"pws",
"swa",
"swf",
"txt",
"vbs",
"w32",
"wav",
"midi",
"wbmp",
"wml",
"wmlc",
"wmls",
"wmlsc",
"xsd",
"zip",
"pict",
"tif",
"tiff",
"mid",
"jxr",
"jar"
]
}
}
],
"name": "Other static objects",
"options": {},
"criteriaMustSatisfy": "any"
},
{
"behaviors": [
{
"name": "caching",
"options": {
"behavior": "NO_STORE"
}
},
{
"name": "cacheKeyQueryParams",
"options": {
"behavior": "IGNORE",
"exactMatch": true,
"parameters": [
"gclid",
"fbclid",
"utm_source",
"utm_campaign",
"utm_medium",
"utm_content"
]
}
}
],
"comments": "Override the default caching behavior for HTML pages cached on edge servers.",
"criteria": [
{
"name": "fileExtension",
"options": {
"matchCaseSensitive": false,
"matchOperator": "IS_ONE_OF",
"values": [
"html",
"htm",
"php",
"jsp",
"aspx",
"EMPTY_STRING"
]
}
}
],
"name": "HTML pages",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "cacheRedirect",
"options": {
"enabled": "false"
}
}
],
"comments": "Configure caching for HTTP redirects. The redirect is cached for the same TTL as a 200 HTTP response when this feature is enabled.",
"name": "Redirects",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "cachePost",
"options": {
"enabled": false
}
}
],
"comments": "Define when HTTP POST requests should be cached. You should enable it under a criteria match.",
"name": "POST responses",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "graphqlCaching",
"options": {
"enabled": false
}
}
],
"comments": "Define when your GraphQL queries should be cached.",
"criteria": [
{
"name": "path",
"options": {
"matchCaseSensitive": false,
"matchOperator": "MATCHES_ONE_OF",
"normalize": false,
"values": [
"/graphql"
]
}
}
],
"name": "GraphQL",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "downstreamCache",
"options": {
"behavior": "BUST"
}
}
],
"comments": "Configure the default client caching behavior for uncacheable content at the edge.",
"criteria": [
{
"name": "cacheability",
"options": {
"matchOperator": "IS_NOT",
"value": "CACHEABLE"
}
}
],
"name": "Uncacheable objects",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control the settings related to caching content at the edge and in the browser. As a result, fewer requests go to your origin, fewer bytes leave your data centers, and your assets are closer to your users.",
"name": "Offload origin",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 162
- 0
GSAutomation/malware-lab/property/property-snippets/Strengthen_security.json Bestand weergeven

@@ -0,0 +1,162 @@
{
"children": [
{
"behaviors": [
{
"name": "allHttpInCacheHierarchy",
"options": {
"enabled": true
}
}
],
"children": [
{
"behaviors": [
{
"name": "allowPost",
"options": {
"allowWithoutContentLength": false,
"enabled": true
}
}
],
"comments": "Allow use of the POST HTTP request method.",
"name": "POST",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "allowOptions",
"options": {
"enabled": true
}
}
],
"comments": "Allow use of the OPTIONS HTTP request method.",
"name": "OPTIONS",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "allowPut",
"options": {
"enabled": false
}
}
],
"comments": "Allow use of the PUT HTTP request method.",
"name": "PUT",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "allowDelete",
"options": {
"enabled": false
}
}
],
"comments": "Allow use of the DELETE HTTP request method.",
"name": "DELETE",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "allowPatch",
"options": {
"enabled": false
}
}
],
"comments": "Allow use of the PATCH HTTP request method.",
"name": "PATCH",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Allow the use of HTTP methods. Consider enabling additional methods under a path match for increased origin security.",
"name": "Allowed methods",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "cacheTagVisible",
"options": {
"behavior": "PRAGMA_HEADER"
}
}
],
"comments": "Do not expose back-end information unless the request contains the Pragma debug header.",
"name": "Obfuscate debug info",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "modifyOutgoingResponseHeader",
"options": {
"action": "DELETE",
"customHeaderName": "X-Powered-By",
"standardDeleteHeaderName": "OTHER"
}
},
{
"name": "modifyOutgoingResponseHeader",
"options": {
"action": "DELETE",
"customHeaderName": "Server",
"standardDeleteHeaderName": "OTHER"
}
}
],
"comments": "Do not expose back-end information unless the request contains an additional secret header. Regularly change the criteria to use a specific unique value for the secret header.",
"criteria": [
{
"name": "requestHeader",
"options": {
"headerName": "X-Akamai-Debug",
"matchCaseSensitiveValue": true,
"matchOperator": "IS_NOT_ONE_OF",
"matchWildcardName": false,
"matchWildcardValue": false,
"values": [
"true"
]
}
}
],
"name": "Obfuscate backend info",
"options": {},
"criteriaMustSatisfy": "all"
},
{
"behaviors": [
{
"name": "httpStrictTransportSecurity",
"options": {
"enable": false
}
}
],
"comments": "Require all browsers to connect to your site using HTTPS.",
"name": "HSTS",
"options": {},
"criteriaMustSatisfy": "all"
}
],
"comments": "Control the settings that minimize the information your website shares with clients and malicious entities to reduce your exposure to threats.",
"name": "Strengthen security",
"options": {},
"criteriaMustSatisfy": "all"
}

+ 50
- 0
GSAutomation/malware-lab/property/property-snippets/main.json Bestand weergeven

@@ -0,0 +1,50 @@
{
"ruleFormat": "v2024-08-13",
"comments": "Terraform property for Malware Protection Lab",
"rules": {
"name": "default",
"behaviors": [
{
"name": "origin",
"options": {
"cacheKeyHostname": "REQUEST_HOST_HEADER",
"compress": true,
"customValidCnValues": [
"{{Origin Hostname}}",
"{{Forward Host Header}}"
],
"enableTrueClientIp": true,
"forwardHostHeader": "ORIGIN_HOSTNAME",
"hostname": "${env.origin_hostname}",
"httpPort": 80,
"httpsPort": 443,
"ipVersion": "IPV4",
"originCertificate": "",
"originCertsToHonor": "STANDARD_CERTIFICATE_AUTHORITIES",
"originSni": true,
"originType": "CUSTOMER",
"ports": "",
"standardCertificateAuthorities": [
"akamai-permissive"
],
"trueClientIpClientSetting": false,
"trueClientIpHeader": "True-Client-IP",
"verificationMode": "CUSTOM",
"minTlsVersion": "DYNAMIC"
}
}
],
"children": [
"#include:Augment_insights.json",
"#include:Accelerate_delivery.json",
"#include:Offload_origin.json",
"#include:Strengthen_security.json",
"#include:Increase_availability.json",
"#include:Minimize_payload.json"
],
"comments": "The Default Rule template contains all the necessary and recommended behaviors. Rules are evaluated from top to bottom and the last matching rule wins.",
"options": {
"is_secure": "${env.secure}"
}
}
}

+ 63
- 0
GSAutomation/malware-lab/property/property.tf Bestand weergeven

@@ -0,0 +1,63 @@
data "akamai_property_rules_template" "rules-template" {
template_file = abspath("${path.root}/property-snippets/main.json")
variables {
name = "secure"
value = "${var.secure}"
type = "bool"
}
variables {
name = "cp_code_id"
value = "${var.cp_code_id}"
type = "number"
}
variables {
name = "Prefix"
value = "${var.Prefix}"
type = "string"
}
variables {
name = "origin_hostname"
value = "${var.origin_hostname}"
type = "string"
}
}

resource "akamai_property" "lab_property" {
name = "${var.Prefix}-malwarelab"
product_id = "prd_SPM"
contract_id = "ctr_${var.contract_id}"
group_id = "grp_${var.group_id}"
hostnames {
cname_from = "${var.Prefix}malware.gslab-juiceshop.com"
cname_to = var.edge_hostname
cert_provisioning_type = "CPS_MANAGED"
}
rule_format = "latest"
rules = data.akamai_property_rules_template.rules-template.json
}

resource "akamai_property_activation" "activation_staging" {
property_id = "${akamai_property.lab_property.id}"
version = "${akamai_property.lab_property.latest_version}"
network = "${var.network}"
contact = ["${var.email}"]
note = "Malware Protection Lab"
auto_acknowledge_rule_warnings = true
timeouts {
default = "1h"
}
}

data "akamai_property_hostnames" "property_hostnames" {
contract_id = "ctr_${var.contract_id}"
group_id = "grp_${var.group_id}"
property_id = "${akamai_property.lab_property.id}"
}

output "property_id" {
value = "${akamai_property.lab_property.id}"
}

output "property_hostnames" {
value = data.akamai_property_hostnames.property_hostnames.hostnames
}

+ 46
- 0
GSAutomation/malware-lab/property/variables.tf Bestand weergeven

@@ -0,0 +1,46 @@
variable "edgerc" {
type = string
default = "~/.edgerc"
}
variable "section" {
type = string
default = "protector"
}
variable "Prefix" {
type = string
}
variable "contract_id" {
type = string
default = "V-3VC1HD6"
}

variable "group_id" {
type = string
default = "202825"
}

variable "cp_code_id" {
type = number
default = 1244209
}
variable "secure" {
type = bool
default = true
}
variable "network" {
default = "staging"
}

variable "edge_hostname" {
type = string
default = "gslab-juiceshop.com.edgekey.net"
}

variable "email" {
type = string
}

variable "origin_hostname" {
type = string
default = "upload.akamaitechnicalcertification.com"
}

+ 115
- 0
GSAutomation/malware-lab/upload_file.sh Bestand weergeven

@@ -0,0 +1,115 @@
#!/bin/bash

file=''
host=''
debug=false

while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--file)
if [[ -z "$2" ]]; then
echo "Option --file requires a file path as argument, specify the file you want to upload to the server"
exit 1
fi
file="$2"
shift
shift
;;
--debug)
debug=true
shift
;;
-v)
debug=true
shift
;;
--host)
if [[ -z "$2" ]]; then
echo "Option --host requires a host name as argument, specify the hostname of the server where the upload.php script is located"
exit 1
fi
host="$2"
shift
shift
;;
-h|--help)
echo "Options:"
echo "--file <file path> - Specify the file to upload to the server"
echo "--host <host name> - Specify the hostname of the server where the upload.php script is located"
echo "-h, --help - Show this help message"
exit 0
;;
*)
if [[ $key == -* ]]; then
echo "Unknown option: $key"
else
echo "Unknown command: $key"
fi
echo "Run the script with -h or --help for a list of options"
exit 1
;;
esac
done

if [[ -z $file || -z $host ]]; then
echo "Both options --file and --host are required"
exit 1
fi

if ! [ -x "$(command -v curl)" ]; then
echo 'Error: curl is not installed.' >&2
echo 'You can install it by running: sudo apt-get install curl' >&2
exit 1
fi

if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.' >&2
echo 'You can install it by running: sudo apt-get install jq' >&2
exit 1
fi

echo "Uploading file, please wait..."

# Upload the file using curl
curl_command="curl -s -X POST -F \"uploaded_file=@$file\" https://$host/upload.php -w \"%{http_code}\""
response=$(eval $curl_command)

if $debug
then
echo "Executing the following curl command: $curl_command"
echo "Response is: $response"
fi

debug_info=$(curl -s -X POST -F "uploaded_file=@$file" https://$host/upload.php)

http_status=${response: -3}
response=${response%???}

if [[ $http_status -eq 403 ]]; then
echo -e "\e[91mError: 403 Forbidden\e[0m"
echo -e "\e[91mThe server did not allow the file to be uploaded\e[0m"
debug_info=$(echo "$debug_info" | sed -r 's/Reference&#32;&#35;/Reference #/g' | sed -r 's/&#46;/./g')
reference=$(echo "$debug_info" | grep -oP 'Reference #\K[^<]+')
echo -e "\e[91mReference ID is: $reference\e[0m"
exit 1
elif [[ $http_status -eq 404 ]]; then
echo -e "\e[91mError: 404 Not Found\e[0m"
echo -e "\e[91mThe upload.php script could not be located on the server\e[0m"
debug_info=$(echo "$debug_info" | sed -r 's/Reference&#32;&#35;/Reference #/g' | sed -r 's/&#46;/./g')
reference=$(echo "$debug_info" | grep -oP 'Reference #\K[^<]+')
echo -e "\e[91mReference ID is: $reference\e[0m"
exit 1
fi

success=$(echo $response | jq -r '.success')
error=$(echo $response | jq -r '.error')
file_path=$(echo $response | jq -r '.file_path')

if [[ $success != "null" ]]; then
echo -e "\e[92mSuccess: $success\e[0m"
echo -e "\e[92mThe file was successfully uploaded and was stored as $file_path\e[0m"
else
echo -e "\e[91mError: $error\e[0m"
fi

+ 8
- 0
GSAutomation/scripts/malwarelab.sh Bestand weergeven

@@ -0,0 +1,8 @@
#!/bin/bash

echo $PWD &&
cd malware-lab/property &&
terraform init &&
terraform plan -out=.plan &&
terraform apply .plan &&
cd $OLDPWD

Laden…
Annuleren
Opslaan