Skip to content

Commit 1a38667

Browse files
author
Razvan
committed
Minor fixes of some task implementation for AWS
1 parent 822e954 commit 1a38667

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

instantiation/attacks_emulation/attack_paramiko_ssh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ def ssh_connect():
8888
elif basevm_type == 'aws':
8989
correct_date = subprocess.check_output("date +%Y%m%d", shell=True)
9090
correct_time = subprocess.check_output("date +%T", shell=True)
91-
os.system("ssh -i TESTKEY.pem ec2-user@{0} date +%Y%m%d -s {1}".format(attacked_addr, correct_date))
92-
os.system("ssh -i TESTKEY.pem ec2-user@{0} date +%T -s {1}".format(attacked_addr, correct_time))
93-
os.system("ssh -i TESTKEY.pem ec2-user@{0} sort --stable --reverse --key=1,2 /var/log/secure -o /var/log/secure".format(attacked_addr))
91+
os.system("ssh -i TESTKEY.pem ec2-user@{0} sudo date +%Y%m%d -s {1}".format(attacked_addr, correct_date))
92+
os.system("ssh -i TESTKEY.pem ec2-user@{0} sudo date +%T -s {1}".format(attacked_addr, correct_time))
93+
os.system("ssh -i TESTKEY.pem ec2-user@{0} sudo sort --stable --reverse --key=1,2 /var/log/secure -o /var/log/secure".format(attacked_addr))

instantiation/content_copy_program_run/copy_content.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ elif [ ${basevm_type} = "aws" ]; then
3434
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${image_addr} "sudo mkdir -p ${dst}"
3535
fi
3636
scp -r -i TESTKEY.pem -o StrictHostKeyChecking=no ${src} ec2-user@${image_addr}:
37-
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${image_addr} "sudo mv ${src} ${dst}"
37+
# Special syntax for ${src} to preserve the last part of the name (after /) for the local 'mv'
38+
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${image_addr} "sudo mv ${src##*/} ${dst}"
3839
elif [ ${os_type} = "ubuntu_20" -o ${os_type} = "ubuntu_18" -o ${os_type} = "ubuntu_16" ]; then
3940
if (ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ubuntu@${image_addr} "[ -d ${dst} ]")
4041
then
@@ -43,6 +44,7 @@ elif [ ${basevm_type} = "aws" ]; then
4344
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ubuntu@${image_addr} "sudo mkdir -p ${dst}"
4445
fi
4546
scp -r -i TESTKEY.pem -o StrictHostKeyChecking=no ${src} ubuntu@${image_addr}:
46-
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ubuntu@${image_addr} "sudo mv ${src} ${dst}"
47+
# Special syntax for ${src} to preserve the last part of the name (after /) for the local 'mv'
48+
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ubuntu@${image_addr} "sudo mv ${src##*/} ${dst}"
4749
fi
4850
fi

instantiation/malware_creation/malware_launch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ elif [ ${basevm_type} = "aws" ]; then
3434
scp -r -i TESTKEY.pem -o StrictHostKeyChecking=no ${abs_path}${inst_dir}/malware_creation/cpulimit/src/cpulimit ec2-user@${addr}:
3535
command="\"exec -a cpusage cpulimit -l ${crspd_option} ${malware_name} ${mode} 1000 &\"";
3636
#ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${addr} "chmod +x cpulimit; sudo mv cpulimit /usr/bin"
37-
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${addr} "chmod +x cpulimit; sudo mv cpulimit /usr/bin; sudo chmod 777 /etc/rc.d/rc.local; echo 'bash -c ${command}' >> /etc/rc.d/rc.local";
37+
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${addr} "chmod +x cpulimit; sudo mv cpulimit /usr/bin; sudo chmod 777 /etc/rc.d/rc.local; echo 'bash -c ${command}' >> /etc/rc.d/rc.local";
3838
else
3939
command="${malware_name} ${mode} ${crspd_option} &";
4040
ssh -i TESTKEY.pem -o StrictHostKeyChecking=no ec2-user@${addr} "echo '${command}' >> /etc/rc.d/rc.local";

0 commit comments

Comments
 (0)