-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwild.py
75 lines (71 loc) · 4.36 KB
/
wild.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
from git import Repo
import os,platform,boto3
import shutil, time
import uuid,datetime
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
time.sleep(10)
dirpath = os.path.join('plz_del')
if os.path.exists(dirpath) and os.path.isdir(dirpath):
shutil.rmtree(dirpath)
Repo.clone_from("https://github.com/chanduusc/malware.git", "plz_del")
unique_malware_filename = str(uuid.uuid4().hex)+ '-' + str(datetime.datetime.now().time()).replace(':', '-').replace('.', '-')
unique_sensitive_filename = str(uuid.uuid4().hex)+ '-' + str(datetime.datetime.now().time()).replace(':', '-').replace('.', '-') + '.docx'
unique_hipaa_filename = str(uuid.uuid4().hex)+ '-' + str(datetime.datetime.now().time()).replace(':', '-').replace('.', '-') + '.csv'
cloud_provider = platform.uname()[2]
if 'amzn' in cloud_provider:
s3 = boto3.resource('s3')
bucketname = os.environ.get("S3_BUCKET_NAME") if "S3_BUCKET_NAME" in os.environ else "cnappdemo"
s3.meta.client.upload_file('/plz_del/FritzFrog/001eb377f0452060012124cb214f658754c7488ccb82e23ec56b2f45a636c859', bucketname, unique_malware_filename)
s3.meta.client.upload_file('/plz_del/FritzFrog/10-MB-Test.docx', bucketname, unique_sensitive_filename, ExtraArgs={'ACL':'public-read'})
s3.meta.client.upload_file('/plz_del/FritzFrog/clia-lab-search-results-02.22.2023-19_43_13.csv', bucketname, unique_hipaa_filename, ExtraArgs={'ACL':'public-read'})
elif 'azure' in cloud_provider:
blob_endpoint = os.environ["BLOB_ENDPOINT"] if "BLOB_ENDPOINT" in os.environ else "https://cnappdemo.blob.core.windows.net/"
container_name = os.environ["CONTAINER_NAME"] if "CONTAINER_NAME" in os.environ else "cnappdemo"
default_credential = DefaultAzureCredential()
blob_service_client = BlobServiceClient(blob_endpoint,credential=default_credential)
container_client = blob_service_client.get_container_client(container_name)
with open('/plz_del/FritzFrog/001eb377f0452060012124cb214f658754c7488ccb82e23ec56b2f45a636c859', "rb") as data:
blob_client = container_client.upload_blob(name=unique_malware_filename, data=data)
with open('/plz_del/FritzFrog/10-MB-Test.docx', "rb") as data:
blob_client = container_client.upload_blob(name=unique_sensitive_filename, data=data)
with open('/plz_del/FritzFrog/clia-lab-search-results-02.22.2023-19_43_13.csv', "rb") as data:
blob_client = container_client.upload_blob(name=unique_hipaa_filename, data=data)
else:
next
hostName = "0.0.0.0"
serverPort = 8080
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<html><head><title>Prisma Cloud CNAPP Darwin Demo with out policy</title></head>", "utf-8"))
self.wfile.write(bytes("<html><head><title>Prisma Cloud Demo without block policy</title></head>", "utf-8"))
self.wfile.write(bytes("<p>Host Requested: %s</p>" % self.headers.get('Host'), "utf-8"))
self.wfile.write(bytes("<p>XFF Requested: %s</p>" % self.headers.get("X-Forwarded-For"), "utf-8"))
self.wfile.write(bytes("<p>Command: %s</p>" % self.command, "utf-8"))
self.wfile.write(bytes("<p>HTTP Req version: %s</p>" % self.request_version, "utf-8"))
self.wfile.write(bytes("<p>Path: %s</p>" % self.path, "utf-8"))
self.wfile.write(bytes("<p>Requestor: %s</p>" % self.request.getpeername()[0], "utf-8"))
self.wfile.write(bytes("<body>", "utf-8"))
self.wfile.write(bytes("<p>Demo Server- CNAPP Demo</p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "utf-8"))
def do_OPTIONS(self):
self.send_response(200, "ok")
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
self.send_header("Access-Control-Allow-Headers", "X-Requested-With")
self.send_header("Access-Control-Allow-Headers", "Content-Type")
self.end_headers()
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")