0x00 TL;DR
This article documents how to use AWS SSM to execute remote script files at EC2 instances.There are two general methods:1.Running Scripts from GitHub and Amazon S32.First upload the file to EC2 through SSM, and then use SSM to execute the command to run the uploaded script.
0x01 Running Scripts from GitHub
Use the following AWS Cli command
1
|
aws ssm send-command --document-name "AWS-RunRemoteScript" --instance-ids "i-0d781805630c8edc0" --parameters '{"sourceType":["GitHub"],"sourceInfo":["{\"owner\":\"omg2hei\", \"repository\":\"PowerShellDemo\", \"path\": \"/\"}"],"commandLine":["get-process.ps1"]}'
|
Then EC2 instance(Windows Server 2016) will be execute get-process.ps1.
0x02 First upload the file to EC2 through SSM, and then use SSM to execute the command to run the uploaded script
Step 1.Upload file to EC2 use SSM
1
|
aws ssm send-command --document-name "AWS-RunPowerShellScript" --parameters commands="Invoke-WebRequest http://52.80.67.123:8000/get-process.ps1 -OutFile c:\get-process.ps1" --instance-ids i-0d781805630c8edc0 --document-version "\$DEFAULT"
|
Step 2.use SSM to execute the command to run the uploaded script
1
|
aws ssm send-command --document-name "AWS-RunPowerShellScript" --parameters commands="c:\get-process.ps1" --instance-ids i-0d781805630c8edc0 --document-version "\$DEFAULT"
|
0x03 Reference
[1] Running Scripts from GitHub and Amazon S3 - https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-remote-scripts.html
- source:tonghuaroot.com
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论