readlines and break apart based on letters

R

rtilley

I got this to work... just FYI:

s =
'O:eek:wner_sidG:group_sidD:dacl_flags(string_ace1)(string_ace2)...(string_acen)S:sacl_flags(string_ace1)(string_ace2)...(string_acen)'

SD = {}

S = str.split(s, 'S:')
SD['S_ACL'] = S[1]
D = str.split(S[0], 'D:')
SD['D_ACL'] = D[1]
G = str.split(D[0], 'G:')
SD['G_SID'] = G[1]
O = str.split(G[0], 'O:')
SD['O_SID'] = O[1]

for k,v in SD.iteritems():
print k,v
 
R

rtilley

Hi,

While trying to better understand security descriptors on Windows. I've
been examining text-based security descriptors. I have the security
descriptors on individual lines stored in a text file. I want to break
these lines apart based on owner, group, dacl and sacl. These areas are
demarcated by O: G: D: and S:

There are no spaces in the lines. How can I read each line so that each
area is broken out? I'd like output like this:

O: details
G: details or NONE
D: details or NONE
S: details or NONE

Here is an example SD:
O:eek:wner_sidG:group_sidD:dacl_flags(string_ace1)(string_ace2)...(string_acen)S:sacl_flags(string_ace1)(string_ace2)...(string_acen)

I want to read this and break it apart like this:
O:eek:wner_sid
G:group_sid
D:dacl_flags(string_ace1)(string_ace2)...(string_acen)
S:sacl_flags(string_ace1)(string_ace2)...(string_acen)

Any tips?
Brad
 
K

Kent Johnson

rtilley said:
Hi,

While trying to better understand security descriptors on Windows. I've
been examining text-based security descriptors. I have the security
descriptors on individual lines stored in a text file. I want to break
these lines apart based on owner, group, dacl and sacl. These areas are
demarcated by O: G: D: and S:

There are no spaces in the lines. How can I read each line so that each
area is broken out? I'd like output like this:

O: details
G: details or NONE
D: details or NONE
S: details or NONE

Here is an example SD:
O:eek:wner_sidG:group_sidD:dacl_flags(string_ace1)(string_ace2)...(string_acen)S:sacl_flags(string_ace1)(string_ace2)...(string_acen)

It's a pretty simple regex:('owner_sid', 'group_sid',
'dacl_flags(string_ace1)(string_ace2)...(string_acen)',
'sacl_flags(string_ace1)(string_ace2)...(string_acen)')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top