Skip to content

Commit

Permalink
Merge pull request #357 from m-1-k-3/metasploit-live-check
Browse files Browse the repository at this point in the history
Metasploit system emulation integration
  • Loading branch information
m-1-k-3 authored Oct 20, 2022
2 parents 7d39300 + e175b24 commit 38f8728
Show file tree
Hide file tree
Showing 20 changed files with 500 additions and 58 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Steps to reproduce the behavior:
1. EMBA installation (dev-mode/default mode)
2. Use the firmware available here: <Insert URL>
3. Start EMBA with the following parameters: sudo ./emba.sh <insert further parameters>
4.
4. additional steps
5. See error

**Expected behavior**
Expand All @@ -25,7 +25,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Kali Linux 2022.01]
- OS: e.g. Kali Linux 2022.03
- EMBA version: v1.1.2 or current master branch
- Installation method: default with up to date docker image

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when ...

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
43 changes: 23 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,37 @@ It also sketches the typical integration process of patches.
## 1) Contribution Checklist


- use git to manage your changes [*recommended*]
- use git to manage your changes \[*recommended*]

- add the required copyright header to each new file introduced, see
[licensing information](./LICENSE) [**required**]
[licensing information](./LICENSE) \[**required**]

- structure patches logically, in small steps [**required**]
- one separable functionality/fix/refactoring = one patch
- do not mix those three into a single patch (e.g., first refactor, then add a new functionality that builds onto the refactoring)
- after each patch, *EMBA* has to work. Do not add
even temporary breakages inside a patch series (helps when tracking down bugs)
- use `git rebase -i` to restructure a patch series
- structure patches logically, in small steps \[**required**]
- one separable functionality/fix/refactoring = one patch
- do not mix those three into a single patch (e.g., first refactor, then add a new functionality that builds onto the refactoring)
- after each patch, *EMBA* has to work. Do not add
even temporary breakages inside a patch series (helps when tracking down bugs)
- use `git rebase -i` to restructure a patch series

- base patches on top of latest master or - if there are dependencies - on next
(note: next is an integration branch that may change non-linearly)

- add signed-off to all patches [**required**]
- to certify the "Developer's Certificate of Origin", see below
- check with your employer when not working on your own!
- add signed-off to all patches \[**required**]
- to certify the "Developer's Certificate of Origin", see below
- check with your employer when not working on your own!

- test your code with shellcheck [**required**]
- see the included [shellchecker script](./check_project.sh)
- test your code with shellcheck \[**required**]
- see the included [codechecker script](./check_project.sh)
- shellcheck should not be disabled on areas with issues -> solve these problems before the PR

- test your code in strict mode (EMBA parameter -S) [**required**]
- all code should be strict mode compatible
- test your code in strict mode (EMBA parameter -S) \[**required**]
- all code should be strict mode compatible

- send reminder if nothing happens after about a week

