In this article I am going to demonstrate a basic use of low-level language to demonstrate how you can get your CPU Vendor string, and other hardware information using x86 assembly coding
section .data string db "The Vendor id string is 'XXXXXXXXXXXX'",0xA section .text global _start _start: xor eax,eax cpuid mov edi,string mov [edi+25],ebx mov [edi+29],edx mov [edi+33],ecx mov eax,4 mov ebx,1 mov ecx,string mov edx,41 int 0x80 mov eax,1 xor ebx,ebx int 0x80
It contains a basic String declaration (You should know this if you have some basic knowledge) with a 0x0A at the end that is the ascii code for a Line Feed or New Line...Section .text
The string contains 12 X's because these later will be overwritten by cpuid output..
It contains a global declaration of _start label .._start : label
We xor the eax with eax(to make it zero) ….cpuid Syntax
cpuid (The main part of the code is this little instruction)..
cpuid returns a number of things about our processor and this instruction can also be used to check if the processor is genuine or not...
cpuid acts (ouputs) differently on different eax values
The cpiuid instruction outputs the data byte – by – byte in the following syntax :-Code:Eax | Output | 0 | The vendor string and the maximum input value supported 1 | Processor type , model , stepping info etc etc... 2 | Processor Cache information like no of threads , etc etc... 3 | Processor serial number 4 | Cache Configuration 5 | Monitor information 0x80000000 | Extended vendor ID and supported levels 0x80000001 | Extended Processor type , family , model , etc etc... 0x80000002 – 0x80000004 | Extended Processor name string...
The data is contained in register byte-by-byte...
Fell free to feed these values and post the output here..Code:Register | Byte no | EBX | [byte 4] [byte 3] [byte 2] [byte 1] ECX | [byte 8] [byte 7] [byte 6] [byte 5] EDX | [byte 12] [byte 11] [byte 10] [byte 9]
- We first move the address of the string into edi...
- Then we move the address pointed by the ebx register into string(25th byte) As seen in the syntax it contains the data bytes...Then we do the same in the next couple of instructions that should be self-explanatory..
- Then we move 4 into eax and this is the syscall for write...
- Rest couple of instructions are just passing the arguments for write instruction that should be basic if you know assembly
- int 0x80 switch back to kernel mode
- Then is the basic exit routine and we exit...