-1

I have a task which is to extract and analyse a payload. the payload is stored in the array below:

byte[] source = new byte[449]
            {
                252, 72, 131, 228, 240, 232, 204,
                0, 0, 0, 65, 81, 65, 80,
                82, 81, 72, 49, 210, 86,
                101, 72, 139, 82, 96, 72, 139,
                82, 24, 72, 139, 82, 32,
                72, 139, 114, 80, 77, 49, 201, 72,
                15, 183, 74, 74, 72, 49, 192, 172,
                60, 97, 124, 2, 44, 32,
                65, 193, 201, 13, 65, 1, 193, 226,
                237, 82, 72, 139,82, 32, 139, 66,
                60, 72, 1, 208, 102, 129, 120, 24, 11,
                2,65, 81, 15, 133, 114, 0, 0, 0,
                139, 128, 136, 0, 0, 0, 72, 133,
                192, 116, 103, 72, 1, 208, 80, 139,
                72, 24, 68, 139, 64, 32, 73, 1, 208,
                227, 86, 72, 255, 201, 65, 139, 52, 136,
                72, 1, 214, 77, 49, 201, 72, 49,
                192, 172, 65, 193, 201, 13, 65, 1,
                193, 56, 224, 117, 241, 76, 3, 76,
                36, 8, 69, 57, 209, 117, 216, 88, 68,
                139, 64, 36, 73, 1, 208, 102, 65, 139,
                12, 72, 68, 139, 64, 28, 73, 1, 208,
                65, 139, 4, 136, 65, 88, 65, 88,
                72, 1, 208, 94, 89, 90, 65, 88, 65,
                89, 65, 90, 72, 131, 236, 32, 65,
                82, 255, 224, 88, 65, 89, 90, 72, 139, 18,
                233, 75, 255, 255, 255, 93, 73,
                190, 119, 115, 50, 95, 51, 50, 0, 0,
                65, 86, 73, 137, 230, 72, 129,
                236, 160, 1, 0, 0, 73, 137, 229, 73,
                188, 2, 0, 1, 187, 51, 161, 134, 90,
                65, 84, 73, 137, 228, 76, 137, 241,
                65, 186, 76, 119, 38, 7, 255, 213, 76,
                137, 234, 104, 1, 1, 0, 0, 89,
                65, 186, 41, 128, 107, 0, 255, 213, 106, 10,
                65, 94, 80, 80, 77, 49, 201,77, 49, 192, 72,
                255, 192, 72, 137, 194,
                72, 255, 192, 72, 137, 193, 65,
                186, 234, 15, 223, 224, 255, 213, 72, 137,
                199, 106, 16, 65, 88, 76, 137, 226, 72,
                137, 249, 65, 186, 153, 165, 116, 97,
                255, 213, 133, 192, 116, 12, 73, 255,
                206, 117, 229, 104, 240, 181, 162, 86,
                255, 213, 72, 131, 236, 16, 72, 137,
                226, 77, 49, 201, 106, 4, 65, 88,
                72, 137, 249, 65, 186, 2, 217, 200, 95,
                255, 213, 72, 131, 196, 32, 94, 137,
                246, 106, 64, 65, 89, 104, 0,
                16, 0, 0, 65, 88, 72, 137, 242,
                72, 49, 201, 65, 186, 88, 164, 83,
                229, 255, 213, 72, 137, 195, 73, 137,
                199, 77, 49, 201, 73, 137, 240,
                72, 137, 218, 72, 137, 249, 65, 186, 2,
                217, 200, 95, 255, 213, 72,
                1, 195, 72, 41, 198, 72, 133, 246, 117,
                225, 65, 255, 231,
            };

