RemoveNullBytes

Removes null bytes from string.

python · Filters And Transformers

Details

IDRemoveNullBytes
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsgeneral transformer

README

Removes null bytes from string.

Script Data


Name Description
Script Type python3
Tags general, transformer

Inputs


Argument Name Description
value The string value to remove null bytes

Outputs


There are no outputs for this script.

import pytest
import base64
from RemoveNullBytes import removenullbytes

"""
First base64 encoded data when decoded contains null bytes
"""


@pytest.mark.parametrize(
    "value, expected_result",
    [
        ("cABvAHcAZQByAHMAaABlAGwAbAAuAGUAeABlAA==", "powershell.exe"),
        ("Y21kLmV4ZQ==", "cmd.exe"),
    ],
)
def test_removenullbytes(value, expected_result):
    base64decoded = base64.b64decode(value).decode("latin1")
    value = removenullbytes(base64decoded)
    assert value == expected_result