I am parsing a csv file of names, emails, & departments. I want to create groups by department.
I create a list of Users, then post the group.
_grp_targ.append(User(first_name=targ.name.split(' ')[0], last_name=targ.name.split(' ')[2:], email=targ.email, position=targ.title))
print "[+] Creating group " + current_group + " with " + str(grp_targ)
new_group = Group(name=current_group, targets=grp_targ)
resp = api.groups.post(newgroup)
When I do this, I receive the following error:
_File "GoPhish_Script.py", line 79, in parse_group_file
resp = api.groups.post(new_group)
File "../2.7/lib/python2.7/site-packages/gophish/api/groups.py", line 14, in post
return super(API, self).post(group)
File "../2.7/lib/python2.7/site-packages/gophish/api/api.py", line 60, in post
response = self.api.execute("POST", self.endpoint, json=(resource.as_dict()))
File "../2.7/lib/python2.7/site-packages/gophish/models.py", line 27, in as_dict
val = [e.as_dict() for e in val]
File "../2.7/lib/python2.7/site-packages/gophish/models.py", line 27, in as_dict
val = [e.as_dict() for e in val]
AttributeError: 'str' object has no attribute 'asdict'
Oddly enough, if the group has a dash in the string it imports fine. Some of our groups are Dept - Location and these import but it bombs out when getting to a single or multiple word department.
I am parsing a csv file of names, emails, & departments. I want to create groups by department.
I create a list of Users, then post the group.
_grp_targ.append(User(first_name=targ.name.split(' ')[0], last_name=targ.name.split(' ')[2:], email=targ.email, position=targ.title)) print "[+] Creating group " + current_group + " with " + str(grp_targ) new_group = Group(name=current_group, targets=grp_targ) resp = api.groups.post(newgroup)
When I do this, I receive the following error: _File "GoPhish_Script.py", line 79, in parse_group_file resp = api.groups.post(new_group) File "../2.7/lib/python2.7/site-packages/gophish/api/groups.py", line 14, in post return super(API, self).post(group) File "../2.7/lib/python2.7/site-packages/gophish/api/api.py", line 60, in post response = self.api.execute("POST", self.endpoint, json=(resource.as_dict())) File "../2.7/lib/python2.7/site-packages/gophish/models.py", line 27, in as_dict val = [e.as_dict() for e in val] File "../2.7/lib/python2.7/site-packages/gophish/models.py", line 27, in as_dict val = [e.as_dict() for e in val] AttributeError: 'str' object has no attribute 'asdict'
Oddly enough, if the group has a dash in the string it imports fine. Some of our groups are Dept - Location and these import but it bombs out when getting to a single or multiple word department.
GoPhish version 0.5.0
Thank you for any help.