View | Details | Raw Unified | Return to bug 50575
Collapse All | Expand All

(-)setup.py (-14 / +11 lines)
 Lines 7-26    Link Here 
7
#
7
#
8
# 2002-10-27 Barry Pederson <bp@barryp.org>
8
# 2002-10-27 Barry Pederson <bp@barryp.org>
9
9
10
import sys
11
from distutils.core import setup, Extension
10
from distutils.core import setup, Extension
12
11
13
setup(name = "smbpasswd", 
12
setup(
14
      description = "SMB Password Hash Generator - suitable for use with Samba",
13
    name="smbpasswd",
15
      version = "1.0.1",
14
    description="SMB Password Hash Generator - suitable for use with Samba",
16
      license = "GPL",
15
    version="1.0.1",
17
      author = "Barry Pederson",
16
    license="GPL",
18
      author_email = "bp@barryp.org",
17
    author="Barry Pederson",
19
      url = "http://barryp.org/software/py-smbpasswd",
18
    author_email="bp@barryp.org",
20
      ext_modules = 
19
    url="http://barryp.org/software/py-smbpasswd",
21
        [
20
    ext_modules=[
22
        Extension("smbpasswd", ['md4.c', 'smbdes.c', 'smbpasswd.c'])
21
        Extension("smbpasswd", ['md4.c', 'smbdes.c', 'smbpasswd.c'])
23
        ]
22
    ]
24
     )
23
)
25
    
26
##### That's all folks ###########    
(-)smbpasswd.c (-31 / +29 lines)
 Lines 1-6    Link Here 
1
/*
1
/*
2
    Python Samba Password Hash Generating module
2
    Python Samba Password Hash Generating module
3
    
3
4
    Copyright (C) 2002 Barry Pederson <bp@barryp.org>
4
    Copyright (C) 2002 Barry Pederson <bp@barryp.org>
5
5
6
    This program is free software; you can redistribute it and/or modify
6
    This program is free software; you can redistribute it and/or modify
 Lines 23-30    Link Here 
23
23
24
*/
24
*/
25
25
26
 
26
27
#include "Python.h" 
27
#include "Python.h"
28
#include <memory.h>
28
#include <memory.h>
29
#include <ctype.h>
29
#include <ctype.h>
30
30
 Lines 56-80   Functions:\n\ Link Here 
56
static char HEXCHARS[] = "0123456789ABCDEF";
56
static char HEXCHARS[] = "0123456789ABCDEF";
57
57
58
static PyObject *
58
static PyObject *
59
hash_to_string(char *tmp) 
59
hash_to_string(char *tmp)
60
    {
60
    {
61
    int i;
61
    int i;
62
    unsigned char c;
62
    unsigned char c;
63
    char outbuffer[32];
63
    char outbuffer[32];
64
64
65
    /* build string from binary hash */
65
    /* build string from binary hash */
66
    for(i = 0; i < 16; i++) 
66
    for(i = 0; i < 16; i++)
67
        {
67
        {
68
        c=tmp[i];
68
        c=tmp[i];
69
        outbuffer[ i*2   ] = HEXCHARS[(c>>4) & 0x0f];
69
        outbuffer[ i*2   ] = HEXCHARS[(c>>4) & 0x0f];
70
        outbuffer[(i*2)+1] = HEXCHARS[   c   & 0x0f];
70
        outbuffer[(i*2)+1] = HEXCHARS[   c   & 0x0f];
71
        }
71
        }
72
        
72
73
    return PyString_FromStringAndSize(outbuffer, 32);
73
    return PyString_FromStringAndSize(outbuffer, 32);
74
    }
74
    }
