Extract and convert shellcode to be embedded into Golang code using objdump

objdump -d ./shellcode |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' | sed 's/"//g' | sed 's/\\/0/g' |sed 's/.\{4\}/&,/g' | sed s/.$//
Built on command mentioned at https://www.commandlinefu.com/commands/view/6051/get-all-shellcode-on-binary-file-from-objdump
Sample Output
root@kali:~/slae/assembly/shellcode/execve# objdump -d sh -M intel

sh:     file format elf32-i386


Disassembly of section .text:

08049000 <_start>:
 8049000:       31 c0                   xor    eax,eax
 8049002:       50                      push   eax
 8049003:       68 6e 2f 73 68          push   0x68732f6e
 8049008:       68 2f 2f 62 69          push   0x69622f2f
 804900d:       89 e3                   mov    ebx,esp
 804900f:       50                      push   eax
 8049010:       89 e2                   mov    edx,esp
 8049012:       53                      push   ebx
 8049013:       89 e1                   mov    ecx,esp
 8049015:       b0 0b                   mov    al,0xb
 8049017:       cd 80                   int    0x80
root@kali:~/slae/assembly/shellcode/execve# objdump -d sh |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' | sed 's/"//g' | sed 's/\\/0/g' |sed 's/.\{4\}/&,/g' | sed s/.$//
0x31,0xc0,0x50,0x68,0x6e,0x2f,0x73,0x68,0x68,0x2f,0x2f,0x62,0x69,0x89,0xe3,0x50,0x89,0xe2,0x53,0x89,0xe1,0xb0,0x0b,0xcd,0x80

0
By: mosunit
2020-08-13 07:46:50

What Others Think

This site called explanatory synthesis essay example is the best thing about internet. Literally with just in time I am able to get everything on my hands. No cons at all!
seoexpert · 110 weeks and 1 day ago
people want immediate solutions for their problems and for that they look for different websites. A system introduced by this organization informing about https://www.signnow.com/ask/how-does-the-esign-act-recognize-electronic-contracts-as-equivalent-to-written-contracts has given people an opportunity to check different websites. This eases the tension of getting into fraud or anything like that.
seoexpert · 106 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: