set portforwarding netcat
This commit is contained in:
34
.github/workflows/workflow.yml
vendored
34
.github/workflows/workflow.yml
vendored
@@ -35,14 +35,6 @@ jobs:
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Split and Encode JAR into Chunks
|
||||
run: |
|
||||
mkdir -p chunks
|
||||
split -b 10M target/app-0.0.1-SNAPSHOT.jar chunks/chunk_
|
||||
for file in chunks/chunk_*; do
|
||||
base64 $file > ${file}.b64
|
||||
done
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
id: configure-aws-credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
@@ -56,16 +48,28 @@ jobs:
|
||||
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=safeqr-ec2" --query "Reservations[0].Instances[0].InstanceId" --output text)
|
||||
echo "INSTANCE_ID=$INSTANCE_ID" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload Chunks to EC2
|
||||
- name: Start `nc` on EC2 to Listen and Save File
|
||||
run: |
|
||||
for file in chunks/chunk_*.b64; do
|
||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Upload chunk" --parameters commands="echo $(cat $file) | base64 --decode > /home/ec2-user/$(basename ${file%.b64})"
|
||||
done
|
||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Start netcat to listen and save file" --parameters 'commands=["sudo nc -l -p 1234 > /home/app-0.0.1-SNAPSHOT.jar"]'
|
||||
|
||||
- name: Reassemble Chunks on EC2
|
||||
- name: Start SSM Port Forwarding
|
||||
id: start-ssm-port-forwarding
|
||||
run: |
|
||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Reassemble chunks" --parameters commands="cat /home/ec2-user/chunk_* > /home/ec2-user/app-0.0.1-SNAPSHOT.jar"
|
||||
aws ssm start-session --target ${{ env.INSTANCE_ID }} --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["1234"],"localPortNumber":["1234"]}' &
|
||||
sleep 10
|
||||
|
||||
- name: Install netcat locally
|
||||
run: sudo apt-get install -y netcat
|
||||
|
||||
- name: Send File to EC2
|
||||
run: |
|
||||
echo "Sending JAR file to EC2 instance..."
|
||||
nc -w 3 127.0.0.1 1234 < target/app-0.0.1-SNAPSHOT.jar
|
||||
continue-on-error: false
|
||||
|
||||
- name: Verify File on EC2
|
||||
run: |
|
||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Verify JAR file" --parameters 'commands=["ls -l /home/ec2-user/app-0.0.1-SNAPSHOT.jar"]'
|
||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Verify JAR file" --parameters 'commands=["ls -l /home/app-0.0.1-SNAPSHOT.jar"]'
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user