75
75
76
76
77
static PyObject * 
77
static PyObject *
78
lmhash(PyObject *self, PyObject *args)
78
lmhash(PyObject *self, PyObject *args)
79
    {
79
    {
80
    char *pwd;
80
    char *pwd;
 Lines 88-156   lmhash(PyObject *self, PyObject *args) Link Here 
88
    if (!(PyArg_ParseTuple(args, "s#", &pwd, &pwd_len)))
88
    if (!(PyArg_ParseTuple(args, "s#", &pwd, &pwd_len)))
89
        return NULL;
89
        return NULL;
90
90
91
    /* make a copy that's truncated to 14 chars and uppercased */ 
91
    /* make a copy that's truncated to 14 chars and uppercased */
92
    if (pwd_len > LMPASSWDLEN)       
92
    if (pwd_len > LMPASSWDLEN)
93
        pwd_len = LMPASSWDLEN;
93
        pwd_len = LMPASSWDLEN;
94
    memset(lmpwd, '\0', sizeof(lmpwd));
94
    memset(lmpwd, '\0', sizeof(lmpwd));
95
    for (i = 0; i < pwd_len; i++)
95
    for (i = 0; i < pwd_len; i++)
96
        lmpwd[i]=toupper(pwd[i]);        
96
        lmpwd[i]=toupper(pwd[i]);
97
97
98
    /* Generate the hash */
98
    /* Generate the hash */
99
    memset(hashout,'\0',sizeof(hashout));
99
    memset(hashout,'\0',sizeof(hashout));
100
    E_P16(lmpwd, hashout);                
100
    E_P16(lmpwd, hashout);
101
    
101
102
    /* clean things up  - don't know how much good it does since 
102
    /* clean things up  - don't know how much good it does since
103
       Python presumably has other copies of the password floating 
103
       Python presumably has other copies of the password floating
104
       around, but what the hell - I'll do my part since I know it's
104
       around, but what the hell - I'll do my part since I know it's
105
       safe.
105
       safe.
106
    */
106
    */
107
    memset(lmpwd, '\0', sizeof(lmpwd));
107
    memset(lmpwd, '\0', sizeof(lmpwd));
108
        
108
109
    return hash_to_string(hashout);
109
    return hash_to_string(hashout);
110
    }
110
    }
111
111
112
112
113
static PyObject * 
113
static PyObject *
114
nthash(PyObject *self, PyObject *args)
114
nthash(PyObject *self, PyObject *args)
115
    {
115
    {
116
    char *pwd;
116
    char *pwd;
117
    int pwd_len;
117
    int pwd_len;
118
    char hashout[17];
118
    char hashout[17];
119
         
119
120
    pwd = NULL;         
120
    pwd = NULL;
121
    if (!(PyArg_ParseTuple(args, "es#", "utf-16le", &pwd, &pwd_len)))
121
    if (!(PyArg_ParseTuple(args, "es#", "utf-16le", &pwd, &pwd_len)))
122
        return NULL;
122
        return NULL;
123
123
124
    memset(hashout,'\0',sizeof(hashout));
124
    memset(hashout,'\0',sizeof(hashout));
125
    mdfour(hashout, pwd, pwd_len);        
125
    mdfour(hashout, pwd, pwd_len);
126
    
126
127
    /* clean things up  - don't know how much good it does since 
127
    /* clean things up  - don't know how much good it does since
128
       Python presumably has other copies of the password floating 
128
       Python presumably has other copies of the password floating
129
       around, but what the hell - I'll do my part since I'm pretty
129
       around, but what the hell - I'll do my part since I'm pretty
130
       sure it's safe, from my understanding of PyArg_ParseTuple and "es#"
130
       sure it's safe, from my understanding of PyArg_ParseTuple and "es#"
131
    */
131
    */
132
    memset(pwd, '\0', pwd_len);
132
    memset(pwd, '\0', pwd_len);
133
    PyMem_Free(pwd);
133
    PyMem_Free(pwd);
134
    
134
135
    return hash_to_string(hashout);
135
    return hash_to_string(hashout);
136
    }
136
    }
