Skip to content

Commit 2f28d05

Browse files
committed
Updated to 2.3.0; bug fixes; appveyor support
1 parent 1967834 commit 2f28d05

File tree

5 files changed

+43
-44
lines changed

5 files changed

+43
-44
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Xenos
22
=====
33

4-
Windows dll injector. This project completely depends on Blackbone library - https://github.com/DarthTon/Blackbone
4+
Windows dll injector. Based on Blackbone library - https://github.com/DarthTon/Blackbone
55

66
## Features ##
77

@@ -31,4 +31,6 @@ Manual map features:
3131
Supported OS: Win7 - Win10 x64
3232

3333
## License ##
34-
Xenos is licensed under the MIT License. Dependencies are under their respective licenses.
34+
Xenos is licensed under the MIT License. Dependencies are under their respective licenses.
35+
36+
[![Build status](https://ci.appveyor.com/api/projects/status/eu6lpbla89gjgy5m?svg=true)](https://ci.appveyor.com/project/DarthTon/xenos)

appveyor.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 1.0.{build}
2+
3+
branches:
4+
only:
5+
- master
6+
- VS2017
7+
8+
image: Visual Studio 2017
9+
clone_folder: c:\projects\xenos
10+
11+
platform:
12+
- Win32
13+
- x64
14+
15+
configuration:
16+
- Debug
17+
- Release
18+
19+
build:
20+
parallel: true
21+
project: Xenos.sln

src/InjectionCore.cpp

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,13 @@ NTSTATUS InjectionCore::GetTargetProcess( InjectContext& context, PROCESS_INFORM
131131
else
132132
{
133133
// Attach for thread init
134-
status = _process.Attach(
135-
pi.dwProcessId,
136-
PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_CREATE_THREAD | PROCESS_VM_READ
137-
);
134+
status = _process.Attach( pi.dwProcessId );
138135
}
139136

140137
// Create new thread to make sure LdrInitializeProcess gets called
141138
if (NT_SUCCESS( status ))
142-
{
143139
_process.EnsureInit();
144140

145-
// Reattach with full rights
146-
if (!context.cfg.krnHandle)
147-
status = _process.Attach( pi.dwProcessId );
148-
}
149-
150141
if (!NT_SUCCESS( status ))
151142
{
152143
xlog::Error( "Failed to attach to process, status 0x%X", status );
@@ -677,37 +668,19 @@ blackbone::call_result_t<blackbone::ModuleDataPtr> InjectionCore::InjectDefault(
677668
code = STATUS_UNSUCCESSFUL;
678669

679670
xlog::Error( "Failed to inject pure IL image, status: %d", code );
671+
if (NT_SUCCESS( code ))
672+
code = STATUS_UNSUCCESSFUL;
673+
680674
return code;
681675
}
682676

683677
auto mod = _process.modules().GetModule( img.name(), blackbone::Sections );
684678
return mod ? blackbone::call_result_t<blackbone::ModuleDataPtr>( mod )
685679
: blackbone::call_result_t<blackbone::ModuleDataPtr>( STATUS_NOT_FOUND );
686680
}
687-
// Inject through existing thread
688-
else if (pThread != nullptr)
689-
{
690-
// Load
691-
auto pLoadLib = _process.modules().GetExport( _process.modules().GetModule( L"kernel32.dll" ), "LoadLibraryW" );
692-
if (!pLoadLib)
693-
return pLoadLib.status;
694-
695-
blackbone::RemoteFunction<decltype(&LoadLibraryW)> pfn( _process, pLoadLib->procAddress );
696-
697-
auto injectedMod = pfn.Call( img.path().c_str(), pThread );
698-
if (!injectedMod)
699-
{
700-
xlog::Error( "Failed to inject image using thread hijack, status 0x%X", injectedMod.status );
701-
return injectedMod.status;
702-
}
703-
704-
auto mod = _process.modules().GetModule( img.path() );
705-
return mod ? blackbone::call_result_t<blackbone::ModuleDataPtr>( mod )
706-
: blackbone::call_result_t<blackbone::ModuleDataPtr>( STATUS_NOT_FOUND );
707-
}
708681
else
709682
{
710-
auto injectedMod = _process.modules().Inject( img.path() );
683+
auto injectedMod = _process.modules().Inject( img.path(), pThread );
711684
if (!injectedMod)
712685
xlog::Error( "Failed to inject image using default injection, status: 0x%X", injectedMod.status );
713686

@@ -734,7 +707,7 @@ NTSTATUS InjectionCore::InjectKernel(
734707
img.path(),
735708
(KMmapFlags)context.cfg.mmapFlags,
736709
initRVA,
737-
context.cfg.initRoutine
710+
context.cfg.initArgs
738711
);
739712
}
740713
else
@@ -744,7 +717,7 @@ NTSTATUS InjectionCore::InjectKernel(
744717
img.path(),
745718
(context.cfg.injectMode == Kernel_Thread ? IT_Thread : IT_Apc),
746719
initRVA,
747-
context.cfg.initRoutine,
720+
context.cfg.initArgs,
748721
context.cfg.unlink,
749722
context.cfg.erasePE
750723
);
@@ -791,14 +764,17 @@ NTSTATUS InjectionCore::CallInitRoutine(
791764
return argMem.status;
792765

793766
argMem->Write( 0, context.cfg.initArgs.length() * sizeof( wchar_t ) + 2, context.cfg.initArgs.c_str() );
767+
auto status = _process.remote().ExecDirect( fnPtr, argMem->ptr() );
794768

795-
xlog::Normal( "Initialization routine returned 0x%X", _process.remote().ExecDirect( fnPtr, argMem->ptr() ) );
769+
xlog::Normal( "Initialization routine returned 0x%X", status );
796770
}
797771
// Execute in existing thread
798772
else
799773
{
800774
blackbone::RemoteFunction<fnInitRoutine> pfn( _process, fnPtr );
801-
xlog::Normal( "Initialization routine returned 0x%X", pfn.Call( context.cfg.initArgs.c_str(), pThread ) );
775+
auto status = pfn.Call( context.cfg.initArgs.c_str(), pThread );
776+
777+
xlog::Normal( "Initialization routine returned 0x%X", status );
802778
}
803779
}
804780

src/Xenos.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ END
197197
//
198198

199199
VS_VERSION_INFO VERSIONINFO
200-
FILEVERSION 2,2,2,0
201-
PRODUCTVERSION 2,2,2,0
200+
FILEVERSION 2,3,0,0
201+
PRODUCTVERSION 2,3,0,0
202202
FILEFLAGSMASK 0x3fL
203203
#ifdef _DEBUG
204204
FILEFLAGS 0x1L
@@ -214,12 +214,12 @@ BEGIN
214214
BLOCK "040004b0"
215215
BEGIN
216216
VALUE "FileDescription", "PE injector"
217-
VALUE "FileVersion", "2.2.2.0"
217+
VALUE "FileVersion", "2.3.0.0"
218218
VALUE "InternalName", "Xenos.exe"
219-
VALUE "LegalCopyright", "Copyright (C) 2015"
219+
VALUE "LegalCopyright", "Copyright (C) 2017"
220220
VALUE "OriginalFilename", "Xenos.exe"
221221
VALUE "ProductName", "Xenos"
222-
VALUE "ProductVersion", "2.2.2.0"
222+
VALUE "ProductVersion", "2.3.0.0"
223223
END
224224
END
225225
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)