Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus API & Prometheus Node Exporter Interrogator #18290

Merged
merged 7 commits into from Sep 8, 2023

Conversation

h00die
Copy link
Contributor

@h00die h00die commented Aug 15, 2023

This PR creates 2 modules, a library and spec to handle various Prometheus things based on https://jfrog.com/blog/dont-let-prometheus-steal-your-fire/ .

  1. prometheus API interrogator will check a few API calls for any credentials/tokens/etc and print them as well as store the configs as loot.
  2. prometheus node exporter module (also works with windows exporter) will look for valuable information. PNE is almost SNMP like in nature, and you can expect 1,000-20,000 lines of output. Automating pulling valuable fields is a crucial timesaver.
  3. a library to parse a bunch of this information
  4. tests to ensure this is working

I based the library for Prometheus on the example in their docs, however this product looks almost infinitely configurable. I've covered as many cases as I found in the test case AND on the Internet that were accessible. However I'm sure I've missed some.

Verification

  • make sure spec passes
  • install prometheus and test the prometheus docker module, or just scan one on the internet.
  • install node exporter and/or windows exporter, scan with the module
  • Document for both modules

@h00die
Copy link
Contributor Author

h00die commented Aug 15, 2023

If you find any other pieces of information that are valuable anywhere, let me know, easy to add things in, I've only tackled the ones I found.

@bwatters-r7 bwatters-r7 self-assigned this Aug 18, 2023

yamlconf['scrape_configs']&.each do |scrape|
# check for targets which have creds built in to the URL
if scrape['static_configs']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like being "that guy," but this is a 450-line conditional statement. Is there any chance we might rework it to dispatch to methods rather than contain everything into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you aren't wrong. when I wrote it to exploit a customer they only had a few fields so it was simple. then when I got into the example config from prometheus, it kinda got out of hand. I'll see what I can do about re-writing it

@bwatters-r7
Copy link
Contributor

I went through testing the Prometheus API, but when I went to test the node, the docs look incomplete.

@h00die
Copy link
Contributor Author

h00die commented Sep 6, 2023

you are 100% correct, lemme get that fixed real quick

@h00die
Copy link
Contributor Author

h00die commented Sep 6, 2023

fixed up.

@bwatters-r7
Copy link
Contributor

Prometheus Node

msf6 auxiliary(gather/prometheus_node_exporter_gather) > show options

Module options (auxiliary/gather/prometheus_node_exporter_gather):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                      yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-met
                                         asploit.html
   RPORT      9100             yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The URI of the Prometheus Node Exporter
   VHOST                       no        HTTP server virtual host


View the full module info with the info, or info -d command.

msf6 auxiliary(gather/prometheus_node_exporter_gather) > set rhost 10.5.134.129
rhost => 10.5.134.129
msf6 auxiliary(gather/prometheus_node_exporter_gather) > run
[*] Running module against 10.5.134.129

[+] Go Version: go1.20.6
[+] SELinux enabled: 0
[+] Timezone: UTC
[+] BIOS Information
================

  Field              Value
  -----              -----
  Asset Tag
  Board Name         440BX Desktop Reference Platform
  Board Vendor       Intel Corporation
  Board Version      None
  Chassis Asset Tag  No Asset Tag
  Chassis Vendor     No Enclosure
  Date               11/12/2020
  Product Family
  Product Name       VMware Virtual Platform
  System Vendor      VMware, Inc.
  Vendor             Phoenix Technologies LTD
  Version            6.00

[+] OS Information
==============

  Field             Value
  -----             -----
  Family            ubuntu
  Name              Ubuntu
  Pretty Name       Ubuntu 22.04.3 LTS
  Version           22.04.3 LTS (Jammy Jellyfish)
  Version Codename  jammy
  Version ID        22.04

[+] Network Interfaces
==================

  Device   MAC                Broadcast          State
  ------   ---                ---------          -----
  docker0  02:42:69:cf:b5:8b  ff:ff:ff:ff:ff:ff  down
  ens32    00:0c:29:93:02:de  ff:ff:ff:ff:ff:ff  up
  lo       00:00:00:00:00:00  00:00:00:00:00:00  unknown

[+] File Systems
============

  Device     Mount Point                             FS Type
  ------     -----------                             -------
  /dev/sda2  /boot/efi                               vfat
  /dev/sda3  /                                       ext4
  /dev/sda3  /var/snap/firefox/common/host-hunspell  ext4
  tmpfs      /run                                    tmpfs
  tmpfs      /run/lock                               tmpfs
  tmpfs      /run/snapd/ns                           tmpfs
  tmpfs      /run/user/1000                          tmpfs

[+] uname Information
=================

  Field        Value
  -----        -----
  Arch         x86_64
  Domain Name  (none)
  Node Name    ubuntu2204x64
  OS Type      Linux
  Release      5.15.0-43-generic
  Version      #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022

[*] Auxiliary module execution completed

Prometheus API

msf6 auxiliary(gather/prometheus_api_gather) > run
[*] Running module against 10.5.134.129

[+] Prometheus found, version: 2.47.0
[+] YAML config saved to /home/tmoose/.msf4/loot/20230908124659_default_10.5.134.129_PrometheusYAML_564243.yaml
[+] JSON targets saved to /home/tmoose/.msf4/loot/20230908124659_default_10.5.134.129_PrometheusJSON_004145.json
[+] Config file: /etc/prometheus/prometheus.yml
[*] Auxiliary module execution completed

@bwatters-r7 bwatters-r7 merged commit fdae495 into rapid7:master Sep 8, 2023
57 checks passed
@bwatters-r7
Copy link
Contributor

Release Notes

This PR creates 2 modules: one to interrogate Prometheus API endpoints for information, the other to query Prometheus Node Exporters for information. This is supported by a new Prometheus library and specs.

@bwatters-r7 bwatters-r7 added the rn-modules release notes for new or majorly enhanced modules label Sep 8, 2023
@h00die h00die deleted the prometheus branch September 8, 2023 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs library module rn-modules release notes for new or majorly enhanced modules tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants