build: made it so dev containers can partly debug

symbol tables appear to be messed up and it doesn't work with async
Rust, so will try to refactor the code to be sync and see how it fares
This commit is contained in:
Andrew Rioux 2023-05-07 14:17:28 -04:00
parent 813dc104e8
commit 8aab9be638
Signed by: andrew.rioux
GPG Key ID: 9B8BAC47C17ABB94
7 changed files with 62 additions and 75 deletions

View File

@ -38,8 +38,5 @@ RUN apt-get update && \
--component rustfmt --component rust-src --component clippy && \ --component rustfmt --component rust-src --component clippy && \
rm rustup-init && \ rm rustup-init && \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \
echo "alias make='cargo make'" >> /etc/profile echo "alias make='cargo make'" >> /etc/profile && \
cargo install cargo-make convco
USER vscode
RUN cargo install cargo-make convco

View File

@ -25,11 +25,11 @@
"runArgs": [ "runArgs": [
"--privileged", "--privileged",
"--cap-add=SYS_PTRACE", "--cap-add=SYS_PTRACE",
"--cap-add=NET_RAW",
"--security-opt", "--security-opt",
"seccomp=unconfined" "seccomp=unconfined"
], ],
"postStartCommand": "cargo make setup", "postStartCommand": "cargo make setup",
"remoteUser": "vscode",
"features": { "features": {
"ghcr.io/devcontainers/features/docker-in-docker": {} "ghcr.io/devcontainers/features/docker-in-docker": {}
} }

64
.vscode/launch.json vendored
View File

@ -4,43 +4,6 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'pcap-sys'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=pcap-sys"
],
"filter": {
"name": "pcap-sys",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'nl-sys'",
"cargo": {
"args": [
"build",
"--bin=nl-sys",
"--package=nl-sys"
],
"filter": {
"name": "nl-sys",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{ {
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
@ -61,27 +24,19 @@
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },
{ {
"name": "Debug executable 'ex-bind-shell-backdoor'",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "Debug executable 'ex-bind-shell-backdoor'", "preLaunchTask": "Build project",
"cargo": { "program": "${workspaceFolder}/target/debug/ex-bind-shell-backdoor",
"args": [
"build",
"--bin=ex-bind-shell-backdoor",
"--package=ex-bind-shell-backdoor"
],
"filter": {
"name": "ex-bind-shell-backdoor",
"kind": "bin"
}
},
"args": [], "args": [],
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}",
"breakpointMode": "path"
}, },
{ {
"name": "Attach to 'ex-bind-shell-backdoor'",
"type": "lldb", "type": "lldb",
"request": "attach", "request": "attach",
"name": "Debug executable 'ex-bind-shell-backdoor' (attach)",
"program": "ex-bind-shell-backdoor" "program": "ex-bind-shell-backdoor"
}, },
{ {
@ -101,13 +56,6 @@
}, },
"args": [], "args": [],
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
},
{
"name": "test launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/ex-bind-shell-backdoor",
"args": []
} }
] ]
} }

30
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,30 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build project",
"type": "shell",
"command": "cargo make build",
"problemMatcher": [
"$rustc"
]
},
{
"label": "Watch project",
"type": "shell",
"command": "cargo make check-watch",
"problemMatcher": [
"$rustc-watch"
]
},
{
"label": "Assign capabilities",
"type": "shell",
"command": "find ${workspaceFolder}/target/debug -maxdepth 1 -type f -executable -exec sudo setcap cap_net_raw=eip {} \\;",
"dependsOn": [
"Build project"
],
"problemMatcher": []
}
]
}

View File

@ -26,6 +26,17 @@ workspace = false
command = "docker-compose" command = "docker-compose"
args = ["run", "build", "test", "${@}"] args = ["run", "build", "test", "${@}"]
[tasks.clean]
workspace = false
command = "cargo"
args = ["clean"]
[tasks.check-watch]
workspace = false
command = "docker-compose"
args = ["run", "build", "check", "${@}"]
watch = { watch = ["nl-sys/src", "pcap-sys/src"] }
#----------------------- #-----------------------
# #
# Git tasks # Git tasks

View File

@ -3,7 +3,8 @@
Developed using libpcap to enable evading local firewalls and with an eye towards hiding itself from inspection Developed using libpcap to enable evading local firewalls and with an eye towards hiding itself from inspection
* Packages * Packages
** [[./pcap-sys/README.org][pcap-sys]] ** [[./pcap-sys/README.org][pcap-sys]]: A Rust wrapper around the libpcap library for Linux
** [[./nl-sys/README.org][nl-sys]]: A Rust wrapper around the netlink (nl) library on Linux
* Development * Development
To develop or compile this project, open it in GitHub Codespaces or using Visual Studio Code's Dev Container extension (requires Docker to be installed) To develop or compile this project, open it in GitHub Codespaces or using Visual Studio Code's Dev Container extension (requires Docker to be installed)

View File

@ -6,8 +6,8 @@ services:
dockerfile: Dockerfile.alpine dockerfile: Dockerfile.alpine
volumes: volumes:
- ${CARGO_HOME}/registry:${CARGO_HOME}/registry - ${CARGO_HOME}/registry:${CARGO_HOME}/registry
- ${PWD}:/sparse - /workspaces/sparse:/workspaces/sparse
working_dir: /sparse working_dir: /workspaces/sparse
entrypoint: /usr/local/cargo/bin/cargo entrypoint: /usr/local/cargo/bin/cargo
tty: true tty: true
@ -16,31 +16,31 @@ services:
context: examples/secure-image context: examples/secure-image
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- ./target:/backdoor - ./target:/workspaces/sparse/target
command: /backdoor/release/ex-bind-shell-backdoor command: /workspaces/sparse/target/debug/ex-bind-shell-backdoor
# privileged flag is for iptables, not for the backdoor # privileged flag is for iptables, not for the backdoor
privileged: true privileged: true
examples_bindshell_client: examples_bindshell_client:
image: alpine image: alpine
volumes: volumes:
- ./target:/backdoor - ./target:/workspaces/sparse/target
command: /backdoor/release/ex-bind-shell-client examples_bindshell_target:54248 command: /workspaces/sparse/target/debug/ex-bind-shell-client examples_bindshell_target:54248
examples_revshell_beacon: examples_revshell_beacon:
build: build:
context: examples/secure-image context: examples/secure-image
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- ./target:/bacodkkr - ./target:/workspaces/sparse/target
command: /backdoor/release/ex-revshell-beacon command: /workspaces/sparse/target/debug/ex-revshell-beacon
# privileged flag is for iptables, not for the backdoor # privileged flag is for iptables, not for the backdoor
privileged: true privileged: true
examples_revshell_server: examples_revshell_server:
image: alpine image: alpine
volumes: volumes:
- ./target:/backdoor - ./target:/workspaces/sparse/target
expose: expose:
- '54248/udp' - '54248/udp'
command: /backdoor/release/ex-revshell-server command: /workspaces/sparse/target/debug/ex-revshell-server