can anyone help with this? like how to convert it e.g writing a python script or if there are any online converters (I looked but I couldn't find anything). I need it in actual bytes format so I can analyse it and understand what the payload does exactly. note - I do not mean the data type byte thanks

friya67
  • 1
  • 1

2 Answers2

1

This is an unusual question, as you're already creating a Java bytes object, but if you want a Python bytes object, you can use bytes. From the documentation:

bytes(iterable_of_ints) -> bytes
bytes(string, encoding[, errors]) -> bytes
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
bytes() -> empty bytes object

Construct an immutable array of bytes from:
  - an iterable yielding integers in range(256)
  - a text string encoded using the specified encoding
  - any object implementing the buffer API.
  - an integer

In this case, we're interested in bytes(iterable_of_ints), which we pass a Python list of your arguments.

source=[
                252, 72, 131, 228, 240, 232, 204,
                0, 0, 0, 65, 81, 65, 80,
                82, 81, 72, 49, 210, 86,
                101, 72, 139, 82, 96, 72, 139,
                82, 24, 72, 139, 82, 32,
                72, 139, 114, 80, 77, 49, 201, 72,
                15, 183, 74, 74, 72, 49, 192, 172,
                60, 97, 124, 2, 44, 32,
                65, 193, 201, 13, 65, 1, 193, 226,
                237, 82, 72, 139,82, 32, 139, 66,
                60, 72, 1, 208, 102, 129, 120, 24, 11,
                2,65, 81, 15, 133, 114, 0, 0, 0,
                139, 128, 136, 0, 0, 0, 72, 133,
                192, 116, 103, 72, 1, 208, 80, 139,
                72, 24, 68, 139, 64, 32, 73, 1, 208,
                227, 86, 72, 255, 201, 65, 139, 52, 136,
                72, 1, 214, 77, 49, 201, 72, 49,
                192, 172, 65, 193, 201, 13, 65, 1,
                193, 56, 224, 117, 241, 76, 3, 76,
                36, 8, 69, 57, 209, 117, 216, 88, 68,
                139, 64, 36, 73, 1, 208, 102, 65, 139,
                12, 72, 68, 139, 64, 28, 73, 1, 208,
                65, 139, 4, 136, 65, 88, 65, 88,
                72, 1, 208, 94, 89, 90, 65, 88, 65,
                89, 65, 90, 72, 131, 236, 32, 65,
                82, 255, 224, 88, 65, 89, 90, 72, 139, 18,
                233, 75, 255, 255, 255, 93, 73,
                190, 119, 115, 50, 95, 51, 50, 0, 0,
                65, 86, 73, 137, 230, 72, 129,
                236, 160, 1, 0, 0, 73, 137, 229, 73,
                188, 2, 0, 1, 187, 51, 161, 134, 90,
                65, 84, 73, 137, 228, 76, 137, 241,
                65, 186, 76, 119, 38, 7, 255, 213, 76,
                137, 234, 104, 1, 1, 0, 0, 89,
                65, 186, 41, 128, 107, 0, 255, 213, 106, 10,
                65, 94, 80, 80, 77, 49, 201,77, 49, 192, 72,
                255, 192, 72, 137, 194,
                72, 255, 192, 72, 137, 193, 65,
                186, 234, 15, 223, 224, 255, 213, 72, 137,
                199, 106, 16, 65, 88, 76, 137, 226, 72,
                137, 249, 65, 186, 153, 165, 116, 97,
                255, 213, 133, 192, 116, 12, 73, 255,
                206, 117, 229, 104, 240, 181, 162, 86,
                255, 213, 72, 131, 236, 16, 72, 137,
                226, 77, 49, 201, 106, 4, 65, 88,
                72, 137, 249, 65, 186, 2, 217, 200, 95,
                255, 213, 72, 131, 196, 32, 94, 137,
                246, 106, 64, 65, 89, 104, 0,
                16, 0, 0, 65, 88, 72, 137, 242,
                72, 49, 201, 65, 186, 88, 164, 83,
                229, 255, 213, 72, 137, 195, 73, 137,
                199, 77, 49, 201, 73, 137, 240,
                72, 137, 218, 72, 137, 249, 65, 186, 2,
                217, 200, 95, 255, 213, 72,
                1, 195, 72, 41, 198, 72, 133, 246, 117,
                225, 65, 255, 231,
            ]
my_bytes=bytes(source)
print(my_bytes)
    ```
Mous
  • 953
  • 3
  • 14
-1

Presumably you want to take a number represented by a decimal string and convert in to a sting of 8 0's and 1's (i.e. have leading 0's)

The way to do this is

  a='100'
  format(int(a),'0=8b')
  '01100100'

If you want to apply it to every string in a list you can use map

  a=['0','1','2']
  list(map(lambda k: format(int(k),'0=8b'),a))
  ['00000000', '00000001', '00000010']
William
  • 324
  • 1
  • 8