Skip to content

Commit 12ebc21

Browse files
committed
Initial commit
1 parent 6f34542 commit 12ebc21

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# whocalls
1+
# What
2+
3+
___whocalls___ is a simple Windows DLL that logs some info whenever it gets loaded.
4+
5+
# Why
6+
7+
For use in identifying and demonstrating DLL planting opportunities.
8+
9+
(I can never find other people's implementations when I need them.)
10+
11+
# How
12+
13+
1. Customise the output filename in the source code.
14+
15+
2. Compile to PE format.
16+
17+
e.g. Using MinGW on Kali:
18+
19+
`x86_64-w64-mingw32-gcc -shared -s -o whocalls.dll whocalls.c`
20+
21+
3. Customise the DLL name and drop it somewhere.
22+
3. Periodically review the log file.
23+
24+
# Where
25+
26+
That's up to you.
27+

whocalls.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <stdio.h>
2+
#include <time.h>
3+
#include <windows.h>
4+
5+
6+
#if defined(__cplusplus)
7+
extern "C" {
8+
#endif
9+
__declspec(dllexport) int DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
10+
{
11+
12+
if (fdwReason != 1 && fdwReason !=2) { // DLL_PROCESS_ATTACH or DLL_THREAD_ATTACH
13+
return 1;
14+
}
15+
16+
FILE *fp;
17+
fp = fopen ("C:/HONKHONK.TXT", "a"); // You probably want to customise this... ;-)
18+
19+
char hostname[255] = "";
20+
ZeroMemory(hostname, sizeof(hostname) );
21+
DWORD CompBuffer = 255;
22+
GetComputerName(hostname, &CompBuffer);
23+
24+
char username[255] = "";
25+
ZeroMemory(username, sizeof(username) );
26+
DWORD NameBuffer = 255;
27+
GetUserName(username, &NameBuffer);
28+
29+
char dllpath[65535];
30+
GetModuleFileName(hinstDLL, dllpath, sizeof(dllpath));
31+
32+
char exepath[65535];
33+
GetModuleFileName(NULL, exepath, sizeof(exepath));
34+
35+
SYSTEMTIME st;
36+
GetSystemTime(&st); // This is UTC time. GetLocalTime, er, gets the local time
37+
38+
fprintf(fp, "%s|%s|%s|%s|%d|%d/%d/%d %d:%d:%d:%d\n", hostname, username, dllpath, exepath, fdwReason, st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
39+
40+
41+
fclose (fp);
42+
return 1;
43+
}
44+
45+
#if defined(__cplusplus)
46+
}
47+
#endif

0 commit comments

Comments
 (0)