- the code needs to work on the latest Kali Linux (other distributions are welcome but currently not tested)
- feel free to mention [EMBA team members](https://github.com/orgs/e-m-b-a/people) in the issue/PR.

- the code needs to work on the latest Kali Linux and Ubuntu 22.04LTS (other distributions are welcome but currently not tested)

## 2) Code Guidelines

Expand All @@ -48,22 +51,22 @@ It also sketches the typical integration process of patches.

- Variables: Variables should be capitalized, with underscore as word separator (e.g. `PROCESS_EXISTS=1`)

- If you use external code, add `# Test source: [LINK TO CODE]` above
- If you use external code, add `# Test source: \[LINK TO CODE]` above

- Scope of variables: Use local variables if possible

- Variables always need to be initialized
- e.g., local VARIABLE=""

- Use parameters to functions
- work with local variables inside the functions
- do not rely on globals if not needed
- work with local variables inside the functions
- do not rely on globals if not needed

- Use `export` for variables which aren't only used in one file - it isn't necessary, but helps for readability

- Don't use backticks anymore, use $(..) instead

- Use double square [[]] brackets (conditional expressions) instead of single square [] brackets
- Use double square \[[]] brackets (conditional expressions) instead of single square [] brackets

- Whenever possible try to avoid `tr` `sed` `awk` and use bash internal functions instead, see e.g. [bash shell parameter substitution](http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html). Using bash internals is faster as it does not fork, fopen and pipes the results back.

Expand Down
28 changes: 16 additions & 12 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

The EMBA project is very thankful to the individuals who contributed to the project.

Want to contribute as well? Here are some suggestions:

- Create new module for a test currently not supported by EMBA
- Report or fix (unexpected) errors
- Share missing results and findings
- Share firmware where EMBA is not performing as expected
- Improve code quality
- Improve performance
- Check the current [issues](https://github.com/e-m-b-a/emba/issues) if some issue needs help

See [CONTRIBUTING.md](https://github.com/e-m-b-a/emba/blob/master/CONTRIBUTING.md) for more details.
Want to contribute as well? Here are some suggestions:

- Create new module for a test currently not supported by EMBA
- Report or fix (unexpected) errors
- Share missing results and findings
- Share firmware where EMBA is not performing as expected
- Improve code quality
- Improve performance
- Improve textblocks for [report templates](https://github.com/e-m-b-a/emba/tree/master/config/report_templates)
- Improve license and version detection [configuration](https://github.com/e-m-b-a/emba/blob/master/config/bin_version_strings.cfg)
- Review the [wiki](https://github.com/e-m-b-a/emba/wiki) for outdated information and open dedicated issues
- Check the current [issues](https://github.com/e-m-b-a/emba/issues) if some issue needs help.
- For interested first-time contributors we created the label [good first issue](https://github.com/e-m-b-a/emba/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)

See [CONTRIBUTING.md](https://github.com/e-m-b-a/emba/blob/master/CONTRIBUTING.md) for more details.

==========================================================================================

Expand All @@ -24,8 +28,8 @@ These people have contributed to EMBA:

* Michael Messner (original author)
* Pascal Eckmann (original author)
* [Arnold Unterauer](https://github.com/Anemosx)
* [Benedikt Kuehne](https://github.com/BenediktMKuehne)
* [Arnold Unterauer](https://github.com/Anemosx)
* [seanog8](https://github.com/seanog8)
* [Stefan Haboeck](https://github.com/StefanHaboeck)
* [firmianay](https://github.com/firmianay)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@ sudo ./emba.sh -l ./log -f /firmware -p ./scan-profiles/default-scan.emba

## Get involved
The IoT is growing, the development is ongoing, and there are many new features that we want to add.
We welcome [pull requests](https://github.com/e-m-b-a/emba/pulls) and [issues](https://github.com/e-m-b-a/emba/issues) on GitHub.
We welcome [pull requests](https://github.com/e-m-b-a/emba/pulls) and [issues](https://github.com/e-m-b-a/emba/issues) on GitHub. Also check the [CONTRIBUTING](./CONTRIBUTING.md) and [CONTRIBUTORS](./CONTRIBUTORS.md) documentation for further information.

## Team

https://github.com/orgs/e-m-b-a/people
30 changes: 27 additions & 3 deletions check_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SOURCES=()
MODULES_TO_CHECK_ARR=()
MODULES_TO_CHECK_ARR_TAB=()
MODULES_TO_CHECK_ARR_SEMGREP=()
MODULES_TO_CHECK_ARR_DOCKER=()

import_config_scripts() {
mapfile -t HELPERS < <(find "$CONF_DIR" -iname "*.sh" 2>/dev/null)
Expand Down Expand Up @@ -101,9 +102,22 @@ import_installer() {
done
}

dockerchecker() {
echo -e "\\n""$ORANGE""$BOLD""EMBA docker-files check""$NC""\\n""$BOLD""=================================================================""$NC"
mapfile -t DOCKER_COMPS < <(find . -maxdepth 1 -iname "docker-compose*.yml")
for DOCKER_COMP in "${DOCKER_COMPS[@]}"; do
echo -e "\\n""$GREEN""Run docker check on $DOCKER_COMP:""$NC""\\n"
if docker-compose -f "$DOCKER_COMP" config 1>/dev/null || [[ $? -ne 1 ]]; then
echo -e "$GREEN""$BOLD""==> SUCCESS""$NC""\\n"
else
echo -e "\\n""$ORANGE$BOLD==> FIX ERRORS""$NC""\\n"
((MODULES_TO_CHECK=MODULES_TO_CHECK+1))
MODULES_TO_CHECK_ARR_DOCKER+=( "$DOCKER_COMP" )
fi
done
}

check()
{
check() {
echo -e "\\n""$ORANGE""$BOLD""Embedded Linux Analyzer Shellcheck""$NC""\\n""$BOLD""=================================================================""$NC"

echo -e "\\n""$GREEN""Run shellcheck on this script:""$NC""\\n"
Expand Down Expand Up @@ -193,10 +207,19 @@ summary() {
done
echo -e "$ORANGE""WARNING: Fix the errors before pushing to the EMBA repository!"
fi
if [[ "${#MODULES_TO_CHECK_ARR_DOCKER[@]}" -gt 0 ]]; then
echo -e "\\n\\n""$GREEN$BOLD""SUMMARY:$NC\\n"
echo -e "Modules to check (docker-compose): ${#MODULES_TO_CHECK_ARR_DOCKER[@]}\\n"
for MODULE in "${MODULES_TO_CHECK_ARR_DOCKER[@]}"; do
echo -e "$ORANGE$BOLD==> FIX MODULE: ""$MODULE""$NC"
done
echo -e "$ORANGE""WARNING: Fix the errors before pushing to the EMBA repository!"
fi

}

# check that all tools are installed
check_tools(){
check_tools() {
TOOLS=("semgrep" "shellcheck")
for TOOL in "${TOOLS[@]}";do
if ! command -v "$TOOL" > /dev/null ; then
Expand All @@ -213,5 +236,6 @@ check_tools(){
# main:
check_tools
check
dockerchecker
summary

4 changes: 2 additions & 2 deletions emba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ main()
print_output "[*] Loading EMBA scan profile." "no_log"
fi
# all profile output and settings are done by the profile file located in ./scan-profiles/
# shellcheck disable=SC1090
# shellcheck source=/dev/null
source "$PROFILE"
print_output "[*] Profile $PROFILE loaded." "no_log"
print_bar "no_log"
Expand All @@ -640,7 +640,7 @@ main()
print_output "[!] Found restart file and backup_vars file ... trying to restart EMBA scan" "no_log"
export RESTART=1
rm "$TMP_DIR"/restart
# shellcheck disable=SC1091
# shellcheck source=/dev/null
source "$LOG_DIR""/backup_vars.log"
fi
fi
Expand Down
2 changes: 2 additions & 0 deletions helpers/fixImage_user_mode_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ SHADOW=$(resolve_link /etc/shadow)
if [ ! -s "$PASSWD" ]; then
echo "[*] Creating $PASSWD file"
"$BUSYBOX" mkdir -p "$(dirname "$PASSWD")"
# nosemgrep
echo "root::0:0:root:/root:/bin/sh" > "$PASSWD"
else
backup_file "$PASSWD"
backup_file "$SHADOW"
if ! "$BUSYBOX" grep -sq "^root:" "$PASSWD" ; then
echo "[*] No root user found, creating root user with shell '/bin/sh'"
# nosemgrep
echo "root::0:0:root:/root:/bin/sh" > "$PASSWD"
"$BUSYBOX" [ ! -d '/root' ] && "$BUSYBOX" mkdir /root
fi
Expand Down
1 change: 1 addition & 0 deletions helpers/helpers_emba_dependency_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ dependency_check()
check_dep_tool "Nmap portscanner" "nmap"
check_dep_tool "hping3" "hping3"
check_dep_tool "ping" "ping"
check_dep_tool "Metasploit framework" "msfconsole"
# This port is used by our Qemu installation and should not be used by another process.
# This check is not a blocker for the test. It is checked again by the emulation module:
check_emulation_port "Running Qemu service" "2001"
Expand Down
6 changes: 3 additions & 3 deletions helpers/helpers_emba_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ mod_path_array() {

create_log_dir() {
if ! [[ -d "$LOG_DIR" ]] ; then
mkdir "$LOG_DIR" 2> /dev/null || true
mkdir "$LOG_DIR" || (print_output "[!] WARNING: Cannot create log directory" "no_log" && exit 1)
fi
if ! [[ -d "$TMP_DIR" ]] ; then
mkdir "$TMP_DIR" 2> /dev/null || true
mkdir "$TMP_DIR" || (print_output "[!] WARNING: Cannot create log directory" "no_log" && exit 1)
fi
if ! [[ -d "$CSV_DIR" ]]; then
mkdir "$CSV_DIR" 2> /dev/null || true
mkdir "$CSV_DIR" || (print_output "[!] WARNING: Cannot create log directory" "no_log" && exit 1)
fi

if [[ $FIRMWARE -eq 1 ]] ; then
Expand Down
Loading

0 comments on commit 38f8728

Please sign in to comment.