|
1 |
| -# emba |
2 |
| -emba - Embedded Analyzer |
| 1 | +<!-- |
| 2 | +emba - EMBEDDED LINUX ANALYZER |
| 3 | +
|
| 4 | +Copyright 2020 Siemens AG |
| 5 | +
|
| 6 | +emba comes with ABSOLUTELY NO WARRANTY. This is free software, and you are |
| 7 | +welcome to redistribute it under the terms of the GNU General Public License. |
| 8 | +See LICENSE file for usage of this software. |
| 9 | +
|
| 10 | +Emba is licensed under GPLv3 |
| 11 | +
|
| 12 | +Author(s): Michael Messner, Pascal Eckmann |
| 13 | +--> |
| 14 | +# emba, an analyzer for Linux-based firmware of embedded devices |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +### Why? |
| 20 | + |
| 21 | +_emba_ is being developed as a firmware scanner that analyses already-extracted Linux-based firmware images. It should help you to identify and focus on the interesting areas of a huge firmware image. |
| 22 | +Although _emba_ is optimized for offline firmware images, it can test both, live systems and extracted images. Additionally, it can also analyze kernel configurations. |
| 23 | +_emba_ is designed to assist a penetration tester. It is not designed as a standalone tool without human interaction. _emba_ is designed to give as much information as possible about the firmware. The tester can decide on the areas to focus on and is always responsible for verifying and interpreting the results. |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +### How to use it? |
| 28 | + |
| 29 | + |
| 30 | +__Before starting, check that all dependencies are met and use the installer.sh script: |
| 31 | +`./emba.sh -d` or `./emba.sh -d -F`__ |
| 32 | + |
| 33 | +##### Arguments: |
| 34 | +``` |
| 35 | +Test firmware / live system |
| 36 | +-a [MIPS] Architecture of the linux firmware [MIPS, ARM, x86, x64] |
| 37 | +-A [MIPS] Force Architecture of the linux firmware [MIPS, ARM, x86, x64] (disable architecture check) |
| 38 | +-l [./path] Log path |
| 39 | +-f [./path] Firmware path |
| 40 | +-e [./path] Exclude paths from testing (multiple usage possible) |
| 41 | +-m [MODULE_NO.] Test only with set modules [e.g. -m 05 -m 10 ... ] (multiple usage possible) |
| 42 | +-c Enable cwe-checker |
| 43 | +
|
| 44 | +Dependency check |
| 45 | +-d Only check dependencies |
| 46 | +-F Check dependencies but ignore errors |
| 47 | +
|
| 48 | +Test kernel config |
| 49 | +-k [./config] Kernel config path |
| 50 | +
|
| 51 | +Modify output |
| 52 | +-s Print only relative paths |
| 53 | +-z Add ANSI color codes to log |
| 54 | +
|
| 55 | +Help |
| 56 | +-h Print this help message |
| 57 | +
|
| 58 | +``` |
| 59 | + |
| 60 | +#### Examples |
| 61 | + |
| 62 | +##### Static firmware testing: |
| 63 | +- Extract the firmware from an update file or from flash storage with [binwalk](https://github.com/ReFirmLabs/binwalk) or something else |
| 64 | +- Execute _emba_ with set parameters, e.g. |
| 65 | + |
| 66 | +`sudo ./emba.sh -l ./logs/arm_test -f ./firmware/arm_firmware/` |
| 67 | + |
| 68 | +<img src="./documentation/emba_01.png" alt="emba example startup" width="600"/> |
| 69 | + |
| 70 | +- Path for logs and firmware path are necessary for testing successfully (__WARNING:__ emba needs some free disk space for logging) |
| 71 | +- Architecture will be detected automatically; you can overwrite it with `-a [ARCH]` |
| 72 | +- Use `-A [ARCH]` if you don't want to use auto detection for architecture |
| 73 | +- _emba_ currently supports the following architectures: MIPS, ARM, PPC, x86 and x64 |
| 74 | + |
| 75 | +##### Live testing: |
| 76 | +For testing live system with _emba_ run it as if you were testing static firmware, but with `/` as firmware path: |
| 77 | + |
| 78 | +`sudo ./emba.sh -l ./logs/local_test -f /` |
| 79 | + |
| 80 | +- Path for logs and firmware path are necessary for testing successfully |
| 81 | +- Architecture will be detected automatically; you can overwrite it with `-a [ARCH]` |
| 82 | +- Use `-A [ARCH]` if you don't want to use auto detection for architecture |
| 83 | +- The paths `/proc` and `/sys` will be automatically excluded |
| 84 | +- It improves output and performance, if you exclude docker |
| 85 | +`-e /var/lib/docker` |
| 86 | + |
| 87 | +##### Test kernel config: |
| 88 | +Test only a kernel configuration with the kernel checker of [checksec](https://github.com/slimm609/checksec.sh): |
| 89 | + |
| 90 | +`sudo ./emba.sh -l ./logs/kernel_conf -k ./kernel.config` |
| 91 | + |
| 92 | +- If you add `-f ./firmware/x86_firmware/`, it will ignore `-k` and search for a kernel config inside |
| 93 | +the firmware |
| 94 | + |
| 95 | +__Good to know:__ |
| 96 | +- `sudo` is necessary for some modules to run properly |
| 97 | +- Currently only tested on [Kali Linux](https://kali.org/downloads)(2020.2) |
| 98 | +- _emba_ needs some free disk space for logging |
| 99 | +- _emba_ uses well known tools like objdump, [LinEnum](https://github.com/rebootuser/LinEnum), [checksec](https://github.com/slimm609/checksec.sh), [linux-exploit-suggester.sh](https://github.com/mzet-/linux-exploit-suggester), [cwe-checker](https://github.com/fkie-cad/cwe_checker) |
| 100 | +- _emba_ includes multiple modules of the well known Linux analyser [Lynis](https://cisofy.com/lynis/) |
| 101 | + |
| 102 | +### Dependencies |
| 103 | + |
| 104 | +_emba_ uses multiple other tools and components. |
| 105 | + |
| 106 | +For using _emba_ with all features, you will need following tools on your __Kali Linux__: |
| 107 | +- `readelf` |
| 108 | +- `find` |
| 109 | +- `grep` |
| 110 | +- `modinfo` |
| 111 | +- `realpath` |
| 112 | +- `sed` |
| 113 | +- `cut` |
| 114 | +- `sort` |
| 115 | +- `basename` |
| 116 | +- `strings` |
| 117 | +- `Option: tree` |
| 118 | +- `Option: shellcheck` |
| 119 | +- `Option: docker` |
| 120 | +- `Option: yara` |
| 121 | + |
| 122 | +To check these dependencies, only run `sudo ./emba.sh -d` |
| 123 | + |
| 124 | +For installation of all needed dependencies, run `sudo ./installer.sh` |
| 125 | + |
| 126 | +### Structure |
| 127 | + |
| 128 | +``` |
| 129 | +├── installer.sh |
| 130 | +``` |
| 131 | + |
| 132 | +-> Tries to install all needed dependencies. Internet access for downloading is required. |
| 133 | + - Afterwards no Internet access is needed |
| 134 | +``` |
| 135 | +├── check_project.sh |
| 136 | +``` |
| 137 | + |
| 138 | +-> Check full project with all subdirectories with [shellchecker](https://github.com/koalaman/shellcheck) |
| 139 | + - Install it on your system (Kali) with `apt-get install shellcheck` |
| 140 | +``` |
| 141 | +├── emba.sh |
| 142 | +``` |
| 143 | +-> Main script of this project |
| 144 | +``` |
| 145 | +├── config |
| 146 | +``` |
| 147 | +-> Configuration files for different modules with file names, regular expressions or paths. These files are very handy, |
| 148 | + easy to use and they also keep the modules clean. |
| 149 | +``` |
| 150 | +├── external |
| 151 | +``` |
| 152 | +-> All tools and files which are from other projects and necessary for _emba_ |
| 153 | +``` |
| 154 | +├── helpers |
| 155 | +``` |
| 156 | +-> Some scripts for stuff like pretty formatting on your terminal or path handling |
| 157 | +``` |
| 158 | +└── modules |
| 159 | +``` |
| 160 | +-> The stars of the project - every module is an own file and will be called by [_emba_](/emba.sh). |
| 161 | + |
| 162 | +### External tools in directory 'external' |
| 163 | +- ./yara |
| 164 | + - yara rule files - add your own rules here |
| 165 | +- ./checksec |
| 166 | + - https://github.com/slimm609/checksec.sh |
| 167 | +- ./linux-exploit-suggester.sh |
| 168 | + - https://github.com/mzet-/linux-exploit-suggester |
| 169 | +- ./objdump with all architectures enabled |
| 170 | + - https://www.gnu.org/software/binutils/ |
| 171 | +- ./allitems.csv |
| 172 | + - Use the CSV formated vulnerability list from Mitre: https://cve.mitre.org/data/downloads/ |
| 173 | + |
| 174 | +### How to write own modules? |
| 175 | + |
| 176 | +[Look here](/modules/template_module.sh) - read this file, copy and modify it. Add your _main_ function, where `module_log_init` |
| 177 | +and `module_title` are been called to the [_emba_](/emba.sh) script. That's it. Or if you only want to run a single command: |
| 178 | +Add your command to [_user\_check_](/modules/user_check.sh) and uncomment `user_check` in the [_emba_](/emba.sh) script. |
| 179 | + |
0 commit comments