Git Product home page Git Product logo

hash-dumper's Introduction

Windows NTLM hash dump utility written in C language, that supports Windows and Linux.

Hash dumper has got 2 modes:

  • Realtime mode (only for windows);
  • Extraction mode (dumps from saved SAM and SYSTEM hives files);

GitHub issues GitHub closed issues GitHub release (latest by SemVer including pre-releases) GitHub pull requests

GitHub License GitHub commit activity (branch)

Linux support NTLMv1 NTLMv2

Table of content

Responsibility

The author is not responsible for the actions of third parties committed while using the provided software. This software is regarded as a tool for legal penetration testing or conducting research. In case of misuse, the author does not bear any responsibility for the actions of third parties.

Building the project

For building required OpenSSL >= 3.0 or OpenSSL 1.1.1 library. Use cmake to generate a solution for Visual Studio or Make file. If CMake cannot find OpenSSL, than set OPENSSL_ROOT_DIR and OPENSSL_LIB_DIR variables.

If OpenSSL >= 3.0 was chosen, than legacy provider have to be compiled for RC4 and DES

Basic setup

Cloning repository

$ git clone https://github.com/Retr0-code/hash-dumper
$ git submodule update --init

If You work alone

$ git branch dev_<username>
$ git checkout dev_<username>
$ git push -u origin dev_<username>

OR

If You work in a small team

$ git checkout dev_<team_tag>
$ git pull

Building using cmake

Use BUILD_ARCH parameter to specify architecture of output binary

Architectures:

  • amd64 (default);
  • i386;

Use BUILD_TARGET parameter to specify compiling configuration

Configurations:

  • RELEASE (default);
  • DEBUG;

Manual

You can use this utility to dump NTLMv1/2 hashes from already compromised host by using --realtime flag

> ./hash_dumper.exe --realtime
[+] Hives successfully opened
[+] Successfully dumped bootkey: 2766FA60DBAB4DEE67237AC942E35271
[+] Successfully hashed the bootkey: 966408e98667069a4884956c5e397575

Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:9cf3445f9555a4c246fe2c3c2446b103:::
sandbox:1002:aad3b435b51404eeaad3b435b51404ee:67b6acadb87c12e9d84e6e73b6883601:::

[+] Successfully finished

Otherwise You can extract hashes from already saved hives using parameters --sam <path_to_sam_hive> and --system <path_to_system_hive>

> ./hash_dumper.exe --sam hives/sam --system hives/system
[+] Hives successfully opened
[+] Successfully dumped bootkey: 2766FA60DBAB4DEE67237AC942E35271
[+] Successfully hashed the bootkey: 966408e98667069a4884956c5e397575

Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:9cf3445f9555a4c246fe2c3c2446b103:::
sandbox:1002:aad3b435b51404eeaad3b435b51404ee:67b6acadb87c12e9d84e6e73b6883601:::

[+] Successfully finished

If You supply all parameters only --realtime will work.

hash-dumper's People

Contributors

retr0-code avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hash-dumper's Issues

CMake

CMake

CMake cannot find OpenSSL 3 on linux machine and using enviroment variables does not help

Crypto files

Crypto files

Describes functions for encryption, decryption and hashing.

  • Wrapper for EVP_Cipher
  • AES_128_CBC function using wrapper;
  • RC4 function using wrapper;
  • MD5 function;
  • Enumeration for encryption/decryption;

Rework decrypt hash functions

Summary

Write API function that takes function pointer to NTLM specific callback. Change decrypt_ntlm_hash switch logic to multiple if blocks. In first checks existance of hash, and second sets proper callback function for decryption.

Basic example

// ...
int exists_cmp = 0x14;
decrypt_callback_t decrypt_callback = &ntlmv1_decrypt_callback;
uint8_t* salt = hash_type ? NTPASSWORD : LMPASSWORD;
if (revision == 2)
{
    exists_cmp = 0x38;
    decrypt_callback = &ntlmv2_decrypt_callback;
    salt = encrypted_hash_salt;
}

if (hash_exists != exists_cmp)
{
    memcpy(hash_pointer, hash_type ? EMPTY_NT_HASH : EMPTY_LM_HASH, 16);
    return 0;
}

if (decrypt_hash(
    encrypted_hash,
    hashed_bootkey,
    salt,
    user_info_ptr,
    decrypt_callback,
    hash_pointer
) != 0)
    return error;

return 0;

Motivation

  • Simpler maintain;
  • Works faster, because «if» uses cmovcc instead of jmpcc;
  • Less code;

Big Endian compatibility

Description

Program does not support binaries.

Expected behavior

Work in BE mode as in LE

Fix

Add convertion lines in macros conditions.

Commit policy

Summary

Write commiting rules to help developers follow the course;
Suggest commiting rules in comments, please.

Basic example

  • All commits must have got breif, but specific comment;
  • Commits must follow single responsibility principle;
  • Developer must use own branch and follow rules described in contrbuting guidelines;

Motivation

If commits are properly constructed, developers will easily join to the development process and understand what everything is doing.

Better CMake

Summary

Update CMakeLists.txt to make it more useful.

  • Add RELEASE and DEBUG flags, which provides different levels of optimization and debug info;
  • Add install parameter, that copies compiled binary to specified paths;

Motivation

Contributers and users will interact more efficiently with our application

Hashed bootkey

Hashed bootkey

Create a function that constructs hashed bootkey depending on NTLM version

What have to be done:

  • #4
  • Error enumeration;
  • NTLMv1 hashing function;
  • NTLMv2 hashing function;

Pull Requests guidelines

Summary

Write rules for pulling request.
Suggest rules in the comments.

Basic example

  • Developer must fork the repository and create own working branch;
  • When creating a pull request developer should use existing quick pull templates;
  • Commited code have to be reviewed by contributors;
  • Developers must follow single responsibility princple;

Suggestions

  • Add "patch/fix" template;

Motivation

Pull requests help integrate new developers and provide safety for end product.

Linux Support

Linux Support

Linux does not support realtime dump, but it can dump hashes from given hive files.

What have to be done:

  • #2
  • #6
  • Macros for linux;
  • Functions dummy defenitions;

Git Branching

Summary

Use GitFlow in order to develop a new own model of branching.
Please suggest rules in the comments.

Suggestions

  • Add protection rules
  • Decide procedure of pulling requests;
  • Decide branching strategy;

Motivation

Developing a branching strategy will make integration of new code safer and faster.

CMake for Visual Studio

Summary

Write a CMakeLists for proper Visual Studio solution generation. CMake generates wrong configuration for Visual Studio, that totally cannot be used inside Visual Studio.

Motivation

By using cmake developers can skip setting up a VS solution and project, so they can add new features and fix bugs faster.

Small refactoring

Summary

  • Change condition in line 319 of hive.c to inversion;
  • Add parameters validation macro #define validate_parameters(condition, error);
  • Add doxygen documentation comments;

Motivation

Make code more standarized and easier to understand.

Contributing guidelines

Summary

Write a guidelines for contributors, to help developers cooperate more effective.
Suggest good practices in the comments.

What have to be included?

Motivation

Contributors will integrate faster into development process and in the result develop more effective and efficient.

Linux GCC operates with 4 byte wchar_t instead of 2

Description

Linux GCC operates with 4 byte wchar_t instead of 2. This cause invalid parsing and conversion of bootkey. Besides that characters displayed with it are unreadable.

To Reproduce

Steps to reproduce the behavior:

  1. Compile on linux with clang or gcc
  2. Run the binary

Expected behavior

Properly displayed characters, valid bootkey parsing and conversion.

Show unknown argument

Summary

When unknown parameter was specified, app will show message only about this fact, without pointing to wrong argument.

Basic example

  1. Add a static global variable, which contains unknown parameter key;
  2. Set the variable's value if unknown parameter was specified;
  3. Add a function that returns value of the variable;

Motivation

User will recognize a mistake in command much easier.

Memory Leaks

Description

Using full leak check in valgrind, was found out that 1300 bytes of data were leaked

To Reproduce

Command used

$ valgrind --leak-check all ./hash_dumper --sam hives/sam --system hives/system

Expected behavior

Expected to free all used memory

Solution

Create deletion functions for core structures of hive and create end label in every function where will be full cleanup, than on error just goto label

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.