Skip to content

Instantly share code, notes, and snippets.

View ed-george's full-sized avatar
🌍
Working remotely...

Ed Holloway-George ed-george

🌍
Working remotely...
View GitHub Profile
@ed-george
ed-george / gist:47766747a634bb900860d7fba3ed2406
Created November 5, 2019 11:31
Print a method's parameters using Live Template
groovyScript("'' + _1.collect { it + ' = [${' + it + '}]'}.join(', ') + ''", functionParameters())
@ed-george
ed-george / app-build.gradle
Last active February 12, 2020 13:29
A small example of how to generate a report for a Gradle Project's dependencies as per - https://ed-george.github.io/articles/12-02-2020/versioning
// APP Level app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../dependency-update.gradle'
android {
@ed-george
ed-george / Ext.kt
Last active October 15, 2021 07:02
A RecyclerView that can display a 'masked' selection
package com.himumsaiddad.example.util
import android.content.res.Resources
val Int.dp: Int
get() = (this * Resources.getSystem().displayMetrics.density).toInt()
@ed-george
ed-george / AndroidManifest.xml
Created January 27, 2022 18:05
Unpicking Android Security: Part 1  -  Improper Platform Usage (Example 1)
<activity
android:name=".login.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
@ed-george
ed-george / adb.sh
Created January 27, 2022 18:07
Unpicking Android Security: Part 1  -  Improper Platform Usage (Example 2)
adb shell am start -n dev.spght.owasp/dev.spght.owasp.home.MainActivity
@ed-george
ed-george / AndroidManifest.xml
Created January 27, 2022 18:09
Unpicking Android Security: Part 1  -  Improper Platform Usage (Example 3)
<!-- In the main application -->
<permission android:name="dev.spght.permission.example.MY_PERMISSION"
android:protectionLevel="signature"
android:label="A custom permission" />
<!-- In the secondary application -->
<uses-permission android:name="dev.spght.permission.example.MY_PERMISSION"/>
@ed-george
ed-george / Example1.kt
Created June 4, 2022 00:05
Unpacking Android Security: Part 2 - Insecure Data Storage (Example 1)
val prefs = context?.getSharedPreferences("mySharedPrefFile", Context.MODE_PRIVATE) ?: return
// Store some credentials we might not want others to read
prefs.edit().putString("mySecretKey", "mySecretValue").apply()
@ed-george
ed-george / Example2.kt
Created June 4, 2022 00:07
Unpacking Android Security: Part 2 - Insecure Data Storage (Example 2)
val masterKey = MasterKey.Builder(this)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
EncryptedSharedPreferences.create(this, "myEncryptedPrefsFile", masterKey, PrefKeyEncryptionScheme.AES256_SIV, PrefValueEncryptionScheme.AES256_GCM).edit {
putString("mySecretKey", "mySecretValue")
}
@ed-george
ed-george / Example3.xml
Created June 4, 2022 00:08
Unpacking Android Security: Part 2 - Insecure Data Storage (Example 3)
<map>
<string name="ARTYCGdkOdwAqjLCjWdsepYfbO+lJzJFFrHIta8JSE0=">ASTonpk6n1buL/VN6mB/S95HNcyHzvFp5qbcpkJMjSQbqRkzO3HWe5KKcP6eTwtzIFamU3Ag</string>
<string name="__androidx_security_crypto_encrypted_prefs_key_keyset__">12a90155259183605a12481ccf406838afc98126862109cc5e083185fe7259a052ccb4d1f859ac62ee1ab624f4b35df36c53a23c24547ee322aacc4526a654fd99e9997c0e6bf389b3bf2706a2e29b63d99a1e74535d68457fda16f04e706f127ca09c01622e26db72339720e814af1d6533efc8705eb8a073fa4e5afb2dbfb9446eaa27801942e0c8a8462ff6aed86738f500cdb77655294549810c2cfbe011b4c3900e3504eb3947502c7c1a4408e790e0a601123c0a30747970652e676f6f676c65617069732e636f6d2f676f6f676c652e63727970746f2e74696e6b2e4165735369764b6579100118e790e0a6012001</string>
<string name="__androidx_security_crypto_encrypted_prefs_value_keyset__">128801700a3e737db7b3f8385be4aea6f74fbb844b86532055fa99032c67df4c5a5543e799dd9a621013ba716749b3decef994896914cea1d8dbf25fc13e6a7c6f19a0488dbd4a339642f4bfc4ad82fe1b27b4d4ca0a79c55e57354389f7c2e115af8c0d6f8fff0093299c2481a6cf25b5
@ed-george
ed-george / Example4.kt
Created June 4, 2022 00:10
Unpacking Android Security: Part 2 - Insecure Data Storage (Example 4)
// Use a user-entered passphrase to encrypt/decrypt
val passPhrase: ByteArray = "password".encodeToByteArray()
val sqlCipherSupportFactory: SupportSQLiteOpenHelper.Factory = SupportFactory(passPhrase)
val database = Room.databaseBuilder(
applicationContext,
YourRoomDatabase::class.java,
"secure-database")
.openHelperFactory(sqlCipherSupportFactory)
.build()