Extracted user name creation to separate function

This commit is contained in:
Shay Nehmad 2019-09-16 14:06:21 +03:00
parent 889c8a2378
commit 77269fb3ce
1 changed files with 5 additions and 1 deletions

View File

@ -35,12 +35,16 @@ class CommunicateAsNewUser(PBA):
super(CommunicateAsNewUser, self).__init__(name=POST_BREACH_COMMUNICATE_AS_NEW_USER)
def run(self):
username = USERNAME + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))
username = self.get_random_new_user_name()
if is_windows_os():
self.communicate_as_new_user_windows(username)
else:
self.communicate_as_new_user_linux(username)
@staticmethod
def get_random_new_user_name():
return USERNAME + "_" + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))
def communicate_as_new_user_linux(self, username):
try:
# add user + ping