-
Notifications
You must be signed in to change notification settings - Fork 793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create new user with a random password #1174
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8dc72b2
Swimm: update exercise Add a simple Post Breach action (id: tbxb2cGgU…
shreyamalviya 51b996c
Generate password randomly when creating a new user for Create User P…
shreyamalviya 6e0c5eb
Swimm: update exercise Add a simple Post Breach action (id: tbxb2cGgU…
shreyamalviya 1d544d1
Update CHANGELOG (generate random pwds)
shreyamalviya 636a201
Set default password length to 32 in `get_random_password()`
shreyamalviya fc82b2a
Replace "remote_user_pwd" with "random_password"
shreyamalviya c779655
Swimm: update exercise Add a simple Post Breach action (id: tbxb2cGgU…
shreyamalviya 58b04ec
Added unit test of random password generator
VakarisZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
from common.common_consts.post_breach_consts import POST_BREACH_BACKDOOR_USER | ||
from infection_monkey.config import WormConfiguration | ||
from infection_monkey.post_breach.pba import PBA | ||
from infection_monkey.utils.random_password_generator import get_random_password | ||
from infection_monkey.utils.users import get_commands_to_add_user | ||
|
||
|
||
class BackdoorUser(PBA): | ||
def __init__(self): | ||
remote_user_pwd = get_random_password() | ||
|
||
linux_cmds, windows_cmds = get_commands_to_add_user( | ||
WormConfiguration.user_to_add, WormConfiguration.remote_user_pass | ||
WormConfiguration.user_to_add, remote_user_pwd | ||
) | ||
|
||
super(BackdoorUser, self).__init__( | ||
POST_BREACH_BACKDOOR_USER, linux_cmd=" ".join(linux_cmds), windows_cmd=windows_cmds | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import secrets | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a constant here, called |
||
|
||
def get_random_password(length: int = 12) -> str: | ||
password = secrets.token_urlsafe(length) | ||
return password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be more readable if called
random_password
, because that's what it is in this context. It's not a password of remote user yet andpwd
is not consistent (also means print working directory), either..._pass
or..._password