• Stars
    star
    312
  • Rank 133,530 (Top 3 %)
  • Language
    C#
  • Created about 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An implementation of PSExec in C#

CSExec (a C Sharp psexec implementation)

This is an example for how to implement psexec (from SysInternals Suite) functionality, but in open source C#. This does not implement all of the psexec functionality, but it does implement the equivalent functionality to running: psexec -s \\target-host cmd.exe

screenshot

psexec works by doing the following steps:

  • copy a windows service executable (psexecsvc.exe) that is embedded within the psexec.exe binary to \\target-host\admin$\system32
  • remotely connect to the service control manager on \\target-host to install and start the psexecsvc.exe service
  • connect to the named pipe on the target host: \\target-host\pipe\psexecsvc
  • send commands to the psexecsvc via the named pipe
  • receive output via the psexecsvc named pipe
  • upon exit, uninstall service, delete service executable

This project csexec mimicks those steps in native C# with only a minimal amount of pinvoke for the remote service installation. It's actually surprisingly simple and takes a very minimal amount of code to implement.

The primary difference between this and psexec is that it must determine the .NET runtime on the remote host in order to install the correctly compiled service executable.

Build in Visual Studio to create .NET 3.5, 4.0, and 4.5 executables for your client preference (Win 7 - Win 10+).

More Repositories

1

ManagedInjection

A proof of concept for dynamically loading .net assemblies at runtime with only a minimal convention pre-knowledge
C#
164
star
2

NamedPipes

A pattern for client/server communication via Named Pipes via C#
C#
96
star
3

UnstoppableService

A pattern for a self-installing Windows service in C# with the unstoppable attributes in C#.
C#
66
star
4

WMIProcessWatcher

An example pattern in C# for using WMI to monitor process creation and termination events.
C#
50
star
5

DnsCache

C++
44
star
6

AntiDebug

PoC: Prevent a debugger from attaching to managed .NET processes via a watcher process code pattern.
C#
34
star
7

WcfScan

A tool for scanning NET.TCP WCF endpoints to test the security of their binding configurations.
C#
28
star
8

WidgetSender

Intentionally Vulnerable Demo App: .NET MVC, WCF, WebAPI, Web Forms
C#
22
star
9

ActiveDirectoryServices

A more full featured C# API for connecting to and managing Active Directory (AD) and Lightweight Directory (AD-LDS) instances, complete with consumer application examples.
C#
22
star
10

Periscope

C#
20
star
11

ChromePasswords

C
20
star
12

WhoDis

An example pattern in C# for watching security events (logon/logoff/privilege)
C#
19
star
13

BlueScreenOnExit

PoC of a protected process causing a blue screen if killed.
C#
16
star
14

RunAs

An example in C# for programmatically calling UAC to escalate to admin
C#
15
star
15

CertCheck

Programmatically access a TLS certificate chain in C++ and C#
C++
15
star
16

SneakyService

A simple, minimal C# windows service implementation that can be used to demonstrate privilege escalation from misconfigured windows services.
C#
14
star
17

DieHard

PoC: process watcher patterns to make killing a process hard.
C#
12
star
18

TLAD

The Totally Legit Authentication Dialog
C#
12
star
19

fake-ransomware

C#
11
star
20

ProtectProcessFromJoeUser

PoC: Protecting Joe User from killing his own process.
C#
10
star
21

kata

A collection of breach and post-exploitation kata for the red teamer to constantly train to maintain proficiency.
8
star
22

LuhnForce

A C# tool for brute forcing Credit Card numbers with valid Luhn checks.
C#
7
star
23

PlanetExpressStockTracker

A silly little example how to trojan a C# windows app, as demonstrated at the southwest region CCDC competition.
C#
5
star
24

Trojan-RetailDiagnostics

C#
5
star
25

HeapSurf

A credit card memory scraper written in C#
C#
5
star
26

BurpHmac

An HMAC authentication header plugin for Burp Proxy, written in Python.
Python
3
star
27

SpoofParentProcess

C++
3
star
28

netstat

C++
2
star
29

WindowsSessions

C++
2
star
30

taskkill

C++
2
star
31

SunburstStrings

C#
1
star
32

screenshot

C++
1
star
33

HappySad

Sometimes you just need a Happy EXE and a Sad EXE
C++
1
star