利用驱动程序读取硬盘序列号的汇编程序

这里有个小程序hdsn32.asm,是我2000年写的,在win9x下读取硬盘的序列号,它利用了类似CIH病毒的办法获得ring0权限,在win2000下不能运行.
      ;   hdsn32.asm
      .386
      .model flat, stdcall  ; 32 bit memory model
      option casemap :none  ; case sensitive
      
      include \masm32\include\windows.inc
      include \MASM32\INCLUDE\shell32.inc
      include \MASM32\INCLUDE\masm32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      
      includelib \MASM32\LIB\shell32.lib
      includelib \MASM32\LIB\masm32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      
.data

IDTR        df 0            ; This will receive the contents of the IDTR
                            ; register

SavedGate   dq 0            ; We save the gate we replace in here

OurGate     dw 0            ; Offset low-order word
            dw 028h         ; Segment selector
            dw 0EE00h       ;
            dw 0            ; Offset high-order word
BUFF1 DW 256 DUP(20H)             
hdsn_1 db '硬盘C序列号:',0DH,0AH
hdsn_2 db 256 dup(0)
hdsn_3 db 20 dup(0)
szCaption db 'hdsn32 v1.0 for win9x 山东海化集团 盛玉增 编制 2000.12.21',0
name_buffer db 'hdsn.bin',0

.data?
hFile HANDLE ?
SizeReadWrite DWORD ?

.code
Start:
      mov      eax, offset Ring0Proc
      mov      [OurGate], ax              ; Put the offset words
      shr      eax, 16                    ; into our descriptor
      mov      [OurGate+6], ax

      sidt     fword ptr IDTR
      mov      ebx, dword ptr [IDTR+2]    ; load IDT Base Address
      add      ebx, 8*3                   ; Address of int 3 descriptor in ebx

      mov      edi, offset SavedGate
      mov      esi, ebx
      movsd                               ; Save the old descriptor
      movsd                               ; into SavedGate

      mov      edi, ebx
      mov      esi, offset OurGate
      movsd                               ; Replace the old handler
      movsd                               ; with our new one

      int    3h                           ; Trigger the exception, thus
                                          ; passing control to our Ring0
                                          ; procedure

      mov      edi, ebx
      mov      esi, offset SavedGate
      movsd                               ; Restore the old handler
      movsd
      
      invoke MessageBox,NULL,addr hdsn_1,addr szCaption,MB_OK

   invoke CreateFile,ADDR name_buffer,\
             GENERIC_READ or GENERIC_WRITE ,\
             FILE_SHARE_READ or FILE_SHARE_WRITE,\
             NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,\
             NULL
   mov hFile,eax
      push offset hdsn_2
      pop esi
      push offset hdsn_3
      pop edi
      mov ecx,20
jm_1:      
      lodsb
      xor al,36h
      stosb
      loop jm_1
   invoke WriteFile,hFile,ADDR hdsn_3,20,\
             ADDR SizeReadWrite,NULL
   invoke CloseHandle,hFile
      invoke ExitProcess,eax

Ring0Proc PROC
start_1:
      mov edx,1f7h
      in al,dx
      cmp al,50h
      jnz start_1
      dec dx
      mov al,0a0h
      out dx,al
      mov dx,1f7h
      mov al,0ech
      out dx,al
      mov dx,1f7h
st_1: 
      in al,dx
      cmp al,58h
      jnz st_1
      mov dx,1f0h
      mov edi,offset BUFF1
      mov ecx,0
      mov cx,256
st_2: 
      in ax,dx
      xchg ah,al
      stosw
      loop st_2
      sti
      push offset BUFF1[20]
      pop esi
      push offset hdsn_2
      pop edi
      mov ecx,20
      rep movsb
      iretd
     
Ring0Proc ENDP
    end Start

时间: 2024-09-12 20:49:45

利用驱动程序读取硬盘序列号的汇编程序的相关文章

C#应用:读取指定盘符的硬盘序列号

