A program analysis tool to find cryptographic misuse in Java and Android.

Overview
layout
default

CryptoGuard $CVER 04.05.03$

badge Docker Badge Version Badge GitHub Release Downloads

Java Vulnerabilities (by Snyk.io): CryptoGuard Vulnerabilities Python3 Vulnerabilities (by Snyk.io): Python Vulnerabilities

A program analysis tool to find cryptographic misuse in Java and Android.

CryptoSouple.py

This python file is the wrapper created to assist with various portions of the project. You should use it for various commands including:

  • setting the environment
  • clean the project
  • building the project
  • running tests
  • building a simple command

MyBinder

This is a website hosting a Docker image that actively runs either Java or Python3 samples. The Java Notebook is only possible by utilitzing IJava. This is still under progress as the following are not active yet:

  • Android SDK tests
  • Sample Java Tests

Please run the following command to get more information on how to use it ./cryptosouple.py.

IMPORTANT NOTICE

  • Due to 'leaky tests' from the environment and persistent variables, a python test runner was made
  • Please run make tests
    • this ensures isolated environments via gradle calls

Building From Source

  • Run make, this will build CryptoGuard and move the jar to the current directory
  • Run scans to scan all of the tests included in the source
    • There is currently a sample project for each scan type within src/test
  • Run clean to clean the entire project

Prerequisites (Environment Variables)

  1. JAVA_HOME: Point to a valid Java 8 JDK Installation

    • Needed for all of the scans
  2. JAVA7_HOME: Point to a valid Java 7 JDK Installation

    • Needed for project scans and java file scans
  3. ANDROID_SDK_HOME: Point to a valid Android JDK Installation

    • Needed for Android

Note

  • Run make env to verify (and set) all of these variables by following the instructions.

Different Scanning Options

Source (Maven or Gradle Project Directory only)

  • raw command (without dependencies) java -jar cryptoguard.jar -in source -s /rootPath
  • raw command (with dependencies) java -jar cryptoguard.jar -in source -s /rootPath -d /dependencies
Note

If the project have external dependencies then first gather the dependencies under a folder that is relative to the project root (e.g., "build/dependencies").

If you have multiple subprojects with external dependencies, then you have to gather all the corresponding subproject dependencies under a path that is relative to each of the subprojects.

JAR Files

  • raw command java -jar cryptoguard.jar -in jar -s /path/to/jar/my-jar.jar

APK Files

  • raw command java -jar cryptoguard.jar -in apk -s /path/to/apk/my-apk.apk

Java Files (Currently Unstable, currently limited to Java JDK 8 by library constraint)

  • raw command java -jar cryptoguard.jar -in java -s /path/to/java/file.java
  • raw command (for files) java -jar cryptoguard.jar -in java -s /path/to/java/file1.java /path/to/java/file2.java

Java Class Files (Currently limited to Java JDK 8)

  • raw command java -jar cryptoguard.jar -in class -s /path/to/java/file.class
  • raw command (for files) java -jar cryptoguard.jar -in java -s /path/to/java/file1.class /path/to/java/file2.class

Different Scanning Options

Source/Dependencies options

  • By default, both source and dependencies are expecting a list of files
    • or for source the .in file
  • The source and dependencies can also handle a class path based string
    • ex: -s ~/tester/PBEUsage.class:~/tester/UrlFrameWorks.class:~/tester/NewTestCase1.class:~/tester/NewTestCase2.class

Output options

  • using the argument -m, you can add the identifier of the other output formats
Default
  • Argument -m D

    • example command java -jar cryptoguard.jar -in jar -s /path/to/jar/my-jar.jar -m D
  • This is a json file that represents a more simplified output

    • This will be iterated over time as more functionality is available
Legacy
  • Argument -m L
    • example command java -jar cryptoguard.jar -in jar -s /path/to/jar/my-jar.jar -m L
  • This will output a txt file used within early CryptoGuard versions
Scarf XML
  • Argument -m SX

    • example command java -jar cryptoguard.jar -in jar -s /path/to/jar/my-jar.jar -m SX
  • This will ouput an xml file using the scarf_v1.2.xsd used by SWAMP.

  • By using the argument -Sconfig properties.file, this will load the properties from within the file

    • example command java -jar cryptoguard.jar -in jar -s /path/to/jar/my-jar.jar -m SX -Sconfig properties.file

