Intro to Assembly Shellcodes error message

I’m unable to move past the Shellcode section in Intro to Assembly Language. I am unable to complete the question at the bottom. I followed along verbatim, but continuously get an error when attempting to load and run shellcode with the provided python script.

[ERROR] There was an error running [‘/usr/bin/x86_64-linux-gnu-ld’, ‘–oformat=elf64-x86-64’, ‘-EL’, ‘-z’, ‘execstack’, ‘-o’, ‘/tmp/pwn-asm-puhrbw07/step3-elf’, ‘/tmp/pwn-asm-puhrbw07/step2-obj’]:
It had this on stdout:
/usr/bin/x86_64-linux-gnu-ld: warning: /tmp/pwn-asm-puhrbw07/step3-elf has a LOAD segment with RWX permissions

[ERROR] An error occurred while building an ELF:
.section .shellcode,“awx”
.global _start
.global __start
.p2align 2
.intel_syntax noprefix
.string “\x48\x31\xdb\x53\x6a\x0a\x48\xb8\x6d\x33\x6d\x30\x72\x79\x21\x7d\x50\x48\xb8\x33\x64\x5f\x31\x6e\x37\x30\x5f\x50\x48\xb8\x48\x54\x42\x7b\x6c\x30\x34\x64\x50\x48\x89\xe6\x48\x31\xc0\xb0\x01\x48\x31\xff\x40\xb7\x01\x48\x31\xd2\xb2\x19\x0f\x05\x48\x31\xc0\x04\x3c\x40\x30\xff\x0f\x05”

I’ve tried reinstalling pwntools with and without sudo. I’ve tried running the script as root. I’ve tried upgrading and updating. I’ve also attempted to run the shell code on 2 physically seperate systems for a total of 3 systems(1 linux mint, 2 kalis). I can’t find anything online that helps solve this.

Can someone help determine the cause of this error and how to fix it?
python version 3.10.8 when I type python3 into terminal for kalis

EDIT* On my linux mint, python 3.8.10 will run the shellcode provided as an example within the section.

I ran across a very similar issue a few days ago where I was unable to generate shellcode on the fly with shellcraft on a box with newer libc/ld versions installed on a Debian testing distro.

You will need to modify pwntools to include two additional linker arguments.
On my local checkout, it was line 598 of ~/.local/lib/python3.10/site-packages/pwnlib/

linker_options = ['-z', 'execstack']

linker_options = ['-z', 'execstack', '--no-warn-rwx-segments', '--no-warn-execstack']

test it out:
shellcraft -z -r


Wow! It worked. Thank you so much. It was a pain having to switch PCs in order to practice the module. Much appreciated. How exactly did you figure this out?

1 Like

Heyo! Glad to hear that helped!

When shellcraft, called directly on the cli, was unable to compile any of the built-in shellcode options, like a simple I recreated a few simple as/nasm vs c/gcc/ld tests. as/nasm shellcode built just fine, but that doesn’t use ld :wink: Same issue trying to compile with gcc and link with ld. So I figured it was a linker option that was missing!

Then I stumbled on this helpful message thread:

1 Like

thank you!! Awesome research dude!

1 Like

“Shellcodes” typically refer to small pieces of code used to exploit vulnerabilities in software or systems. If you are encountering an error related to shellcodes, it could indicate a problem with the code or with the system it is being run on. Here are some general steps you can take to try to fix the error:

Check the shellcode: If you are developing or working with shellcode, make sure that the code is correct and free of errors. Test the code in a controlled environment and make sure that it is functioning as expected.

Check system configuration: If you are encountering errors while running shellcode, it could indicate a problem with the system configuration. Make sure that the system is properly configured and that all necessary libraries and dependencies are installed.

Check permissions: If you are encountering errors related to permissions while running shellcode, make sure that the user or process running the code has the necessary permissions to access the resources it needs.

Check for antivirus or security software: Some antivirus or security software can flag shellcode as malicious and block its execution. Make sure that any antivirus or security software is not interfering with the execution of the shellcode.

Consult documentation or forums: If you’re still having trouble fixing the error, consult the documentation or forums for the software or system you’re using. You may find that others have encountered the same issue and have already found a solution.

Note that shellcode can be dangerous and potentially harmful if used improperly or maliciously. Be sure to use caution and take appropriate precautions when working with shellcode.

Rachel Gomez