MCPcopy Index your code
hub / github.com/Splinter0/tensorflow-rce / detect

Function detect

dector.py:6–30  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

4import base64
5
6def detect(path):
7 print("Checking model", path)
8
9 with open(path, "rb") as f:
10 content = f.read().decode("latin-1")
11
12 body = re.search("{(.*)}", content).group()
13 model = json.loads(body)
14 found = 0
15 for layer in model["config"]["layers"]:
16 if layer['class_name'] != "Lambda":
17 continue
18
19 print("\nFound Lambda layer with name \"" + layer["config"]["name"] + "\"")
20
21 func = layer["config"]["function"]
22 print("With body function:")
23 print("Raw base64:")
24 print(func[0])
25 decoded = base64.b64decode(func[0]).decode("latin-1")
26 print("Decoded:")
27 print(decoded)
28 found += 1
29
30 print("\nFound {} Lambda functions".format(found))
31
32
33if __name__ == "__main__":

Callers 1

dector.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected