smb_ntlm.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //---------------------------------------------------------------------------
  2. // __________________ _________ _____ _____ .__ ._.
  3. // \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
  4. // | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
  5. // | | \| ` \/ / Y \ / | | \ ___/ \|
  6. // |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
  7. // \/ \/ \/ \/ )/ \/ \/ \/
  8. //
  9. // This file is part of libdsm. Copyright © 2014 VideoLabs SAS
  10. //
  11. // Author: Julien 'Lta' BALLET <contact@lta.io>
  12. //
  13. // This program is free software. It comes without any warranty, to the extent
  14. // permitted by applicable law. You can redistribute it and/or modify it under
  15. // the terms of the Do What The Fuck You Want To Public License, Version 2, as
  16. // published by Sam Hocevar. See the COPYING file for more details.
  17. //----------------------------------------------------------------------------
  18. #ifndef __BDSM_SMB_NTLM_H_
  19. #define __BDSM_SMB_NTLM_H_
  20. #include "bdsm/smb_defs.h"
  21. typedef uint8_t smb_ntlmh_t[SMB_NTLM_HASH_SIZE];
  22. typedef struct
  23. {
  24. uint32_t header;
  25. uint32_t reserved;
  26. uint64_t timestamp;
  27. uint64_t challenge;
  28. uint32_t unknown;
  29. uint8_t domain[];
  30. } __attribute__((packed)) smb_ntlm_blob_t;
  31. uint64_t smb_ntlm_generate_challenge();
  32. void smb_ntlm_hash(const char *password, smb_ntlmh_t *hash);
  33. void smb_ntlm2_hash(const char *username, const char *password,
  34. const char *destination, smb_ntlmh_t *hash);
  35. // Returned response is blob_size + 16 long. You'll have to free it
  36. uint8_t *smb_ntlm2_response(smb_ntlmh_t *hash_v2, uint64_t srv_challenge,
  37. uint8_t *blob, size_t blob_size);
  38. // This method seems useless on Win7 (other untested)
  39. size_t smb_ntlm_blob(smb_ntlm_blob_t *blob, uint64_t ts,
  40. uint64_t user_challenge, const char *domain);
  41. #endif