├── .devcontainer └── devcontainer.json ├── .dockerignore ├── .env ├── .gitignore ├── .res ├── SignApk │ ├── signapk.jar │ ├── testkey.pk8 │ └── testkey.x509.pem ├── settings │ ├── usersettings-template.json │ └── usersettings.json └── watermark │ ├── dbg │ ├── unlock.png │ ├── unlock_hdpi.png │ ├── unlock_xhdpi.png │ └── unlock_xxhdpi.png │ └── watermark │ └── dbg │ ├── unlock.png │ ├── unlock_hdpi.png │ ├── unlock_xhdpi.png │ └── unlock_xxhdpi.png ├── .vscode └── launch.json ├── DockerFiles ├── Alpine │ └── Dockerfile ├── Development │ └── Dockerfile └── Ubuntu │ └── Dockerfile ├── Dockerfile ├── LICENSE.md ├── README.md ├── androSecTest.go ├── androidpkg ├── name.go ├── repackage.go └── save.go ├── attacks ├── folders.go ├── insecurelogging.go ├── insecurestorage.go ├── perform.go └── reverseengineering.go ├── command ├── adb │ └── adb.go ├── apktool │ └── apktool.go ├── command.go ├── grep │ └── grep.go └── sed │ └── sed.go ├── config ├── config.go ├── config_dev.go ├── config_prod.go └── config_testing.go ├── devices └── connection.go ├── docker-compose.yml ├── file └── extension.go ├── folder ├── copy.go └── delete.go ├── go.mod ├── go.sum ├── images └── watermark.go ├── logging ├── colors.go └── logging.go ├── manifest └── manifest.go ├── res ├── SignApk │ ├── signapk.jar │ ├── testkey.pk8 │ └── testkey.x509.pem ├── settings │ ├── usersettings-template.json │ └── usersettings.json └── watermark │ └── dbg │ ├── unlock.png │ ├── unlock_hdpi.png │ ├── unlock_xhdpi.png │ └── unlock_xxhdpi.png ├── settings ├── dependency.go └── settings.go ├── terminal └── input.go └── variables └── variables.go /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "AndroSecTest_Dev_Env", 3 | // Sets the run context to one level up instead of the .devcontainer folder. 4 | "context": "..", 5 | // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. 6 | "dockerFile": "../DockerFiles/Development/Dockerfile", 7 | 8 | "customizations": { 9 | "vscode": { 10 | // Add the IDs of extensions you want installed when the container is created. 11 | "extensions": [ 12 | "golang.go", 13 | "eamodio.gitlens", 14 | "coenraads.bracket-pair-colorizer", 15 | "formulahendry.code-runner", 16 | "aaron-bond.better-comments", 17 | "oderwat.indent-rainbow", 18 | "visualstudioexptteam.vscodeintellicode", 19 | "Veracode.veracode-vscode-plugin" 20 | ], 21 | // Set *default* container specific settings.json values on container create. 22 | "settings": { 23 | "go.useLanguageServer": true, 24 | "terminal.integrated.defaultProfile.linux": "zsh" 25 | } 26 | } 27 | }, 28 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 29 | "forwardPorts": [ 30 | 5037 31 | ], 32 | // Uncomment the next line to run commands after the container is created - for example installing curl. 33 | "postCreateCommand": "go get ./... && cp -r ./res/SignApk /home/Developpement/HackingTools/SignApkUtils/ && chmod +x /home/Developpement/HackingTools/SignApkUtils/signapk.jar", 34 | // Uncomment when using a ptrace-based debugger like C++, Go, and Rust 35 | "runArgs": [ 36 | "--cap-add=SYS_PTRACE", 37 | "--security-opt", 38 | "seccomp=unconfined", 39 | "--privileged", 40 | "-v", 41 | "${localWorkspaceFolder}/android/security:/home/androSecTest-Results" 42 | ], 43 | // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. 44 | // "mounts": [ 45 | // "source=/home/shosta/android/security,target=/home/androSecTest-Results,type=bind,consistency=cached" 46 | // ], 47 | // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. 48 | // "remoteUser": "vscode" 49 | "workspaceMount": "source=${localWorkspaceFolder},target=/root/go/src/github.com/Shosta/androSecTest,type=bind,consistency=cached", 50 | "workspaceFolder": "/root/go/src/github.com/Shosta/androSecTest" 51 | } -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | ./res/SignApk/README 2 | ./res/settings/usersettings-template.json 3 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=andro-sec-test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | \.vscode/settings\.json 3 | \.res/* 4 | 5 | config/config_* 6 | 7 | androSecTest 8 | 9 | res/SignApk/README 10 | 11 | debug 12 | 13 | DockerFiles/Development/veracode* 14 | .dccache 15 | -------------------------------------------------------------------------------- /.res/SignApk/signapk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/SignApk/signapk.jar -------------------------------------------------------------------------------- /.res/SignApk/testkey.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/SignApk/testkey.pk8 -------------------------------------------------------------------------------- /.res/SignApk/testkey.x509.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD 3 | VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g 4 | VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE 5 | AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe 6 | Fw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET 7 | MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G 8 | A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p 9 | ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI 10 | hvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waM 11 | qOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4 12 | wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy 13 | 4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzU 14 | RNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97s 15 | zI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkw 16 | HQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZ 17 | AFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE 18 | CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH 19 | QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG 20 | CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1Ud 21 | EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZa 22 | J6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4Y 23 | LCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe 24 | +ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX 25 | 31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwr 26 | sBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0= 27 | -----END CERTIFICATE----- 28 | -------------------------------------------------------------------------------- /.res/settings/usersettings-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "application": { 3 | "version": "0.1" 4 | }, 5 | "tools": { 6 | "jadx": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/jadx/bin/jadx", 7 | "apktool": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/apktool/apktool.jar", 8 | "signapk": "/home/Developpement/HackingTools/SignApkUtils/sign.jar" 9 | }, 10 | "hackingtools": { 11 | "humpty-dumpty": "/home/Developpement/HackingTools/humpty-dumpty-android-master/humpty.sh" 12 | }, 13 | 14 | 15 | "application": { 16 | "version": "0.1" 17 | }, 18 | "tools": { 19 | "jadx": "", 20 | "apktool": "", 21 | "signapk": "" 22 | }, 23 | "hackingtools": { 24 | "humpty-dumpty": "" 25 | } 26 | } -------------------------------------------------------------------------------- /.res/settings/usersettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "application": { 3 | "version": "0.1" 4 | }, 5 | "tools": { 6 | "jadx": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/jadx/bin/jadx", 7 | "apktool": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/apktool/apktool.jar", 8 | "signapk": "/home/Developpement/HackingTools/SignApkUtils/signapk.jar" 9 | }, 10 | "hackingtools": { 11 | "humpty-dumpty": "/home/Developpement/HackingTools/humpty-dumpty-android-master/humpty.sh" 12 | } 13 | } -------------------------------------------------------------------------------- /.res/watermark/dbg/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/dbg/unlock.png -------------------------------------------------------------------------------- /.res/watermark/dbg/unlock_hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/dbg/unlock_hdpi.png -------------------------------------------------------------------------------- /.res/watermark/dbg/unlock_xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/dbg/unlock_xhdpi.png -------------------------------------------------------------------------------- /.res/watermark/dbg/unlock_xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/dbg/unlock_xxhdpi.png -------------------------------------------------------------------------------- /.res/watermark/watermark/dbg/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/watermark/dbg/unlock.png -------------------------------------------------------------------------------- /.res/watermark/watermark/dbg/unlock_hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/watermark/dbg/unlock_hdpi.png -------------------------------------------------------------------------------- /.res/watermark/watermark/dbg/unlock_xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/watermark/dbg/unlock_xhdpi.png -------------------------------------------------------------------------------- /.res/watermark/watermark/dbg/unlock_xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/.res/watermark/watermark/dbg/unlock_xxhdpi.png -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "name": "Pentest orange", 10 | "type": "go", 11 | "request": "launch", 12 | "mode": "debug", 13 | "program": "/root/go/src/github.com/Shosta/androSecTest/androSecTest.go", 14 | "args": [ 15 | "-p", "orange" 16 | ] 17 | }, 18 | { 19 | "name": "Pentest leboncoin", 20 | "type": "go", 21 | "request": "launch", 22 | "mode": "debug", 23 | "program": "/root/go/src/github.com/Shosta/androSecTest/androSecTest.go", 24 | "args": [ 25 | "-p", "leboncoin" 26 | ] 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /DockerFiles/Alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build the AndroSecTest App on the golang latest image. 2 | FROM golang:latest as go-builder 3 | 4 | # Environmentn variables 5 | ENV SRC_DIR=/go/src/github.com/Shosta/androSecTest 6 | ENV GIT_SSL_NO_VERIFY=1 7 | 8 | # Set the Current Working Directory inside the container 9 | WORKDIR $SRC_DIR 10 | 11 | # Copy the source from the current directory to the Working Directory inside the container 12 | COPY . $SRC_DIR 13 | 14 | # Dowload the Go Dependancies 15 | RUN go get $SRC_DIR/... 16 | 17 | # Build the Go app for a Linux target 18 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o androSecTest . 19 | 20 | 21 | 22 | # Download the Required Hacking Tools 23 | FROM ubuntu:20.04 as ubuntu-downloader 24 | 25 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 26 | 27 | WORKDIR $HACKTOOLS_DIR 28 | 29 | # Install adb tools, unzip, wget, signapk and apktool 30 | RUN apt update -y && apt install -y --no-install-recommends \ 31 | wget \ 32 | unzip 33 | 34 | # Install SignApk 35 | RUN mkdir -p SignApkUtils && \ 36 | wget --no-check-certificate --quiet -O ./SignApkUtils/signapk.jar https://github.com/techexpertize/SignApk/blob/master/signapk.jar 37 | 38 | # Install jadx 39 | RUN wget --no-check-certificate --quiet https://github.com/skylot/jadx/releases/download/v1.1.0/jadx-1.1.0.zip && \ 40 | mkdir -p ./DecompilingAndroidAppUtils/jadx && \ 41 | unzip jadx-1.1.0.zip -d ./DecompilingAndroidAppUtils/jadx && rm jadx-1.1.0.zip 42 | 43 | # Download apktool-2 & Rename downloaded jar to apktool.jar 44 | RUN mkdir -p ./DecompilingAndroidAppUtils/apktool && \ 45 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar 46 | 47 | # Install Humpty-dumpty 48 | RUN mkdir -p ./humpty-dumpty-android-master && \ 49 | wget --no-check-certificate --quiet -O ./humpty-dumpty-android-master/humpty.sh https://github.com/Pixplicity/humpty-dumpty-android/blob/master/humpty.sh 50 | 51 | 52 | 53 | FROM alpine:latest 54 | 55 | # Labels and Credits 56 | LABEL \ 57 | name="AndroSecTest on Alpine" \ 58 | author="Rémi Lavedrine " \ 59 | maintainer="Rémi Lavedrine " \ 60 | description="Android Security Test (AndroSecTest) is an automated, all-in-one mobile application (Android) security assessment framework capable of performing static." 61 | 62 | ENV SRC_DIR=/root/go/src/github.com/Shosta/androSecTest 63 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 64 | WORKDIR $SRC_DIR 65 | 66 | RUN apk add openjdk8 \ 67 | usbutils \ 68 | unzip 69 | RUN apk --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ add android-tools 70 | 71 | # Copy jadx and apktool 72 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/DecompilingAndroidAppUtils $HACKTOOLS_DIR/DecompilingAndroidAppUtils 73 | RUN chmod +x $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool.jar 74 | 75 | # Copy Humpty-dumpty 76 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/humpty-dumpty-android-master $HACKTOOLS_DIR/humpty-dumpty-android-master 77 | 78 | # Copy the built executable from the go-builder container and add it to this container. 79 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/androSecTest $SRC_DIR 80 | 81 | # Copy the User Settings 82 | RUN mkdir $SRC_DIR/.res 83 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/res/ $SRC_DIR/.res/ 84 | 85 | # Copy SignApk to Proper Location in Container 86 | RUN mv $SRC_DIR/.res/SignApk $HACKTOOLS_DIR/SignApkUtils/ && \ 87 | chmod +x $HACKTOOLS_DIR/SignApkUtils/signapk.jar -------------------------------------------------------------------------------- /DockerFiles/Development/Dockerfile: -------------------------------------------------------------------------------- 1 | # The Container that allows to develop the Go app, androSecTest, within a container, without any install. 2 | 3 | FROM ubuntu:mantic-20240427 as ubuntu-downloader 4 | 5 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 6 | 7 | WORKDIR $HACKTOOLS_DIR 8 | 9 | # Install adb tools, unzip, wget, signapk and apktool 10 | RUN apt update -y && apt install -y --no-install-recommends \ 11 | wget \ 12 | unzip 13 | 14 | # Install SignApk 15 | RUN mkdir -p SignApkUtils && \ 16 | wget --no-check-certificate --quiet -O ./SignApkUtils/signapk.jar https://github.com/techexpertize/SignApk/blob/master/signapk.jar 17 | 18 | # Install jadx 19 | RUN wget --no-check-certificate --quiet https://github.com/skylot/jadx/releases/download/v1.1.0/jadx-1.1.0.zip && \ 20 | mkdir -p ./DecompilingAndroidAppUtils/jadx && \ 21 | unzip jadx-1.1.0.zip -d ./DecompilingAndroidAppUtils/jadx && rm jadx-1.1.0.zip 22 | 23 | # Download apktool-2 & Rename downloaded jar to apktool.jar 24 | RUN mkdir -p ./DecompilingAndroidAppUtils/apktool && \ 25 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar && \ 26 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool 27 | 28 | # Install Humpty-dumpty 29 | RUN mkdir -p ./humpty-dumpty-android-master && \ 30 | wget --no-check-certificate --quiet -O ./humpty-dumpty-android-master/humpty.sh https://github.com/Pixplicity/humpty-dumpty-android/blob/master/humpty.sh 31 | 32 | 33 | 34 | 35 | # Pull Ubuntu LTS image. 36 | FROM ubuntu:mantic-20240427 37 | 38 | # Labels and Credits 39 | LABEL \ 40 | name="AndroSecTest as Dev Env" \ 41 | author="Rémi Lavedrine " \ 42 | maintainer="Rémi Lavedrine " \ 43 | description="Android Security Test (AndroSecTest) is an automated, all-in-one mobile application (Android) security assessment framework capable of performing static." 44 | 45 | ENV SRC_DIR=/root/go/src/github.com/Shosta/androSecTest 46 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 47 | WORKDIR $SRC_DIR 48 | 49 | # Install adb tools, unzip, wget, signapk and apktool 50 | RUN apt update -y && apt install -y --no-install-recommends \ 51 | openjdk-8-jdk \ 52 | usbutils \ 53 | unzip \ 54 | wget \ 55 | android-tools-adb \ 56 | bash-completion \ 57 | golang-go \ 58 | gcc 59 | 60 | # Copy jadx and apktool 61 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/DecompilingAndroidAppUtils $HACKTOOLS_DIR/DecompilingAndroidAppUtils 62 | RUN chmod +x $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool* && cp $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool* /usr/local/bin 63 | 64 | # Copy Humpty-dumpty 65 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/humpty-dumpty-android-master $HACKTOOLS_DIR/humpty-dumpty-android-master 66 | 67 | RUN apt install -y --no-install-recommends git zsh && chsh -s /usr/bin/zsh 68 | 69 | RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \ 70 | -t https://github.com/denysdovhan/spaceship-prompt \ 71 | -a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \ 72 | -a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \ 73 | -p git \ 74 | -p sudo \ 75 | -p https://github.com/zsh-users/zsh-autosuggestions \ 76 | -p https://github.com/zsh-users/zsh-completions 77 | 78 | RUN mkdir $SRC_DIR/.res 79 | COPY ./res/ $SRC_DIR/.res/ 80 | 81 | # On copie les credentials pour l'authentification de Veracode 82 | RUN mkdir $HOME/.veracode 83 | # RUN cp $SRC_DIR/DockerFiles/Development/veracode.txt $HOME/.veracode/credentials 84 | 85 | # Install the go tools to debug the app during development. 86 | RUN apt install -y --reinstall build-essential 87 | RUN go install github.com/go-delve/delve/cmd/dlv@latest 88 | RUN go install -v golang.org/x/tools/gopls@latest 89 | 90 | # S'il y a des erreurs d'importation des modules, il faut ajouter les commandes suivantes : 91 | # RUN go mod init 92 | # RUN go mode tidy -------------------------------------------------------------------------------- /DockerFiles/Ubuntu/Dockerfile: -------------------------------------------------------------------------------- 1 | # Download the Required Hacking Tools 2 | FROM ubuntu:20.04 as ubuntu-downloader 3 | 4 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 5 | 6 | WORKDIR $HACKTOOLS_DIR 7 | 8 | # Install adb tools, unzip, wget, signapk and apktool 9 | RUN apt update -y && apt install -y --no-install-recommends \ 10 | wget \ 11 | unzip 12 | 13 | # Install SignApk 14 | RUN mkdir -p SignApkUtils && \ 15 | wget --no-check-certificate --quiet -O ./SignApkUtils/signapk.jar https://github.com/techexpertize/SignApk/blob/master/signapk.jar 16 | 17 | # Install jadx 18 | RUN wget --no-check-certificate --quiet https://github.com/skylot/jadx/releases/download/v1.1.0/jadx-1.1.0.zip && \ 19 | mkdir -p ./DecompilingAndroidAppUtils/jadx && \ 20 | unzip jadx-1.1.0.zip -d ./DecompilingAndroidAppUtils/jadx && rm jadx-1.1.0.zip 21 | 22 | # Download apktool-2 & Rename downloaded jar to apktool.jar 23 | RUN mkdir -p ./DecompilingAndroidAppUtils/apktool && \ 24 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar 25 | 26 | # Install Humpty-dumpty 27 | RUN mkdir -p ./humpty-dumpty-android-master && \ 28 | wget --no-check-certificate --quiet -O ./humpty-dumpty-android-master/humpty.sh https://github.com/Pixplicity/humpty-dumpty-android/blob/master/humpty.sh 29 | 30 | 31 | 32 | # Build the AndroSecTest App on the golang latest image. 33 | FROM golang:latest as go-builder 34 | 35 | # Environmentn variables 36 | ENV SRC_DIR=/go/src/github.com/Shosta/androSecTest 37 | ENV GIT_SSL_NO_VERIFY=1 38 | 39 | # Set the Current Working Directory inside the container 40 | WORKDIR $SRC_DIR 41 | 42 | # Copy the source from the current directory to the Working Directory inside the container 43 | COPY . $SRC_DIR 44 | 45 | # Dowload the Go Dependancies 46 | RUN go get $SRC_DIR/... 47 | 48 | # Build the Go app for a Linux target 49 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o androSecTest . 50 | 51 | 52 | 53 | # Pull Ubuntu LTS image. 54 | FROM ubuntu:20.04 55 | 56 | # Labels and Credits 57 | LABEL \ 58 | name="AndroSecTest on Ubuntu" \ 59 | author="Rémi Lavedrine " \ 60 | maintainer="Rémi Lavedrine " \ 61 | description="Android Security Test (AndroSecTest) is an automated, all-in-one mobile application (Android) security assessment framework capable of performing static." 62 | 63 | ENV SRC_DIR=/root/go/src/github.com/Shosta/androSecTest 64 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 65 | WORKDIR $SRC_DIR 66 | 67 | # Install adb tools, unzip, wget, signapk and apktool 68 | RUN apt update -y && apt install -y --no-install-recommends \ 69 | openjdk-8-jdk \ 70 | usbutils \ 71 | unzip \ 72 | android-tools-adb \ 73 | bash-completion 74 | 75 | # Copy jadx and apktool 76 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/DecompilingAndroidAppUtils $HACKTOOLS_DIR/DecompilingAndroidAppUtils 77 | RUN chmod +x $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool.jar 78 | 79 | # Copy Humpty-dumpty 80 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/humpty-dumpty-android-master $HACKTOOLS_DIR/humpty-dumpty-android-master 81 | 82 | # Copy the built executable from the go-builder container and add it to this container. 83 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/androSecTest $SRC_DIR 84 | 85 | # Copy the User Settings 86 | RUN mkdir $SRC_DIR/.res 87 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/res/ $SRC_DIR/.res/ 88 | 89 | # Copy SignApk to Proper Location in Container 90 | RUN mv $SRC_DIR/.res/SignApk $HACKTOOLS_DIR/SignApkUtils/ && \ 91 | chmod +x $HACKTOOLS_DIR/SignApkUtils/signapk.jar 92 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Download the Required Hacking Tools 2 | FROM ubuntu as ubuntu-downloader 3 | 4 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 5 | 6 | WORKDIR $HACKTOOLS_DIR 7 | 8 | # Install adb tools, unzip, wget, signapk and apktool 9 | RUN apt update -y && apt install -y --no-install-recommends \ 10 | wget \ 11 | unzip 12 | 13 | # Install SignApk 14 | RUN mkdir -p SignApkUtils && \ 15 | wget --no-check-certificate --quiet -O ./SignApkUtils/signapk.jar https://github.com/techexpertize/SignApk/blob/master/signapk.jar 16 | 17 | # Install jadx 18 | RUN wget --no-check-certificate --quiet https://github.com/skylot/jadx/releases/download/v1.1.0/jadx-1.1.0.zip && \ 19 | mkdir -p ./DecompilingAndroidAppUtils/jadx && \ 20 | unzip jadx-1.1.0.zip -d ./DecompilingAndroidAppUtils/jadx && rm jadx-1.1.0.zip 21 | 22 | # Download apktool-2 & Rename downloaded jar to apktool.jar 23 | RUN mkdir -p ./DecompilingAndroidAppUtils/apktool && \ 24 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar && \ 25 | wget --no-check-certificate --quiet -O ./DecompilingAndroidAppUtils/apktool/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool 26 | 27 | # Install Humpty-dumpty 28 | RUN mkdir -p ./humpty-dumpty-android-master && \ 29 | wget --no-check-certificate --quiet -O ./humpty-dumpty-android-master/humpty.sh https://github.com/Pixplicity/humpty-dumpty-android/blob/master/humpty.sh 30 | 31 | 32 | 33 | # Build the AndroSecTest App on the golang latest image. 34 | FROM golang:1.20 as go-builder 35 | 36 | # Environment variables 37 | ENV SRC_DIR=/go/src/github.com/Shosta/androSecTest 38 | ENV GIT_SSL_NO_VERIFY=1 39 | 40 | # Set the Current Working Directory inside the container 41 | WORKDIR $SRC_DIR 42 | 43 | # Copy the source from the current directory to the Working Directory inside the container 44 | COPY . $SRC_DIR 45 | 46 | # Dowload the Go Dependencies 47 | RUN go get $SRC_DIR/... 48 | 49 | # Build the Go app for a Linux target 50 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o androSecTest . 51 | 52 | 53 | 54 | # Pull Ubuntu LTS image. 55 | FROM ubuntu 56 | 57 | # Labels and Credits 58 | LABEL \ 59 | name="AndroSecTest on Ubuntu" \ 60 | author="Rémi Lavedrine " \ 61 | maintainer="Rémi Lavedrine " \ 62 | description="Android Security Test (AndroSecTest) is an automated, all-in-one mobile application (Android) security assessment framework capable of performing static." 63 | 64 | ENV SRC_DIR=/root/go/src/github.com/Shosta/androSecTest 65 | ENV HACKTOOLS_DIR=/home/Developpement/HackingTools 66 | WORKDIR $SRC_DIR 67 | 68 | # Install adb tools, unzip, wget, signapk and apktool 69 | RUN apt update -y && apt install -y --no-install-recommends \ 70 | openjdk-8-jdk \ 71 | usbutils \ 72 | unzip \ 73 | android-tools-adb \ 74 | bash-completion 75 | 76 | # Copy jadx and apktool 77 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/DecompilingAndroidAppUtils $HACKTOOLS_DIR/DecompilingAndroidAppUtils 78 | RUN chmod +x $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool* && cp $HACKTOOLS_DIR/DecompilingAndroidAppUtils/apktool/apktool* /usr/local/bin 79 | 80 | # Copy Humpty-dumpty 81 | COPY --from=ubuntu-downloader $HACKTOOLS_DIR/humpty-dumpty-android-master $HACKTOOLS_DIR/humpty-dumpty-android-master 82 | 83 | # Copy the built executable from the go-builder container and add it to this container. 84 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/androSecTest $SRC_DIR 85 | 86 | # Copy the User Settings 87 | RUN mkdir $SRC_DIR/.res 88 | COPY --from=go-builder /go/src/github.com/Shosta/androSecTest/res/ $SRC_DIR/.res/ 89 | 90 | # Copy SignApk to Proper Location in Container 91 | RUN mv $SRC_DIR/.res/SignApk $HACKTOOLS_DIR/SignApkUtils/ && \ 92 | chmod +x $HACKTOOLS_DIR/SignApkUtils/signapk.jar 93 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | Mozilla Public License, version 2.0 3 | 4 | 1. Definitions 5 | 6 | 1.1. "Contributor" 7 | 8 | means each individual or legal entity that creates, contributes to the 9 | creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | 13 | means the combination of the Contributions of others (if any) used by a 14 | Contributor and that particular Contributor's Contribution. 15 | 16 | 1.3. "Contribution" 17 | 18 | means Covered Software of a particular Contributor. 19 | 20 | 1.4. "Covered Software" 21 | 22 | means Source Code Form to which the initial Contributor has attached the 23 | notice in Exhibit A, the Executable Form of such Source Code Form, and 24 | Modifications of such Source Code Form, in each case including portions 25 | thereof. 26 | 27 | 1.5. "Incompatible With Secondary Licenses" 28 | means 29 | 30 | a. that the initial Contributor has attached the notice described in 31 | Exhibit B to the Covered Software; or 32 | 33 | b. that the Covered Software was made available under the terms of 34 | version 1.1 or earlier of the License, but not also under the terms of 35 | a Secondary License. 36 | 37 | 1.6. "Executable Form" 38 | 39 | means any form of the work other than Source Code Form. 40 | 41 | 1.7. "Larger Work" 42 | 43 | means a work that combines Covered Software with other material, in a 44 | separate file or files, that is not Covered Software. 45 | 46 | 1.8. "License" 47 | 48 | means this document. 49 | 50 | 1.9. "Licensable" 51 | 52 | means having the right to grant, to the maximum extent possible, whether 53 | at the time of the initial grant or subsequently, any and all of the 54 | rights conveyed by this License. 55 | 56 | 1.10. "Modifications" 57 | 58 | means any of the following: 59 | 60 | a. any file in Source Code Form that results from an addition to, 61 | deletion from, or modification of the contents of Covered Software; or 62 | 63 | b. any new file in Source Code Form that contains any Covered Software. 64 | 65 | 1.11. "Patent Claims" of a Contributor 66 | 67 | means any patent claim(s), including without limitation, method, 68 | process, and apparatus claims, in any patent Licensable by such 69 | Contributor that would be infringed, but for the grant of the License, 70 | by the making, using, selling, offering for sale, having made, import, 71 | or transfer of either its Contributions or its Contributor Version. 72 | 73 | 1.12. "Secondary License" 74 | 75 | means either the GNU General Public License, Version 2.0, the GNU Lesser 76 | General Public License, Version 2.1, the GNU Affero General Public 77 | License, Version 3.0, or any later versions of those licenses. 78 | 79 | 1.13. "Source Code Form" 80 | 81 | means the form of the work preferred for making modifications. 82 | 83 | 1.14. "You" (or "Your") 84 | 85 | means an individual or a legal entity exercising rights under this 86 | License. For legal entities, "You" includes any entity that controls, is 87 | controlled by, or is under common control with You. For purposes of this 88 | definition, "control" means (a) the power, direct or indirect, to cause 89 | the direction or management of such entity, whether by contract or 90 | otherwise, or (b) ownership of more than fifty percent (50%) of the 91 | outstanding shares or beneficial ownership of such entity. 92 | 93 | 94 | 2. License Grants and Conditions 95 | 96 | 2.1. Grants 97 | 98 | Each Contributor hereby grants You a world-wide, royalty-free, 99 | non-exclusive license: 100 | 101 | a. under intellectual property rights (other than patent or trademark) 102 | Licensable by such Contributor to use, reproduce, make available, 103 | modify, display, perform, distribute, and otherwise exploit its 104 | Contributions, either on an unmodified basis, with Modifications, or 105 | as part of a Larger Work; and 106 | 107 | b. under Patent Claims of such Contributor to make, use, sell, offer for 108 | sale, have made, import, and otherwise transfer either its 109 | Contributions or its Contributor Version. 110 | 111 | 2.2. Effective Date 112 | 113 | The licenses granted in Section 2.1 with respect to any Contribution 114 | become effective for each Contribution on the date the Contributor first 115 | distributes such Contribution. 116 | 117 | 2.3. Limitations on Grant Scope 118 | 119 | The licenses granted in this Section 2 are the only rights granted under 120 | this License. No additional rights or licenses will be implied from the 121 | distribution or licensing of Covered Software under this License. 122 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 123 | Contributor: 124 | 125 | a. for any code that a Contributor has removed from Covered Software; or 126 | 127 | b. for infringements caused by: (i) Your and any other third party's 128 | modifications of Covered Software, or (ii) the combination of its 129 | Contributions with other software (except as part of its Contributor 130 | Version); or 131 | 132 | c. under Patent Claims infringed by Covered Software in the absence of 133 | its Contributions. 134 | 135 | This License does not grant any rights in the trademarks, service marks, 136 | or logos of any Contributor (except as may be necessary to comply with 137 | the notice requirements in Section 3.4). 138 | 139 | 2.4. Subsequent Licenses 140 | 141 | No Contributor makes additional grants as a result of Your choice to 142 | distribute the Covered Software under a subsequent version of this 143 | License (see Section 10.2) or under the terms of a Secondary License (if 144 | permitted under the terms of Section 3.3). 145 | 146 | 2.5. Representation 147 | 148 | Each Contributor represents that the Contributor believes its 149 | Contributions are its original creation(s) or it has sufficient rights to 150 | grant the rights to its Contributions conveyed by this License. 151 | 152 | 2.6. Fair Use 153 | 154 | This License is not intended to limit any rights You have under 155 | applicable copyright doctrines of fair use, fair dealing, or other 156 | equivalents. 157 | 158 | 2.7. Conditions 159 | 160 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in 161 | Section 2.1. 162 | 163 | 164 | 3. Responsibilities 165 | 166 | 3.1. Distribution of Source Form 167 | 168 | All distribution of Covered Software in Source Code Form, including any 169 | Modifications that You create or to which You contribute, must be under 170 | the terms of this License. You must inform recipients that the Source 171 | Code Form of the Covered Software is governed by the terms of this 172 | License, and how they can obtain a copy of this License. You may not 173 | attempt to alter or restrict the recipients' rights in the Source Code 174 | Form. 175 | 176 | 3.2. Distribution of Executable Form 177 | 178 | If You distribute Covered Software in Executable Form then: 179 | 180 | a. such Covered Software must also be made available in Source Code Form, 181 | as described in Section 3.1, and You must inform recipients of the 182 | Executable Form how they can obtain a copy of such Source Code Form by 183 | reasonable means in a timely manner, at a charge no more than the cost 184 | of distribution to the recipient; and 185 | 186 | b. You may distribute such Executable Form under the terms of this 187 | License, or sublicense it under different terms, provided that the 188 | license for the Executable Form does not attempt to limit or alter the 189 | recipients' rights in the Source Code Form under this License. 190 | 191 | 3.3. Distribution of a Larger Work 192 | 193 | You may create and distribute a Larger Work under terms of Your choice, 194 | provided that You also comply with the requirements of this License for 195 | the Covered Software. If the Larger Work is a combination of Covered 196 | Software with a work governed by one or more Secondary Licenses, and the 197 | Covered Software is not Incompatible With Secondary Licenses, this 198 | License permits You to additionally distribute such Covered Software 199 | under the terms of such Secondary License(s), so that the recipient of 200 | the Larger Work may, at their option, further distribute the Covered 201 | Software under the terms of either this License or such Secondary 202 | License(s). 203 | 204 | 3.4. Notices 205 | 206 | You may not remove or alter the substance of any license notices 207 | (including copyright notices, patent notices, disclaimers of warranty, or 208 | limitations of liability) contained within the Source Code Form of the 209 | Covered Software, except that You may alter any license notices to the 210 | extent required to remedy known factual inaccuracies. 211 | 212 | 3.5. Application of Additional Terms 213 | 214 | You may choose to offer, and to charge a fee for, warranty, support, 215 | indemnity or liability obligations to one or more recipients of Covered 216 | Software. However, You may do so only on Your own behalf, and not on 217 | behalf of any Contributor. You must make it absolutely clear that any 218 | such warranty, support, indemnity, or liability obligation is offered by 219 | You alone, and You hereby agree to indemnify every Contributor for any 220 | liability incurred by such Contributor as a result of warranty, support, 221 | indemnity or liability terms You offer. You may include additional 222 | disclaimers of warranty and limitations of liability specific to any 223 | jurisdiction. 224 | 225 | 4. Inability to Comply Due to Statute or Regulation 226 | 227 | If it is impossible for You to comply with any of the terms of this License 228 | with respect to some or all of the Covered Software due to statute, 229 | judicial order, or regulation then You must: (a) comply with the terms of 230 | this License to the maximum extent possible; and (b) describe the 231 | limitations and the code they affect. Such description must be placed in a 232 | text file included with all distributions of the Covered Software under 233 | this License. Except to the extent prohibited by statute or regulation, 234 | such description must be sufficiently detailed for a recipient of ordinary 235 | skill to be able to understand it. 236 | 237 | 5. Termination 238 | 239 | 5.1. The rights granted under this License will terminate automatically if You 240 | fail to comply with any of its terms. However, if You become compliant, 241 | then the rights granted under this License from a particular Contributor 242 | are reinstated (a) provisionally, unless and until such Contributor 243 | explicitly and finally terminates Your grants, and (b) on an ongoing 244 | basis, if such Contributor fails to notify You of the non-compliance by 245 | some reasonable means prior to 60 days after You have come back into 246 | compliance. Moreover, Your grants from a particular Contributor are 247 | reinstated on an ongoing basis if such Contributor notifies You of the 248 | non-compliance by some reasonable means, this is the first time You have 249 | received notice of non-compliance with this License from such 250 | Contributor, and You become compliant prior to 30 days after Your receipt 251 | of the notice. 252 | 253 | 5.2. If You initiate litigation against any entity by asserting a patent 254 | infringement claim (excluding declaratory judgment actions, 255 | counter-claims, and cross-claims) alleging that a Contributor Version 256 | directly or indirectly infringes any patent, then the rights granted to 257 | You by any and all Contributors for the Covered Software under Section 258 | 2.1 of this License shall terminate. 259 | 260 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user 261 | license agreements (excluding distributors and resellers) which have been 262 | validly granted by You or Your distributors under this License prior to 263 | termination shall survive termination. 264 | 265 | 6. Disclaimer of Warranty 266 | 267 | Covered Software is provided under this License on an "as is" basis, 268 | without warranty of any kind, either expressed, implied, or statutory, 269 | including, without limitation, warranties that the Covered Software is free 270 | of defects, merchantable, fit for a particular purpose or non-infringing. 271 | The entire risk as to the quality and performance of the Covered Software 272 | is with You. Should any Covered Software prove defective in any respect, 273 | You (not any Contributor) assume the cost of any necessary servicing, 274 | repair, or correction. This disclaimer of warranty constitutes an essential 275 | part of this License. No use of any Covered Software is authorized under 276 | this License except under this disclaimer. 277 | 278 | 7. Limitation of Liability 279 | 280 | Under no circumstances and under no legal theory, whether tort (including 281 | negligence), contract, or otherwise, shall any Contributor, or anyone who 282 | distributes Covered Software as permitted above, be liable to You for any 283 | direct, indirect, special, incidental, or consequential damages of any 284 | character including, without limitation, damages for lost profits, loss of 285 | goodwill, work stoppage, computer failure or malfunction, or any and all 286 | other commercial damages or losses, even if such party shall have been 287 | informed of the possibility of such damages. This limitation of liability 288 | shall not apply to liability for death or personal injury resulting from 289 | such party's negligence to the extent applicable law prohibits such 290 | limitation. Some jurisdictions do not allow the exclusion or limitation of 291 | incidental or consequential damages, so this exclusion and limitation may 292 | not apply to You. 293 | 294 | 8. Litigation 295 | 296 | Any litigation relating to this License may be brought only in the courts 297 | of a jurisdiction where the defendant maintains its principal place of 298 | business and such litigation shall be governed by laws of that 299 | jurisdiction, without reference to its conflict-of-law provisions. Nothing 300 | in this Section shall prevent a party's ability to bring cross-claims or 301 | counter-claims. 302 | 303 | 9. Miscellaneous 304 | 305 | This License represents the complete agreement concerning the subject 306 | matter hereof. If any provision of this License is held to be 307 | unenforceable, such provision shall be reformed only to the extent 308 | necessary to make it enforceable. Any law or regulation which provides that 309 | the language of a contract shall be construed against the drafter shall not 310 | be used to construe this License against a Contributor. 311 | 312 | 313 | 10. Versions of the License 314 | 315 | 10.1. New Versions 316 | 317 | Mozilla Foundation is the license steward. Except as provided in Section 318 | 10.3, no one other than the license steward has the right to modify or 319 | publish new versions of this License. Each version will be given a 320 | distinguishing version number. 321 | 322 | 10.2. Effect of New Versions 323 | 324 | You may distribute the Covered Software under the terms of the version 325 | of the License under which You originally received the Covered Software, 326 | or under the terms of any subsequent version published by the license 327 | steward. 328 | 329 | 10.3. Modified Versions 330 | 331 | If you create software not governed by this License, and you want to 332 | create a new license for such software, you may create and use a 333 | modified version of this License if you rename the license and remove 334 | any references to the name of the license steward (except to note that 335 | such modified license differs from this License). 336 | 337 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 338 | Licenses If You choose to distribute Source Code Form that is 339 | Incompatible With Secondary Licenses under the terms of this version of 340 | the License, the notice described in Exhibit B of this License must be 341 | attached. 342 | 343 | Exhibit A - Source Code Form License Notice 344 | 345 | This Source Code Form is subject to the 346 | terms of the Mozilla Public License, v. 347 | 2.0. If a copy of the MPL was not 348 | distributed with this file, You can 349 | obtain one at 350 | http://mozilla.org/MPL/2.0/. 351 | 352 | If it is not possible or desirable to put the notice in a particular file, 353 | then You may include the notice in a location (such as a LICENSE file in a 354 | relevant directory) where a recipient would be likely to look for such a 355 | notice. 356 | 357 | You may add additional accurate notices of copyright ownership. 358 | 359 | Exhibit B - "Incompatible With Secondary Licenses" Notice 360 | 361 | This Source Code Form is "Incompatible 362 | With Secondary Licenses", as defined by 363 | the Mozilla Public License, v. 2.0. 364 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Ask me anything 3 | Maintained 4 | GitHub stars 5 | GitHub forks 6 | GitHub license 7 | Pentest 8 | 9 | 10 | # Android-Static-Security-Audit 11 | 12 | Here is a quick Cheat Sheet to test the security of an Android app that AndroSecTest is doing. 13 | 14 | You can have a quick look at how the application is pentesting an Android app on Youtube : https://youtu.be/zzyTFjnwolo 15 | 16 | ## Easiest Way to Try It 17 | 18 | ### Use the docker Container 19 | 20 | 1. Build the Docker Container that has all the dependencies and tools already installed. 21 | > `docker build .` 22 | 23 | 2. Connect your Android Device 24 | 25 | 2.1. Be sure that the "adb server" is **not** running on the host machine as an android phone can only be connected to one adb server at a given time. 26 | 27 | 2.2. USB connection is not working from host device to Container on MacOS, so it is only working on a Linux host for the time being. 28 | 29 | 3. Run the Docker Container 30 | > `docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb "The Container ID"` 31 | 32 | 3.1 `-it` is here so that we can have an iteractive session. 33 | 34 | 3.2. `--privileged` is required to use a USB device. 35 | 36 | 3.3. `-v /dev/bus/usb:/dev/bus/usb` defines a shared volume between the host machine and the Container in order to share the USB device (*the android phone*) information 37 | 38 | ⚠️ The results from the SAST is not persisted outside of the Docker Container at the moment. 39 | I am planning to add a shared volume to persist it in the near future. 40 | 41 | ## The first part of the Security testing is to : 42 | 1. Get the application from the Store, 43 | 1. Pull it from the device, 44 | 1. Unpackaged it, 45 | 1. Look for some unsecure behavior, 46 | 1. Make it debuggable, 47 | 1. Repackage it and reinstall it on the device. 48 | 49 | ### 1. Get the application from your device, using the `adb` command 50 | #### 1.1. List the applications' package names on your device : 51 | > `adb shell pm list packages | grep “hint from the app you are looking for”` 52 | 53 | #### 1.2. Get the path of the desired application on the device : 54 | > `adb shell pm path app.package.name.apk` 55 | 56 | #### 1.3. Pull it from your device to your computer : 57 | > `adb pull app.path` 58 | 59 | 60 | #### 1.4. Change the file name from ".apk" to ".zip". 61 | Unzip the file. 62 | You now have access to the application's file system. 63 | 64 | ### 2. Look for interesting strings or files in the application 65 | #### 2.1. Locate interesting files or strings 66 | Run the following commands at the root of the application file system. 67 | * `find . -name "*key"` 68 | * `find . -name "*cer*"` 69 | * `find . -name "*pass*"'''` 70 | 71 | If you find some files whose name contains 'key' try these commands : 72 | * `hexdump ./path/to/.appkey -vC` 73 | * `more ./path/to/.appkey ` 74 | 75 | 76 | #### 2.2. Check the application signature. 77 | 78 | Verify the signature : 79 | > `apksigner verify --verbose Application.apk` 80 | 81 | or 82 | > `jarsigner -verify -certs -verbose app.apk` 83 | 84 | and 85 | 86 | Move to the META.INF folder and check the signature with openssl : 87 | > `openssl pkcs7 -inform DER -in CERT.RSA -noout -print_certs -text` 88 | 89 | Extract CERT.RSA from the package and display the certificate with keytool. 90 | > `keytool -printcert -file CERT.RSA ` 91 | 92 | You can then check the type of encryption used (hint, [SHA-1 is no more secure](https://shattered.io)). 93 | 94 | 95 | ### 2. Make the application debuggable and ready for penetration testing 96 | 97 | Now that you have the apk file from the application you want, you must disassemble the app to make it debuggable. 98 | 99 | #### 1. To disassemble the application, you can use the tool 'apktool'. 100 | 101 | >`apktool d -o localAppFolder/ app.package.name.apk` 102 | 103 | #### 2. Make the application debuggable and allow backup 104 | 105 | In the `" 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | ... 127 | ``` 128 | 129 | #### 4. Add the certificate to the device. 130 | Download it from Burp, Charles, etc… and add it to your device following your preferred method (add push to the sdcard is the method I use). 131 | You can use Bettercap to monitor the UDP traffic. 132 | 133 | 134 | #### 5. Repackage and sign the app: 135 | 1. Repackage the app: 136 | ``` 137 | apk tool b -o app.package.name.apk localAppFolder/ 138 | ``` 139 | 140 | 2. Generate a signing key : 141 | ``` 142 | keytool -genkey -v -keystore resign.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 143 | ``` 144 | 3. then sign the app with it : 145 | ``` 146 | jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore resign.keystore app.package.name.apk alias_name 147 | ``` 148 | or 149 | ``` 150 | apksigner sign -ks resign.keystore app.package.name.apk 151 | ``` 152 | 153 | #### 6. Install the app on the device : 154 | 155 | Run the following command to install the repackage app to the device: 156 | ``` 157 | adb install app.package.name.apk 158 | ``` 159 | 160 | ## The next steps of the security testing areto use some static test tool 161 | 162 | I want to use some Man in the Middle attack while the user is using the application. It will jsute intercept all the requests/responses for later analysis. 163 | I plan to use Bettercap or mitmproxy to do it. 164 | 165 | We are going to use [MobSF](https://github.com/MobSF/Mobile-Security-Framework-MobSF) (MobSF stands for Mobile Security Framework) to test some part of the security of the app. 166 | 167 | As described in the Github page of the Project : 168 | > Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing framework capable of performing static, dynamic and malware analysis. It can be used for effective and fast security analysis of Android, iOS and Windows mobile applications and support both binaries (APK, IPA & APPX ) and zipped source code. MobSF can do dynamic application testing at runtime for Android apps and has Web API fuzzing capabilities powered by CapFuzz, a Web API specific security scanner. MobSF is designed to make your CI/CD or DevSecOps pipeline integration seamless. 169 | 170 | I personnaly use the Docker container to use MobSF for Android security audit. 171 | So you could just launch that command `docker run -it -p 8000:8000 -v :/root/.MobSF opensecurity/mobile-security-framework-mobsf:latest` 172 | 173 | MobSF is going to automate a lot of the process of static security analysis and deliver a report that will make it easier to start the dynamic security audit. 174 | 175 | -------------------------------------------------------------------------------- /androSecTest.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package main : The main file that starts the program 21 | package main 22 | 23 | import ( 24 | "github.com/Shosta/androSecTest/androidpkg" 25 | "github.com/Shosta/androSecTest/attacks" 26 | "github.com/Shosta/androSecTest/config" 27 | "github.com/Shosta/androSecTest/devices" 28 | "github.com/Shosta/androSecTest/logging" 29 | "github.com/Shosta/androSecTest/settings" 30 | "github.com/Shosta/androSecTest/terminal" 31 | arg "github.com/alexflint/go-arg" 32 | ) 33 | 34 | func main() { 35 | var args struct { 36 | Settings bool `arg:"-s" help:"set up the user settings"` 37 | Package string `arg:"-p" help:"package name (enter the app name you want to test)"` 38 | Dest string `arg:"-d" help:"destination folder absolute path"` 39 | Attacksonly bool `arg:"-a" help:"perform only attacks (do not repackage the app on the device)"` 40 | Verbose bool `arg:"-v" help:"verbosity level (verbose or not)"` 41 | } 42 | arg.MustParse(&args) 43 | settings.Setup(args.Settings) 44 | 45 | if !devices.IsConnected() { 46 | logging.Println(logging.Green("No device is connected.") + "\nPlease " + logging.Bold("connect a device to your computer") + " prior to any penetration testing.") 47 | return 48 | } 49 | 50 | pkgname := "" 51 | if args.Package == "" { 52 | logging.PrintDebug("No package provided.\nPlease provide the name of the package you want to test.\n" + logging.Blue("> ")) 53 | pkgname = terminal.Waitfor() 54 | } else { 55 | pkgname = androidpkg.Package(args.Package) 56 | } 57 | 58 | if args.Verbose { 59 | config.IsVerboseLogRequired = true 60 | } 61 | logging.Println(pkgname) 62 | 63 | if args.Attacksonly == false { 64 | androidpkg.Savelocal(pkgname) 65 | androidpkg.Setup(pkgname) 66 | } 67 | 68 | attacks.Do(pkgname) 69 | } 70 | -------------------------------------------------------------------------------- /androidpkg/name.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package androidpkg : Scan the packages on the device that contains a string and allows the user to work on it. 18 | package androidpkg 19 | 20 | import ( 21 | "fmt" 22 | "os" 23 | "strconv" 24 | "strings" 25 | 26 | "github.com/Shosta/androSecTest/command/adb" 27 | "github.com/Shosta/androSecTest/logging" 28 | ) 29 | 30 | // Display a list of packages and let the user choose one of them. 31 | // It returns the package name the user chose. 32 | func choose(pkgs []string) string { 33 | 34 | for i, pkg := range pkgs { 35 | if pkg != "" { 36 | fmt.Println(logging.Blue("[") + logging.Red(strconv.Itoa(i+1)) + logging.Blue("] ") + logging.Bold(strings.Split(pkg, ":")[1])) 37 | } 38 | } 39 | 40 | // Wait for input from user in order to choose which apk to retrive through adb 41 | logging.Println(logging.Blue("Which package do you want to investigate ? (enter a number)")) 42 | 43 | var input string 44 | fmt.Scanln(&input) 45 | 46 | var i, err = strconv.Atoi(input) 47 | if err != nil { 48 | // handle error 49 | fmt.Println(err) 50 | os.Exit(2) 51 | } 52 | 53 | return strings.Split(pkgs[i-1], ":")[1] 54 | } 55 | 56 | // Package Allow the user to select the package he wants to work on thanks to a simple part of the package name. 57 | func Package(pkgnamepart string) string { 58 | var pkgs = adb.ListPackages(pkgnamepart) 59 | 60 | var pkgname = choose(pkgs) 61 | 62 | return pkgname 63 | } 64 | -------------------------------------------------------------------------------- /androidpkg/repackage.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package androidpkg : Repackage a package after enabling some penetration testing features in it. 18 | package androidpkg 19 | 20 | import ( 21 | "io/ioutil" 22 | "log" 23 | "os" 24 | "path/filepath" 25 | "strings" 26 | "sync" 27 | 28 | "github.com/Shosta/androSecTest/settings" 29 | 30 | "github.com/Shosta/androSecTest/images" 31 | "github.com/Shosta/androSecTest/manifest" 32 | 33 | "github.com/Shosta/androSecTest/command/sed" 34 | 35 | folders "github.com/Shosta/androSecTest/attacks" 36 | "github.com/Shosta/androSecTest/command" 37 | "github.com/Shosta/androSecTest/command/adb" 38 | "github.com/Shosta/androSecTest/command/apktool" 39 | "github.com/Shosta/androSecTest/logging" 40 | ) 41 | 42 | // Setup : 43 | func Setup(pkgname string) { 44 | unzip(pkgname) 45 | disassemble(pkgname) 46 | mkdbg(pkgname) 47 | allowbackup(pkgname) 48 | addDbgBadgeOnAppIcon(pkgname) 49 | rebuild(pkgname) 50 | sign(pkgname) 51 | reinstall(pkgname) 52 | } 53 | 54 | // Unzip the package to the 'unzippedPackage' Folder 55 | // cmd = "unzip " + attacksDir + variables.SourcePackageDir + "/" + pkgname + ".apk '*' -d " + unzipDir 56 | func unzip(pkgname string) { 57 | sourceDirPath := folders.SourcePackageDirPath(pkgname) 58 | unzipDirPath := folders.UnzipDirPath(pkgname) 59 | logging.Println(logging.Green("Unzip package : ") + logging.Bold(pkgname) + " to " + logging.Bold(unzipDirPath)) 60 | 61 | cmdName := "unzip" 62 | cmdArgs := []string{ 63 | sourceDirPath + "/" + pkgname + ".apk", 64 | "-d", 65 | unzipDirPath, 66 | } 67 | command.Run(cmdName, cmdArgs) 68 | 69 | logging.Println(logging.Bold("Done")) 70 | } 71 | 72 | // Disassemble the package using the apktool that is installed on the system. 73 | func disassemble(pkgname string) { 74 | logging.Println(logging.Green("Disassemble package : ") + logging.Bold(pkgname)) 75 | logging.Println("Work in progress...") 76 | apktool.Disassemble(pkgname) 77 | 78 | logging.Println(logging.Bold("Done")) 79 | } 80 | 81 | func mkdbg(pkgname string) { 82 | logging.Println(logging.Green("Make package debuggable")) 83 | 84 | disassembledDirPath := folders.DisassemblePackageDirPath(pkgname) 85 | sed.Replace(disassembledDirPath+"/AndroidManifest.xml", " " + resFilePath 38 | command.RunAlias(cmd) 39 | } 40 | 41 | // Get all the occurence of words related to "password" and store them in a file. 42 | func passwordStrInLog(pkgname string) { 43 | strInLog("password", pkgname) 44 | strInLog("pass", pkgname) 45 | strInLog("passwd", pkgname) 46 | } 47 | 48 | // Get all the occurence of words related to "key" and store them in a file. 49 | func keyStrInLog(pkgname string) { 50 | strInLog("key", pkgname) 51 | } 52 | 53 | // Get all the occurence of words related to "admin" and store them in a file. 54 | func adminStrInLog(pkgname string) { 55 | strInLog("admin", pkgname) 56 | strInLog("adm", pkgname) 57 | } 58 | 59 | // A loop method that ask the user to enter a string, then search it in the log file through a grep command and ask the user if he wants to do another search. 60 | func userInputStrInLog(pkgname string) { 61 | logging.Print(logging.Blue("Enter the string you want to look for in the log file.\n> ")) 62 | usrinput := terminal.Waitfor() 63 | if usrinput != "" { 64 | logging.Println(logging.Green("Looking for \"") + logging.Bold(usrinput) + "\" in log file.") 65 | strInLog(usrinput, pkgname) 66 | logging.Print(logging.Blue("Do you want to look for another string? [y][n]\n> ")) 67 | newSearch := terminal.Waitfor() 68 | if newSearch == "y" { 69 | userInputStrInLog(pkgname) 70 | } 71 | 72 | return 73 | } 74 | } 75 | 76 | // Launch a logcat command and push the result to a file. 77 | func launchlogcat(pkgname string) { 78 | insecLoggingDirPath := InsecLoggingDirPath(pkgname) 79 | logging.Println("Log svg : " + insecLoggingDirPath + "/log.txt") 80 | cmd := exec.Command("/bin/sh", "-c", "adb logcat > "+insecLoggingDirPath+"/log.txt") 81 | 82 | // Start command asynchronously 83 | logging.PrintlnDebug("Launched logcat asynchronously.") 84 | cmd.Start() 85 | logging.PrintlnDebug("Wait for any user input to kill the logcat process.") 86 | logging.Println("Press any key to stop getting logs.") 87 | terminal.Waitfor() 88 | 89 | logging.PrintlnDebug("Stopped logcat.") 90 | cmd.Process.Signal(os.Kill) 91 | } 92 | 93 | // DoInsecureLog : Test if something insecure is logged through logcat while using the device. 94 | // It tests the "password", "admin" and "key" related strings and then let the user test its own strings. 95 | func DoInsecureLog(pkgname string) { 96 | logging.Println(logging.Green("Test Insecure Logging")) 97 | launchlogcat(pkgname) 98 | 99 | passwordStrInLog(pkgname) 100 | keyStrInLog(pkgname) 101 | adminStrInLog(pkgname) 102 | 103 | userInputStrInLog(pkgname) 104 | } 105 | -------------------------------------------------------------------------------- /attacks/insecurestorage.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package attacks : Tests the insecure storage 18 | package attacks 19 | 20 | import ( 21 | "github.com/Shosta/androSecTest/command" 22 | "github.com/Shosta/androSecTest/folder" 23 | "github.com/Shosta/androSecTest/logging" 24 | "github.com/Shosta/androSecTest/terminal" 25 | ) 26 | 27 | func copyDump(pkgname string) { 28 | srcDir := "/home/shosta/ShostaSyncBox/Developpement/HackingTools/humpty-dumpty-android-master/dumps/" + pkgname 29 | destDir := InsecStorageDirPath(pkgname) 30 | logging.PrintlnDebug("Source : " + srcDir) 31 | logging.PrintlnDebug("Dest : " + destDir) 32 | 33 | logging.PrintlnDebug("Delete \"dump\" folder if it exists") 34 | folder.Delete(destDir) 35 | 36 | logging.PrintlnDebug("Copy \"dump\" folder to proper location") 37 | folder.CopyDir(srcDir, destDir) 38 | } 39 | 40 | // humpty.sh -a com.pixplicity.example 41 | func pullLocalStorage(pkgname string) { 42 | logging.Println(logging.Green("Pull every files from the local storage of the \"" + pkgname + "\" package.")) 43 | 44 | logging.Println("Work in progress...") 45 | var cmd = "/home/shosta/ShostaSyncBox/Developpement/HackingTools/humpty-dumpty-android-master/humpty.sh -a " + pkgname 46 | command.RunAlias(cmd) 47 | 48 | logging.Println(logging.Bold("Done")) 49 | } 50 | 51 | // DoInsecureStorage : 52 | func DoInsecureStorage(pkgname string) { 53 | logging.Println(logging.Green("Test Insecure Storage")) 54 | 55 | logging.Println(logging.Blue("Did you use all the features of the application?") + "[" + logging.Red("y") + "]es [" + logging.Red("n") + "]o") 56 | terminal.Waitfor() 57 | 58 | pullLocalStorage(pkgname) 59 | copyDump(pkgname) 60 | logging.Println(logging.Bold("Done")) 61 | } 62 | -------------------------------------------------------------------------------- /attacks/perform.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package attacks : does all the attacks at once. 21 | package attacks 22 | 23 | import ( 24 | "github.com/Shosta/androSecTest/logging" 25 | "github.com/Shosta/androSecTest/terminal" 26 | ) 27 | 28 | // Do : 29 | func Do(pkgname string) { 30 | logging.Print(logging.Blue("What kind of attacks do you want to perform? [") + 31 | logging.Red("a") + 32 | logging.Blue("]ll, [") + 33 | logging.Red("i") + 34 | logging.Blue("]nsecure logging, [") + 35 | logging.Red("r") + 36 | logging.Blue("]everse engineering, [") + 37 | logging.Red("m") + 38 | logging.Blue("]an in the middle.\n> ")) 39 | usrInput := terminal.Waitfor() 40 | 41 | switch usrInput { 42 | case "a": 43 | DoInsecureLog(pkgname) 44 | DoInsecureStorage(pkgname) 45 | DoReverse(pkgname) 46 | 47 | case "i": 48 | DoInsecureStorage(pkgname) 49 | 50 | case "r": 51 | DoReverse(pkgname) 52 | 53 | case "m": 54 | logging.PrintlnDebug("Man in the Middle is not ready yet (Work in Progress).") 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /attacks/reverseengineering.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package attacks : does the reverse engineering attack on the application through decompiling the application and looling at improper strings in it. 21 | package attacks 22 | 23 | import ( 24 | "github.com/Shosta/androSecTest/command" 25 | grep "github.com/Shosta/androSecTest/command/grep" 26 | "github.com/Shosta/androSecTest/logging" 27 | "github.com/Shosta/androSecTest/settings" 28 | "github.com/Shosta/androSecTest/variables" 29 | ) 30 | 31 | // Voici le commande à utiliser : 32 | // ./ShostaSyncBox/Developpement/HackingTools/DecompilingAndroidApp/jadx/bin/jadx --deobf -d ~/android/security/com.orange.owtv/attacks/decodedPackage ~/android/security/com.orange.owtv/attacks/sourcePackage/com.orange.owtv.apk 33 | func reverseApk(apkname string) { 34 | // TODO : Il faut changer le chemin absolu vers le binaire de jadx pour que cela soit rentré par l'utilisateur dans un fichier settings. 35 | 36 | cmd := settings.Jadx() + " " + 37 | UnzipDirPath(apkname) + "/classes.dex" + " " + 38 | "-d " + DecompiledPackageDirPath(apkname) + " " + 39 | "--deobf" 40 | 41 | logging.PrintlnDebug("Cmd : " + cmd) 42 | 43 | logging.Println("Decompiling apk to " + logging.Bold(apkname+"/attacks/decodedPackage/") + "\nWork in progress...") 44 | command.RunAlias(cmd) 45 | logging.PrintlnDebug(cmd) 46 | } 47 | 48 | // DoReverse : Reverse the ".apk" to the ".java" files. 49 | // Try to deobfuscate code while reversing it. 50 | // Then it performs some research for specific leak in the codebase, looking for strings as "password", "admin", "key", etc. The results are stored in specific files. 51 | func DoReverse(pkgname string) { 52 | logging.Println(logging.Green("Reverse apk")) 53 | reverseApk(pkgname) 54 | logging.Println(logging.Bold("Done")) 55 | 56 | logging.Println(logging.Green("Check for leakage in codebase") + "\nWork in progress...") 57 | checkForLeaks(pkgname) 58 | logging.Println(logging.Bold("Done")) 59 | } 60 | 61 | func checkForLeaks(pkgname string) { 62 | decoPkgPath := DecompiledPackageDirPath(pkgname) 63 | createLeakageDir(pkgname) 64 | grep.Passwd(decoPkgPath, decoPkgPath+variables.LeakagesDir) 65 | grep.Admin(decoPkgPath, decoPkgPath+variables.LeakagesDir) 66 | grep.Key(decoPkgPath, decoPkgPath+variables.LeakagesDir) 67 | } 68 | -------------------------------------------------------------------------------- /command/adb/adb.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package adb : It executes binaries on an android device using adb. 21 | package adb 22 | 23 | import ( 24 | "fmt" 25 | "os/exec" 26 | "strings" 27 | 28 | "github.com/Shosta/androSecTest/logging" 29 | ) 30 | 31 | func runAdb(args ...string) string { 32 | cmd := exec.Command("adb", args...) 33 | 34 | output, err := cmd.CombinedOutput() 35 | if err != nil { 36 | logging.PrintlnError(fmt.Sprint(err) + ": " + string(output)) 37 | return "" 38 | } 39 | return string(output) 40 | } 41 | 42 | // Pull : 43 | func Pull(pkgpath string, pkgdest string) string { 44 | logging.PrintlnDebug(logging.Green("Package path : ") + logging.Bold(pkgpath)) 45 | logging.PrintlnDebug(logging.Green("Package destination : ") + logging.Bold(pkgdest)) 46 | 47 | cmd := exec.Command("adb", "pull", pkgpath, pkgdest) 48 | 49 | output, err := cmd.CombinedOutput() 50 | if err != nil { 51 | logging.PrintlnError(fmt.Sprint(err) + ": " + string(output)) 52 | return "" 53 | } 54 | return string(output) 55 | } 56 | 57 | // PkgPath : Get the path of the package name on the connected device on adb. 58 | // It returns the package's path on the device as a string. 59 | func PkgPath(pkgname string) string { 60 | logging.PrintlnDebug(logging.Green("Package name: ") + pkgname) 61 | 62 | var args = []string{"shell", "pm", "path", pkgname} 63 | var out = runAdb(args...) 64 | 65 | var pkgpath = strings.TrimSpace(strings.Split(out, ":")[1]) 66 | logging.Println(logging.Green("Path: ") + pkgpath) 67 | 68 | return pkgpath 69 | } 70 | 71 | // ListPackages : 72 | func ListPackages(pkgnamepart string) []string { 73 | logging.Println(logging.Green("Get the packages names") + " on the device that contains \"" + logging.Bold(pkgnamepart) + "\":") 74 | 75 | var args = []string{"shell", "pm", "list", "packages", "|", "grep " + pkgnamepart} 76 | var out = runAdb(args...) 77 | pkgs := strings.Split(out, "\n") 78 | 79 | return pkgs 80 | } 81 | 82 | //Uninstall : adb uninstall " + package_name 83 | func Uninstall(pkgname string) string { 84 | logging.PrintlnDebug("Uninstall app on the device.") 85 | out := runAdb("uninstall", pkgname) 86 | 87 | return string(out) 88 | } 89 | 90 | //Install : adb install /tmp/Attacks/DebuggablePackage/" + package_name + ".b.s.apk" 91 | func Install(localpkgpath string) string { 92 | logging.PrintlnDebug("Install app on the device.") 93 | logging.PrintlnDebug("Local package path: " + localpkgpath) 94 | out := runAdb("install", localpkgpath) 95 | 96 | return string(out) 97 | } 98 | 99 | // Devices : List the devices connected to the computer. 100 | func Devices() string { 101 | logging.PrintlnDebug("List devices connected to the computer.") 102 | out := runAdb("devices", "-l") 103 | 104 | return string(out) 105 | } 106 | -------------------------------------------------------------------------------- /command/apktool/apktool.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package apktool : It executes binaries on an computer using apktool. 18 | package apktool 19 | 20 | import ( 21 | "github.com/Shosta/androSecTest/attacks" 22 | "github.com/Shosta/androSecTest/command" 23 | "github.com/Shosta/androSecTest/settings" 24 | 25 | "github.com/Shosta/androSecTest/logging" 26 | ) 27 | 28 | func runApktool(args ...string) { 29 | cmdArgs := []string{ 30 | "-jar", 31 | settings.ApkTool(), 32 | } 33 | command.Run("java", append(cmdArgs, args...)) 34 | } 35 | 36 | // Disassemble : 37 | // TODO Il faut prendre en compte les cas d'erreurs d'apktool. 38 | func Disassemble(pkgname string) { 39 | 40 | cmdArgs := []string{ 41 | "d", 42 | attacks.SourcePackageDirPath(pkgname) + "/" + pkgname + ".apk", 43 | "-f", 44 | "-o", 45 | attacks.DisassemblePackageDirPath(pkgname), 46 | } 47 | 48 | runApktool(cmdArgs...) 49 | 50 | logging.Println(logging.Green("Package disassembled with success") + " to " + logging.Bold(attacks.DisassemblePackageDirPath(pkgname))) 51 | } 52 | 53 | // Build : 54 | // TODO Il faut prendre en compte les cas d'erreurs d'apktool. 55 | //cmd = "apktool b /tmp/Attacks/DecodedPackage -o /tmp/Attacks/DebuggablePackage/" + package_name + ".b.apk" 56 | func Build(pkgname string) { 57 | 58 | cmdArgs := []string{ 59 | "b", 60 | attacks.DisassemblePackageDirPath(pkgname), 61 | "-o", 62 | attacks.DebugPkgDirPath(pkgname) + "/" + pkgname + ".b.apk", 63 | } 64 | 65 | runApktool(cmdArgs...) 66 | 67 | logging.Println(logging.Green("Package built with success") + " to " + logging.Bold(attacks.DebugPkgDirPath(pkgname))) 68 | } 69 | -------------------------------------------------------------------------------- /command/command.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package command : It executes bash command on a computer. 18 | package command 19 | 20 | import ( 21 | "fmt" 22 | "os/exec" 23 | 24 | "github.com/Shosta/androSecTest/logging" 25 | ) 26 | 27 | // Run : 28 | func Run(command string, args []string) string { 29 | cmd := exec.Command(command, args...) 30 | 31 | output, err := cmd.CombinedOutput() 32 | if err != nil { 33 | logging.PrintlnError(fmt.Sprint(err) + ": " + string(output)) 34 | return "" 35 | } 36 | return string(output) 37 | } 38 | 39 | // RunCmd : 40 | func RunCmd(cmd string) string { 41 | out, err := exec.Command(cmd).Output() 42 | if err != nil { 43 | logging.PrintlnError("error occured") 44 | logging.PrintlnError(fmt.Sprint(err)) 45 | } 46 | fmt.Printf("%s", out) 47 | 48 | return string(out) 49 | } 50 | 51 | // func Start(cmd string, args []string) string { 52 | // command := exec.Command(cmd, args...) 53 | // err := command.Start() 54 | // if err != nil { 55 | 56 | // log.Fatal(err) 57 | // } 58 | // log.Printf("Waiting for command to finish...") 59 | // err = command.Wait() 60 | // log.Printf("Command finished with error: %v", err) 61 | // } 62 | 63 | // RunAlias : Run a command that is defined as an alias in ~/.bashrc or ~/.bash_aliases files. 64 | // The aliasCmd is the entire command you want to run. 65 | func RunAlias(aliasCmd string) string { 66 | out, err := exec.Command("/bin/bash", "-c", aliasCmd).Output() 67 | if err != nil { 68 | logging.PrintlnError("error occured") 69 | logging.PrintlnError(err) 70 | } 71 | // logging.PrintlnVerbose(string(out)) 72 | 73 | return string(out) 74 | } 75 | -------------------------------------------------------------------------------- /command/grep/grep.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package grep : It executes grep commands on a computer. 18 | package grep 19 | 20 | import ( 21 | "github.com/Shosta/androSecTest/command" 22 | "github.com/Shosta/androSecTest/logging" 23 | ) 24 | 25 | // Motif : Check if the files that are in the dest folder have some urls. 26 | // grep command used is : grep -Eo motif -R . 27 | func Motif(motif string, src string, dest string) { 28 | logging.PrintlnDebug("Src : " + src) 29 | logging.PrintlnDebug("Dest : " + dest) 30 | 31 | cmd := "grep " + motif + " -R " + src + " >> " + dest + "/grep-" + motif + ".txt" 32 | logging.PrintlnDebug("Run command : " + cmd) 33 | command.RunAlias(cmd) 34 | } 35 | 36 | // HTTP : Check if the files that are in the dest folder have some urls. 37 | // grep command used is : grep -Eo '(http|https)://[^/"]+' -R . 38 | func HTTP(src string, dest string) { 39 | Motif("'(http|https)://[^/\"]+'", src, dest) 40 | } 41 | 42 | // Admin : Check if the files that are in the dest folder have the following patterns in it, "admin", "adm". 43 | // It stores the results in a specific file, named as followed grep-"motif".txt, in the "dest" folder. 44 | func Admin(src string, dest string) { 45 | Motif("admin", src, dest) 46 | Motif("adm", src, dest) 47 | } 48 | 49 | // Passwd : Check if the files that are in the dest folder have the following patterns in it, "pass", "passwd", "password". 50 | // It stores the results in a specific file, named as followed grep-"motif".txt, in the "dest" folder. 51 | func Passwd(src string, dest string) { 52 | Motif("password", src, dest) 53 | Motif("passwd", src, dest) 54 | Motif("pass", src, dest) 55 | } 56 | 57 | // Key : Check if the files that are in the dest folder have the following patterns in it, "key". 58 | // It stores the results in a specific file, named as followed grep-"motif".txt, in the "dest" folder. 59 | func Key(src string, dest string) { 60 | Motif("key", src, dest) 61 | } 62 | -------------------------------------------------------------------------------- /command/sed/sed.go: -------------------------------------------------------------------------------- 1 | package sed 2 | 3 | import ( 4 | "github.com/Shosta/androSecTest/command" 5 | ) 6 | 7 | // Replace : Replace a motif in a file through a sed bash command. 8 | // Here is an example of a command: cmd = "sed -i -e 's/src/replace/' filePath" 9 | // and the function arguments : 10 | // filePath := "/absolute/Path/to/file.ext" 11 | // src := "isAdmin=false" 12 | // replace := "isAdmin=true" 13 | func Replace(filePath string, src string, replace string) { 14 | 15 | cmdName := "sed" 16 | cmdArgs := []string{ 17 | "-i", 18 | "-e", 19 | "s/" + src + "/" + replace + "/", 20 | filePath, 21 | } 22 | command.Run(cmdName, cmdArgs) 23 | } 24 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | // Development ready configuration const based on the build tags. 4 | const ( 5 | SecurityAssessmentRootDir = "/home/androSecTest-Results" 6 | IsDebug = true 7 | ) 8 | 9 | var IsVerboseLogRequired = true 10 | -------------------------------------------------------------------------------- /config/config_dev.go: -------------------------------------------------------------------------------- 1 | // +build dev 2 | 3 | package config 4 | 5 | // Development ready configuration const based on the build tags. 6 | const ( 7 | SecurityAssessmentRootDir = "/home/androSecTest-Results" 8 | IsDebug = true 9 | ) 10 | 11 | var IsVerboseLogRequired = true 12 | -------------------------------------------------------------------------------- /config/config_prod.go: -------------------------------------------------------------------------------- 1 | // +build prod 2 | 3 | package config 4 | 5 | // Production ready configuration const based on the build tags. 6 | const ( 7 | SecurityAssessmentRootDir = "/home/androSecTest-Results" 8 | IsDebug = false 9 | ) 10 | 11 | var IsVerboseLogRequired = false 12 | -------------------------------------------------------------------------------- /config/config_testing.go: -------------------------------------------------------------------------------- 1 | // +build testing 2 | 3 | package config 4 | 5 | // Testing ready configuration const based on the build tags. 6 | const ( 7 | SecurityAssessmentRootDir = "/home/androSecTest-Results" 8 | IsDebug = true 9 | ) 10 | 11 | var IsVerboseLogRequired = true 12 | -------------------------------------------------------------------------------- /devices/connection.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package devices : Check that a device is connected and adb commands can then be performed on it. 18 | package devices 19 | 20 | import ( 21 | "strings" 22 | 23 | "github.com/Shosta/androSecTest/command/adb" 24 | "github.com/Shosta/androSecTest/logging" 25 | ) 26 | 27 | func connectedDevices(adbOutput string) []string { 28 | devices := strings.Split(strings.TrimSpace(adbOutput), "List of devices attached")[1] 29 | devicesArray := strings.Split(devices, "\n") 30 | 31 | return devicesArray[1:len(devicesArray)] 32 | } 33 | 34 | // IsConnected : Check is a device is connected through USB to the computer and is ready to receive "adb" commands. 35 | // It uses the command : "adb devices -l" to verify it. 36 | func IsConnected() bool { 37 | output := adb.Devices() 38 | logging.PrintlnDebug("Devices : \n" + output) 39 | devicesArray := connectedDevices(output) 40 | 41 | if len(devicesArray) <= 0 { 42 | logging.PrintlnDebug(logging.Red("No device") + " connected to the computer.\nPlease connect a device before launching that app.") 43 | return false 44 | } 45 | 46 | return true 47 | } 48 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | app: 4 | build: 5 | context: . 6 | dockerfile: ./DockerFiles/Ubuntu/Dockerfile 7 | image: androsectest-ubuntu 8 | app-alpine: 9 | build: 10 | context: . 11 | dockerfile: ./DockerFiles/Alpine/Dockerfile 12 | image: androsectest-alpine -------------------------------------------------------------------------------- /file/extension.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package file : Check the extension of a file. 18 | package file 19 | 20 | import ( 21 | "path" 22 | "strings" 23 | ) 24 | 25 | // IsPNG : Return true if the file extension is "png". 26 | func IsPNG(filePath string) bool { 27 | if strings.ToUpper(path.Ext(filePath)) == ".PNG" { 28 | return true 29 | } 30 | 31 | return false 32 | } 33 | 34 | // IsJPG : Return true if the file extension is "jpg" or "jpeg". 35 | func IsJPG(filePath string) bool { 36 | if strings.ToUpper(path.Ext(filePath)) == ".JPG" || strings.ToUpper(path.Ext(filePath)) == ".JPEG" { 37 | return true 38 | } 39 | 40 | return false 41 | } 42 | -------------------------------------------------------------------------------- /folder/copy.go: -------------------------------------------------------------------------------- 1 | package folder 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | "os" 8 | "path/filepath" 9 | ) 10 | 11 | /* MIT License 12 | * 13 | * Copyright (c) 2017 Roland Singer [roland.singer@desertbit.com] 14 | * 15 | * Permission is hereby granted, free of charge, to any person obtaining a copy 16 | * of this software and associated documentation files (the "Software"), to deal 17 | * in the Software without restriction, including without limitation the rights 18 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | * copies of the Software, and to permit persons to whom the Software is 20 | * furnished to do so, subject to the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be included in all 23 | * copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | * SOFTWARE. 32 | */ 33 | 34 | // CopyFile copies the contents of the file named src to the file named 35 | // by dst. The file will be created if it does not already exist. If the 36 | // destination file exists, all it's contents will be replaced by the contents 37 | // of the source file. The file mode will be copied from the source and 38 | // the copied data is synced/flushed to stable storage. 39 | func CopyFile(src, dst string) (err error) { 40 | in, err := os.Open(src) 41 | if err != nil { 42 | return 43 | } 44 | defer in.Close() 45 | 46 | out, err := os.Create(dst) 47 | if err != nil { 48 | return 49 | } 50 | defer func() { 51 | if e := out.Close(); e != nil { 52 | err = e 53 | } 54 | }() 55 | 56 | _, err = io.Copy(out, in) 57 | if err != nil { 58 | return 59 | } 60 | 61 | err = out.Sync() 62 | if err != nil { 63 | return 64 | } 65 | 66 | si, err := os.Stat(src) 67 | if err != nil { 68 | return 69 | } 70 | err = os.Chmod(dst, si.Mode()) 71 | if err != nil { 72 | return 73 | } 74 | 75 | return 76 | } 77 | 78 | // CopyDir recursively copies a directory tree, attempting to preserve permissions. 79 | // Source directory must exist, destination directory must *not* exist. 80 | // Symlinks are ignored and skipped. 81 | func CopyDir(src string, dst string) (err error) { 82 | src = filepath.Clean(src) 83 | dst = filepath.Clean(dst) 84 | 85 | si, err := os.Stat(src) 86 | if err != nil { 87 | return err 88 | } 89 | if !si.IsDir() { 90 | return fmt.Errorf("source is not a directory") 91 | } 92 | 93 | _, err = os.Stat(dst) 94 | if err != nil && !os.IsNotExist(err) { 95 | return 96 | } 97 | if err == nil { 98 | return fmt.Errorf("destination already exists") 99 | } 100 | 101 | err = os.MkdirAll(dst, si.Mode()) 102 | if err != nil { 103 | return 104 | } 105 | 106 | entries, err := ioutil.ReadDir(src) 107 | if err != nil { 108 | return 109 | } 110 | 111 | for _, entry := range entries { 112 | srcPath := filepath.Join(src, entry.Name()) 113 | dstPath := filepath.Join(dst, entry.Name()) 114 | 115 | if entry.IsDir() { 116 | err = CopyDir(srcPath, dstPath) 117 | if err != nil { 118 | return 119 | } 120 | } else { 121 | // Skip symlinks. 122 | if entry.Mode()&os.ModeSymlink != 0 { 123 | continue 124 | } 125 | 126 | err = CopyFile(srcPath, dstPath) 127 | if err != nil { 128 | return 129 | } 130 | } 131 | } 132 | 133 | return 134 | } 135 | -------------------------------------------------------------------------------- /folder/delete.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package folder : 21 | package folder 22 | 23 | import ( 24 | "os" 25 | ) 26 | 27 | // Delete : Delete a folder and all of its children. 28 | func Delete(path string) { 29 | os.RemoveAll(path) 30 | } 31 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Shosta/androSecTest 2 | 3 | go 1.20 4 | 5 | require github.com/alexflint/go-arg v1.4.3 6 | 7 | require github.com/alexflint/go-scalar v1.2.0 // indirect 8 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/alexflint/go-arg v1.4.3 h1:9rwwEBpMXfKQKceuZfYcwuc/7YY7tWJbFsgG5cAU/uo= 2 | github.com/alexflint/go-arg v1.4.3/go.mod h1:3PZ/wp/8HuqRZMUUgu7I+e1qcpUbvmS258mRXkFH4IA= 3 | github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= 4 | github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw= 5 | github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= 6 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 7 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 10 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 11 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 12 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 13 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 14 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 15 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 16 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 17 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 18 | -------------------------------------------------------------------------------- /images/watermark.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package images : Provides manipulation functions on images. 21 | package images 22 | 23 | import ( 24 | "image" 25 | "image/draw" 26 | "image/jpeg" 27 | "image/png" 28 | "log" 29 | "os" 30 | 31 | "github.com/Shosta/androSecTest/logging" 32 | 33 | extension "github.com/Shosta/androSecTest/file" 34 | ) 35 | 36 | func decodeSrcImage(imgSrcPath string) image.Image { 37 | imgSrc, err := os.Open(imgSrcPath) 38 | if err != nil { 39 | log.Fatalf("failed to open: %s", err) 40 | } 41 | defer imgSrc.Close() 42 | 43 | var srcImg image.Image 44 | if extension.IsPNG(imgSrcPath) { 45 | src, err := png.Decode(imgSrc) 46 | if err != nil { 47 | log.Fatalf("failed to decode: %s", err) 48 | } 49 | srcImg = src 50 | } else if extension.IsJPG(imgSrcPath) { 51 | src, err := jpeg.Decode(imgSrc) 52 | if err != nil { 53 | log.Fatalf("failed to decode: %s", err) 54 | } 55 | srcImg = src 56 | } 57 | 58 | return srcImg 59 | } 60 | 61 | // Watermark : 62 | func Watermark(watermarkPath string, imgSrcPath string) { 63 | // Open and create the Source image 64 | logging.PrintlnDebug("Decode image : " + imgSrcPath) 65 | src := decodeSrcImage(imgSrcPath) 66 | 67 | // Open and create the watermark image 68 | watermarkImg, err := os.Open(watermarkPath) 69 | if err != nil { 70 | log.Fatalf("failed to open: %s", err) 71 | } 72 | 73 | watermark, err := png.Decode(watermarkImg) 74 | if err != nil { 75 | log.Fatalf("failed to decode: %s", err) 76 | } 77 | defer watermarkImg.Close() 78 | 79 | // Add watermak on Source image at one third of the final image. 80 | b := src.Bounds() 81 | offset := image.Pt(b.Dx()/5, b.Dy()/5) 82 | 83 | image3 := image.NewRGBA(b) 84 | draw.Draw(image3, b, src, image.ZP, draw.Src) 85 | draw.Draw(image3, watermark.Bounds().Add(offset), watermark, image.ZP, draw.Over) 86 | 87 | os.RemoveAll(imgSrcPath) 88 | third, err := os.Create(imgSrcPath) 89 | if err != nil { 90 | log.Fatalf("failed to create: %s", err) 91 | } 92 | // jpeg.Encode(third, image3, &jpeg.Options{jpeg.DefaultQuality}) 93 | png.Encode(third, image3) 94 | defer third.Close() 95 | } 96 | -------------------------------------------------------------------------------- /logging/colors.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package logging : Provides printing on the terminal using several colors. 21 | package logging 22 | 23 | import "github.com/Shosta/androSecTest/variables" 24 | 25 | // Orange : 26 | func Orange(str string) string { 27 | return variables.Orange + str + variables.Endc 28 | } 29 | 30 | // Green : 31 | func Green(str string) string { 32 | return variables.Green + str + variables.Endc 33 | } 34 | 35 | // Red : 36 | func Red(str string) string { 37 | return variables.Red + str + variables.Endc 38 | } 39 | 40 | // Blue : 41 | func Blue(str string) string { 42 | return variables.Blue + str + variables.Endc 43 | } 44 | 45 | // Bold : 46 | func Bold(str string) string { 47 | return variables.Bold + str + variables.Endc 48 | } 49 | -------------------------------------------------------------------------------- /logging/logging.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package logging contains utility functions to work with logs. 21 | package logging 22 | 23 | import ( 24 | "fmt" 25 | 26 | "github.com/Shosta/androSecTest/config" 27 | ) 28 | 29 | // PrintlnDebug : 30 | func PrintlnDebug(log string) { 31 | if config.IsDebug { 32 | fmt.Println(Orange("[dbg:info] ") + log) 33 | } 34 | } 35 | 36 | // PrintDebug : 37 | func PrintDebug(log string) { 38 | if config.IsDebug { 39 | fmt.Print(Orange("[dbg:info] ") + log) 40 | } 41 | } 42 | 43 | // PrintlnError : 44 | func PrintlnError(err interface{}) { 45 | if config.IsDebug { 46 | fmt.Println(Red("[error] ") + fmt.Sprint(err)) 47 | } 48 | } 49 | 50 | // PrintlnVerbose : Print the log to the terminal if the configuration's "IsVerboseLogRequired" value is set to "true". 51 | func PrintlnVerbose(log string) { 52 | if config.IsVerboseLogRequired { 53 | fmt.Println(log) 54 | } 55 | } 56 | 57 | // Println : 58 | func Println(log string) { 59 | fmt.Println(log) 60 | } 61 | 62 | // Print : 63 | func Print(log string) { 64 | fmt.Print(log) 65 | } 66 | -------------------------------------------------------------------------------- /manifest/manifest.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package manifest : Provides manipulation on an Android manifest file to retrieve or change some information in it. 21 | package manifest 22 | 23 | import ( 24 | "encoding/xml" 25 | "fmt" 26 | "io/ioutil" 27 | "os" 28 | "strings" 29 | 30 | "github.com/Shosta/androSecTest/attacks" 31 | "github.com/Shosta/androSecTest/logging" 32 | ) 33 | 34 | // Manifest : 35 | type Manifest struct { 36 | Application Application `xml:"application"` 37 | } 38 | 39 | // Application : 40 | type Application struct { 41 | Icon string `xml:"icon,attr"` 42 | AllowBackup string `xml:"allowBackup,attr"` 43 | } 44 | 45 | func icon(pkgname string) string { 46 | // Open our xmlFile 47 | attacks.DisassemblePackageDirPath(pkgname) 48 | xmlFile, err := os.Open("/home/androSecTest-Results/com.orange.orangeetmoi/attacks/disassemblePackage/AndroidManifest.xml") 49 | // if we os.Open returns an error then handle it 50 | if err != nil { 51 | logging.PrintlnError(err) 52 | } 53 | logging.PrintlnDebug("Successfully Opened AndroidManifest.xml") 54 | // defer the closing of our xmlFile so that we can parse it later on 55 | defer xmlFile.Close() 56 | 57 | // read our opened xmlFile as a byte array. 58 | byteValue, _ := ioutil.ReadAll(xmlFile) 59 | 60 | manifest := Manifest{} 61 | err = xml.Unmarshal(byteValue, &manifest) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | logging.PrintlnDebug("Icon : " + manifest.Application.Icon) 66 | 67 | return manifest.Application.Icon 68 | } 69 | 70 | // IconName : Parse the Android application manifest file in order to retrieve the icon's name in order to later be able to work on it. 71 | func IconName(pkgname string) string { 72 | // Split the Android Manifest's "icon" attribute that contains the "folder/icon name" and return only the icon name. 73 | return strings.Split(icon(pkgname), "/")[1] 74 | } 75 | -------------------------------------------------------------------------------- /res/SignApk/signapk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/SignApk/signapk.jar -------------------------------------------------------------------------------- /res/SignApk/testkey.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/SignApk/testkey.pk8 -------------------------------------------------------------------------------- /res/SignApk/testkey.x509.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD 3 | VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g 4 | VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE 5 | AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe 6 | Fw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET 7 | MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G 8 | A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p 9 | ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI 10 | hvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waM 11 | qOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4 12 | wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy 13 | 4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzU 14 | RNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97s 15 | zI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkw 16 | HQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZ 17 | AFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE 18 | CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH 19 | QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG 20 | CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1Ud 21 | EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZa 22 | J6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4Y 23 | LCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe 24 | +ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX 25 | 31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwr 26 | sBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0= 27 | -----END CERTIFICATE----- 28 | -------------------------------------------------------------------------------- /res/settings/usersettings-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "application": { 3 | "version": "0.1" 4 | }, 5 | "tools": { 6 | "jadx": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/jadx/bin/jadx", 7 | "apktool": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/apktool/apktool.jar", 8 | "signapk": "/home/Developpement/HackingTools/SignApkUtils/sign.jar" 9 | }, 10 | "hackingtools": { 11 | "humpty-dumpty": "/home/Developpement/HackingTools/humpty-dumpty-android-master/humpty.sh" 12 | }, 13 | 14 | 15 | "application": { 16 | "version": "0.1" 17 | }, 18 | "tools": { 19 | "jadx": "", 20 | "apktool": "", 21 | "signapk": "" 22 | }, 23 | "hackingtools": { 24 | "humpty-dumpty": "" 25 | } 26 | } -------------------------------------------------------------------------------- /res/settings/usersettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "application": { 3 | "version": "0.1" 4 | }, 5 | "tools": { 6 | "jadx": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/jadx/bin/jadx", 7 | "apktool": "/home/Developpement/HackingTools/DecompilingAndroidAppUtils/apktool/apktool.jar", 8 | "signapk": "/home/Developpement/HackingTools/SignApkUtils/signapk.jar" 9 | }, 10 | "hackingtools": { 11 | "humpty-dumpty": "/home/Developpement/HackingTools/humpty-dumpty-android-master/humpty.sh" 12 | } 13 | } -------------------------------------------------------------------------------- /res/watermark/dbg/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/watermark/dbg/unlock.png -------------------------------------------------------------------------------- /res/watermark/dbg/unlock_hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/watermark/dbg/unlock_hdpi.png -------------------------------------------------------------------------------- /res/watermark/dbg/unlock_xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/watermark/dbg/unlock_xhdpi.png -------------------------------------------------------------------------------- /res/watermark/dbg/unlock_xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shosta/androSecTest/da0a988822aa3ddacabaa7f7555c83fde745d238/res/watermark/dbg/unlock_xxhdpi.png -------------------------------------------------------------------------------- /settings/dependency.go: -------------------------------------------------------------------------------- 1 | package settings 2 | 3 | import ( 4 | "os/exec" 5 | 6 | "github.com/Shosta/androSecTest/logging" 7 | ) 8 | 9 | // AreAllReady : 10 | func AreAllReady() bool { 11 | var areAllReady = true 12 | 13 | areAllReady = isAdbInstalled() 14 | if areAllReady != true { 15 | return false 16 | } 17 | 18 | areAllReady, _ = IsApktoolInstalled() 19 | if areAllReady != true { 20 | return false 21 | } 22 | 23 | areAllReady = isSignApkInstalled() 24 | if areAllReady != true { 25 | return false 26 | } 27 | 28 | areAllReady = isJadxInstalled() 29 | if areAllReady != true { 30 | return false 31 | } 32 | 33 | return true 34 | } 35 | 36 | func isAdbInstalled() bool { 37 | path, err := exec.LookPath("adb") 38 | if err != nil { 39 | logging.PrintlnError("didn't find 'adb' executable\n") 40 | return false 41 | } 42 | logging.PrintlnVerbose("'adb' executable is in " + path) 43 | 44 | return true 45 | } 46 | 47 | // IsApktoolInstalled : Return if apktool is in the user's PATH so that we could call it directly when executing a command. 48 | func IsApktoolInstalled() (bool, string) { 49 | path, err := exec.LookPath("apktool") 50 | if err != nil { 51 | logging.PrintlnError("didn't find 'apktool' executable\n") 52 | return false, "" 53 | } 54 | logging.PrintlnVerbose("'apktool' executable is in " + path) 55 | 56 | return true, path 57 | } 58 | 59 | // TODO : Move the signapk executable path to an external folder. 60 | // Add a setup process at the beginning of the program. And an argument to redo the setup if necessary. 61 | func isSignApkInstalled() bool { 62 | // TODO : Check from the internal setup file and not the LookPath as signapk is not in the PATH. 63 | path, err := exec.LookPath("signapk") 64 | if err != nil { 65 | logging.PrintlnError("didn't find 'signapk' executable\n") 66 | return false 67 | } 68 | logging.PrintlnVerbose("'signapk' executable is in " + path) 69 | 70 | return true 71 | } 72 | 73 | // TODO : Move the jadx executable path to an external folder. 74 | // Add a setup process at the beginning of the program. And an argument to redo the setup if necessary. 75 | func isJadxInstalled() bool { 76 | // TODO : Check from the internal setup file and not the LookPath as signapk is not in the PATH. 77 | path, err := exec.LookPath("jadx") 78 | if err != nil { 79 | logging.PrintlnError("didn't find 'jadx' executable\n") 80 | return false 81 | } 82 | logging.PrintlnVerbose("'jadx' executable is in " + path) 83 | 84 | return true 85 | } 86 | -------------------------------------------------------------------------------- /settings/settings.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package settings : Provides features to store the user settings in a file. 21 | // It stores or updates the path to the executables that are required to pursue the penetration testing. 22 | package settings 23 | 24 | import ( 25 | "encoding/json" 26 | "fmt" 27 | "io/ioutil" 28 | 29 | "github.com/Shosta/androSecTest/logging" 30 | "github.com/Shosta/androSecTest/terminal" 31 | ) 32 | 33 | var version string 34 | var jadxpath string 35 | var apktoolpath string 36 | var signapkpath string 37 | var humptydumptypath string 38 | 39 | // UserSettings : 40 | type UserSettings struct { 41 | Application Application `json:"application"` 42 | Tools Tools `json:"tools"` 43 | HackingTools HackingTools `json:"hackingtools"` 44 | } 45 | 46 | // Application : 47 | type Application struct { 48 | Version string `json:"version"` 49 | } 50 | 51 | // Tools : 52 | type Tools struct { 53 | Jadx string `json:"jadx"` 54 | Apktool string `json:"apktool"` 55 | SignApk string `json:"signapk"` 56 | } 57 | 58 | // HackingTools :HumptyDumpty 59 | type HackingTools struct { 60 | HumptyDumpty string `json:"humpty-dumpty"` 61 | } 62 | 63 | // Setup : It does the Settings set up if we don't know where to look for the external tools required to do the repackaging and the attacks. 64 | // You can use force=true to setup the settings whatever the values in the usersettings.json file. 65 | func Setup(force bool) { 66 | us, err := loadUsrSettings() 67 | if err != nil { 68 | logging.PrintlnError(fmt.Sprint(err)) 69 | return 70 | } 71 | 72 | isApktoolInstalled, apktoolpath := IsApktoolInstalled() 73 | us.Tools.Apktool = apktoolpath 74 | 75 | if us.Tools.Jadx == "" || us.Tools.SignApk == "" || us.HackingTools.HumptyDumpty == "" || force == true { 76 | // Ask user to fill in the tools paths. 77 | logging.Print(logging.Green("Where is located Jadx?") + " (copy and paste the absolute path to your jadx executable, should look like \"/home/user/hacking/tools/jadx/jadx\"\n" + logging.Blue("> ")) 78 | jadxuserentry := terminal.Waitfor() 79 | us.Tools.Jadx = jadxuserentry 80 | 81 | logging.Print(logging.Green("Where is located SignApk?") + " (copy and paste the absolute path to your signapk jar file, should look like \"/home/user/hacking/tools/signapk/sign.jar\"\n" + logging.Blue("> ")) 82 | signuserentry := terminal.Waitfor() 83 | us.Tools.SignApk = signuserentry 84 | 85 | if isApktoolInstalled == false { 86 | logging.Print(logging.Green("Where is located ApkTool?") + " (copy and paste the absolute path to your apktool executable, should look like \"/usr/local/bin/apktool\"\n" + logging.Blue("> ")) 87 | apktuserentry := terminal.Waitfor() 88 | us.Tools.Apktool = apktuserentry 89 | } else { 90 | us.Tools.Apktool = apktoolpath 91 | } 92 | 93 | logging.Print(logging.Green("Where is located Humpty-Dumpty?") + " (copy and paste the absolute path to your humpty-dumpty shell file, should look like \"/home/user/hacking/tools/humpty-dumpty/humpty.sh\"\n" + logging.Blue("> ")) 94 | hduserentry := terminal.Waitfor() 95 | us.HackingTools.HumptyDumpty = hduserentry 96 | 97 | saveUsrSettings(us) 98 | } 99 | } 100 | 101 | // It saves the User defined settings into a Json file. 102 | // So that we can rely on these path when using these tools later on. 103 | func saveUsrSettings(us UserSettings) error { 104 | bytes, err := json.MarshalIndent(us, "", " ") 105 | if err != nil { 106 | return err 107 | } 108 | 109 | return ioutil.WriteFile("./.res/settings/usersettings.json", bytes, 0644) 110 | } 111 | 112 | // It reads the Settings file and update the variables accordingly. 113 | // When using these tools, we can rely on the user defined ones instead of something hard coded. 114 | func loadUsrSettings() (UserSettings, error) { 115 | bytes, err := ioutil.ReadFile("./.res/settings/usersettings.json") 116 | if err != nil { 117 | return UserSettings{}, err 118 | } 119 | 120 | var s UserSettings 121 | err = json.Unmarshal(bytes, &s) 122 | if err != nil { 123 | return UserSettings{}, err 124 | } 125 | 126 | version = s.Application.Version 127 | jadxpath = s.Tools.Jadx 128 | apktoolpath = s.Tools.Apktool 129 | signapkpath = s.Tools.SignApk 130 | humptydumptypath = s.HackingTools.HumptyDumpty 131 | 132 | return s, nil 133 | } 134 | 135 | // SetJadx : Set the path to the Jadx executable in the settings file so that wee could call it later. 136 | func setJadx(path string) { 137 | us, _ := loadUsrSettings() 138 | jadxpath = path 139 | us.Tools.Jadx = path 140 | saveUsrSettings(us) 141 | } 142 | 143 | // SetSignapk : Set the path to the SignApk executable in the settings file so that wee could call it later. 144 | func setSignapk(path string) { 145 | us, _ := loadUsrSettings() 146 | signapkpath = path 147 | us.Tools.SignApk = path 148 | saveUsrSettings(us) 149 | } 150 | 151 | // SetApktool : Set the path to the apktool executable in the settings file so that wee could call it later. 152 | func setApktool(path string) { 153 | us, _ := loadUsrSettings() 154 | apktoolpath = path 155 | us.Tools.Apktool = path 156 | saveUsrSettings(us) 157 | } 158 | 159 | // SetHumptyDumpty : Set the path to the humpty-dumpty shell script in the settings file so that wee could call it later. 160 | func setHumptyDumpty(path string) { 161 | us, _ := loadUsrSettings() 162 | humptydumptypath = path 163 | us.HackingTools.HumptyDumpty = path 164 | saveUsrSettings(us) 165 | } 166 | 167 | // Jadx : 168 | func Jadx() string { 169 | return jadxpath 170 | } 171 | 172 | // SignApk : 173 | func SignApk() string { 174 | return signapkpath 175 | } 176 | 177 | // ApkTool : 178 | func ApkTool() string { 179 | return apktoolpath 180 | } 181 | -------------------------------------------------------------------------------- /terminal/input.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package terminal : Provides the features to read a user input from the terminal. 21 | package terminal 22 | 23 | import ( 24 | "bufio" 25 | "os" 26 | 27 | "github.com/Shosta/androSecTest/logging" 28 | ) 29 | 30 | // Waitfor a user input on the CLI. 31 | // It returns the user input as a string. 32 | func Waitfor() string { 33 | scanner := bufio.NewScanner(os.Stdin) 34 | for scanner.Scan() { 35 | logging.PrintlnDebug("User wrote: " + scanner.Text()) 36 | return scanner.Text() 37 | } 38 | 39 | if scanner.Err() != nil { 40 | // handle error. 41 | } 42 | 43 | return "" 44 | } 45 | -------------------------------------------------------------------------------- /variables/variables.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Rémi Lavedrine. 3 | 4 | Licensed under the Mozilla Public License, version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | https://www.mozilla.org/en-US/MPL/ 9 | 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Package variables : has all the global variables that are used in the program. 21 | package variables 22 | 23 | // Attacks folder names to have them gathered in one single place. 24 | const ( 25 | AttacksDir = "/attacks" 26 | SourcePackageDir = "/sourcePackage" 27 | UnzippedPackageDir = "/unzippedPackage" 28 | DisassemblePackageDir = "/disassemblePackage" 29 | DecompiledPackageDir = "/decompiledPackage" 30 | LeakagesDir = "/leakages" 31 | DebuggablePackageDir = "/debuggablePackage" 32 | InsecureBackupDir = "/insecureBackup" 33 | InsecureLoggingDir = "/insecureLogging" 34 | InsecureStorageDir = "/insecureStorage" 35 | ) 36 | 37 | // Color const to display color on the terminal command. 38 | const ( 39 | Header = "\033[95m" 40 | Blue = "\033[94m" 41 | Green = "\033[92m" 42 | Orange = "\033[93m" 43 | Red = "\033[91m" 44 | Endc = "\033[0m" 45 | Bold = "\033[1m" 46 | Underline = "\033[4m" 47 | ) 48 | --------------------------------------------------------------------------------