IPCalcReturnAddressBinary
An automation script to return address in binary format.
python · Community Common Scripts
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 from CommonServerUserPython import * import ipaddress import traceback """ COMMAND FUNCTION """ def return_address_binary_command(args: Dict[str, Any]) -> CommandResults: ip_address = args.get("ip_address", None) ip_binary = str(ipaddress.ip_address(ip_address).__format__("b")) binary_object = {"address": ip_address, "binary": ip_binary} readable_output = tableToMarkdown(t=binary_object, name="Subnet Binary") return CommandResults( outputs_prefix="IPCalc.IP.Binary", outputs_key_field="", readable_output=readable_output, outputs=binary_object ) """ MAIN FUNCTION """ def main(): try: return_results(return_address_binary_command(demisto.args())) except Exception as ex: demisto.error(traceback.format_exc()) return_error(f"Failed to execute IPCalcReturnSubnetBinary. Error: {str(ex)}") """ ENTRY POINT """ if __name__ in ("__main__", "__builtin__", "builtins"): main()
README
An automation script to return address in binary format
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| ip_address | Address to use |
Outputs
| Path | Description | Type |
|---|---|---|
| IPCalc.IP.Binary.binary | Subnet binary | String |
| IPCalc.IP.Binary.address | IP address | String |
Script Example
!IPCalcReturnAddressBinary ip_address=192.158.2.2
Context Example
{
"IPCalc": {
"IP": {
"Binary": {
"address": "192.158.2.2",
"binary": "11000000100111100000001000000010"
}
}
}
}
Human Readable Output
Subnet Binary
address binary 192.158.2.2 11000000100111100000001000000010