-1

I have a problem when cut information dumped out from an executable file in linux. The information is as follows:

08048060 <__bss_start-0x100a>:
 8048060:   31 db                   xor    %ebx,%ebx
 8048062:   53                      push   %ebx
 8048063:   bb 75 a2 45 7e          mov    $0x7e45a275,%ebx
 8048068:   ff d3                   call   *%ebx

Is there any way to cut faster the data "31 db 53 bb 75 a2 45 7e ff d3" without copy single line then remove command in every line? Sometime when the code too long, it take many times to cut all data in that column.

Anvh
  • 11
  • 3
  • Column select mode. Does your editor support it? (Why are you copying out the instruction bytes anyway??) – Cody Gray - on strike Jun 25 '17 at 07:53
  • My work just need only middle column, so that I just want to cut it out without any instructions of last column nor address in first column. – Anvh Jun 25 '17 at 07:55
  • 1
    If it is for shellcode maybe this `objdump -d ./progname |grep '[0-9a-f]:'|grep -v 'file'|cut -f2 -d:|cut -f1-6 -d' '|tr -s ' '|tr '\t' ' '|sed 's/ $//g'|sed 's/ /\\x/g'|paste -d '' -s |sed 's/^/"/'|sed 's/$/"/g'` – Michael Petch Jun 25 '17 at 08:12
  • Thanks @MichaelPetch !!! I just solved this problem few second before I see you answer! Btw, thank you ! – Anvh Jun 25 '17 at 08:15

1 Answers1

1

A much, much easier way is to use the related tool objcopy:

 gcc -c shellcode.s
 objcopy -O binary shellcode.o shellcode.bin

objcopy can be used to copy any arbitrary section from the object file.

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67