Skip to content

Commit

Permalink
Add Kali Linux Default Tools Installation and Improve User Data Scrip…
Browse files Browse the repository at this point in the history
…t Logging (#8911)

* Refactor Kali EC2 Instance

* switch to T3 and ssm agent install only

* switch back to t2

* Improve Logging for userdata config

* Add kali-linux-default

---------

Co-authored-by: jodiejones-moj <[email protected]>
  • Loading branch information
ASTRobinson and jodiejones-moj authored Dec 2, 2024
1 parent 6484268 commit 30760f0
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions terraform/environments/panda-cyber-appsec-lab/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,39 @@ resource "aws_instance" "kali_linux" {
}
user_data = <<-EOF
#!/bin/bash
set -e
exec > >(tee /var/log/user-data.log | logger -t user-data) 2>&1
# Update and install dependencies
# Update system packages
echo "Updating and upgrading system packages..."
apt-get update -y
apt-get upgrade -y
apt-get install -y wget git kali-linux-default
# Ensure 'kali' user exists
id -u kali &>/dev/null || useradd -m -s /bin/bash kali
# Download and install the SSM agent
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb
dpkg -i amazon-ssm-agent.deb
systemctl enable amazon-ssm-agent
systemctl start amazon-ssm-agent
# Install necessary tools and Kali default tools
echo "Installing wget, git, and kali-linux-default tools..."
apt-get install -y wget git kali-linux-default
# Create and set permissions for the tooling directory
mkdir -p /home/kali/tooling
chown -R kali:kali /home/kali
# Check if 'kali' user exists
if id "kali" &>/dev/null; then
echo "User 'kali' exists. Proceeding to create tooling directory..."
# Create tooling directory and set ownership
mkdir -p /home/kali/tooling
chown -R kali:kali /home/kali
echo "Tooling directory created under /home/kali and ownership set."
# Clone the repository as 'kali' user
echo "Cloning gotestwaf repository into /home/kali/tooling..."
sudo -u kali git clone https://github.com/wallarm/gotestwaf.git /home/kali/tooling
echo "Repository cloned successfully."
else
echo "User 'kali' does not exist. Exiting."
exit 1
fi
echo "User data script completed successfully."
# Clone the repository as 'kali' user
sudo -u kali git clone https://github.com/wallarm/gotestwaf.git /home/kali/tooling
EOF

tags = {
Expand Down

0 comments on commit 30760f0

Please sign in to comment.