User Input in Tanium package scripts must be decoded before use

From RiceFamily Wiki
Jump to: navigation, search

Summary of Email from Chad Johnson addressing an issue with user input in Packages and Sensors.

When creating platform packages or custom sensors which make use of run-time, user level input, the data input by the user will be percent encoded prior to transmission to the endpoint. To use this data within the package or sensor, the data must first be un-encoded.

If you are writing content for Windows endpoints, below is powershell code to decode the string(s) passed at runtime.

 $encoded = "Hello+World%21"
 $encoded = $encoded -replace '\+', ' '  # Replace + with space
 $decoded = [System.Uri]::UnescapeDataString($encoded)
 Write-Output $decoded

I asked the DeepSeek AI how to decode User Input in Tanium packages and this was it's response.

 import sys
 from urllib.parse import unquote
 
 def decode_url(encoded_input):
     """Decode URL-encoded input."""
     try:
         decoded_string = unquote(encoded_input)
         return decoded_string
     except Exception as e:
         return f"Error decoding input: {e}"
 
 def main():
     if len(sys.argv) < 2:
         print("Usage: python decode_input.py <encoded_input>")
         sys.exit(1)
 
     encoded_input = sys.argv[1]
     decoded_output = decode_url(encoded_input)
     print(f"Decoded input: {decoded_output}")
 
 if __name__ == "__main__":
     main()