<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MKerndl</id>
	<title>Elvis Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MKerndl"/>
	<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php/Special:Contributions/MKerndl"/>
	<updated>2026-09-10T18:25:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.5</generator>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17867</id>
		<title>Mobile Application Obfuscation</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17867"/>
		<updated>2025-01-20T19:05:32Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the obfuscation of mobile application from the angle of reverse-engineering protection. It introduces three different tools that are commonly used to obfuscate Android applications, compares them to each other, and thereby highlights their strengths and weaknesses. By analyzing the behavior of these tools across different applications, this article provides insight into how to balance usability and efficiency of applications, while trying to enhance security.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Mobile App Obfuscation ==&lt;br /&gt;
&lt;br /&gt;
Mobile app obfuscation is a technique used to protect the source code of applications from reverse engineering. By obfuscating code into a form that is more difficult for attackers to understand, obfuscation helps to protect intellectual property and sensitive data. This process is particularly important in the Android development environment, since the APK format makes application much easier to decompile using tools like Jadx. With the growing threat of cybercrime, code obfuscation is becoming an essential aspect of defense, complementing encryption and secure coding practices. &lt;br /&gt;
&lt;br /&gt;
== Mobile Obfuscation Tools ==&lt;br /&gt;
Tools play an important role in mobile application obfuscation by automating the process of transforming code into a more secure and less comprehensible form. These tools help developers to protect their applications against reverse engineering without compromising the functionality of the application. By offering several different obfuscation techniques, like identifier renaming, string encryption, and control flow obfuscation, these tools increase the overall security of mobile applications.&lt;br /&gt;
&lt;br /&gt;
* R8: R8 is Google&#039;s official tool for code obfuscation in Android applications. It is directly integrated into Android Studio and focuses on optimizing application size and performance while adding minor obfuscation layers. Specifically, R8 offers weak obfuscation methods like identifier renaming and code minification, which change variable, method, and class names and remove non-functional aspects of the code (Comments, etc.) while keeping the functionality of the code intact. This complicates a static analysis, but offers no protection against dynamic analysis and reverse engineering during the app&#039;s runtime. However, it&#039;s effortless integration with the Android development ecosystem still makes it a very popular choice for developers.&lt;br /&gt;
&lt;br /&gt;
* DashO: DashO is a commercial obfuscation tool. It offers advanced obfuscation techniques like string encryption, and additional anti-tampering mechanisms to protect the application from unauthorized changes. A license for DashO can be obtained at a starting price of 50$ per month. DashO offers no default Android Studio integration, but can be added to Android Studio builds through code modifications.&lt;br /&gt;
&lt;br /&gt;
* Allatori:Allatori is another commercial tool that focuses on Java bytecode obfuscation, and can also be used to obfuscate Android applications. It supports several advanced obfuscation strategies and can, like DashO, be integrated into the Android Studio development process. A license for Allatori costs 290$ as one-time purchase.&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
=== Obfuscation process ===&lt;br /&gt;
The project behind this article evaluated the impact of the aforementioned obfuscation tools on the performance of mobile applications. For this purpose, the following mobile applications were selected, in order of increasing complexity:&lt;br /&gt;
* Markor: A small app to add personal notes.&lt;br /&gt;
* K9: A mobile mail-client.&lt;br /&gt;
* FastHub: A mobile GitHub-like client.&lt;br /&gt;
&lt;br /&gt;
In the testing process, each of these apps was obfuscated using the three selected tools. For R8, the testing process was integrated into Android Studio directly. For DashO and Allatori, the APKs were processed externally using their UI and command-line integration respectively.&lt;br /&gt;
&lt;br /&gt;
=== Performance Testing ===&lt;br /&gt;
The obfuscated APKs were tested on an Android emulator to measure several key performance indicators:&lt;br /&gt;
* APK size&lt;br /&gt;
* Build time&lt;br /&gt;
* Startup time&lt;br /&gt;
* Memory usage&lt;br /&gt;
To ensure consistency and hedge against outliers, each of the tests except for APK size was conducted three times, with the average of these attempts being used for the final comparison.&lt;br /&gt;
&lt;br /&gt;
=== Testing Environment ===&lt;br /&gt;
The performance tests were conducted using the Android Profiler feature in Android Studio. The Android Profiler is an extensive tool for measuring application behavior. Within Android Profiler, the following features were used to track the selected metrics:&lt;br /&gt;
* Capture System Activities&lt;br /&gt;
* Track Memory Consumption&lt;br /&gt;
&lt;br /&gt;
[[File:AndroidProfiler.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
This approach provided an understanding of how the selected obfuscation tools affect the performance of the applications, while at the same time highlighting the practical implications and difficulties of integrating these tools into the development process.&lt;br /&gt;
&lt;br /&gt;
== Findings and Analysis ==&lt;br /&gt;
The evaluation of R8, DashO, and Allatori revealed their strengths and weaknesses in terms of impact on application performance. While the project successfully tested most combinations of tools and apps, four tests could not be completed due to compatibility issues with DashO and Allatori for certain applications.&lt;br /&gt;
&lt;br /&gt;
=== Performance Indicators ===&lt;br /&gt;
Across all four chosen metrics, R8 significantly outperformed both DashO and Allatori. This makes sense, considering that R8 is focused on application optimization, as previously mentioned. DashO and Allatori had weaker test results, which can be explained by their focus on obfuscation. The additional layers of obfuscation added by these tools contributed to increasing startup times and larger APK sizes. However, they outperformed R8 in the &amp;quot;Memory usage&amp;quot; metric, which shows that they include better Resource Management in their obfuscation. &lt;br /&gt;
&lt;br /&gt;
=== Usability and Integration ===&lt;br /&gt;
R8, per default integrated into Android Studio and the Gradle build process, makes it the by far easiest tool to use for Android app development. Its automated configuration is a notable advantage. DashO and Allatori on the other hand required additional setup, which makes them more difficult to integrate in the Android Studio development process. Additionally, both of these tools require commercial licensing, making them less accessible than R8.&lt;br /&gt;
&lt;br /&gt;
Overall, the findings highlight the tradeoffs between security and performance when selecting an obfuscation tool for an application. R8 was found to be the most practical choice for developers focused on optimization and performance rather than obfuscation, while DashO and Allatori offer stronger reverse-engineering protection at the cost of worse performance and additional complexity.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* https://github.com/skylot/jadx&lt;br /&gt;
* https://www.preemptive.com/blog/migrating-from-proguard-or-dexguard-to-dasho&lt;br /&gt;
* https://www.guardsquare.com/blog/proguard-and-r8&lt;br /&gt;
* https://www.preemptive.com/products/dasho/&lt;br /&gt;
* https://www.dash0.com/pricing&lt;br /&gt;
* https://allatori.com/price.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17837</id>
		<title>Mobile Application Obfuscation</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17837"/>
		<updated>2025-01-15T00:36:06Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added image&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the obfuscation of mobile application from the angle of reverse-engineering protection. It introduces three different tools that are commonly used to obfuscate Android applications, compares them to each other, and thereby highlights their strengths and weaknesses. By analyzing the behavior of these tools across different applications, this article provides insight into how to balance usability and efficiency of applications, while trying to enhance security.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Mobile App Obfuscation ==&lt;br /&gt;
&lt;br /&gt;
Mobile app obfuscation is a technique used to protect the source code of applications from reverse engineering. By obfuscating code into a form that is more difficult for attackers to understand, obfuscation helps to protect intellectual property and sensitive data. This process is particularly important in the Android development environment, since the APK format makes application much easier to decompile using tools like Jadx. With the growing threat of cybercrime, code obfuscation is becoming an essential aspect of defense, complementing encryption and secure coding practices. &lt;br /&gt;
&lt;br /&gt;
== Mobile Obfuscation Tools ==&lt;br /&gt;
Tools play an important role in mobile application obfuscation by automating the process of transforming code into a more secure and less comprehensible form. These tools help developers to protect their applications against reverse engineering without compromising the functionality of the application. By offering several different obfuscation techniques, like identifier renaming, string encryption, and control flow obfuscation, these tools increase the overall security of mobile applications.&lt;br /&gt;
&lt;br /&gt;
* R8: R8 is Google&#039;s official tool for code obfuscation in Android applications. It is directly integrated into Android Studio and focuses on optimizing application size and performance while adding minor obfuscation layers. Specifically, R8 offers weak obfuscation methods like identifier renaming and code minification, which change variable, method, and class names and remove non-functional aspects of the code (Comments, etc.) while keeping the functionality of the code intact. This complicates a static analysis, but offers no protection against dynamic analysis and reverse engineering during the app&#039;s runtime. However, it&#039;s effortless integration with the Android development ecosystem still makes it a very popular choice for developers.&lt;br /&gt;
&lt;br /&gt;
* DashO: DashO is a commercial obfuscation tool. It offers advanced obfuscation techniques like string encryption, and additional anti-tampering mechanisms to protect the application from unauthorized changes. A license for DashO can be obtained at a starting price of 50$ per month. DashO offers no default Android Studio integration, but can be added to Android Studio builds through code modifications.&lt;br /&gt;
&lt;br /&gt;
* Allatori:Allatori is another commercial tool that focuses on Java bytecode obfuscation, and can also be used to obfuscate Android applications. It supports several advanced obfuscation strategies and can, like DashO, be integrated into the Android Studio development process. A license for Allatori costs 290$ as one-time purchase.&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
=== Obfuscation process ===&lt;br /&gt;
The project behind this article aimed to evaluate the impact of the aforementioned obfuscation tools on the performance of mobile applications. For this purpose, the following mobile applications were selected, in order of increasing complexity:&lt;br /&gt;
* Markor: A small app to add personal notes.&lt;br /&gt;
* K9: A mobile mail-client.&lt;br /&gt;
* FastHub: A mobile GitHub-like client.&lt;br /&gt;
&lt;br /&gt;
In the testing process, each of these apps was obfuscated using the three selected tools. For R8, the testing process was integrated into Android Studio directly. For DashO and Allatori, the APKs were processed externally using their UI and command-line integration respectively.&lt;br /&gt;
&lt;br /&gt;
=== Performance Testing ===&lt;br /&gt;
The obfuscated APKs were tested on an Android emulator to measure several key performance indicators:&lt;br /&gt;
* APK size&lt;br /&gt;
* Build time&lt;br /&gt;
* Startup time&lt;br /&gt;
* Memory usage&lt;br /&gt;
To ensure consistency and hedge against outliers, each of the tests except for APK size was conducted three times, with the average of these attempts being used for the final comparison.&lt;br /&gt;
&lt;br /&gt;
=== Testing Environment ===&lt;br /&gt;
The performance tests were conducted using the Android Profiler feature in Android Studio. The Android Profiler is an extensive tool for measuring application behavior. Within Android Profiler, the following features were used to track the selected metrics:&lt;br /&gt;
* Capture System Activities&lt;br /&gt;
* Track Memory Consumption&lt;br /&gt;
&lt;br /&gt;
[[File:AndroidProfiler.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
This approach provided an understanding of how the selected obfuscation tools affect the performance of the applications, while at the same time highlighting the practical implications and difficulties of integrating these tools into the development process.&lt;br /&gt;
&lt;br /&gt;
== Findings and Analysis ==&lt;br /&gt;
The evaluation of R8, DashO, and Allatori revealed their strengths and weaknesses in terms of impact on application performance. While the project successfully tested most combinations of tools and apps, four tests could not be completed due to compatibility issues with DashO and Allatori for certain applications.&lt;br /&gt;
&lt;br /&gt;
=== Performance Indicators ===&lt;br /&gt;
Across all four chosen metrics, R8 significantly outperformed both DashO and Allatori. This makes sense, considering that R8 is focused on application optimization, as previously mentioned. DashO and Allatori had weaker test results, which can be explained by their focus on obfuscation. The additional layers of obfuscation added by these tools contributed to increasing startup times and larger APK sizes. However, they outperformed R8 in the &amp;quot;Memory usage&amp;quot; metric, which shows that they include better Resource Management in their obfuscation. &lt;br /&gt;
&lt;br /&gt;
=== Usability and Integration ===&lt;br /&gt;
R8, per default integrated into Android Studio and the Gradle build process, makes it the by far easiest tool to use for Android app development. Its automated configuration is a notable advantage. DashO and Allatori on the other hand required additional setup, which makes them more difficult to integrate in the Android Studio development process. Additionally, both of these tools require commercial licensing, making them less accessible than R8.&lt;br /&gt;
&lt;br /&gt;
Overall, the findings highlight the tradeoffs between security and performance when selecting an obfuscation tool for an application. R8 was found to be the most practical choice for developers focused on optimization and performance rather than obfuscation, while DashO and Allatori offer stronger reverse-engineering protection at the cost of worse performance and additional complexity.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* https://github.com/skylot/jadx&lt;br /&gt;
* https://www.preemptive.com/blog/migrating-from-proguard-or-dexguard-to-dasho&lt;br /&gt;
* https://www.guardsquare.com/blog/proguard-and-r8&lt;br /&gt;
* https://www.preemptive.com/products/dasho/&lt;br /&gt;
* https://www.dash0.com/pricing&lt;br /&gt;
* https://allatori.com/price.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:AndroidProfiler.png&amp;diff=17836</id>
		<title>File:AndroidProfiler.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:AndroidProfiler.png&amp;diff=17836"/>
		<updated>2025-01-15T00:33:35Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Image of Android Profiler&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Image of Android Profiler&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17835</id>
		<title>Mobile Application Obfuscation</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17835"/>
		<updated>2025-01-14T21:36:50Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added more paragraphs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the obfuscation of mobile application from the angle of reverse-engineering protection. It introduces three different tools that are commonly used to obfuscate Android applications, compares them to each other, and thereby highlights their strengths and weaknesses. By analyzing the behavior of these tools across different applications, this article provides insight into how to balance usability and efficiency of applications, while trying to enhance security.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Mobile App Obfuscation ==&lt;br /&gt;
&lt;br /&gt;
Mobile app obfuscation is a technique used to protect the source code of applications from reverse engineering. By obfuscating code into a form that is more difficult for attackers to understand, obfuscation helps to protect intellectual property and sensitive data. This process is particularly important in the Android development environment, since the APK format makes application much easier to decompile using tools like Jadx. With the growing threat of cybercrime, code obfuscation is becoming an essential aspect of defense, complementing encryption and secure coding practices. &lt;br /&gt;
&lt;br /&gt;
== Mobile Obfuscation Tools ==&lt;br /&gt;
Tools play an important role in mobile application obfuscation by automating the process of transforming code into a more secure and less comprehensible form. These tools help developers to protect their applications against reverse engineering without compromising the functionality of the application. By offering several different obfuscation techniques, like identifier renaming, string encryption, and control flow obfuscation, these tools increase the overall security of mobile applications.&lt;br /&gt;
&lt;br /&gt;
* R8: R8 is Google&#039;s official tool for code obfuscation in Android applications. It is directly integrated into Android Studio and focuses on optimizing application size and performance while adding minor obfuscation layers. Specifically, R8 offers weak obfuscation methods like identifier renaming and code minification, which change variable, method, and class names and remove non-functional aspects of the code (Comments, etc.) while keeping the functionality of the code intact. This complicates a static analysis, but offers no protection against dynamic analysis and reverse engineering during the app&#039;s runtime. However, it&#039;s effortless integration with the Android development ecosystem still makes it a very popular choice for developers.&lt;br /&gt;
&lt;br /&gt;
* DashO: DashO is a commercial obfuscation tool. It offers advanced obfuscation techniques like string encryption, and additional anti-tampering mechanisms to protect the application from unauthorized changes. A license for DashO can be obtained at a starting price of 50$ per month. DashO offers no default Android Studio integration, but can be added to Android Studio builds through code modifications.&lt;br /&gt;
&lt;br /&gt;
* Allatori:Allatori is another commercial tool that focuses on Java bytecode obfuscation, and can also be used to obfuscate Android applications. It supports several advanced obfuscation strategies and can, like DashO, be integrated into the Android Studio development process. A license for Allatori costs 290$ as one-time purchase.&lt;br /&gt;
&lt;br /&gt;
== Methodology ==&lt;br /&gt;
=== Obfuscation process ===&lt;br /&gt;
The project behind this article aimed to evaluate the impact of the aforementioned obfuscation tools on the performance of mobile applications. For this purpose, the following mobile applications were selected, in order of increasing complexity:&lt;br /&gt;
* Markor: A small app to add personal notes.&lt;br /&gt;
* K9: A mobile mail-client.&lt;br /&gt;
* FastHub: A mobile GitHub-like client.&lt;br /&gt;
&lt;br /&gt;
In the testing process, each of these apps was obfuscated using the three selected tools. For R8, the testing process was integrated into Android Studio directly. For DashO and Allatori, the APKs were processed externally using their UI and command-line integration respectively.&lt;br /&gt;
&lt;br /&gt;
=== Performance Testing ===&lt;br /&gt;
The obfuscated APKs were tested on an Android emulator to measure several key performance indicators:&lt;br /&gt;
* APK size&lt;br /&gt;
* Build time&lt;br /&gt;
* Startup time&lt;br /&gt;
* Memory usage&lt;br /&gt;
To ensure consistency and hedge against outliers, each of the tests except for APK size was conducted three times, with the average of these attempts being used for the final comparison.&lt;br /&gt;
&lt;br /&gt;
=== Testing Environment ===&lt;br /&gt;
The performance tests were conducted using the Android Profiler feature in Android Studio. The Android Profiler is an extensive tool for measuring application behavior. Within Android Profiler, the following features were used to track the selected metrics:&lt;br /&gt;
* Capture System Activities&lt;br /&gt;
* Track Memory Consumption&lt;br /&gt;
&lt;br /&gt;
This approach provided an understanding of how the selected obfuscation tools affect the performance of the applications, while at the same time highlighting the practical implications and difficulties of integrating these tools into the development process.&lt;br /&gt;
&lt;br /&gt;
== Findings and Analysis ==&lt;br /&gt;
The evaluation of R8, DashO, and Allatori revealed their strengths and weaknesses in terms of impact on application performance. While the project successfully tested most combinations of tools and apps, four tests could not be completed due to compatibility issues with DashO and Allatori for certain applications.&lt;br /&gt;
&lt;br /&gt;
=== Performance Indicators ===&lt;br /&gt;
Across all four chosen metrics, R8 significantly outperformed both DashO and Allatori. This makes sense, considering that R8 is focused on application optimization, as previously mentioned. DashO and Allatori had weaker test results, which can be explained by their focus on obfuscation. The additional layers of obfuscation added by these tools contributed to increasing startup times and larger APK sizes. However, they outperformed R8 in the &amp;quot;Memory usage&amp;quot; metric, which shows that they include better Resource Management in their obfuscation. &lt;br /&gt;
&lt;br /&gt;
=== Usability and Integration ===&lt;br /&gt;
R8, per default integrated into Android Studio and the Gradle build process, makes it the by far easiest tool to use for Android app development. Its automated configuration is a notable advantage. DashO and Allatori on the other hand required additional setup, which makes them more difficult to integrate in the Android Studio development process. Additionally, both of these tools require commercial licensing, making them less accessible than R8.&lt;br /&gt;
&lt;br /&gt;
Overall, the findings highlight the tradeoffs between security and performance when selecting an obfuscation tool for an application. R8 was found to be the most practical choice for developers focused on optimization and performance rather than obfuscation, while DashO and Allatori offer stronger reverse-engineering protection at the cost of worse performance and additional complexity.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* https://github.com/skylot/jadx&lt;br /&gt;
* https://www.preemptive.com/blog/migrating-from-proguard-or-dexguard-to-dasho&lt;br /&gt;
* https://www.guardsquare.com/blog/proguard-and-r8&lt;br /&gt;
* https://www.preemptive.com/products/dasho/&lt;br /&gt;
* https://www.dash0.com/pricing&lt;br /&gt;
* https://allatori.com/price.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17834</id>
		<title>Mobile Application Obfuscation</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17834"/>
		<updated>2025-01-14T21:11:52Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added References&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the obfuscation of mobile application from the angle of reverse-engineering protection. It introduces three different tools that are commonly used to obfuscate Android applications, compares them to each other, and thereby highlights their strengths and weaknesses. By analyzing the behavior of these tools across different applications, this article provides insight into how to balance usability and efficiency of applications, while trying to enhance security.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Mobile App Obfuscation ==&lt;br /&gt;
&lt;br /&gt;
Mobile app obfuscation is a technique used to protect the source code of applications from reverse engineering. By obfuscating code into a form that is more difficult for attackers to understand, obfuscation helps to protect intellectual property and sensitive data. This process is particularly important in the Android development environment, since the APK format makes application much easier to decompile using tools like Jadx. With the growing threat of cybercrime, code obfuscation is becoming an essential aspect of defense, complementing encryption and secure coding practices. &lt;br /&gt;
&lt;br /&gt;
== Mobile Obfuscation Tools ==&lt;br /&gt;
Tools play an important role in mobile application obfuscation by automating the process of transforming code into a more secure and less comprehensible form. These tools help developers to protect their applications against reverse engineering without compromising the functionality of the application. By offering several different obfuscation techniques, like identifier renaming, string encryption, and control flow obfuscation, these tools increase the overall security of mobile applications.&lt;br /&gt;
&lt;br /&gt;
* R8: R8 is Google&#039;s official tool for code obfuscation in Android applications. It is directly integrated into Android Studio and focuses on optimizing application size and performance while adding minor obfuscation layers. Specifically, R8 offers weak obfuscation methods like identifier renaming and code minification, which change variable, method, and class names and remove non-functional aspects of the code (Comments, etc.) while keeping the functionality of the code intact. This complicates a static analysis, but offers no protection against dynamic analysis and reverse engineering during the app&#039;s runtime. However, it&#039;s effortless integration with the Android development ecosystem still makes it a very popular choice for developers.&lt;br /&gt;
&lt;br /&gt;
* DashO: DashO is a commercial obfuscation tool. It offers advanced obfuscation techniques like string encryption, and additional anti-tampering mechanisms to protect the application from unauthorized changes. A license for DashO can be obtained at a starting price of 50$ per month. DashO offers no default Android Studio integration, but can be added to Android Studio builds through code modifications.&lt;br /&gt;
&lt;br /&gt;
* Allatori:Allatori is another commercial tool that focuses on Java bytecode obfuscation, and can also be used to obfuscate Android applications. It supports several advanced obfuscation strategies and can, like DashO, be integrated into the Android Studio development process. A license for Allatori costs 290$ as one-time purchase.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* https://github.com/skylot/jadx&lt;br /&gt;
* https://www.preemptive.com/blog/migrating-from-proguard-or-dexguard-to-dasho&lt;br /&gt;
* https://www.guardsquare.com/blog/proguard-and-r8&lt;br /&gt;
* https://www.preemptive.com/products/dasho/&lt;br /&gt;
* https://www.dash0.com/pricing&lt;br /&gt;
* https://allatori.com/price.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17833</id>
		<title>Mobile Application Obfuscation</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Application_Obfuscation&amp;diff=17833"/>
		<updated>2025-01-14T21:08:59Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added first paragraphs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the obfuscation of mobile application from the angle of reverse-engineering protection. It introduces three different tools that are commonly used to obfuscate Android applications, compares them to each other, and thereby highlights their strengths and weaknesses. By analyzing the behavior of these tools across different applications, this article provides insight into how to balance usability and efficiency of applications, while trying to enhance security.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Mobile App Obfuscation ==&lt;br /&gt;
&lt;br /&gt;
Mobile app obfuscation is a technique used to protect the source code of applications from reverse engineering. By obfuscating code into a form that is more difficult for attackers to understand, obfuscation helps to protect intellectual property and sensitive data. This process is particularly important in the Android development environment, since the APK format makes application much easier to decompile using tools like Jadx. With the growing threat of cybercrime, code obfuscation is becoming an essential aspect of defense, complementing encryption and secure coding practices. &lt;br /&gt;
&lt;br /&gt;
== Mobile Obfuscation Tools ==&lt;br /&gt;
Tools play an important role in mobile application obfuscation by automating the process of transforming code into a more secure and less comprehensible form. These tools help developers to protect their applications against reverse engineering without compromising the functionality of the application. By offering several different obfuscation techniques, like identifier renaming, string encryption, and control flow obfuscation, these tools increase the overall security of mobile applications.&lt;br /&gt;
&lt;br /&gt;
* R8: R8 is Google&#039;s official tool for code obfuscation in Android applications. It is directly integrated into Android Studio and focuses on optimizing application size and performance while adding minor obfuscation layers. Specifically, R8 offers weak obfuscation methods like identifier renaming and code minification, which change variable, method, and class names and remove non-functional aspects of the code (Comments, etc.) while keeping the functionality of the code intact. This complicates a static analysis, but offers no protection against dynamic analysis and reverse engineering during the app&#039;s runtime. However, it&#039;s effortless integration with the Android development ecosystem still makes it a very popular choice for developers.&lt;br /&gt;
&lt;br /&gt;
* DashO: DashO is a commercial obfuscation tool. It offers advanced obfuscation techniques like string encryption, and additional anti-tampering mechanisms to protect the application from unauthorized changes. A license for DashO can be obtained at a starting price of 50$ per month. DashO offers no default Android Studio integration, but can be added to Android Studio builds through code modifications.&lt;br /&gt;
&lt;br /&gt;
* Allatori:Allatori is another commercial tool that focuses on Java bytecode obfuscation, and can also be used to obfuscate Android applications. It supports several advanced obfuscation strategies and can, like DashO, be integrated into the Android Studio development process. A license for Allatori costs 290$ as one-time purchase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17737</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17737"/>
		<updated>2024-12-19T01:13:07Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Expanded on the Overview&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This article explores the family of Potato Vulnerabilities, a group of privilege escalation exploits targeting Windows operating systems. These vulnerabilities exploit weaknesses in token handling, impersonation privileges, and authentication protocols, using techniques like NTLM reflection and token manipulation. This article provides an overview of the vulnerabilities, explains the exploitation techniques used, details specific vulnerabilities within the Potato family, and discusses mitigation strategies to defend against these attacks.&lt;br /&gt;
&lt;br /&gt;
== Overview of Potato Vulnerabilities ==&lt;br /&gt;
Potato Vulnerabilities are a family of privilege escalation exploits that utilize token-based weaknesses in Windows operating systems. These vulnerabilities make it possible for attackers to elevate privileges from low-level user accounts to high-privilege accounts, for example system or administrator accounts. First introduced in 2016 with the &amp;quot;Hot Potato&amp;quot; exploit by Stephen Breen, the Potato Vulnerabilities have continually evolved, including new techniques to bypass Microsoft&#039;s security updates and mitigations. They commonly target flaws in Windows authentication protocols, such as NTLM and misconfigured token handling.&lt;br /&gt;
Over time, these vulnerabilities have demonstrated their adaptability with new variants, using new and different weaknesses in Windows security mechanisms. This family of vulnerabilities remains important in cybersecurity because of its effectiveness, easy usability, and the continued discovery of previously unknown variations.&lt;br /&gt;
&lt;br /&gt;
== Exploitation Techniques ==&lt;br /&gt;
Potato Vulnerabilities utilize advanced exploitation techniques to achieve privilege escalation. The most important methods are:&lt;br /&gt;
&lt;br /&gt;
* Token Manipulation: Token manipulation is an essential part of privilege escalation attacks within Windows systems. Access tokens in Windows represent the security identity of a process, most notably including user privileges and group memberships. By exploiting vulnerabilities in the generation and management processes of these tokens, attackers can impersonate tokens belonging to higher-privileged accounts. This allows them to execute actions with administrative or system-level privileges, bypassing security restrictions. For example, in vulnerabilities like Juicy Potato, attackers exploit the SeImpersonatePrivilege to craft and impersonate tokens. This allows them to execute code with elevated permissions. Such attacks are particularly effective against misconfigured service accounts that operate with unnecessarily high privileges.&lt;br /&gt;
* NTLM Reflection: NTLM Reflection attacks exploit weaknesses in the NT LAN Manager (NTLM) authentication protocol, which is often used in Windows systems. In these attacks, the victim is tricked into authenticating with a malicious server controlled by the attacker. During this process, the attacker captures the victim&#039;s credentials and &amp;quot;reflects&amp;quot; the authentication attempt back to the victim or another target. By using these stolen credentials, the attacker can impersonate the victim and gain access to their privileged resources. Potato vulnerabilities, such as Hot Potato and Ghost Potato, heavily rely on NTLM Reflection to bypass authentication protocols and elevate privileges. These attacks are particularly dangerous because they exploit Windows services that are often trusted by the operating system, making them very effective at evading detection.&lt;br /&gt;
* RPC/DCOM Exploitation: Misusing Windows services and protocols, such as Distributed Component Object Model (DCOM), to interact with privileged services and gain elevated access.&lt;br /&gt;
* Resource-Based Constrained Delegation (RBCD): Exploiting delegation settings in Active Directory to gain unauthorized access through ticket manipulation.&lt;br /&gt;
&lt;br /&gt;
== Specific Potato Vulnerabilities ==&lt;br /&gt;
* Hot Potato: The first Potato vulnerability, introduced in 2016 by Stephen Breen, exploited NetBIOS Name Service (NBNS) spoofing and NTLM reflection to escalate privileges to the system level. It has been patched under CVE-2016-3213.&lt;br /&gt;
&lt;br /&gt;
* Rotten Potato: An evolution of Hot Potato disclosed in 2016, it uses NTLM reflection to trick the &amp;quot;NT Authority\System&amp;quot; account into authenticating to an attacker-controlled endpoint. It has been patched in Windows 10 1809 and later versions.&lt;br /&gt;
&lt;br /&gt;
* Lonely Potato: A variant of Rotten Potato, it replaced meterpreter with API calls for token impersonation, simplifying the process. Released in 2017, it is now deprecated on the same patched versions as Rotten Potato.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato: Introduced in 2018, this exploit improved upon Rotten Potato by allowing the attacker to specify the CLSID for targeting, enabling greater flexibility. It was patched in Windows 10 1809.&lt;br /&gt;
&lt;br /&gt;
* Ghost Potato: Disclosed in 2019, it bypasses the patched NTLM reflection protections by exploiting the Local Security Authority Subsystem Service (LSASS). It works by delaying NTLM reflection until cached challenges expire. This vulnerability was patched under CVE-2019-1384.&lt;br /&gt;
&lt;br /&gt;
* Sweet Potato: Released in 2020, it is a C# version of Juicy Potato that also targets WinRM services for privilege escalation. It remains unpatched and works on Windows 7 through Windows 10 and Server 2019.&lt;br /&gt;
&lt;br /&gt;
* Rogue Potato: This 2020 vulnerability uses a forged Object Exporter Identifier (OXID) response to trigger privileged authentication to an attacker-controlled listener. It remains unpatched by Microsoft.&lt;br /&gt;
&lt;br /&gt;
* Generic Potato: A 2021 tool that allows users to craft their own exploits based on the Potato family techniques. It uses HTTP and named pipe listeners to exploit NTLM authentication. It is primarily used for Capture The Flag (CTF) activities and remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Remote Potato: Released in 2021, this exploit uses a cross-protocol relay from RPC to LDAP or HTTP. It bypasses impersonation privileges required by earlier variants. Microsoft patched it in October 2022.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato NG: A 2022 update of Juicy Potato that bypasses patched CLSIDs using a Kerberos DCOM authentication trick. It remains unpatched and continues to function.&lt;br /&gt;
&lt;br /&gt;
* Cert Potato: Introduced in 2022, it abuses Active Directory Certificate Services (ADCS) to obtain a machine’s Ticket Granting Ticket (TGT) and create a Silver Ticket for domain-level privileges. It remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Local Potato: Released in 2023, it targets LSASS and swaps NTLM messages to authenticate as a privileged user. It was patched under CVE-2023-21746.&lt;br /&gt;
&lt;br /&gt;
* Coerced Potato: The most recent vulnerability, disclosed in 2023, enhances PrintSpoofer with new RPC call exploits, enabling privilege escalation to the system level. It remains effective on current Windows versions, including Windows 10, 11, and Server 2022.&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
Mitigating Potato Vulnerabilities requires both vendor updates as well as some security practices:&lt;br /&gt;
&lt;br /&gt;
* Microsoft Security Updates: Regularly apply patches and updates provided by Microsoft to address known vulnerabilities.&lt;br /&gt;
* Access Controls: Implement the principle of least privilege to restrict unnecessary elevated permissions.&lt;br /&gt;
* Network Monitoring: Use logging and monitoring tools to detect privilege escalation attacks or unauthorized authentication events.&lt;br /&gt;
* Patch Management: Make sure that all systems are updated to the latest versions, to decrease the likelihood of being vulnerable to Potato exploits.&lt;br /&gt;
&lt;br /&gt;
These measures enhance system defenses not only against privilege escalation, but also against most other attacks and therefore reduce the impact and threat of Potato Vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
  &lt;br /&gt;
* https://jlajara.gitlab.io/Potatoes_Windows_Privesc  &lt;br /&gt;
* https://foxglovesecurity.com/2016/01/16/hot-potato/  &lt;br /&gt;
* https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/  &lt;br /&gt;
* https://hideandsec.sh/books/windows-sNL/page/in-the-potato-family-i-want-them-all  &lt;br /&gt;
* https://decoder.cloud/2017/12/23/the-lonely-potato/  &lt;br /&gt;
* http://ohpe.it/juicy-potato/  &lt;br /&gt;
* https://shenaniganslabs.io/2019/11/12/Ghost-Potato.html  &lt;br /&gt;
* https://www.pentestpartners.com/security-blog/sweetpotato-service-to-system/  &lt;br /&gt;
* https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/  &lt;br /&gt;
* https://micahvandeusen.com/the-power-of-seimpersonation/  &lt;br /&gt;
* https://www.sentinelone.com/labs/relaying-potatoes-another-unexpected-privilege-escalation-vulnerability-in-windows-rpc-protocol/  &lt;br /&gt;
* https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/  &lt;br /&gt;
* https://sensepost.com/blog/2022/certpotato-using-adcs-to-privesc-from-virtual-and-network-service-accounts-to-local-system/  &lt;br /&gt;
* https://decoder.cloud/2023/02/13/localpotato-when-swapping-the-context-leads-you-to-system/  &lt;br /&gt;
* https://blog.hackvens.fr/articles/CoercedPotato.html  &lt;br /&gt;
* https://purplesec.us/learn/privilege-escalation-attacks/  &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17736</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17736"/>
		<updated>2024-12-19T01:09:06Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Expanded on Exploitation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This article explores the family of Potato Vulnerabilities, a group of privilege escalation exploits targeting Windows operating systems. These vulnerabilities exploit weaknesses in token handling, impersonation privileges, and authentication protocols, using techniques like NTLM reflection and token manipulation. This article provides an overview of the vulnerabilities, explains the exploitation techniques used, details specific vulnerabilities within the Potato family, and discusses mitigation strategies to defend against these attacks.&lt;br /&gt;
&lt;br /&gt;
== Overview of Potato Vulnerabilities ==&lt;br /&gt;
Potato Vulnerabilities are a family of exploits that target token-based weaknesses in Windows operating systems, allowing attackers to escalate privileges from low-level user accounts to high-privilege system accounts. First introduced in 2016 with &amp;quot;Hot Potato&amp;quot; by Stephen Breen, these vulnerabilities have evolved to bypass various security measures implemented by Microsoft. They exploit Windows authentication mechanisms, misconfigured permissions and handling of tokens and delegation protocols. Several of these vulnerabilities remain important in cybersecurity due to their adaptability and continued discovery of new variants.&lt;br /&gt;
&lt;br /&gt;
== Exploitation Techniques ==&lt;br /&gt;
Potato Vulnerabilities utilize advanced exploitation techniques to achieve privilege escalation. The most important methods are:&lt;br /&gt;
&lt;br /&gt;
* Token Manipulation: Token manipulation is an essential part of privilege escalation attacks within Windows systems. Access tokens in Windows represent the security identity of a process, most notably including user privileges and group memberships. By exploiting vulnerabilities in the generation and management processes of these tokens, attackers can impersonate tokens belonging to higher-privileged accounts. This allows them to execute actions with administrative or system-level privileges, bypassing security restrictions. For example, in vulnerabilities like Juicy Potato, attackers exploit the SeImpersonatePrivilege to craft and impersonate tokens. This allows them to execute code with elevated permissions. Such attacks are particularly effective against misconfigured service accounts that operate with unnecessarily high privileges.&lt;br /&gt;
* NTLM Reflection: NTLM Reflection attacks exploit weaknesses in the NT LAN Manager (NTLM) authentication protocol, which is often used in Windows systems. In these attacks, the victim is tricked into authenticating with a malicious server controlled by the attacker. During this process, the attacker captures the victim&#039;s credentials and &amp;quot;reflects&amp;quot; the authentication attempt back to the victim or another target. By using these stolen credentials, the attacker can impersonate the victim and gain access to their privileged resources. Potato vulnerabilities, such as Hot Potato and Ghost Potato, heavily rely on NTLM Reflection to bypass authentication protocols and elevate privileges. These attacks are particularly dangerous because they exploit Windows services that are often trusted by the operating system, making them very effective at evading detection.&lt;br /&gt;
* RPC/DCOM Exploitation: Misusing Windows services and protocols, such as Distributed Component Object Model (DCOM), to interact with privileged services and gain elevated access.&lt;br /&gt;
* Resource-Based Constrained Delegation (RBCD): Exploiting delegation settings in Active Directory to gain unauthorized access through ticket manipulation.&lt;br /&gt;
&lt;br /&gt;
== Specific Potato Vulnerabilities ==&lt;br /&gt;
* Hot Potato: The first Potato vulnerability, introduced in 2016 by Stephen Breen, exploited NetBIOS Name Service (NBNS) spoofing and NTLM reflection to escalate privileges to the system level. It has been patched under CVE-2016-3213.&lt;br /&gt;
&lt;br /&gt;
* Rotten Potato: An evolution of Hot Potato disclosed in 2016, it uses NTLM reflection to trick the &amp;quot;NT Authority\System&amp;quot; account into authenticating to an attacker-controlled endpoint. It has been patched in Windows 10 1809 and later versions.&lt;br /&gt;
&lt;br /&gt;
* Lonely Potato: A variant of Rotten Potato, it replaced meterpreter with API calls for token impersonation, simplifying the process. Released in 2017, it is now deprecated on the same patched versions as Rotten Potato.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato: Introduced in 2018, this exploit improved upon Rotten Potato by allowing the attacker to specify the CLSID for targeting, enabling greater flexibility. It was patched in Windows 10 1809.&lt;br /&gt;
&lt;br /&gt;
* Ghost Potato: Disclosed in 2019, it bypasses the patched NTLM reflection protections by exploiting the Local Security Authority Subsystem Service (LSASS). It works by delaying NTLM reflection until cached challenges expire. This vulnerability was patched under CVE-2019-1384.&lt;br /&gt;
&lt;br /&gt;
* Sweet Potato: Released in 2020, it is a C# version of Juicy Potato that also targets WinRM services for privilege escalation. It remains unpatched and works on Windows 7 through Windows 10 and Server 2019.&lt;br /&gt;
&lt;br /&gt;
* Rogue Potato: This 2020 vulnerability uses a forged Object Exporter Identifier (OXID) response to trigger privileged authentication to an attacker-controlled listener. It remains unpatched by Microsoft.&lt;br /&gt;
&lt;br /&gt;
* Generic Potato: A 2021 tool that allows users to craft their own exploits based on the Potato family techniques. It uses HTTP and named pipe listeners to exploit NTLM authentication. It is primarily used for Capture The Flag (CTF) activities and remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Remote Potato: Released in 2021, this exploit uses a cross-protocol relay from RPC to LDAP or HTTP. It bypasses impersonation privileges required by earlier variants. Microsoft patched it in October 2022.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato NG: A 2022 update of Juicy Potato that bypasses patched CLSIDs using a Kerberos DCOM authentication trick. It remains unpatched and continues to function.&lt;br /&gt;
&lt;br /&gt;
* Cert Potato: Introduced in 2022, it abuses Active Directory Certificate Services (ADCS) to obtain a machine’s Ticket Granting Ticket (TGT) and create a Silver Ticket for domain-level privileges. It remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Local Potato: Released in 2023, it targets LSASS and swaps NTLM messages to authenticate as a privileged user. It was patched under CVE-2023-21746.&lt;br /&gt;
&lt;br /&gt;
* Coerced Potato: The most recent vulnerability, disclosed in 2023, enhances PrintSpoofer with new RPC call exploits, enabling privilege escalation to the system level. It remains effective on current Windows versions, including Windows 10, 11, and Server 2022.&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
Mitigating Potato Vulnerabilities requires both vendor updates as well as some security practices:&lt;br /&gt;
&lt;br /&gt;
* Microsoft Security Updates: Regularly apply patches and updates provided by Microsoft to address known vulnerabilities.&lt;br /&gt;
* Access Controls: Implement the principle of least privilege to restrict unnecessary elevated permissions.&lt;br /&gt;
* Network Monitoring: Use logging and monitoring tools to detect privilege escalation attacks or unauthorized authentication events.&lt;br /&gt;
* Patch Management: Make sure that all systems are updated to the latest versions, to decrease the likelihood of being vulnerable to Potato exploits.&lt;br /&gt;
&lt;br /&gt;
These measures enhance system defenses not only against privilege escalation, but also against most other attacks and therefore reduce the impact and threat of Potato Vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
  &lt;br /&gt;
* https://jlajara.gitlab.io/Potatoes_Windows_Privesc  &lt;br /&gt;
* https://foxglovesecurity.com/2016/01/16/hot-potato/  &lt;br /&gt;
* https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/  &lt;br /&gt;
* https://hideandsec.sh/books/windows-sNL/page/in-the-potato-family-i-want-them-all  &lt;br /&gt;
* https://decoder.cloud/2017/12/23/the-lonely-potato/  &lt;br /&gt;
* http://ohpe.it/juicy-potato/  &lt;br /&gt;
* https://shenaniganslabs.io/2019/11/12/Ghost-Potato.html  &lt;br /&gt;
* https://www.pentestpartners.com/security-blog/sweetpotato-service-to-system/  &lt;br /&gt;
* https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/  &lt;br /&gt;
* https://micahvandeusen.com/the-power-of-seimpersonation/  &lt;br /&gt;
* https://www.sentinelone.com/labs/relaying-potatoes-another-unexpected-privilege-escalation-vulnerability-in-windows-rpc-protocol/  &lt;br /&gt;
* https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/  &lt;br /&gt;
* https://sensepost.com/blog/2022/certpotato-using-adcs-to-privesc-from-virtual-and-network-service-accounts-to-local-system/  &lt;br /&gt;
* https://decoder.cloud/2023/02/13/localpotato-when-swapping-the-context-leads-you-to-system/  &lt;br /&gt;
* https://blog.hackvens.fr/articles/CoercedPotato.html  &lt;br /&gt;
* https://purplesec.us/learn/privilege-escalation-attacks/  &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17548</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17548"/>
		<updated>2024-12-18T17:33:00Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Main page content&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This article explores the family of Potato Vulnerabilities, a group of privilege escalation exploits targeting Windows operating systems. These vulnerabilities exploit weaknesses in token handling, impersonation privileges, and authentication protocols, using techniques like NTLM reflection and token manipulation. This article provides an overview of the vulnerabilities, explains the exploitation techniques used, details specific vulnerabilities within the Potato family, and discusses mitigation strategies to defend against these attacks.&lt;br /&gt;
&lt;br /&gt;
== Overview of Potato Vulnerabilities ==&lt;br /&gt;
Potato Vulnerabilities are a family of exploits that target token-based weaknesses in Windows operating systems, allowing attackers to escalate privileges from low-level user accounts to high-privilege system accounts. First introduced in 2016 with &amp;quot;Hot Potato&amp;quot; by Stephen Breen, these vulnerabilities have evolved to bypass various security measures implemented by Microsoft. They exploit Windows authentication mechanisms, misconfigured permissions and handling of tokens and delegation protocols. Several of these vulnerabilities remain important in cybersecurity due to their adaptability and continued discovery of new variants.&lt;br /&gt;
&lt;br /&gt;
== Exploitation Techniques ==&lt;br /&gt;
Potato Vulnerabilities utilize advanced exploitation techniques to achieve privilege escalation. The most important methods are:&lt;br /&gt;
&lt;br /&gt;
* Token Manipulation: Exploiting Windows access tokens to impersonate higher-privilege users and execute actions with admin-level user accounts.&lt;br /&gt;
* NTLM Reflection: Redirecting authentication requests to malicious servers to capture credentials and impersonate users.&lt;br /&gt;
* RPC/DCOM Exploitation: Misusing Windows services and protocols, such as Distributed Component Object Model (DCOM), to interact with privileged services and gain elevated access.&lt;br /&gt;
* Resource-Based Constrained Delegation (RBCD): Exploiting delegation settings in Active Directory to gain unauthorized access through ticket manipulation.&lt;br /&gt;
&lt;br /&gt;
== Specific Potato Vulnerabilities ==&lt;br /&gt;
* Hot Potato: The first Potato vulnerability, introduced in 2016 by Stephen Breen, exploited NetBIOS Name Service (NBNS) spoofing and NTLM reflection to escalate privileges to the system level. It has been patched under CVE-2016-3213.&lt;br /&gt;
&lt;br /&gt;
* Rotten Potato: An evolution of Hot Potato disclosed in 2016, it uses NTLM reflection to trick the &amp;quot;NT Authority\System&amp;quot; account into authenticating to an attacker-controlled endpoint. It has been patched in Windows 10 1809 and later versions.&lt;br /&gt;
&lt;br /&gt;
* Lonely Potato: A variant of Rotten Potato, it replaced meterpreter with API calls for token impersonation, simplifying the process. Released in 2017, it is now deprecated on the same patched versions as Rotten Potato.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato: Introduced in 2018, this exploit improved upon Rotten Potato by allowing the attacker to specify the CLSID for targeting, enabling greater flexibility. It was patched in Windows 10 1809.&lt;br /&gt;
&lt;br /&gt;
* Ghost Potato: Disclosed in 2019, it bypasses the patched NTLM reflection protections by exploiting the Local Security Authority Subsystem Service (LSASS). It works by delaying NTLM reflection until cached challenges expire. This vulnerability was patched under CVE-2019-1384.&lt;br /&gt;
&lt;br /&gt;
* Sweet Potato: Released in 2020, it is a C# version of Juicy Potato that also targets WinRM services for privilege escalation. It remains unpatched and works on Windows 7 through Windows 10 and Server 2019.&lt;br /&gt;
&lt;br /&gt;
* Rogue Potato: This 2020 vulnerability uses a forged Object Exporter Identifier (OXID) response to trigger privileged authentication to an attacker-controlled listener. It remains unpatched by Microsoft.&lt;br /&gt;
&lt;br /&gt;
* Generic Potato: A 2021 tool that allows users to craft their own exploits based on the Potato family techniques. It uses HTTP and named pipe listeners to exploit NTLM authentication. It is primarily used for Capture The Flag (CTF) activities and remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Remote Potato: Released in 2021, this exploit uses a cross-protocol relay from RPC to LDAP or HTTP. It bypasses impersonation privileges required by earlier variants. Microsoft patched it in October 2022.&lt;br /&gt;
&lt;br /&gt;
* Juicy Potato NG: A 2022 update of Juicy Potato that bypasses patched CLSIDs using a Kerberos DCOM authentication trick. It remains unpatched and continues to function.&lt;br /&gt;
&lt;br /&gt;
* Cert Potato: Introduced in 2022, it abuses Active Directory Certificate Services (ADCS) to obtain a machine’s Ticket Granting Ticket (TGT) and create a Silver Ticket for domain-level privileges. It remains unpatched.&lt;br /&gt;
&lt;br /&gt;
* Local Potato: Released in 2023, it targets LSASS and swaps NTLM messages to authenticate as a privileged user. It was patched under CVE-2023-21746.&lt;br /&gt;
&lt;br /&gt;
* Coerced Potato: The most recent vulnerability, disclosed in 2023, enhances PrintSpoofer with new RPC call exploits, enabling privilege escalation to the system level. It remains effective on current Windows versions, including Windows 10, 11, and Server 2022.&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
Mitigating Potato Vulnerabilities requires both vendor updates as well as some security practices:&lt;br /&gt;
&lt;br /&gt;
* Microsoft Security Updates: Regularly apply patches and updates provided by Microsoft to address known vulnerabilities.&lt;br /&gt;
* Access Controls: Implement the principle of least privilege to restrict unnecessary elevated permissions.&lt;br /&gt;
* Network Monitoring: Use logging and monitoring tools to detect privilege escalation attacks or unauthorized authentication events.&lt;br /&gt;
* Patch Management: Make sure that all systems are updated to the latest versions, to decrease the likelihood of being vulnerable to Potato exploits.&lt;br /&gt;
&lt;br /&gt;
These measures enhance system defenses not only against privilege escalation, but also against most other attacks and therefore reduce the impact and threat of Potato Vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
  &lt;br /&gt;
* https://jlajara.gitlab.io/Potatoes_Windows_Privesc  &lt;br /&gt;
* https://foxglovesecurity.com/2016/01/16/hot-potato/  &lt;br /&gt;
* https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/  &lt;br /&gt;
* https://hideandsec.sh/books/windows-sNL/page/in-the-potato-family-i-want-them-all  &lt;br /&gt;
* https://decoder.cloud/2017/12/23/the-lonely-potato/  &lt;br /&gt;
* http://ohpe.it/juicy-potato/  &lt;br /&gt;
* https://shenaniganslabs.io/2019/11/12/Ghost-Potato.html  &lt;br /&gt;
* https://www.pentestpartners.com/security-blog/sweetpotato-service-to-system/  &lt;br /&gt;
* https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/  &lt;br /&gt;
* https://micahvandeusen.com/the-power-of-seimpersonation/  &lt;br /&gt;
* https://www.sentinelone.com/labs/relaying-potatoes-another-unexpected-privilege-escalation-vulnerability-in-windows-rpc-protocol/  &lt;br /&gt;
* https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/  &lt;br /&gt;
* https://sensepost.com/blog/2022/certpotato-using-adcs-to-privesc-from-virtual-and-network-service-accounts-to-local-system/  &lt;br /&gt;
* https://decoder.cloud/2023/02/13/localpotato-when-swapping-the-context-leads-you-to-system/  &lt;br /&gt;
* https://blog.hackvens.fr/articles/CoercedPotato.html  &lt;br /&gt;
* https://purplesec.us/learn/privilege-escalation-attacks/  &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17523</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17523"/>
		<updated>2024-12-18T17:11:37Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added references&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
This article explores the family of Potato Vulnerabilities&lt;br /&gt;
&lt;br /&gt;
== Overview of Potato Vulnerabilities ==&lt;br /&gt;
&lt;br /&gt;
== Exploitation Techniques ==&lt;br /&gt;
&lt;br /&gt;
== Specific Potato Vulnerabilities ==&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
  &lt;br /&gt;
* https://jlajara.gitlab.io/Potatoes_Windows_Privesc  &lt;br /&gt;
* https://foxglovesecurity.com/2016/01/16/hot-potato/  &lt;br /&gt;
* https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/  &lt;br /&gt;
* https://hideandsec.sh/books/windows-sNL/page/in-the-potato-family-i-want-them-all  &lt;br /&gt;
* https://decoder.cloud/2017/12/23/the-lonely-potato/  &lt;br /&gt;
* http://ohpe.it/juicy-potato/  &lt;br /&gt;
* https://shenaniganslabs.io/2019/11/12/Ghost-Potato.html  &lt;br /&gt;
* https://www.pentestpartners.com/security-blog/sweetpotato-service-to-system/  &lt;br /&gt;
* https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/  &lt;br /&gt;
* https://micahvandeusen.com/the-power-of-seimpersonation/  &lt;br /&gt;
* https://www.sentinelone.com/labs/relaying-potatoes-another-unexpected-privilege-escalation-vulnerability-in-windows-rpc-protocol/  &lt;br /&gt;
* https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/  &lt;br /&gt;
* https://sensepost.com/blog/2022/certpotato-using-adcs-to-privesc-from-virtual-and-network-service-accounts-to-local-system/  &lt;br /&gt;
* https://decoder.cloud/2023/02/13/localpotato-when-swapping-the-context-leads-you-to-system/  &lt;br /&gt;
* https://blog.hackvens.fr/articles/CoercedPotato.html  &lt;br /&gt;
* https://purplesec.us/learn/privilege-escalation-attacks/  &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17483</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17483"/>
		<updated>2024-12-18T16:49:43Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Category add&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;New page, will get content soon&lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17480</id>
		<title>Potato Vulnerabilities</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Potato_Vulnerabilities&amp;diff=17480"/>
		<updated>2024-12-18T16:48:48Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Created page with &amp;quot;New page, will get content soon&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;New page, will get content soon&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14726</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14726"/>
		<updated>2024-06-21T14:23:11Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Example Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is a mobile application pentesting tool, capable of performing static as well as dynamic analyses. It is well known for its ability to analyze APK files for Android applications and IPA files for IOS applications. It provides detailed security assessments and vulnerability reports. MobSF supports a lot of different functionalities, including code analysis, binary analysis and runtime behavior analysis, therefore making it an important tool for mobile application security testing.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key and the URL to your MobSF instance before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;Put the URL to your MobSF instance here, like http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;Put your API Key here&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
* https://github.com/MobSF/Mobile-Security-Framework-MobSF&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14725</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14725"/>
		<updated>2024-06-21T14:22:39Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Example Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is a mobile application pentesting tool, capable of performing static as well as dynamic analyses. It is well known for its ability to analyze APK files for Android applications and IPA files for IOS applications. It provides detailed security assessments and vulnerability reports. MobSF supports a lot of different functionalities, including code analysis, binary analysis and runtime behavior analysis, therefore making it an important tool for mobile application security testing.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;Put the URL to your MobSF instance here, like http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;Put your API Key here&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
* https://github.com/MobSF/Mobile-Security-Framework-MobSF&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14724</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14724"/>
		<updated>2024-06-21T14:20:52Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is a mobile application pentesting tool, capable of performing static as well as dynamic analyses. It is well known for its ability to analyze APK files for Android applications and IPA files for IOS applications. It provides detailed security assessments and vulnerability reports. MobSF supports a lot of different functionalities, including code analysis, binary analysis and runtime behavior analysis, therefore making it an important tool for mobile application security testing.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
* https://github.com/MobSF/Mobile-Security-Framework-MobSF&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14723</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14723"/>
		<updated>2024-06-21T08:42:20Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Mobile Security Framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is a mobile application pentesting tool, capable of performing static as well as dynamic analyses. It is well known for its ability to analyze APK files for Android applications and IPA files for IOS applications. It provides detailed security assessments and vulnerability reports. MobSF supports a lot of different functionalities, including code analysis, binary analysis and runtime behavior analysis, therefore making it an important tool for mobile application security testing.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14722</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14722"/>
		<updated>2024-06-21T08:39:19Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Mobile Security Framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is a mobile application pentesting tool, capable of performing static as well as dynamic analyses. It is well known for its ability to analyze APK files for Android applications and IPA files for IOS applications. It provides detailed security assessments and vulnerability reports&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14721</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14721"/>
		<updated>2024-06-21T08:31:36Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Expanded summary&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis for mobile applications. It discusses the API endpoints available in MobSF and shows how they can be integrated into scripts. Practical use cases are being presented, to demostrate how MobSF automation enhances mobile seucurity during the development lifecycle of a mobile application.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14720</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14720"/>
		<updated>2024-06-21T08:26:33Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added Category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14719</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14719"/>
		<updated>2024-06-21T08:25:43Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Pentesting]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14704</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14704"/>
		<updated>2024-06-20T17:47:53Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Automation of static analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated by implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14703</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14703"/>
		<updated>2024-06-20T17:40:36Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Example Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated using a script, implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and locally creates a pdf report of the static analysis of the APK. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14702</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14702"/>
		<updated>2024-06-20T17:39:25Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: Added example code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated using a script, implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and finally locally creates a pdf report. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import json&lt;br /&gt;
 import requests &lt;br /&gt;
 from requests_toolbelt.multipart.encoder import MultipartEncoder&lt;br /&gt;
 # -----------------&lt;br /&gt;
 SERVER = &amp;quot;http://127.0.0.1:8000&amp;quot;&lt;br /&gt;
 APIKEY = &#039;266ffc5f22d163c20aea506e9c54a67d8517a4f0e2fc868938080bd9c96b03e6&#039;&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def upload(file_path):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Upload File&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Uploading file:&amp;quot;, file_path)&lt;br /&gt;
    multipart_data = MultipartEncoder(fields={&#039;file&#039;: (os.path.basename(file_path), open(file_path, &#039;rb&#039;), &#039;application/octet-stream&#039;)})&lt;br /&gt;
    headers = {&lt;br /&gt;
        &#039;Content-Type&#039;: multipart_data.content_type,&lt;br /&gt;
        &#039;Authorization&#039;: APIKEY&lt;br /&gt;
    }&lt;br /&gt;
    print(&amp;quot;Headers for upload:&amp;quot;, headers)  # Debugging line to check headers&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/upload&#039;, data=multipart_data, headers=headers)&lt;br /&gt;
    print(&amp;quot;Upload response:&amp;quot;, response.text)&lt;br /&gt;
    return response.json()&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def scan(upload_response):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Scan the file&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Scanning file&amp;quot;)&lt;br /&gt;
    post_dict = {&#039;hash&#039;: upload_response[&#039;hash&#039;]}&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/scan&#039;, data=post_dict, headers=headers)&lt;br /&gt;
    print(&amp;quot;Scan response:&amp;quot;, response.text)&lt;br /&gt;
    return upload_response[&#039;hash&#039;]&lt;br /&gt;
 # -----------------&lt;br /&gt;
 def pdf(file_hash):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Generate PDF Report&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print(&amp;quot;Generate PDF report&amp;quot;)&lt;br /&gt;
    headers = {&#039;Authorization&#039;: APIKEY}&lt;br /&gt;
    data = {&amp;quot;hash&amp;quot;: file_hash}&lt;br /&gt;
    response = requests.post(SERVER + &#039;/api/v1/download_pdf&#039;, data=data, headers=headers, stream=True)&lt;br /&gt;
    with open(&amp;quot;report.pdf&amp;quot;, &#039;wb&#039;) as flip:&lt;br /&gt;
        for chunk in response.iter_content(chunk_size=1024):&lt;br /&gt;
            if chunk:&lt;br /&gt;
                flip.write(chunk)&lt;br /&gt;
    print(&amp;quot;Report saved as report.pdf&amp;quot;)&lt;br /&gt;
 # -----------------&lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
        print(&amp;quot;Usage: python script_name.py &amp;lt;apk_file&amp;gt;&amp;quot;)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    apk_file_path = sys.argv[1]&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if not os.path.isfile(apk_file_path) or not apk_file_path.endswith(&amp;quot;.apk&amp;quot;):&lt;br /&gt;
        print(&amp;quot;Invalid APK file:&amp;quot;, apk_file_path)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
    upload_response = upload(apk_file_path)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    if &#039;hash&#039; not in upload_response:&lt;br /&gt;
        print(&amp;quot;Failed to upload the APK file. Response:&amp;quot;, upload_response)&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 # -----------------&lt;br /&gt;
    file_hash = scan(upload_response)&lt;br /&gt;
    pdf(file_hash)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14701</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14701"/>
		<updated>2024-06-20T17:34:40Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Delete Suppressionsle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated using a script, implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and finally locally creates a pdf report. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 insert code&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14700</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14700"/>
		<updated>2024-06-20T17:34:15Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Automation of static analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated using a script, implementing one of the numerous different API endpoints, which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressionsle ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and finally locally creates a pdf report. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 insert code&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14699</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14699"/>
		<updated>2024-06-20T17:34:03Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: /* Automation of static analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated using a script, implementing one of the numerous different API endpoints. which offer a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressionsle ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and finally locally creates a pdf report. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 insert code&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14687</id>
		<title>Mobile Security: Automation of APK Analysis with MobSF</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Mobile_Security:_Automation_of_APK_Analysis_with_MobSF&amp;diff=14687"/>
		<updated>2024-06-20T14:29:12Z</updated>

		<summary type="html">&lt;p&gt;MKerndl: This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary == &lt;br /&gt;
&lt;br /&gt;
This article explores the automation of the Mobile Security Framework MobSF using its API, highlighting key features of the automation of static analysis as well as discussing practical use cases to demonstrate how MobSF automation enhances mobile security.&lt;br /&gt;
&lt;br /&gt;
== Mobile Security Framework ==&lt;br /&gt;
&lt;br /&gt;
Mobile Security Framework (MobSF) is an all-in mobile application pentesting tool. It is capable of performing static and dynamic analyses of APKs and is widely used for analyzing Android and IOS mobile applications.&lt;br /&gt;
&lt;br /&gt;
== Automation of static analysis ==&lt;br /&gt;
&lt;br /&gt;
Static analysis in MobSF can be automated through its API and offers a wide range of functionalities.&lt;br /&gt;
&lt;br /&gt;
=== Upload a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to upload a file. Supported file types are apk, zip, ipa and appx.&lt;br /&gt;
* URL: /api/v1/upload&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/upload -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Scan a File ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -F &#039;file=@/Users/YourUser/Desktop/base.apk&#039; http://localhost:8000/api/v1/scan -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Display Recent Scans ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to display recent scans.&lt;br /&gt;
* URL: /api/v1/scans&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl --url &amp;quot;http://localhost:8000/api/v1/scans&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete a Scan ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to scan a file that is already uploaded. Supports scanning apk, xapk, apks, jar, aar, zip, ipa, so, dylib, a, and appx extensions.&lt;br /&gt;
* URL: /api/v1/scan&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/delete_scan --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== App Scorecard ===&lt;br /&gt;
&lt;br /&gt;
* Function: Get MobSF Application Security Scorecard.&lt;br /&gt;
* URL: /api/v1/scorecard&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/scorecard --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Download PDF Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate PDF report.&lt;br /&gt;
* URL: /api/v1/download_pdf&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/download_pdf --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Generate JSON Report ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to generate JSON report.&lt;br /&gt;
* URL: /api/v1/report_json&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/report_json --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== View Source Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to view source files.&lt;br /&gt;
* URL: /api/v1/view_source&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/view_source --data &amp;quot;hash=HashOfAPK&amp;amp;type=apk&amp;amp;file=b/a/a/a/a/a.java&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Compare Apps ===&lt;br /&gt;
&lt;br /&gt;
* Function: API to compare scan results.&lt;br /&gt;
* URL: /api/v1/compare&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/compare --data &amp;quot;hash=HashOfAPK&amp;amp;hash2=HashOfOtherAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Rule ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by rule id.&lt;br /&gt;
* URL: /api/v1/suppress_by_rule&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_rule --data &amp;quot;hash=HashOfAPK&amp;amp;type=manifest&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Suppress by Files ===&lt;br /&gt;
&lt;br /&gt;
* Function: Suppress findings by files.&lt;br /&gt;
* URL: /api/v1/suppress_by_files&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/suppress_by_files --data &amp;quot;hash=HashOfAPK&amp;amp;type=code&amp;amp;rule=RuleYouWantToSuppress&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== List Suppressions ===&lt;br /&gt;
&lt;br /&gt;
* Function: View suppressions associated with a scan.&lt;br /&gt;
* URL: /api/v1/list_suppressions&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Delete Suppressionsle ===&lt;br /&gt;
&lt;br /&gt;
* Function: Delete suppressions.&lt;br /&gt;
* URL: /api/v1/delete_suppression&lt;br /&gt;
* Sample Call: &lt;br /&gt;
 curl -X POST --url http://localhost:8000/api/v1/list_suppressions --data &amp;quot;hash=HashOfAPK&amp;amp;kind=file&amp;amp;type=code&amp;amp;rule=RuleYouSuppressed&amp;quot; -H &amp;quot;Authorization:YourAPIKey&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== CI/CD Integration ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automatically analyize mobile applications during the build process, in order to catch security issues before application deployment.&lt;br /&gt;
* Implementation: Include MobSF API calls into the CI/CD pipeline to carry out scans automatically. Retrieve and parse the reults to determine if the build passes all required security criteria.&lt;br /&gt;
* Benefits: Every build is checked for scurity flaws, therefore reducing the risk of deploying vulnerable applications.&lt;br /&gt;
&lt;br /&gt;
=== Scheduled Scans ===&lt;br /&gt;
&lt;br /&gt;
* Description: Perform regular security scans on mobile applications to ensure they remain secure over time after deployment.&lt;br /&gt;
* Implementation: Set up cron jobs or scheduled tasks that use the MobSF API to scan at regular intervals. Collect and review the reports to see if new vulnerabilities apper.&lt;br /&gt;
* Benefits: Maintains security assessment over time, helping to detect and mitigate vulnerabilities introduced with updates or changes in the threat landscape.&lt;br /&gt;
&lt;br /&gt;
=== Bulk analysis ===&lt;br /&gt;
&lt;br /&gt;
* Description: Automate the analysis of multiple applications.&lt;br /&gt;
* Implementation: Develop scripts that use the MobSF API to queue and process multiple applications at once, collecting and comparing the results.&lt;br /&gt;
* Benefits: Manages the security assessment of portfolios of applications, making sure all of them are constantly evaluated and remain secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
This is a simple example of automation of static Analysis in MobSF. It uploads a file, scans this file, and finally locally creates a pdf report. &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #fcf8e3; border: 1px solid #8a6d3b; color: #8a6d3b; padding: 5px 10px; margin-bottom: 5px&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Important&amp;lt;/b&amp;gt;: Make sure to input your API Key before using the script.&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 insert code&lt;br /&gt;
&lt;br /&gt;
The script can be executed as follows:&lt;br /&gt;
&lt;br /&gt;
 python &amp;quot;ScriptName&amp;quot; &amp;quot;PathToAPK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://mobsf.live/api_docs&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>MKerndl</name></author>
	</entry>
</feed>