Malware News
16.2K subscribers
1.64K photos
7 videos
130 files
8.3K links
The latest NEWS about malwares, DFIR, hacking, security issues, thoughts and ...

Partner channel: @cveNotify

For ads: https://telega.io/c/malwr
Download Telegram
X86 Inline Assembly
Hello!
I'm new to inline assembly, whilst I do have experience with assembly, it is mostly geared towards programming micro controllers. I'm trying to get an assignment done, and I have been researching inline assembly. My goal is to successfully implement the functionality of what getchar and putchar would do using inline assembly.(Reading a character from stdin, and putting a character on stdout).
I don't know if this means anything but I'm running this on a Linux machine, compiling with gcc.
Apparently it uses AT&T style as opposed to Intel style, This must use x86 inline assembly.


I'm trying to get the steps down.
Write to std_out

It seems I have to load, register %%eax with 4 (the call for sys\_write).
Load %%ebx with the file descriptor, in this case 1.
Load %%edx with the size, in this case 1.
Load %%ecx with a const char *, a pointer to the character.

My first implementation is here:

int main()
{
char p = 'p';
int ret;
__asm__ __volatile__(
"syscall"
:"=a"(ret)
:"a"(4), "b"(1), "c"(&p), "d"(1)
: "memory"
);
return 0;
}

This code above doesn't output anything, but ret is equivalent to -14/

A second implementation, without using extended Assembly
int main()
{
char c = 'c';
char * pointer = &c;
__asm__ __volatile__(
"mov $1, %%ebx\t\n"
"mov $1, %%edx\t\n"
"mov %1, %%ecx\t\n"
"mov $4, %%eax\t\n"
"syscall"
:
:"r"(pointer)
:
);
// printf("foo+bar=%d\n", foo);
return 0;
}

This code doesn't compile, I get a invalid 'asm': operand number out of range.


I'm trying to work through this before attempting writing putchar, as I may have foundational errors.

I'd appreciate any possible aid/hints!


Thanks in advance!
πŸ—£StandardSBUStudent

Are you compiling for 32-bit or 64-bit? They have different system call numbers and calling conventions.

For 32-bit: Pass parameters in eax/ebx/ecx/edx (i.e. syscall number in eax) and use int $0x80 to execute. sys_write is 4.

For 64-bit: Pass parameters in rax/rdi/rsi/rdx and use syscall. sys_write is 1.

For your second example note that the first operand is %0. See here
πŸ‘€0xa0000


πŸŽ–@malwr
Saudi spies tracked U.S. phones using flaws the FCC failed to fix for years
πŸ—£clash1111

Let me guess - it has something to do with an ancient SS7 vulnerability they should've fixed ages ago.
πŸ‘€deadface008

lol thats what you get for leaving holes open so you can keep eyes on your citizens
πŸ‘€d33pnull

And peiple want to end end-to-end encryption? Like fuck off.
πŸ‘€superking75


πŸŽ–@malwr
Shodan Command line A Step-by-Step walkthrough
Shodan Command line in this article and video, I show you what you can do, and the benefit of using the Shodan command line in your terminal. Searching for Vulnerabilities to port scanning, there is an incredible amount possible with Shodan.

Article:

https://hackingpassion.com/shodan-command-line-a-step-by-step-walkthrough/

Video:

https://youtu.be/ZAyfWtF0-VI

https://preview.redd.it/qex79jcpdsp41.png?width=1299&format=png&auto=webp&s=794a656483153c2b72cfafec337bd64d0bc0cd48
πŸ—£BullsEye_0


πŸŽ–@malwr
Stack Overflow goes to dark side!
πŸ—£im-here-to-lose-time

They already crossed to the dark side couple months ago (Monica affair).
πŸ‘€Haarteppichknupfer


πŸŽ–@malwr
[PDF English ver]
[KR NorthKorea APT37 Campaign Analysis - in Korean](https://blog.alyac.co.kr/2827)
πŸ—£digicat


πŸŽ–@malwr