mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
Dynamic (#77)
This commit is contained in:
parent
55247b7fcd
commit
991c84a1eb
1464 changed files with 225448 additions and 1985 deletions
|
|
@ -0,0 +1,21 @@
|
|||
"""Phase 20 (Track M.2) — Google Pub/Sub Python benign control."""
|
||||
import os
|
||||
import shlex
|
||||
|
||||
_NYX_ADAPTER_MARKER = "from google.cloud import pubsub_v1"
|
||||
_NYX_TOPIC_MARKER = '.subscribe("projects/p/subscriptions/s"'
|
||||
|
||||
|
||||
def callback(message):
|
||||
body = getattr(message, 'data', None)
|
||||
if body is None and isinstance(message, dict):
|
||||
body = message.get('data')
|
||||
if isinstance(body, (bytes, bytearray)):
|
||||
body = body.decode('utf-8', 'replace')
|
||||
if body is None:
|
||||
body = str(message)
|
||||
os.system("echo " + shlex.quote(body))
|
||||
try:
|
||||
message.ack()
|
||||
except Exception:
|
||||
pass
|
||||
28
tests/dynamic_fixtures/message_handler/pubsub_python/vuln.py
Normal file
28
tests/dynamic_fixtures/message_handler/pubsub_python/vuln.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Phase 20 (Track M.2) — Google Pub/Sub Python vuln fixture.
|
||||
|
||||
`callback` is a `pubsub_v1.SubscriberClient.subscribe` callback that
|
||||
takes `message.data` bytes straight into a shell command.
|
||||
|
||||
Adapter marker kept as a string literal so the google-cloud-pubsub dep
|
||||
is not required to load the module.
|
||||
"""
|
||||
import os
|
||||
|
||||
_NYX_ADAPTER_MARKER = "from google.cloud import pubsub_v1"
|
||||
_NYX_TOPIC_MARKER = '.subscribe("projects/p/subscriptions/s"'
|
||||
|
||||
|
||||
def callback(message):
|
||||
body = getattr(message, 'data', None)
|
||||
if body is None and isinstance(message, dict):
|
||||
body = message.get('data')
|
||||
if isinstance(body, (bytes, bytearray)):
|
||||
body = body.decode('utf-8', 'replace')
|
||||
if body is None:
|
||||
body = str(message)
|
||||
# SINK: tainted message body concatenated into shell command
|
||||
os.system("echo " + body)
|
||||
try:
|
||||
message.ack()
|
||||
except Exception:
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue