I'm trying to merge this two codes, and it worked well until the moment I tried executing them. First one:
#include <stdlib.h>
void main() {
__asm__("jmp 0x1f\npop %si\nmov %esi,0xa(%esi)\nxor %eax,%eax\nmov %eax,0x9(%esi)\nmov
%eax,0x9(%esi)\nmov %eax,0x9(%esi)\nmov %eax,0x9(%esi)\nmovl %eax,0xe(%esi)\nmov $0xb,%al\nmovl %esi,%ebx\nleal 0xa(%esi),%ecx\nleal 0xe(%esi),%edx\nint $0x80\nxorl %ebx,%ebx\nmovl %ebx,%eax\ninc %eax\nint $0x80\ncall -0x24\n.string \"bin/csh\"");
}
The second one in assembly:
# Vector-asm
.section .data
output:
.asciz “Current value %d\n”
values:
.int 1, 33, 13, 4, 55, 6, 71, 8, 88, 55, 60
.section .text
.globl _start
_start:
nop
movl $0, %edi
loop:
Moving Data
movl values(, %edi, 4), %eax
pushl %eax
pushl $output
call printf
addl $8, %esp
inc %edi
cmpl $11, %edi
jne loop
movl $0, %ebx
movl $1, %eax
int $0x80
I did try putting the 2 programs together. My intention was to show the values inside my vector in the /bin/sh or /bin/csh shell:
#include <stdio.h>
int main() {
__asm__(".section .data\noutput:\n.asciz \"Current value %d\\n\"\nvalues:\n.int 1, 33, 13, 4, 55, 6, 71, 8, 88, 55, 60\n.section .text\n_start:\nnop\nmovl $0, %edi\nloop:\nmovl values(, %edi, 4), %eax\npushq %rax\npushq $output\ncall printf\naddl $8, %esp\ninc %edi\ncmpl $11, %edi\njne loop\npushq $0x68732f2f\npushq $0x6e69622f\nmovl %esp,%ebx\npushq %rbx\npushq %rax\nmovl %esp,%ecx\nmovb $0x0b,%al\nint $0x80\n");
return 0;
}
Sorry for the Inline assembly. But this is the only way I was capable of compile. None of them worked out. I receive Assembly error: Segmentation fault (core dumped) when I try to execute any of those two. I'm using a 64 bit system and I already tried the same on x86-32 bits. I didn't worked out. I'm gonna provide more information pretty soon. Someone knows what's going on?