15.寻找进程中的MessageBoxA函数Call并调用
[toc]
x86程序中的写法1. ce寻找MessageoxA函数地址并通过自动汇编调用MessageBoxA
打开CE,附加程序
搜索MessageBoxA的地址
编写自动汇编代码调用MessgeBoxA
写法1:使用push传递参数 123456789101112131415161718[ENABLE]Alloc(newaddr,100)createThreadAndWait(newaddr)newaddr:push 0push 0push 0push 0call 7714B730ret[DISABLE]dealloc(newaddr)//Auto Assembler Commands//https://wiki.cheatengine.org/index.php?title=Auto_Assembler:Commands
写法2:使用push传递参数并保存ebp 123456789101112131415161718192021[ENABLE]Alloc(newaddr,100)createThreadAndWait(newaddr)newaddr:push ...
14.使用C语言将动态链接库加载到进程后调用汇编Call
[toc]
使用C语言将动态链接库加载到实验程序后调用汇编Call1.写一个C语言程序,在程序里通过内联汇编调用C语言函数1234567891011121314151617181920212223242526272829//Message.c#include <windows.h>#include <stdio.h> void Message(){ MessageBoxA(NULL, "HellWorld", "Text", MB_OK);}void AsmMessage(){ __asm { mov edx, 0x00411406 //0x00411406 is Message() address call edx }}int main(int argc, char** argv){ printf("MessageBoxA address is 0x%p\n", & ...
13.c语言使用vs2022分析c语言程序并手写x86与x86_64内联汇编程序
[toc]
用C语言写一个x86内联汇编程序1. 用C语言写一个程序,内容为调用MessageBoxA函数完整代码:
123456789101112131415//Message.c#include <windows.h>#include <stdio.h> int main(int argc, char** argv){ printf("0x%p", &MessageBoxA); MessageBoxA(NULL, "HellWorld", "Text", MB_OK); MSG msg; while (GetMessageW(&msg, NULL, NULL, NULL)) { } return 0;}
结果如图所示:
2. 用C语言与x86内联汇编写一个程序,内容为调用MessageBoxA函数完整代码
1234567891011121314151617181920212223242526 ...
12.使用C语言将动态链接库通过远程线程加载到进程中
[toc]
c语言程序动态链接库的简单实例1. 新建一个动态库项目,在动态库入口点中弹出一个MessageBoxW在动态链接库项目中关闭预编译头文件
123456789101112131415161718192021222324// dllmain.c : Defines the entry point for the DLL application.#include <windows.h>BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){ switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: MessageBoxW(NULL, L"how you doing", L"what' ...
11.使用C语言在windows中动态调用动态链接库
[toc]
使用C语言在windows中动态调用自己写的动态链接库1.使用C语言在VistualStudio2022中创建动态链接库项目
新建项目->windows桌面->动态链接库(DLL)->项目名称dll1
属性->c/c++->代码生成->运行库设置为多线程调试DLL(/MTd)
选择Solution Explorer->Property->c/c++->Procompiled Headers->选择Not Using Precompiled Headers
新建文件myfunc.h,与myfunc.c
myfunc.h
1234//myfunc.h#pragma once__declspec(dllexport) int add(int numberA, int numberB);
myfunc.c
12345678//myfunc.c#include "pch.h"#include "myfunc.h"int add(int nu ...
10.使用C语言在windows中获得句柄
[toc]
使用C语言在windows中获得进程句柄C语言在windows中获得自己的进程句柄使用GetCurrentProcess()或者-1可以得到自身进程的句柄
1234567891011121314#include <windows.h>#include <stdio.h>int main(int argc, char* argv[]){ DWORD dwProcessId = 116348; HANDLE hProcess1 = GetCurrentProcess(); printf("hProcess is %p\n", hProcess1); CloseHandle(hProcess1); printf("hProcess is %p\n", -1); return 0;}
C语言在windows中获得其他进程的句柄使用OpenProcess函数
123456789101112131415161718#include <windows.h>#include <s ...
9.C语言注入带参数的函数
[toc]
C语言调用带参函数的例子1.C语言传递参数的例子12345678910111213#include <windows.h>void Message(int a){ MessageBoxA(NULL, "HellWorld", "Text", a);}int main(int argc, char** argv){ int a = 1; Message(a); return 0;}
2. 通过指针传递变量的值1234567891011121314#include <windows.h>void Message(int a){ MessageBoxA(NULL, "HellWorld", "Text", a);}int main(int argc, char** argv){ int a = 1; int* p = &a; Message(* ...
8.使用C语言编写代码将函数注入到32位程序中
[toc]
使用c语言将C语言函数注入到x86程序中1.用c语言写一个弹出消息框MessageBoxA的程序
在项目中属性->高级->随机基地址中选择关闭
代码如下
123456789//message.c#include <windows.h>#include <stdio.h>int main(int argc,char**argv){ MessageBoxA(NULL,"HellWorld","Text",MB_OK); getchar(); return 0;}
3.编译后运行查看结果
2. 用c语言写一个注入内联x86汇编指令的程序1.完善Hello,World程序,打印出函数地址与进程pid12345678910111213141516171819202122232425262728//message.c#include <windows.h>#include <stdio.h>void Message(){ M ...
7.c语言编写x86汇编代码转为机器码注入到32位程序中
[toc]
使用c语言将x86汇编代码注入到32位程序中1.用c语言写一个弹出消息框MessageBoxA的程序
在项目中属性->高级->随机基地址中选择关闭
代码如下
12345678#include <windows.h>#include <stdio.h>int main(int argc,char**argv){ MessageBoxA(NULL,"HellWorld","Text",MB_OK); getchar(); return 0;}
3.编译后运行查看结果
2. 用c语言写一个注入x86汇编指令的程序1.完善Hello,World程序,打印出函数地址与进程pid1234567891011121314151617181920212223242526#include <windows.h>#include <stdio.h>void Message(){ MessageBoxA(NULL, "Hel ...
6.使用C语言在windows中创建线程与进程并且创建具有system权限进程
[toc]
使用C语言在windows中执行远程线程1. C语言中的多线程简单使用thrd_create注意:使用多线程标准库需要C语言C11以上的版本,编译程序时候需选择MTD/MT。
1234567891011121314151617181920212223242526272829303132333435363738#include <stdio.h>#include <stdlib.h>#include <threads.h>#include <windows.h>// 新线程要执行的代码int ThreadFunction(void* arg) { int thread_id = *((int*)arg); for (int i = 0; i < 10; i++) { Sleep(1000); printf("线程 %d 打印次数 %d...\n", thread_id,i+1); } printf(& ...