硬盘 using System;using System.IO;using System.Runtime.InteropServices;using System.Text;using Microsoft.Win32; namespace Wjb.ReadOrWriteIniAndReg{/**/////// 读取指定盘符的硬盘序列号///public class HardDiskVal{[DllImport("kernel32.dll")]private static extern

C#实现读取指定盘符硬盘序列号的方法_C#教程

本文实例讲述了C#实现读取指定盘符硬盘序列号的方法.分享给大家供大家参考,具体如下: using System; using System.IO; using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32; namespace Wjb.ReadOrWriteIniAndReg { /**/////// 读取指定盘符的硬盘序列号 /// public class HardDiskVal { [Dll

关于硬盘序列号的类

硬盘 using System;using System.IO;using System.Runtime.InteropServices;using System.Text;using Microsoft.Win32; namespace Wjb.ReadOrWriteIniAndReg{ /// <summary> /// HardDiskVal 的摘要说明. /// 读取指定盘符的硬盘序列号 /// 功能:读取指定盘符的硬盘序列号 /// </summary> public c

驱动-c语言读取硬盘原始数据的几种方法

问题描述 c语言读取硬盘原始数据的几种方法 我所知道的两种方法是: 1. CreateFile打开硬盘后直接从文件句柄里读 2. DeviceIO驱动读取 <这里都是原始数据,比如第一个扇区就是MBR> 这两种方法都是用 CreateFile("PhysicalDriver0"--)<其他参数省略>打开的句柄, 但我现在遇到两个问题, 第一:PhysicalDriver0 是什么, 第二:有没有打开一个 打开 --.sys驱动的方式读取硬盘呢?(这样速度会快一些

VC++获取网卡MAC、硬盘序列号、CPU ID、BIOS编号

  以下代码可以取得系统特征码(网卡MAC.硬盘序列号.CPU ID.BIOS编号)     BYTE szSystemInfo[4096]; // 在程序执行完毕后,此处存储取得的系统特征码     UINT uSystemInfoLen = 0; // 在程序执行完毕后,此处存储取得的系统特征码的长度     // 网卡 MAC 地址,注意: MAC 地址是可以在注册表中修改的     {         UINT uErrorCode=0;         IP_ADAPTER_INFO

java如何获取网卡MAC、硬盘序列号、CPU ID

问题描述 java如何获取网卡MAC.硬盘序列号.CPUID 解决方案 解决方案二:c:以下代码可以取得系统特征码(网卡MAC.硬盘序列号.CPUID.BIOS编号)BYTEszSystemInfo[4096];//在程序执行完毕后,此处存储取得的系统特征码UINTuSystemInfoLen=0;//在程序执行完毕后,此处存储取得的系统特征码的长度//网卡MAC地址,注意:MAC地址是可以在注册表中修改的{UINTuErrorCode=0;IP_ADAPTER_INFOiai;ULONGuSi

利用opengl读取txt文件,显示点云

问题描述 利用opengl读取txt文件,显示点云 我是将获取到的三维点云数据保存成txt形式的,里面包含x,y,z,r,g,b信息,可以用opengl直接获取这些信息,画出点云吗? 解决方案 是不是考虑用OSG来做这个 解决方案二: 可以,我就是用OPenG做L的,楼上说得OSG也可以,还有VTK我也试过不过速度慢 解决方案三: 具体见 OSG 王锐<最长的一帧>

在.NET下获取硬盘序列号的问题

问题|硬盘 一般软件的注册机制可以通过获取硬件序列号,然后用非对称加密算法生成相应的公钥和私钥.但是用Managed Code写获取硬盘序列号的代码不能解决所有的问题,比如不能在非管理员的权限下使用,前几天Sunmast在他的Blog上发布了<如何得到硬盘序列号?.NET版本[C#]>,就是没有解决这个问题,用WMI也有很多问题. 要想顺利获取硬盘的序列号,目前只能依靠非托管代码了.DiskId32是一个源码公开的C++程序,可以解决上述问题.由于代码比较底层,我对VC和DDK不熟悉,没有能力

关于Linux内核读取磁盘序列号的研究

一向的观点就是"别在内核里面处理字符串"!事实上,确实应该如此! Linux内核的块设备驱动有能力读取磁盘的序列号,这个数据存储在磁盘的控制芯片ROM里面.内核应该以怎样的形式将这个序列号呈现给调用者呢?我们ls一下这个目录: /dev/disk/by-id ll /dev/disk/by-id/ ... lrwxrwxrwx 1 root root 9 10月 17 10:11 scsi-SATA_ST3500413AS_Z2A2AGQA -> ../../sdb 可以看到,一