[Plugin Request] Anti-dll injection
[Plugin Request] Anti-dll injection
Hello,
I need an plugin to block dll injection...
can you create one?
thanks!!!!!!
I need an plugin to block dll injection...
can you create one?
thanks!!!!!!
Re: [Plugin Request] Anti-dll injection
Hi P4ulo, something can be done, but it depends on a result you would like to get.
Do you want to avoid injection of particular dll, or just any dll? And it is better to know the method of the dll injection.
Do you want to avoid injection of particular dll, or just any dll? And it is better to know the method of the dll injection.
Re: [Plugin Request] Anti-dll injection
Hi Enigma,
I want to avoid the injection of any dll other than the system...
I guess that method is LdrLoadDll and LoadLibrary..
I've found a code on the web, but depending on the time that I inject the dll with this code, still blocks some dlls needed in the game, and crash:
Can you do something?
thanks
I want to avoid the injection of any dll other than the system...
I guess that method is LdrLoadDll and LoadLibrary..
I've found a code on the web, but depending on the time that I inject the dll with this code, still blocks some dlls needed in the game, and crash:
Code: Select all
procedure hook(target, newfunc:pointer);
var
jmpto:dword;
OldProtect: Cardinal; // old protect in memory
begin
jmpto:=dword(newfunc)-dword(target)-5;
VirtualProtect(target, 5, PAGE_EXECUTE_READWRITE, @OldProtect);
pbyte(target)^:=$e9;
pdword(dword(target)+1)^:=jmpto;
end;
procedure myLdrLoadDll(PathToFile:PAnsiChar; Flags:variant; ModuleFileName:PAnsiChar; var ModuleHandle:THandle);
begin
MessageBox(0, 'I have blocked your attempt to inject a dll file!!', 'WARNING!', MB_OK);
ModuleHandle:=0;
end;
procedure Main;
begin
Hook(GetProcAddress(GetModuleHandle('ntdll.dll'), 'LdrLoadDll'), @myLdrLoadDll);
end;
begin
end.
thanks
Re: [Plugin Request] Anti-dll injection
This probably one of the methods that allows to avoid injection.
There is a mistake implementing of function myLdrLoadDll. There you have to check the name of the dll that is being injected, and if this dll is not on the list of "trusted" dlls then return a zero handle.
For example,
Also, to avoid another method of injection, you have to disable callback of function CreateRemoteThread, that is starting to run in RtlRemoteCall. I.e. get an address of the function RtlRemoteCall and write a byte $C3 to this address.
There is a mistake implementing of function myLdrLoadDll. There you have to check the name of the dll that is being injected, and if this dll is not on the list of "trusted" dlls then return a zero handle.
For example,
Code: Select all
procedure myLdrLoadDll(PathToFile:PAnsiChar; Flags:variant; ModuleFileName:PAnsiChar; var ModuleHandle:THandle);
const
ALLOWED_MODULES : array [0..2] of string = ('kernel32.dll', 'user32.dll', 'ntdll.dll');
var
s : string;
found : boolean;
begin
s := LowerCase(ExtractFileName(String(PathToFile)));
found := false;
for i := 0 to length(ALLOWED_MODULES) do
begin
if s = ALLOWED_MODULES[i] then
begin
found := true;
break;
end;
end;
if not found then
begin
MessageBox(0, 'I have blocked your attempt to inject a dll file!!', 'WARNING!', MB_OK);
ModuleHandle:=0;
end;
end;
Re: [Plugin Request] Anti-dll injection
Hi Enigma,
The problem is that PathToFile only return 'C', don't return the complete path... and ModuleFileName returns nothing...
Maybe you can fix looking this: http://undocumented.ntinternals.net/Use ... adDll.html
I've tried.. without sucess
The problem is that PathToFile only return 'C', don't return the complete path... and ModuleFileName returns nothing...
Maybe you can fix looking this: http://undocumented.ntinternals.net/Use ... adDll.html
I've tried.. without sucess
Re: [Plugin Request] Anti-dll injection
hi P4ulo
i need this plugin too i tried searching but... no helpful result goodluck ,
i need this plugin too i tried searching but... no helpful result goodluck ,
Re: [Plugin Request] Anti-dll injection
Just noticed, the function hook method is completely wrong there..
I will try to do something and post here. Refer to this thread later.
But you have to know, there is no ideal method of anti dll injection. There are such injection methods, that no way to avoid this..
I will try to do something and post here. Refer to this thread later.
But you have to know, there is no ideal method of anti dll injection. There are such injection methods, that no way to avoid this..
Re: [Plugin Request] Anti-dll injection
Hello Enigma
had any progress with this plugin?
had any progress with this plugin?
Re: [Plugin Request] Anti-dll injection
Hi Pls,
It is better and more useful to analyze what injected dll is really doing and detect it by it's work. For example, if injected dll modifies some code inside the process, we can make a plugin for Enigma that will check if this memory and, for example, terminate processes if memory is modified.
As I already said, this is impossible to avoid any dll injection. There are many methods that can inject dll, and avoid all of them - impossible.Pls wrote:Hello Enigmahad any progress with this plugin?
It is better and more useful to analyze what injected dll is really doing and detect it by it's work. For example, if injected dll modifies some code inside the process, we can make a plugin for Enigma that will check if this memory and, for example, terminate processes if memory is modified.
Re: [Plugin Request] Anti-dll injection
can you make this plugin to me with dll modifies some code inside the process
and
I compiled your example and it did not work
I edited some things to fix the hook thingy
and
I compiled your example and it did not work
I edited some things to fix the hook thingy
Last edited by Pls on Tue Sep 06, 2011 2:39 am, edited 4 times in total.