将十进制转换为实际字节

发布于 2025-01-11 01:14:59 字数 3094 浏览 0 评论 0原文

我的任务是提取和分析有效负载。有效负载存储在下面的数组中:

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,
            };

任何人都可以帮忙解决这个问题吗?比如如何转换它,例如编写一个 python 脚本或者是否有任何在线转换器(我看了但找不到任何东西)。 我需要它的实际字节格式,以便我可以分析它并了解有效负载的确切作用。 注意 - 我不是指数据类型字节 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韶华倾负 2025-01-18 01:14:59

这是一个不寻常的问题,因为您已经创建了一个 Java bytes 对象,但如果您想要一个 Python bytes 对象,则可以使用 bytes
来自文档:

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

在本例中,我们对 bytes(iterable_of_ints) 感兴趣,我们传递了参数的 Python 列表。

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)
    ```

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)
    ```
孤君无依 2025-01-18 01:14:59

假设您想要获取一个由十进制字符串表示的数字,并将其转换为由 8 个 0 和 1 组成的字符串(即有前导 0),

执行此操作的方法是

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

如果您想将其应用于列表中的每个字符串,您可以使用地图

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

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']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文