├── .gitattributes
├── GetWebDAVStatus_BOF
├── GetWebDAVStatus_x64.o
└── src
│ ├── Source.c
│ └── beacon.h
├── GetWebDAVStatus_DotNet
├── GetWebDAVStatus
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── GetWebDAVStatus.csproj
└── GetWebDAVStatus.sln
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_BOF/GetWebDAVStatus_x64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xforcered/GetWebDAVStatus/HEAD/GetWebDAVStatus_BOF/GetWebDAVStatus_x64.o
--------------------------------------------------------------------------------
/GetWebDAVStatus_DotNet/GetWebDAVStatus/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GetWebDAVStatus
2 | Small project to determine if the Web Client service (WebDAV) is running on a remote system by checking for the presence of the DAV RPC SERVICE named pipe. Does not require admin privileges on the remote system, but does require some form of valid credentials (no anonymous access). Both a BOF and C# version of the project are included, the C# version is multi-threaded so would be better suited for scanning a large number of systems.
3 |
4 | ## Usage
5 | Both the BOF and C# versions take a comma-seperated list of systems to scan. The C# version also has an optional arg of "--tc" that allows the operator to control the max amount of threads to be used (default: 5).
6 |
7 | BOF: `inline-execute C:\scripts\GetWebDAVStatus_x64.o server01,server02`
8 |
9 | C#: `execute-assembly C:\assemblies\GetWebDAVStatus.exe server01,server02 --tc 1`
10 |
11 | ## Building
12 | The C# project should be a pretty standard build, x64 + Release is the recommended build configuration. BOF can be built with the following command from the Developer Command Prompt for VS:
13 |
14 | `cl.exe /c /GS- Source.c /Fo./GetWebDAVStatus_x64.o`
15 |
16 | ## Credits
17 | [@tifkin_](https://twitter.com/tifkin_) originally posted about this method of remotely identifying WebDAV [here](https://twitter.com/tifkin_/status/1419806476353298442).
18 |
19 | Originally heard about the above tweet on [@flangvik](https://twitter.com/Flangvik)'s [twitch stream](https://www.twitch.tv/flangvik). Would definitely recommend checking out.
20 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_DotNet/GetWebDAVStatus/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("GetWebDAVStatus")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GetWebDAVStatus")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("89901571-47fb-4237-9ed7-de025913641c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_BOF/src/Source.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "beacon.h"
4 |
5 | WINBASEAPI BOOL WINAPI KERNEL32$WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut);
6 | WINBASEAPI void* WINAPI MSVCRT$malloc(SIZE_T);
7 | WINBASEAPI SIZE_T WINAPI MSVCRT$strlen(const char* str);
8 | WINBASEAPI void* WINAPI MSVCRT$strcpy(const char* dest, const char* source);
9 | WINBASEAPI void* WINAPI MSVCRT$strcat(const char* dest, const char* source);
10 | WINBASEAPI void* WINAPI MSVCRT$strtok(char* str, const char* delim);
11 | WINBASEAPI void* WINAPI MSVCRT$free(void*);
12 |
13 | void go(char* args, int length)
14 | {
15 | char* pipeNameHead = "\\\\";
16 | char* pipeNameTail = "\\pipe\\DAV RPC SERVICE";
17 | BOOL pipeStatus = 0;
18 | char* singleHost = MSVCRT$strtok(args, ",");
19 |
20 | while (singleHost != NULL)
21 | {
22 | char* fullPipeName = MSVCRT$malloc(MSVCRT$strlen(singleHost) + MSVCRT$strlen(pipeNameHead) + MSVCRT$strlen(pipeNameTail) + 1);
23 | MSVCRT$strcpy(fullPipeName, pipeNameHead);
24 | MSVCRT$strcat(fullPipeName, singleHost);
25 | MSVCRT$strcat(fullPipeName, pipeNameTail);
26 | pipeStatus = KERNEL32$WaitNamedPipeA(fullPipeName, 3000);
27 | if (pipeStatus == 0)
28 | {
29 | BeaconPrintf(CALLBACK_OUTPUT, "[x] Unable to hit DAV pipe on %s, system is either unreachable or does not have WebClient service running", singleHost);
30 | }
31 | else
32 | {
33 | BeaconPrintf(CALLBACK_OUTPUT, "[+] WebClient service is active on %s", singleHost);
34 | }
35 | MSVCRT$free((void*)fullPipeName);
36 | singleHost = MSVCRT$strtok(NULL, ",");
37 | }
38 | }
--------------------------------------------------------------------------------
/GetWebDAVStatus_DotNet/GetWebDAVStatus.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31624.102
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetWebDAVStatus", "GetWebDAVStatus\GetWebDAVStatus.csproj", "{89901571-47FB-4237-9ED7-DE025913641C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {89901571-47FB-4237-9ED7-DE025913641C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {89901571-47FB-4237-9ED7-DE025913641C}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {89901571-47FB-4237-9ED7-DE025913641C}.Debug|x64.ActiveCfg = Debug|x64
19 | {89901571-47FB-4237-9ED7-DE025913641C}.Debug|x64.Build.0 = Debug|x64
20 | {89901571-47FB-4237-9ED7-DE025913641C}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {89901571-47FB-4237-9ED7-DE025913641C}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {89901571-47FB-4237-9ED7-DE025913641C}.Release|x64.ActiveCfg = Release|x64
23 | {89901571-47FB-4237-9ED7-DE025913641C}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {D08EC449-D284-4D38-A84F-8BB39A9BCAA7}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_DotNet/GetWebDAVStatus/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Threading.Tasks;
6 |
7 | namespace GetWebDAVStatus
8 | {
9 | class Program
10 | {
11 | [DllImport("kernel32.dll", SetLastError = true)]
12 | [return: MarshalAs(UnmanagedType.Bool)]
13 | static extern bool WaitNamedPipeA(string lpNamedPipeName, uint nTimeOut);
14 |
15 | static void Main(string[] args)
16 | {
17 | int threadCount = 5;
18 | int targetIndex;
19 | List targetHosts;
20 |
21 | if (args.Length == 0)
22 | {
23 | Console.WriteLine("[X] Error: Provide target host(s) on the command line. If providing multiple targets, include as a comma seperated list");
24 | return;
25 | }
26 |
27 | try
28 | {
29 | int tcIndex = Array.FindIndex(args, x => x.Equals("--tc", StringComparison.OrdinalIgnoreCase));
30 | if (tcIndex >= 0)
31 | {
32 | threadCount = Int32.Parse(args[tcIndex + 1]);
33 | tcIndex = tcIndex * 2;
34 | }
35 | targetIndex = ((args.Length - 1) * args.Length / 2) - tcIndex - 1;
36 | targetHosts = args[targetIndex].Split(',').ToList();
37 | }
38 | catch (Exception e)
39 | {
40 | Console.WriteLine("[X] Error parsing arguments, please check command line and try again");
41 | Console.WriteLine(e.Message);
42 | return;
43 | }
44 |
45 | Parallel.ForEach(targetHosts, new ParallelOptions { MaxDegreeOfParallelism = threadCount }, singleTarget =>
46 | {
47 | string pipename = @"\\" + singleTarget + @"\pipe\DAV RPC SERVICE";
48 | //timeout is a somewhat arbitrary value, as if named pipe does not exist the function returns immediately.
49 | bool davActive = WaitNamedPipeA(pipename, 3000);
50 | if (davActive)
51 | {
52 | Console.WriteLine("[+] WebClient service is active on " + singleTarget);
53 | }
54 | else
55 | {
56 | Console.WriteLine("[x] Unable to reach DAV pipe on {0}, system is either unreachable or does not have WebClient service running", singleTarget);
57 | }
58 | });
59 | return;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_BOF/src/beacon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Beacon Object Files (BOF)
3 | * -------------------------
4 | * A Beacon Object File is a light-weight post exploitation tool that runs
5 | * with Beacon's inline-execute command.
6 | *
7 | * Cobalt Strike 4.1.
8 | */
9 |
10 | /* data API */
11 | typedef struct {
12 | char * original; /* the original buffer [so we can free it] */
13 | char * buffer; /* current pointer into our buffer */
14 | int length; /* remaining length of data */
15 | int size; /* total size of this buffer */
16 | } datap;
17 |
18 | DECLSPEC_IMPORT void BeaconDataParse(datap * parser, char * buffer, int size);
19 | DECLSPEC_IMPORT int BeaconDataInt(datap * parser);
20 | DECLSPEC_IMPORT short BeaconDataShort(datap * parser);
21 | DECLSPEC_IMPORT int BeaconDataLength(datap * parser);
22 | DECLSPEC_IMPORT char * BeaconDataExtract(datap * parser, int * size);
23 |
24 | /* format API */
25 | typedef struct {
26 | char * original; /* the original buffer [so we can free it] */
27 | char * buffer; /* current pointer into our buffer */
28 | int length; /* remaining length of data */
29 | int size; /* total size of this buffer */
30 | } formatp;
31 |
32 | DECLSPEC_IMPORT void BeaconFormatAlloc(formatp * format, int maxsz);
33 | DECLSPEC_IMPORT void BeaconFormatReset(formatp * format);
34 | DECLSPEC_IMPORT void BeaconFormatFree(formatp * format);
35 | DECLSPEC_IMPORT void BeaconFormatAppend(formatp * format, char * text, int len);
36 | DECLSPEC_IMPORT void BeaconFormatPrintf(formatp * format, char * fmt, ...);
37 | DECLSPEC_IMPORT char * BeaconFormatToString(formatp * format, int * size);
38 | DECLSPEC_IMPORT void BeaconFormatInt(formatp * format, int value);
39 |
40 | /* Output Functions */
41 | #define CALLBACK_OUTPUT 0x0
42 | #define CALLBACK_OUTPUT_OEM 0x1e
43 | #define CALLBACK_ERROR 0x0d
44 | #define CALLBACK_OUTPUT_UTF8 0x20
45 |
46 | DECLSPEC_IMPORT void BeaconPrintf(int type, char * fmt, ...);
47 | DECLSPEC_IMPORT void BeaconOutput(int type, char * data, int len);
48 |
49 | /* Token Functions */
50 | DECLSPEC_IMPORT BOOL BeaconUseToken(HANDLE token);
51 | DECLSPEC_IMPORT void BeaconRevertToken();
52 | DECLSPEC_IMPORT BOOL BeaconIsAdmin();
53 |
54 | /* Spawn+Inject Functions */
55 | DECLSPEC_IMPORT void BeaconGetSpawnTo(BOOL x86, char * buffer, int length);
56 | DECLSPEC_IMPORT void BeaconInjectProcess(HANDLE hProc, int pid, char * payload, int p_len, int p_offset, char * arg, int a_len);
57 | DECLSPEC_IMPORT void BeaconInjectTemporaryProcess(PROCESS_INFORMATION * pInfo, char * payload, int p_len, int p_offset, char * arg, int a_len);
58 | DECLSPEC_IMPORT void BeaconCleanupProcess(PROCESS_INFORMATION * pInfo);
59 |
60 | /* Utility Functions */
61 | DECLSPEC_IMPORT BOOL toWideChar(char * src, wchar_t * dst, int max);
62 |
--------------------------------------------------------------------------------
/GetWebDAVStatus_DotNet/GetWebDAVStatus/GetWebDAVStatus.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {89901571-47FB-4237-9ED7-DE025913641C}
8 | Exe
9 | GetWebDAVStatus
10 | GetWebDAVStatus
11 | v4.5
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 | true
36 | bin\x64\Debug\
37 | DEBUG;TRACE
38 | full
39 | x64
40 | 7.3
41 | prompt
42 | true
43 |
44 |
45 | bin\x64\Release\
46 | TRACE
47 | true
48 | pdbonly
49 | x64
50 | 7.3
51 | prompt
52 | true
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------