Skip to content

Commit

Permalink
docs(examples): fmt HCL, generic resources examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Apr 9, 2024
1 parent 8b2cb85 commit 03a97ec
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 106 deletions.
160 changes: 73 additions & 87 deletions examples/provider-install-verification/main.tf
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
terraform {
required_providers {
ctfd = {
source = "registry.terraform.io/ctfer-io/ctfd"
}
required_providers {
ctfd = {
source = "registry.terraform.io/ctfer-io/ctfd"
}
}
}

provider "ctfd" {
url = "http://localhost:8080"
url = "http://localhost:8080"
}

resource "ctfd_challenge" "http" {
name = "HTTP Authentication"
category = "network"
description = <<-EOT
name = "HTTP Authentication"
category = "network"
description = <<-EOT
Oh non ! Je n'avais pas vu que ma connexion n'était pas chiffrée !
J'espère que personne ne m'espionnait...
Authors:
- NicolasFgrx
EOT
value = 500
initial = 500
decay = 17
minimum = 50
state = "visible"
function = "logarithmic"

flags = [{
content = "24HIUT{Http_1s_n0t_s3cuR3}"
}]
topics = [
"Network"
]
tags = [
"network",
"http"
]

hints = [{
content = "Les flux http ne sont pas chiffrés"
cost = 50
value = 500
initial = 500
decay = 17
minimum = 50
state = "visible"
function = "logarithmic"

flags = [{
content = "24HIUT{Http_1s_n0t_s3cuR3}"
}]

topics = [
"Network"
]
tags = [
"network",
"http"
]

hints = [{
content = "Les flux http ne sont pas chiffrés"
cost = 50
}, {
content = "Les informations sont POSTées en HTTP :)"
cost = 50
}]

files = [{
name = "capture.pcapng"
contentb64 = filebase64("${path.module}/capture.pcapng")
}]
content = "Les informations sont POSTées en HTTP :)"
cost = 50
}]

files = [{
name = "capture.pcapng"
contentb64 = filebase64("${path.module}/capture.pcapng")
}]
}

resource "ctfd_challenge" "icmp" {
name = "Stealing data"
category = "network"
description = <<-EOT
name = "Stealing data"
category = "network"
description = <<-EOT
L'administrateur réseau vient de nous signaler que des flux étranges étaient à destination d'un serveur.
Visiblement, il s'agit d'un serveur interne. Vous pouvez nous dire de quoi il s'agit ?
Expand All @@ -65,51 +65,37 @@ resource "ctfd_challenge" "icmp" {
Authors:
- NicolasFgrx
EOT
// TODO find a way to avoid this shitty pattern (either <value> with type="static" or <initial,decay,minimum> with type="dynamic")
value = 500
initial = 500
decay = 17
minimum = 50
state = "visible"
requirements = {
behavior = "anonymized"
prerequisites = [ctfd_challenge.http.id]
}

flags = [{
content = "24HIUT{IcmpExfiltrationIsEasy}"
}]

topics = [
"Network"
]
tags = [
"network",
"icmp"
]

hints = [{
content = "Vous ne trouvez pas qu'il ya beaucoup de requêtes ICMP ?"
cost = 50
value = 500
decay = 17
minimum = 50
state = "visible"
requirements = {
behavior = "anonymized"
prerequisites = [ctfd_challenge.http.id]
}

flags = [{
content = "24HIUT{IcmpExfiltrationIsEasy}"
}]

topics = [
"Network"
]
tags = [
"network",
"icmp"
]

hints = [{
content = "Vous ne trouvez pas qu'il ya beaucoup de requêtes ICMP ?"
cost = 50
}, {
content = "Pour l'exo, le ttl a été modifié, tente un `ip.ttl<=20`"
cost = 50
}]

files = [{
name = "icmp.pcap"
# content = file("${path.module}/icmp.pcap")
contentb64 = filebase64("${path.module}/icmp.pcap")
}]
content = "Pour l'exo, le ttl a été modifié, tente un `ip.ttl<=20`"
cost = 50
}]

files = [{
name = "icmp.pcap"
contentb64 = filebase64("${path.module}/icmp.pcap")
}]
}

# resource "ctfd_flag" "some_flag" {
# challenge = ctfd_challenge.icmp.id
# content = "24HIUT{IcmpExfiltrationIsEasy-gg}"
# }

# data "ctfd_challenges" "all" {}

# output "all_challenges" {
# value = data.ctfd_challenges.all
# }
30 changes: 12 additions & 18 deletions examples/resources/ctfd_challenge/resource.tf
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
resource "ctfd_challenge" "http" {
name = "HTTP Authentication"
category = "network"
description = <<-EOT
Oh no ! I did not see my connection was no encrypted !
I hope no one spied me...
Authors:
- NicolasFgrx
EOT
name = "My Challenge"
category = "misc"
description = "..."
value = 500
initial = 500
decay = 17
decay = 100
minimum = 50
state = "visible"
function = "logarithmic"

flags = [{
content = "24HIUT{Http_1s_n0t_s3cuR3}"
content = "CTF{some_flag}"
}]

topics = [
"Network"
"Misc"
]
tags = [
"network",
"http"
"misc",
"basic"
]

hints = [{
content = "HTTP exchanges are not ciphered."
content = "Some super-helpful hint"
cost = 50
}, {
content = "Content is POSTed in HTTP :)"
content = "Even more helpful hint !"
cost = 50
}]

files = [{
name = "capture.pcapng"
contentb64 = filebase64("${path.module}/capture.pcapng")
name = "image.png"
contentb64 = filebase64("${path.module}/image.png")
}]
}
1 change: 0 additions & 1 deletion examples/resources/ctfd_user/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resource "ctfd_user" "ctfer" {
email = "ctfer-io@protonmail.com"
password = "password"

# Define as an administration account
type = "admin"
verified = true
hidden = true
Expand Down

0 comments on commit 03a97ec

Please sign in to comment.