• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Python
  • Created over 1 year ago
  • Updated about 1 year ago

Reviews

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

Repository Details

Detect whether a service is installed (blindly) and/or running (if exposing named pipes) on a remote machine without using local admin privileges.

serviceDetector

Detect whether a service is installed (blindly) and/or running (if exposing named pipes) on a remote machine without using local admin privileges.

About

In more detail, running this script connects to the target SMB service (445/tcp) remotely and does the following:

  1. Checks if the specified service is installed through the [MS-LSAT] RPC call LsarLookupNames(). There is no need to use a privileged account, but only "blind" query is possible (cannot list the services, we can only ask the state of a specific service).

  2. Checks if the specified Named Pipe exists on the target. Services (processes) may expose a named pipe characteristic to the service, which can be seen by an unprivileged user. So checking specific named pipes characteristic to services may allow us to infer whether the specific service is running or not.

Installation

This is a standalone Python script using Impacket, no need to install anything. Tested it on up-to-date Kali and Arch Linux using the latest official Impacket (0.10.0 and 0.9.24) and Python (3.9 and 3.10).

Configuration

The services, service names to check, named pipes characteristic to the service are specified in JSON config files (or CSV files if it is more comfortable, what I realized later :), so a custom csv2json converter is also available) in the conf folder. For understanding the format, see the examples included.

Config files included:

Use cases may be extended by more services / named pipes, EDR config is quite incomplete, feel free to add more.

The script uses the JSON config format, but later I realized writing CSV is much more comfortable, so included the csv2json.py script to convert the CSV to JSON.

Running the tool

Running against a single target to enumerate AV/EDR services (or anything else) is straightforward:

./serviceDetector.py -conf conf/edr.json evil.corp/johndoe:[email protected]

Kerberos authentication is also supported (KRB5CCNAME env var is pointing to the ccache file):

./serviceDetector.py -conf conf/edr.json -k -no-pass server.ecorp.local

For running against multiple targets effectively GNU parallel is super useful:

cat targets.txt | parallel -j 50 ./serviceDetector.py evil.corp/johndoe:Passw0rd1@{}

Note that before running against a bunch of targets test against one in order to prevent account lockout (e.g. in the case of a misspelled password).

Opsec Note: be aware that concurrent mass login to different targets may trigger SOC alerts.

Acknowledgments

The two techniques used here are not new.

  1. [MS-LSAT] RPC call LsarLookupNames() was used earlier by Vincent Le Toux (@mysmartlogon) in the Antivirusscanner module of the awesome PingCastle tool.

  2. The named pipe idea for detecting running services was inspired by this tweet from Lee Christensen (@tifkin_) when he used this for the WebClient service detection. This technique for AV/EDR detection was also used by the NamedPipeTouch tool from NSA (leaked by The Shadow Brokers group).

More Repositories

1

rbcd-attack

Kerberos Resource-Based Constrained Delegation Attack from Outside using Impacket
Python
487
star
2

dll-hijack-by-proxying

Exploiting DLL Hijacking by DLL Proxying Super Easily
C
446
star
3

pwn-hisilicon-dvr

Python
351
star
4

ad-honeypot-autodeploy

Deploy a small, intentionally insecure, vulnerable Windows Domain for RDP Honeypot fully automatically.
Shell
251
star
5

usbgadget-tool

Dumb USB HID gadget creator for Android (for triggering device driver install on Windows for LPE)
Shell
135
star
6

stager_libpeconv

A basic meterpreter protocol stager using the libpeconv library by hasherezade for reflective loading
C++
82
star
7

hs-dvr-telnet

open telnet port on modern HiSilicon devices
Python
51
star
8

log4shell-vulnerable-app

A Basic Java Application Vulnerable to the Log4Shell RCE
Java
38
star
9

ctfs

some example ctf writeups
HTML
27
star
10

azure-function-proxy

basic proxy as an azure function serverless app
Python
18
star
11

smtp2slack4qnap

Compact SMTP to HTTP Gateway (targeting Slack for QNAP-NAS notifications)
Python
14
star
12

kali-rpi-luks-crypt

Full disk encryption for Kali on Raspberry using LUKS
13
star
13

malicious-service

Minimal Windows Service Template for demonstrating privilege escalation via weak service executable permissions
C
12
star
14

malicious-hisilicon-scripts

Materials from my older (2018) HiSilicon research
Python
10
star
15

linkedin-auth-bypass

browse linkedin profiles without a registered account
JavaScript
10
star
16

SharpShot

Trivial .NET desktop capturing for Red Team operations
C#
6
star
17

Bundesnachrichtendienst

reversing / malware analysis recruitment challenge for German Federal Intelligence
6
star
18

gcstar-win32

standalone executable built from GCstar Perl release
6
star
19

issuu-dl

download pdf from issuu.com
Python
5
star
20

remotethermo

remotethermo.com API test
Python
4
star
21

lineageos-bullhead-build

Unofficial LineageOS builds for Google Nexus 5X "bullhead" devices
Shell
4
star
22

oauth-mitmproxy

oauth refresh_token client in mitmproxy
Python
4
star
23

nmap-http-screenshot

take screenshots of http services from an nmap xml output
Perl
3
star
24

railfence

a simple python implementation of the Rail Fence cipher (with offset support)
Python
3
star
25

sencor-bluetooth

Sample development Python scripts for reading data from the Sencor SWS 500 Outdoor Thermo/Humidity Meter Bluetooth LE device.
Python
2
star
26

riemann-nonconvex

Simulation of a totally asymmetric attractive interacting particle system
C
2
star
27

burp-Base64PostRequest

Burp Extension: Base64 decode / encode POST request data
Java
2
star
28

icinga2-plugins

customized plugins for icinga2
Shell
1
star
29

CryptoExamples

Crypto Examples for Java
Java
1
star
30

prosmart-mqtt

Minimal proSmart - MQTT Gateway
Python
1
star
31

malware-agenttesla

Brief Malware Analysis of an Agent Tesla variant
HTML
1
star
32

ringzer0team

https://ringzer0team.com
1
star
33

pyevtx-helpers

Some useful parsers for Windows EventLog (evtx) files using pyevtx
Python
1
star
34

php-mailinglist

php interface to mailing lists through web interface (e.q. ezmlm, qmailadmin)
PHP
1
star
35

azure-function-proxy-ng

Azure Function as a Reverse Proxy (e.g. for C2 ;) )
Python
1
star