137
137
138
138
139
static PyObject * 
139
static PyObject *
140
hash(PyObject *self, PyObject *args)
140
hash(PyObject *self, PyObject *args)
141
    {
141
    {
142
    PyObject *result;
142
    PyObject *result;
143
    
143
144
    result = PyTuple_New(2);
144
    result = PyTuple_New(2);
145
    PyTuple_SetItem(result, 0, lmhash(self, args));
145
    PyTuple_SetItem(result, 0, lmhash(self, args));
146
    PyTuple_SetItem(result, 1, nthash(self, args));
146
    PyTuple_SetItem(result, 1, nthash(self, args));
147
    
147
148
    return result;        
148
    return result;
149
    }
149
    }
150
150
151
151
152
/* List of functions exported by this module */
152
/* List of functions exported by this module */
153
static PyMethodDef smbpasswd_functions[] = 
153
static PyMethodDef smbpasswd_functions[] =
154
    {
154
    {
155
    {"lmhash",  lmhash, METH_VARARGS},
155
    {"lmhash",  lmhash, METH_VARARGS},
156
    {"nthash",  nthash, METH_VARARGS},
156
    {"nthash",  nthash, METH_VARARGS},
 Lines 160-166   static PyMethodDef smbpasswd_functions[] = Link Here 
160
160
161
161
162
/* Initialize this module. */
162
/* Initialize this module. */
163
void 
163
void
164
initsmbpasswd(void)
164
initsmbpasswd(void)
165
    {
165
    {
166
    Py_InitModule3("smbpasswd", smbpasswd_functions, module_doc);
166
    Py_InitModule3("smbpasswd", smbpasswd_functions, module_doc);
167
- 
168
--
169
smbpasswd.c | 31 ++++++++++++++++++++++++++++++-
167
smbpasswd.c | 31 ++++++++++++++++++++++++++++++-
170
1 file changed, 30 insertions(+), 1 deletion(-)
168
1 file changed, 30 insertions(+), 1 deletion(-)
(-)smbpasswd.c (-3 / +30 lines)
 Lines 29-34    Link Here 
29
#include <ctype.h>
29
#include <ctype.h>
30
30
31
#define LMPASSWDLEN 14
31
#define LMPASSWDLEN 14
32
#if PY_MAJOR_VERSION >= 3
33
    #define PyString_FromStringAndSize   PyUnicode_FromStringAndSize
34
#endif
32
35
33
/* from md4.c and smbdes.c */
36
/* from md4.c and smbdes.c */
34
void mdfour(unsigned char *out, unsigned char *in, int n);
37
void mdfour(unsigned char *out, unsigned char *in, int n);
 Lines 160-169   static PyMethodDef smbpasswd_functions[] = Link Here 
160
163
161
164
162
/* Initialize this module. */
165
/* Initialize this module. */
163
void
166
167
#if PY_MAJOR_VERSION >= 3
168
    static struct PyModuleDef moduledef = {
169
        PyModuleDef_HEAD_INIT,
170
        "smbpasswd",     /* m_name */
171
        module_doc,  /* m_doc */
172
        -1,                  /* m_size */
173
        smbpasswd_functions,    /* m_methods */
174
        NULL,                /* m_reload */
175
        NULL,                /* m_traverse */
176
        NULL,                /* m_clear */
177
        NULL,                /* m_free */
178
    };
179
#endif
180
181
182
183
PyMODINIT_FUNC
184
185
#if PY_MAJOR_VERSION >= 3
186
PyInit_smbpasswd(void)
187
#else
164
initsmbpasswd(void)
188
initsmbpasswd(void)
189
#endif
165
    {
190
    {
191
#if PY_MAJOR_VERSION >= 3
192
    PyModule_Create(&moduledef);
193
#else
166
    Py_InitModule3("smbpasswd", smbpasswd_functions, module_doc);
194
    Py_InitModule3("smbpasswd", smbpasswd_functions, module_doc);
195
#endif
167
    }
196
    }
168
197
169
/****** EOF *********/
198
/****** EOF *********/
170
- 
171
--
172
debian/compat                    |  2 +-
199
debian/compat                    |  2 +-
173
debian/control                   | 15 ++++++++++++---
200
debian/control                   | 15 ++++++++++++---
174
debian/pycompat                  |  1 -
201
debian/pycompat                  |  1 -
175
debian/python-smbpasswd.install  |  1 +
202
debian/python-smbpasswd.install  |  1 +
176
debian/python3-smbpasswd.install |  1 +
203
debian/python3-smbpasswd.install |  1 +
177
5 files changed, 15 insertions(+), 5 deletions(-)
204
5 files changed, 15 insertions(+), 5 deletions(-)
178
delete mode 100644 debian/pycompat
205
delete mode 100644 debian/pycompat
179
create mode 100644 debian/python-smbpasswd.install
206
create mode 100644 debian/python-smbpasswd.install
180
create mode 100644 debian/python3-smbpasswd.install
207
create mode 100644 debian/python3-smbpasswd.install
(-)debian/compat (-1 / +1 lines)
Line 1    Link Here 
1
5
1
9
(-)debian/control (-3 / +12 lines)
 Lines 2-9   Source: python-smbpasswd Link Here 
2
Section: python
2
Section: python
3
Priority: optional
3
Priority: optional
4
Maintainer: Bjorn Ove Grotan <bgrotan@grotan.com> 
4
Maintainer: Bjorn Ove Grotan <bgrotan@grotan.com> 
5
Build-Depends: debhelper (>= 5.0.37.2), python-all-dev (>= 2.3.5-11),
5
Build-Depends: debhelper, python-all-dev (>= 2.3.5-11),
6
 cdbs (>= 0.4.5), dh-python
6
 cdbs (>= 0.4.5), dh-python, python3-all-dev
7
Standards-Version: 3.7.2
7
Standards-Version: 3.7.2
8
8
9
Package: python-smbpasswd
9
Package: python-smbpasswd
 Lines 11-17   Architecture: any Link Here 
11
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
11
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
12
Provides: ${python:Provides}
12
Provides: ${python:Provides}
13
Suggests: luma
13
Suggests: luma
14
XB-Python-Version: ${python:Versions}
14
Description: This module can generate both LANMAN and NT password hashes
15
 smbpasswd was written to generate password hashes suitable for use with samba,
16
 and possibly other places which uses LANMAN and/or NT hashes - such as
17
 samba with ldap-backend, or even as hash in some radius implementations.
18
19
Package: python3-smbpasswd
20
Architecture: any
21
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}
22
Provides: ${python3:Provides}
23
Suggests: luma
15
Description: This module can generate both LANMAN and NT password hashes
24
Description: This module can generate both LANMAN and NT password hashes
16
 smbpasswd was written to generate password hashes suitable for use with samba,
25
 smbpasswd was written to generate password hashes suitable for use with samba,
17
 and possibly other places which uses LANMAN and/or NT hashes - such as
26
 and possibly other places which uses LANMAN and/or NT hashes - such as
(-)debian/pycompat (-1 lines)
Line 1    Link Here 
1
2
(-)debian/python-smbpasswd.install (+1 lines)
Line 0    Link Here 
1
usr/lib/python2.7/dist-packages
(-)debian/python3-smbpasswd.install (-2 / +1 lines)
Line 0    Link Here 
0
- 
1
usr/lib/python3/dist-packages
1
--
2
debian/changelog | 7 +++++++
2
debian/changelog | 7 +++++++
3
1 file changed, 7 insertions(+)
3
1 file changed, 7 insertions(+)
(-)debian/changelog (-1 / +7 lines)
 Lines 1-3    Link Here 
1
python-smbpasswd (1.0.2-1) unstable; urgency=medium
2
3
  * Non-maintainer upload.
4
  * Build python3 package
5
6
 -- Florian Best <best@univention.de>  Fri, 29 Nov 2019 14:56:20 +0100
7
1
python-smbpasswd (1.0.1-1.3) unstable; urgency=medium
8
python-smbpasswd (1.0.1-1.3) unstable; urgency=medium
2
9
3
  * Non-maintainer upload.
10
  * Non-maintainer upload.
4
- 

Return to bug 50575