Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
containercap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laurens D'hooge
containercap
Merge requests
!2
remote kubernetes cluster
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
remote kubernetes cluster
remote-cluster
into
master
Overview
0
Commits
12
Pipelines
0
Changes
70
Merged
Miel Verkerken
requested to merge
remote-cluster
into
master
8 months ago
Overview
0
Commits
12
Pipelines
0
Changes
70
Expand
0
0
Merge request reports
Compare
master
version 10
4f035373
8 months ago
version 9
8cb53c06
8 months ago
version 8
86892ef2
8 months ago
version 7
60a07d27
8 months ago
version 6
a082ca9e
8 months ago
version 5
43df43f6
8 months ago
version 4
da63e3b6
8 months ago
version 3
252fb30a
8 months ago
version 2
d3cc6134
8 months ago
version 1
ada7416f
8 months ago
master (base)
and
latest version
latest version
2292a66a
12 commits,
8 months ago
version 10
4f035373
11 commits,
8 months ago
version 9
8cb53c06
10 commits,
8 months ago
version 8
86892ef2
9 commits,
8 months ago
version 7
60a07d27
8 commits,
8 months ago
version 6
a082ca9e
6 commits,
8 months ago
version 5
43df43f6
5 commits,
8 months ago
version 4
da63e3b6
4 commits,
8 months ago
version 3
252fb30a
3 commits,
8 months ago
version 2
d3cc6134
2 commits,
8 months ago
version 1
ada7416f
1 commit,
8 months ago
70 files
+
1159
−
992412
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
70
Search (e.g. *.vue) (Ctrl+P)
atkcommandsetter/commandsetter.go deleted
100644 → 0
+
0
−
54
Options
package
Command
import
(
"strings"
atktools
"gitlab.ilabt.imec.be/lpdhooge/containercap/attack-tools"
"gitlab.ilabt.imec.be/lpdhooge/containercap/scenario"
)
// GenerateAttackCommand is a helper function that returns a string that contains the command to launch an attack
// on a given target using a selected attacker tool. It calls the BuildAtkCommand method of the attacker tool to get
// the command parts, and then replaces any occurrences of localhost or 127.0.0.1 with the target IP address in the
// command parts. It then joins the command parts together into a single string and returns it.
//
// Parameters:
// - scn: A pointer to the Scenario struct that contains the attacker tool and target information.
//
// Returns:
// - A string containing the attack command for the given scenario.
//
// Used but can be removed by changing localhost in all attack tool classes
func
GenerateAttackCommand
(
scn
*
scenario
.
Scenario
)
string
{
// Call BuildAtkCommand method of the selected attacker category to get command string
atk
:=
(
*
(
atktools
.
SelectAttacker
(
scn
.
Attacker
.
Category
,
scn
.
Attacker
.
Name
)))
.
BuildAtkCommand
()
// Extract target IP address from scenario struct and store into target variable
target
:=
"{{.TargetAddress}}"
targetPort
:=
"-p "
+
string
(
scn
.
Target
.
Ports
[
0
])
// Loop through the atk command parts array slice
for
i
,
part
:=
range
atk
{
// If localhost is present inside part then replace it with target using strings.Replace()
if
strings
.
Contains
(
part
,
"localhost"
)
{
atk
[
i
]
=
strings
.
Replace
(
part
,
"localhost"
,
target
,
-
1
)
// If https://127.0.0.1, http://127.0.0.1, or 127.0.0.1 are present inside part then replace it with target using strings.Replace()
}
else
if
strings
.
Contains
(
part
,
"127.0.0.1"
)
{
atk
[
i
]
=
strings
.
Replace
(
part
,
"127.0.0.1"
,
target
,
-
1
)
}
else
if
strings
.
Contains
(
part
,
"-u http://localhost/"
)
{
atk
[
i
]
=
strings
.
Replace
(
part
,
"-u http://localhost/"
,
"-u "
+
target
,
-
1
)
}
if
scn
.
ScenarioType
==
"DoS"
&&
strings
.
Contains
(
part
,
"-p 80"
)
{
atk
[
i
]
=
strings
.
Replace
(
part
,
"-p 80"
,
targetPort
,
-
1
)
}
}
// Return a string by concatenating the modified parts of Nmap command together using Join function
atkC
:=
strings
.
Join
(
atk
,
" "
)
return
atkC
}
Loading