Update: I have fixed the argv array pointers not being valid causing the continuous loop and have updated the assembly code. Now the only issue is the disappearing space char on compilation. I’ve been experimenting with executing shellcode after exploiting a buffer overflow on a 32-bit Linux VM. My assembly program simply uses execve to start a shell via python
Tag: x86
Use of gs register on a 32 bit program over a 64 bit linux
In a 64 bit program the selector:offset used to get the stack protector is fs:0x28, where fs=0. This poses no problem because in 64 bit we have the MSR fs_base (which is set to point to the TLS) and the GDT is completely ignored. But with 32 bit program the stack protector is read from gs:0x14. Running over a 64
Counting L3 cache access event on Amd Zen 2 processors
I am trying to figure out the event to use with the perf stat command to count L3 cache accesses on an AMD Zen 2 processor. As per the PPR (http://developer.amd.com/wordpress/media/2017/11/54945_PPR_Family_17h_Models_00h-0Fh.pdf), section 2.1.13.4.1, page 168, the event is x01 and the umask is x80 for “[L3 Cache Accesses] (L3RequestG1)”. From what I understand, the event to use in perf stat
The implementation of Linux kernel current macro
Generally speaking, if we want to use current macro in Linux kernel, we should: but there is a asm-generic version: the asm version implements the current macro through per-cpu variable, but asm-generic version implements the current macro through thread_info, these two are totally different. Linux kernel headers’ organization says we should use asm version, which include asm/current.h, but so many
How to add 2 numbers together that are of different lengths in x86 linux nasm assembly
I’m very new to assembly and having difficulties in getting basic calculations to work with different length numbers. So this is my adding code, that works with numbers that are 3 or less characters long. for as long as both are the same length. for example 123 + 123 works just fine and outputs 246. But 12 + 123 does
Understanding ELF64 text/data segment layout/padding
I’m trying to brush up on UNIX viruses and one text I’m reading mentions that parasitic code can be inserted in the padding between the text and the data segment, supposedly up to 2MB in size on x86-64 systems. But when I compile a simple hello world program with gcc -no-pie… …and inspect its segment headers with readelf -W -l
How to print the content of a text file to STDOUT in Linux Assembly Language using c library functions?
First I tried opening a file with fopen function and print content of the file using fprint function but it was just printing a bunch of symbols to the terminal. After a while I realized that it does not take pointer to a stream as argument and above mentioned behaviour was expected. It was printing the actual pointer value. putc
Finding the number of bytes of entered string at runtime
I’m new at learning assembly x86. I have written a program that asks the user to enter a number and then checks if it’s even or odd and then print a message to display this information. The code works fine but it has one problem. It only works for 1 digit numbers: It does not work properly for numbers with
x86 NASM | Input in Loop working only the first and third time
I have a loop that runs succesfully 3 times, but the input I have in this loop works only the first time. I am new to assembly so pls have patience. Code: Output: Well, later I thought that the loop might not running a third time, so I changed the code a bit. New Code: New Output: Explaination: 0 is
assembly, how to use mprotect?
I am trying to make self modifying code in Linux. I thought it would works but didn’t. I used nasm on ubuntu 18.04. INT 0x80 return value is -22 0xffffffea I don’t know what is wrong. Answer Run your program under strace, like strace ./a.out to decode system call args and return values. Probably your base address isn’t page-aligned, or