字符串MESSAGE和Hello!Windows
文件路径C:\Documents and Settings\XPMUser…
字符串KERNEL32.dll、MessageBoxW
int APIENTRY _tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if(lstrcmp(lpCmdLine, _T("2012")) == 0){
MessageBox(GetActiveWindow(),
_T("Hello! 2012"), _T("MESSAGE"), MB_OK);
}else{
MessageBox(GetActiveWindow(),
_T("Hello! Windows"), _T("MESSAGE"), MB_OK);
}
return 0;
}
若ZF=1则跳转。
若CF为1则不跳转。
int cpy(void)
{
// 获取自身文件路径
TCHAR szThis[2048];
GetModuleFileName(NULL, szThis, sizeof(szThis));
// 获取启动文件夹路径
SHGetFolderPath(NULL, CSIDL_STARTUP,
NULL, SHGFP_TYPE_CURRENT, szStartup);
lstrcat(szStartup, _T("\\wsample01b.exe"));
// 将自身复制到启动文件夹
CopyFile(szThis, szStartup, FALSE);
return 0;
}
int APIENTRY _tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
cpy();
MessageBox(GetActiveWindow(),
_T("Copied!"), _T("MESSAGE"), MB_OK);
return 0;
}
若eax为0则不跳转
若eax为1则跳转
function(1,2,3);
//对应汇编代码
push 3
push 2
push 1
call function
.text:00401000 Filename = word ptr -2004h
.text:00401000 pszPath = word ptr -1004h
.text:00401000 var_4 = dword ptr -4
.text:00401000
.text:00401000 push ebp
.text:00401001 mov ebp, esp
.text:00401003 mov eax, 2004h
.text:00401008 call __alloca_probe
.text:0040100D mov eax, ___security_cookie
.text:00401012 xor eax, ebp
.text:00401014 mov [ebp+var_4], eax
.text:00401017 push 1000h ; nSize
.text:0040101C lea eax, [ebp+Filename]
.text:00401022 push eax ; lpFilename
.text:00401023 push 0 ; hModule
.text:00401025 call ds:GetModuleFileNameW
.text:0040102B lea ecx, [ebp+pszPath]
.text:00401031 push ecx ; pszPath
.text:00401032 push 0 ; dwFlags
.text:00401034 push 0 ; hToken
.text:00401036 push 7 ; csidl
.text:00401038 push 0 ; hwnd
.text:0040103A call ds:SHGetFolderPathW
.text:00401040 push offset String2 ; "\\wsample01b.exe"
.text:00401045 lea edx, [ebp+pszPath]
.text:0040104B push edx ; lpString1
.text:0040104C call ds:lstrcatW
.text:00401052 push 0 ; bFailIfExists
.text:00401054 lea eax, [ebp+pszPath]
.text:0040105A push eax ; lpNewFileName
.text:0040105B lea ecx, [ebp+Filename]
.text:00401061 push ecx ; lpExistingFileName
.text:00401062 call ds:CopyFileW
.text:00401068 mov ecx, [ebp+var_4]
.text:0040106B xor ecx, ebp
.text:0040106D xor eax, eax
.text:0040106F call @__security_check_cookie@4 ; __security_check_cookie(x)
.text:00401074 mov esp, ebp
.text:00401076 pop ebp
.text:00401077 retn
.text:00401077 sub_401000 endp
.text:00401077
.text:00401077 ; ---------------------------------------------------------------------------
.text:00401078 align 10h
.text:00401080
.text:00401080 ; =============== S U B R O U T I N E =======================================
.text:00401080
.text:00401080
.text:00401080 ; int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
.text:00401080 _wWinMain@16 proc near ; CODE XREF: ___tmainCRTStartup+153↓p
.text:00401080
.text:00401080 hInstance = dword ptr 4
.text:00401080 hPrevInstance = dword ptr 8
.text:00401080 lpCmdLine = dword ptr 0Ch
.text:00401080 nShowCmd = dword ptr 10h
.text:00401080
.text:00401080 call sub_401000
.text:00401085 push 0 ; uType
.text:00401087 push offset Caption ; "MESSAGE"
.text:0040108C push offset Text ; "Copied!"
.text:00401091 call ds:GetActiveWindow
.text:00401097 push eax ; hWnd
.text:00401098 call ds:MessageBoxW
.text:0040109E xor eax, eax
.text:004010A0 retn 10h
.text:004010A0 _wWinMain@16 endp
char fileName[2048];
eax=finName;
RegSetValueExA
RegSetValueExA
RegCreateKeyExA
CopyFileA
.text:00401310
.text:00401310 dwDisposition = dword ptr -8
.text:00401310 phkResult = dword ptr -4
.text:00401310 lpData = dword ptr 8
.text:00401310 cbData = dword ptr 0Ch
.text:00401310
.text:00401310 push ebp
.text:00401311 mov ebp, esp
.text:00401313 sub esp, 8
.text:00401316 push esi
.text:00401317 lea eax, [ebp+dwDisposition]
.text:0040131A push eax ; lpdwDisposition
.text:0040131B xor esi, esi
.text:0040131D lea ecx, [ebp+phkResult]
.text:00401320 push ecx ; phkResult
.text:00401321 push esi ; lpSecurityAttributes
.text:00401322 push 0F003Fh ; samDesired
.text:00401327 push esi ; dwOptions
.text:00401328 push offset Class ; lpClass
.text:0040132D push esi ; Reserved
.text:0040132E push offset SubKey ; "Software\\Microsoft\\Windows\\CurrentVe"...
.text:00401333 push 80000002h ; hKey
.text:00401338 mov [ebp+phkResult], esi
.text:0040133B call ds:RegCreateKeyExA
.text:00401341 test eax, eax
.text:00401343 jnz short loc_401370
.text:00401345 mov edx, [ebp+cbData]
.text:00401348 mov eax, [ebp+lpData]
.text:0040134B mov ecx, [ebp+phkResult]
.text:0040134E push edx ; cbData
.text:0040134F push eax ; lpData
.text:00401350 push 1 ; dwType
.text:00401352 push esi ; Reserved
.text:00401353 push offset ValueName ; "sample_mal"
.text:00401358 push ecx ; hKey
.text:00401359 call ds:RegSetValueExA
.text:0040135F test eax, eax
.text:00401361 jnz short loc_401366
.text:00401363 lea esi, [eax+1]
.text:00401366
.text:00401366 loc_401366: ; CODE XREF: sub_401310+51↑j
.text:00401366 mov edx, [ebp+phkResult]
.text:00401369 push edx ; hKey
.text:0040136A call ds:RegCloseKey
.text:00401370
.text:00401370 loc_401370: ; CODE XREF: sub_401310+33↑j
.text:00401370 mov eax, esi
.text:00401372 pop esi
.text:00401373 mov esp, ebp
.text:00401375 pop ebp
.text:00401376 retn
.text:00401376 sub_401310 endp
.text:00401220 sub_401220 proc near ; CODE XREF: sub_401380+DA↓p
.text:00401220
.text:00401220 String1 = byte ptr -20Ch
.text:00401220 Filename = byte ptr -108h
.text:00401220 var_4 = dword ptr -4
.text:00401220
.text:00401220 push ebp
.text:00401221 mov ebp, esp
.text:00401223 sub esp, 20Ch
.text:00401229 mov eax, ___security_cookie
.text:0040122E xor eax, ebp
.text:00401230 mov [ebp+var_4], eax
.text:00401233 push 104h ; nSize
.text:00401238 lea eax, [ebp+Filename]
.text:0040123E push eax ; lpFilename
.text:0040123F push 0 ; hModule
.text:00401241 call ds:GetModuleFileNameA
.text:00401247 test eax, eax
.text:00401249 jz loc_4012F3
.text:0040124F push 104h ; cchBuffer
.text:00401254 lea ecx, [ebp+Filename]
.text:0040125A push ecx ; lpszShortPath
.text:0040125B mov edx, ecx
.text:0040125D push edx ; lpszLongPath
.text:0040125E call ds:GetShortPathNameA
.text:00401264 test eax, eax
.text:00401266 jz loc_4012F3
.text:0040126C push esi
.text:0040126D push offset aCDel ; "/c del "
.text:00401272 lea eax, [ebp+String1]
.text:00401278 push eax ; lpString1
.text:00401279 call ds:lstrcpyA
.text:0040127F mov esi, ds:lstrcatA
.text:00401285 lea ecx, [ebp+Filename]
.text:0040128B push ecx ; lpString2
.text:0040128C lea edx, [ebp+String1]
.text:00401292 push edx ; lpString1
.text:00401293 call esi ; lstrcatA
.text:00401295 push offset aNul ; " >> NUL"
.text:0040129A lea eax, [ebp+String1]
.text:004012A0 push eax ; lpString1
.text:004012A1 call esi ; lstrcatA
.text:004012A3 push 104h ; nSize
.text:004012A8 lea ecx, [ebp+Filename]
.text:004012AE push ecx ; lpBuffer
.text:004012AF push offset Name ; "ComSpec"
.text:004012B4 call ds:GetEnvironmentVariableA
.text:004012BA pop esi
.text:004012BB test eax, eax
.text:004012BD jz short loc_4012F3
.text:004012BF push 0 ; nShowCmd
.text:004012C1 push 0 ; lpDirectory
.text:004012C3 lea edx, [ebp+String1]
.text:004012C9 push edx ; lpParameters
.text:004012CA lea eax, [ebp+Filename]
.text:004012D0 push eax ; lpFile
.text:004012D1 push 0 ; lpOperation
.text:004012D3 push 0 ; hwnd
.text:004012D5 call ds:ShellExecuteA
.text:004012DB cmp eax, 20h
.text:004012DE jle short loc_4012F3
.text:004012E0 mov eax, 1
.text:004012E5 mov ecx, [ebp+var_4]
.text:004012E8 xor ecx, ebp
.text:004012EA call @__security_check_cookie@4 ; __security_check_cookie(x)
.text:004012EF mov esp, ebp
.text:004012F1 pop ebp
.text:004012F2 retn
extern MessageBoxA
section .text
global main
main:
push dword 0
push dword title
push dword text
push dword 0
call MessageBoxA
ret
section .data
title: db 'MessageBox', 0
text: db 'Hello World!', 0
父窗口句柄
要显示的消息
要显示的消息框标题
要显示的消息框类型
要显示的消息:Hello World!
要显示的标题:MessageBox
将参数按照从后往前的顺序入栈
用call MessageBoxA调用函数