1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/usr/bin/python
#
# Dump Samba3 data
# Copyright Jelmer Vernooij 2005-2007
# Released under the GNU GPL v3 or later
#
import optparse
import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../python"))
import samba
import samba.samba3
parser = optparse.OptionParser("provision <libdir> <smb.conf>")
parser.add_option("--format", type="choice", metavar="FORMAT",
choices=["full", "summary"])
opts, args = parser.parse_args()
if opts.format is None:
opts.format = "summary"
def print_header(txt):
print "\n%s" % txt
print "=========================================="
def print_samba3_policy(pol):
print_header("Account Policies")
print "Min password length: %d" % pol.min_password_length
print "Password history length: %d" % pol.password_history
print "User must logon to change password: %d" % pol.user_must_logon_to_change_password
print "Maximum password age: %d" % pol.maximum_password_age
print "Minimum password age: %d" % pol.minimum_password_age
print "Lockout duration: %d" % pol.lockout_duration
print "Reset Count Minutes: %d" % pol.reset_count_minutes
print "Bad Lockout Minutes: %d" % pol.bad_lockout_minutes
print "Disconnect Time: %d" % pol.disconnect_time
print "Refuse Machine Password Change: %d" % pol.refuse_machine_password_change
def print_samba3_sam(samba3):
print_header("SAM Database")
for a in samba3.samaccounts:
print "%d: %s" % a.user_rid, a.username
def print_samba3_shares(samba3):
print_header("Configured shares")
for s in samba3.shares:
print "--- %s ---" % s.name
for p in s.parameters:
print "\t%s = %s" % (p.name, p.value)
print ""
def print_samba3_secrets(secrets):
print_header("Secrets")
print "IPC Credentials:"
if secrets.ipc_cred.username_obtained:
print " User: %s\n" % secrets.ipc_cred.get_username
if secrets.ipc_cred.password_obtained:
print " Password: %s\n" % secrets.ipc_cred.get_password
if secrets.ipc_cred.domain_obtained:
print " Domain: %s\n" % secrets.ipc_cred.get_domain
print "LDAP passwords:"
for pw in secrets.ldappws:
print "\t%s -> %s" % (pw.dn, pw.password)
print ""
print "Domains:"
for d in secrets.domains:
print "\t--- %s ---" % d.name
print "\tSID: %s" % d.sid
print "\tGUID: %s" % d.guid
print "\tPlaintext pwd: %s" % d.plaintext_pw
print "\tLast Changed: %lu" % d.last_change_time
print "\tSecure Channel Type: %d\n" % d.sec_channel_type
print "Trusted domains:"
for td in secrets.trusted_domains:
for n in td.uni_name:
print "\t--- %s ---" % n
print "\tPassword: %s" % td.password
print "\tModified: %lu" % td.mod_time
print "\tSID: %s" % td.domain_sid
def print_samba3_regdb(regdb):
print_header("Registry")
for k in regdb.keys:
print "%s\n" % k.name
for v in regdb.values(k):
print "\t%s: type %d, length %d" % (v.name, v.type, v.data.length)
def print_samba3_winsdb(samba3):
print_header("WINS Database")
for e in samba3.winsentries:
print "%s, nb_flags: %x, type: %d, ttl: %lu, %d ips, fst: %s" % (e.name, e.nb_flags, e.type, e.ttl, e.ips.length, e.ips[0])
def print_samba3_groupmappings(groupdb):
print_header("Group Mappings")
for g in groupdb.groupmappings:
print "\t--- Group: %s ---" % g.nt_name
print "\tComment: %s" % g.comment
print "\tGID: %d" % g.gid
print "\tSID Name Use: %d" % g.sid_name_use
print "\tSID: %s\n" % g.sid
def print_samba3_aliases(groupdb):
for a in groupdb.aliases:
print "\t--- Alias: %s ---" % a.sid
for m in a.members:
print "\t%s" % m
def print_samba3_idmapdb(idmapdb):
print_header("Winbindd SID<->GID/UID mappings")
print "User High Water Mark: %d" % idmapdb.user_hwm
print "Group High Water Mark: %d\n" % idmapdb.group_hwm
for e in idmapdb.mappings:
if e.type == e.IDMAP_GROUP:
print "%s -> GID %d" % (e.sid, e.unix_id)
else:
print "%s -> UID %d" % (e.sid, e.unix_id)
def print_samba3(samba3):
print_samba3_sam(samba3)
print_samba3_policy(samba3.get_policy_db())
print_samba3_shares(samba3)
print_samba3_winsdb(samba3.get_wins_db())
print_samba3_regdb(samba3.get_registry())
print_samba3_secrets(samba3.get_secrets_db())
print_samba3_groupmappings(samba3.get_groupmapping_db())
print_samba3_aliases(samba3)
print_samba3_idmapdb(samba3.get_idmap_db())
def print_samba3_summary(samba3):
print "WINS db entries: %d" % len(samba3.winsentries)
print "SAM Accounts: %d" % len(samba3.samaccounts)
print "Registry key count: %d" % len(samba3.registry.keys)
print "Shares (including [global]): %d" % len(samba3.shares)
print "Groupmap count: %d" % len(samba3.groupmappings)
print "Alias count: %d" % len(samba3.aliases)
print "Idmap count: %d" % len(samba3.idmapdb.mappings)
samba3 = samba.samba3.Samba3(args[0], args[1])
if opts.format == "summary":
print_samba3_summary(samba3)
elif opts.format == "full":
print_samba3(samba3)
|