Input a single file (list of files)

  • Argument -s *.in
  • By using this argument (and you have to use the .in extension) input a single file containing all of the source input files
  • example
    • command to generate a file like this find -type f -name \*.java \>\> input.in
      • generated input.in file
./samples/testable-jar/src/main/java/tester/UrlFrameWorks.java
./samples/testable-jar/src/main/java/tester/PasswordUtils.java
./samples/testable-jar/src/main/java/tester/Crypto.java
./samples/testable-jar/src/main/java/tester/PBEUsage.java
./samples/testable-jar/src/main/java/tester/NewTestCase2.java
./samples/testable-jar/src/main/java/tester/VeryBusyClass.java
./samples/testable-jar/src/main/java/tester/SymCrypto.java
./samples/testable-jar/src/main/java/tester/NewTestCase1.java
./samples/testable-jar/src/main/java/tester/LiveVarsClass.java
./samples/testable-jar/src/main/java/tester/PassEncryptor.java}
  • command to be used with cryptoguard java -jar -s input.in

    • this is similar to java -jar -s ./samples/testable-jar/src/main/java/tester/UrlFrameWorks.java ... ./samples/testable-jar/src/main/java/tester/PassEncryptor.java
  • NOTE: This can be used with any type of input/output marshalling

Help

  • If you have any questions or suggestions, please email to [email protected].
  • Please also run make help or java -jar cryptoguard.jar -h for argument help.
  • You can also look at the auto-generated USAGE.md file.

FAQ

  • There may be silent failures if any of the environment variables below are not set.
    • This can be checked by running make env

Website

  • The generated website uses a slightly modified Jekyll Hyde template under the MIT License.
  • Technology Reports
    • Gradle Junit Test Reports are generated from Gradle
    • Cobertura Test Coverage Reports are generated from Cobertura
    • Java Documentation are generated from Java

Disclaimer

CryptoGuard is a research prototype under GNU General Public License 3.0

Copyright © 2020 CryptoGuard

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.0 for more details.

You should have received a copy of the GNU General Public License 3.0 along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html.

Reference

If you find this project useful, please cite our CCS'19 CryptoGuard paper and the thesis supporting the latest enhancements from within this fork.

