- Open the firmware binary in Ghidra
- Go to the data view and copy all the string addresses, and paste them into a Jupyter notebook with the code below
- Sort and copy all the possible pointers (probably
undefined4type) similarly
| import re | |
| from ghidra.program.model.data import Undefined | |
| from java.io import File | |
| from ghidra.app.util.exporter import CppExporter | |
| from ghidra.util.task import TaskMonitor | |
| from ghidra.app.util import Option | |
| from ghidra.program.model.listing import Function | |
| from ghidra.program.database.symbol import FunctionSymbol | |
| from ghidra.app.decompiler import DecompInterface | |
| from ghidra.program.model.listing import CodeUnit |
| function isReduxStore(obj) { | |
| return obj && typeof obj === 'object' && | |
| typeof obj.getState === 'function' && | |
| typeof obj.dispatch === 'function' && | |
| typeof obj.subscribe === 'function'; | |
| } | |
| function isValidIdentifier(key) { | |
| return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(key); | |
| } |
| // a more generalized version of https://gist.github.com/YSaxon/bdd00ce836dee657518d1937047e4ec6 | |
| function createCriteriaFunction(propertyNames) { | |
| if (!Array.isArray(propertyNames)) { | |
| propertyNames = [propertyNames]; | |
| } | |
| return function(obj) { | |
| if (!obj || typeof obj !== 'object') return false; |
| def find_and_extract_dex(file_path, output_path): | |
| try: | |
| with open(file_path, 'rb') as file: | |
| data = file.read() | |
| # DEX file header magic number and offset for file size | |
| dex_magic = b'dex\n' | |
| size_offset = 32 | |
| size_length = 4 |
undefined4 type) similarlyInitial setup (paths are assuming an Android target but you can obviously modify it)
cat << EOF > /data/local/tmp/shell1.sh
echo echo START >> /data/local/tmp/shell/infile
tail -n 1 -f /data/local/tmp/shell/infile | sh -i >> /data/local/tmp/shell/outfile 2>>/data/local/tmp/shell/outfile
EOF
chmod +x /data/local/tmp/shell1.sh
mkdir /data/local/tmp/shell
| # Add this to your zshrc etc | |
| # modified from #http://broken-by.me/lazy-load-nvm/ | |
| setup_nvm(){ | |
| unset -f nvm node npm | |
| export NVM_DIR="$HOME/.nvm" | |
| [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm | |
| [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion |
| export GHIDRA_HOME=$(dirname $(readlink -f $(which ghidraRun))) |