@phdthesis{frantz2020enhancing,
	title={Enhancing CryptoGuard's Deployability for Continuous Software Security Scanning},
	author={Frantz, Miles},
	year={2020},
	school={Virginia Tech}
}
You might also like...
A tool translate a apk file to stantard android project include so hook api and il2cpp c++ scaffolding when apk is a unity il2cpp game. Write code on a apk file elegantly.

FakerAndroid (FakerAndroid.jar or FakerAndroid-AS) A tool translate a apk file to stantard android project include so hook api and il2cpp c++ scaffold

A simple text encryption/decryption password based GUI+CLI tool

ZeText: Zero disk exposition texts This is a simple text encryption/decryption password based GUI+CLI tool, allowing to enter, edit and decrypt files

Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.
Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

A Java ePub reader and parser framework for Android.
A Java ePub reader and parser framework for Android.

FolioReader-Android is an EPUB reader written in Java and Kotlin. Features Custom Fonts Custom Text Size Themes / Day mode / Night mode Text Highlight

CRYLOGGER: Detecting Crypto Misuses for Android and Java Apps Dynamically

CRYLOGGER: Detecting Crypto Misuses for Android and Java Apps Dynamically

Signal Protocol library for Java/Android

Overview A ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments. PreKeys This protocol uses a concept

Analyze any Android/Java based app or game
Analyze any Android/Java based app or game

ClassyShark Introduction ClassyShark is a standalone binary inspection tool for Android developers. It can reliably browse any Android executable and

Appdbg - make it possible to run android dex file in original Java Virtual Machine
Appdbg - make it possible to run android dex file in original Java Virtual Machine

Appdbg - make it possible to run android dex file in original Java Virtual Machine

Smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation

About smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on

Comments
  • Case insensitive misuse rule checking for improving detection accuracy

    Case insensitive misuse rule checking for improving detection accuracy

    CryptoGuard currently has this in checkForMatchInternal method under PatternMatcherRuleChecker class:

    for (String regex : getPatternsToMatch()) {
                        if (usebox.getValue().toString().matches(regex)) {
                            putIntoMap(predictableSourcMap, e, usebox.getValue().toString());
                            found = true;
                            break;
                        }
                    }
    

    Whereas the getPatternsToMatch() comes from PatternMatcherRuleChecker abstract class; and further implemented in BrokenCryptoFinder, BrokenHashFinder and HttpUrlFinder.

    The core issue is that the patterns are being checked in a case sensitive manner. As a result, even though Cipher.getInstance("DES") will trigger a Rule 1 violation warning, Cipher.getInstance("des") will result in a different warning related to Rule 1a. Java Cipher class accepts all possible cases as it internally converts it to Upper Case. For example, Cipher class under JDK 7 has this line that allows converting user-defined transformation string to UpperCase.

    private static Cipher.Transform getTransform(Service var0, List<Cipher.Transform> var1) {
    String var2 = var0.getAlgorithm().toUpperCase(Locale.ENGLISH);
    ...
            }
    

    One way to solve this is to redefine regular expressions to handle case sensitivity. However, that approach will result in redefining all regular expressions.

    The other way is to change how the regular expression is being checked; which is what I am proposing through the pull request here.

    for (String regex : getPatternsToMatch()) {
                    	if(Pattern.compile(regex,Pattern.CASE_INSENSITIVE).matcher(usebox.getValue().toString()).matches()) {
                            putIntoMap(predictableSourcMap, e, usebox.getValue().toString());
                            found = true;
                            break;
                        }
                    }
    

    The change now allows checking the predefined patterns while ignoring case of the defined pattern.

    opened by LordAmit 2
Releases(Release_04.05.03_2020-11-25-02-42_)
Owner
null
A Program Analysis Toolkit for Android

PATDroid PATDroid is a collection of tools and data structures for analyzing Android applications and the system itself. We intend to build it as a co

Mingyuan Xia 103 Dec 10, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 29, 2022
A collection of Kotlin Multiplatform Mobile cryptographic hashing functions.

crypto A collection of Kotlin Multiplatform Mobile libraries to aid in mobile app development. cryptohash: A set of cryptographic (and not so cryptogr

Appmattus Limited 58 Dec 15, 2022
Find Security Bugs is the SpotBugs plugin for security audits of Java web applications

The SpotBugs plugin for security audits of Java web applications and Android applications. (Also work with Kotlin, Groovy and Scala projects)

OWASP Find Security Bugs 2k Jan 6, 2023
CLI tool for decompiling Android apps to Java. It does resources! It does Java! Its real easy!

Easy-as-pie Android Decompiler Why One stop shop I got pretty tired of decompiling Android apps with a bunch of steps that I had to remember all the t

Alex Davis 619 Dec 27, 2022
A program to flip every private, protected and package-private access flag to public in an Android dex file!

DexExposed A program to flip every private, protected and package-private access flag to public in an Android dex file! Building Simply run gradle mak

John Doe 2 Aug 29, 2021
Android Malware (Analysis | Scoring) System

An Obfuscation-Neglect Android Malware Scoring System Quark-Engine is also bundled with Kali Linux, BlackArch. A trust-worthy, practical tool that's r

Quark-Engine 999 Dec 20, 2022
Appshark is a static taint analysis platform to scan vulnerabilities in an Android app.

Document Index 1.overview 2.startup 3.how to write rules 4.how to find compliance problems use appshark 5.a path traversal game 6.argument 7.engine co

Bytedance Inc. 998 Jan 7, 2023
A runtime mobile application analysis toolkit with a Web GUI, powered by Frida, written in Python.

___ ___ / | \ ____ __ __ ______ ____ / ~ \/ _ \| | \/ ___// __ \ \ Y ( <_> )

NCC Group Plc 1.2k Dec 21, 2022
BlackDex is an Android unpack tool, it supports Android 5.0~12 and need not rely to any environment. BlackDex can run on any Android mobile phones or emulators, you can unpack APK File in several seconds.

BlackDex is an Android unpack tool, it supports Android 5.0~12 and need not rely to any environment. BlackDex can run on any Android mobile phones or emulators, you can unpack APK File in several seconds.

null 4.3k Jan 2, 2023