Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Add Android Lollipop support and GUI home button
Browse files Browse the repository at this point in the history
  • Loading branch information
B3nac committed Oct 18, 2020
1 parent f2212f3 commit fdbdae1
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 61 deletions.
2 changes: 1 addition & 1 deletion InjuredAndroid/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "b3nac.injuredandroid"
multiDexEnabled true
minSdkVersion 23
minSdkVersion 21
targetSdkVersion 29
versionCode 12
versionName "1.0.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import android.widget.Toast

class FlagFiveReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
SecureSharedPrefs.setContext(context)

if (wtf == 0) {
if (click == 0) {
val sb = StringBuilder()
sb.append("""
Action: ${intent.action}
Expand All @@ -22,24 +23,25 @@ class FlagFiveReceiver : BroadcastReceiver() {
val log = sb.toString()
Log.d("DUDE!:", log)
Toast.makeText(context, log, Toast.LENGTH_LONG).show()
wtf = wtf + 1
} else if (wtf == 1) {
click++
} else if (click == 1) {
val win = "Keep trying!"
Toast.makeText(context, win, Toast.LENGTH_LONG).show()
wtf = wtf + 1
} else if (wtf == 2) {
click++
} else if (click == 2) {
val win = "You are a winner " + VGV4dEVuY3J5cHRpb25Ud28.decrypt("Zkdlt0WwtLQ=")
FlagsOverview().flagFiveButtonColor = true
SecureSharedPrefs().editBoolean(context, "flagFiveButtonColor", true)
Toast.makeText(context, win, Toast.LENGTH_LONG).show()
click = 0
} else {
val win = "Keep trying!"
Toast.makeText(context, win, Toast.LENGTH_LONG).show()
}
}

companion object {
var wtf = 0
var click = 0
const val ACTION_CUSTOM_BROADCAST = "com.b3nac.injuredandroid.intent.action.CUSTOM_INTENT"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package b3nac.injuredandroid

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import b3nac.injuredandroid.FlagNineFirebaseActivity
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import com.google.firebase.database.DataSnapshot
Expand All @@ -19,6 +18,7 @@ import com.google.firebase.database.ValueEventListener
import java.nio.charset.StandardCharsets

class FlagNineFirebaseActivity : AppCompatActivity() {

var click = 0
val directory = "ZmxhZ3Mv"
var decodedDirectory = Base64.decode(directory, Base64.DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
package b3nac.injuredandroid

import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity

class FlagOneSuccess : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_flag_one_success)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val itemId = item.itemId
if (itemId == R.id.action_home) {
startActivity(Intent(this, MainActivity::class.java))
}
if (itemId == R.id.action_contact) {
startActivity(Intent(this, ContactActivity::class.java))
}
if (itemId == R.id.action_settings) {
startActivity(Intent(this, SettingsActivity::class.java))
}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@ class FlagSevenSqliteActivity : AppCompatActivity() {

val fab = findViewById<FloatingActionButton>(R.id.fab)
fab.setOnClickListener { view: View? ->
if (click == 0) {
Snackbar.make(view!!, "Run ADB as root.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
click++
} else if (click == 1) {
Snackbar.make(view!!, "Stay on this activity.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
click = 0
} else if (click == 2) {
Snackbar.make(view!!, "Not all encodings are the same, some need to be rotated.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
when (click) {
0 -> {
Snackbar.make(view!!, "Run ADB as root.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
click++
}
1 -> {
Snackbar.make(view!!, "Stay on this activity.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
click = 0
}
2 -> {
Snackbar.make(view!!, "Not all encodings are the same, some need to be rotated.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
}
}

val db = dbHelper.writableDatabase
val values = ContentValues()
val decode = Base64.decode("VGhlIGZsYWcgaGFzaCE=", 0)
Expand Down Expand Up @@ -95,7 +100,6 @@ class FlagSevenSqliteActivity : AppCompatActivity() {
private fun preloadValues() {
mListener = childRef.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
//val childRefTwo = database.child(refDirectoryTwo)
val value = dataSnapshot.value as String?
val secure = SecureSharedPrefs()
secure.putString(applicationContext, "flagSevenEncrypted", value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package b3nac.injuredandroid

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Base64
import android.view.View
Expand All @@ -20,7 +18,6 @@ import com.google.firebase.database.ValueEventListener
import java.nio.charset.StandardCharsets
import java.util.*


class FlagTenUnicodeActivity : AppCompatActivity() {
internal var click = 0
val directory = "dW5pY29kZS8="
Expand All @@ -44,7 +41,6 @@ class FlagTenUnicodeActivity : AppCompatActivity() {
if (click == 0) {
Snackbar.make(view, "Find the email address.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
//Figure out how to login anonymously on click
click++
} else if (click == 1) {
Snackbar.make(view, "Cause a unicode collision.", Snackbar.LENGTH_LONG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar

class FlagThreeActivity : AppCompatActivity() {

var click = 0

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_flag_three)
Expand All @@ -36,7 +38,7 @@ class FlagThreeActivity : AppCompatActivity() {
fun submitFlag(view: View?) {
val editText2 = findViewById<EditText>(R.id.editText2)
val post = editText2.text.toString()
val settings = getSharedPreferences("b3nac.injuredandroid", Context.MODE_PRIVATE)

if (post == getString(R.string.cmVzb3VyY2VzX3lv)) {
val intent = Intent(this, FlagOneSuccess::class.java)
FlagsOverview().flagThreeButtonColor = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class MainActivity : AppCompatActivity() {

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val itemId = item.itemId
if (itemId == R.id.action_home) {
startActivity(Intent(this, MainActivity::class.java))
}
if (itemId == R.id.action_contact) {
startActivity(Intent(this, ContactActivity::class.java))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,39 @@ class RCEActivity : AppCompatActivity() {
val intentParam = data!!.getQueryParameter("binary")
val binaryParam = data.getQueryParameter("param")
val combinedParam = data.getQueryParameter("combined")
childRef.addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val value = dataSnapshot.value as String?
if (combinedParam != null && combinedParam == value) {
FlagsOverview.flagThirteenButtonColor = true
val secure = SecureSharedPrefs()
secure.editBoolean(applicationContext, "flagThirteenButtonColor", true)
correctFlag()
} else {
Toast.makeText(this@RCEActivity, "Try again! :D",
Toast.LENGTH_SHORT).show()
if (combinedParam != null) {
childRef.addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val value = dataSnapshot.value as String?
if (combinedParam == value) {
FlagsOverview.flagThirteenButtonColor = true
val secure = SecureSharedPrefs()
secure.editBoolean(applicationContext, "flagThirteenButtonColor", true)
correctFlag()
} else {
Toast.makeText(this@RCEActivity, "Try again! :D",
Toast.LENGTH_SHORT).show()
}
}
}

override fun onCancelled(databaseError: DatabaseError) {
Log.e(TAG, "onCancelled", databaseError.toException())
}
})
override fun onCancelled(databaseError: DatabaseError) {
Log.e(TAG, "onCancelled", databaseError.toException())
}
})
}
else {

val process = Runtime.getRuntime().exec(filesDir.parent + "/files/" + intentParam + " " + binaryParam)
val bufferedReader = BufferedReader(
InputStreamReader(process.inputStream))
val log = StringBuilder()
bufferedReader.forEachLine {
log.append(it)
val process = Runtime.getRuntime().exec(filesDir.parent + "/files/" + intentParam + " " + binaryParam)
val bufferedReader = BufferedReader(
InputStreamReader(process.inputStream))
val log = StringBuilder()
bufferedReader.forEachLine {
log.append(it)
}
process.waitFor()
val tv = findViewById<TextView>(R.id.RCEView)
tv.text = log.toString()
}
process.waitFor()
val tv = findViewById<TextView>(R.id.RCEView)
tv.text = log.toString()
} catch (e: IOException) {
Log.e(TAG, "OH NO AN ERROR OCCURED!!!:" + e.message)
}
Expand All @@ -97,7 +101,7 @@ class RCEActivity : AppCompatActivity() {
Log.e("tag", "Failed to get asset file list.", e)
}
if (files != null) for (filename in files) {
if (filename != "webkit" && filename != "images" && filename != "flutter_assets") {
if (filename != "webkit" && filename != "images" && filename != "flutter_assets" && filename != "locales") {
var `in`: InputStream? = null
var out: OutputStream? = null
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void onCreate(Bundle savedInstanceState) {

public void send() {

String uri = "blah";
String uri = "Hi";

Intent intent = new Intent(getApplicationContext(), FlagFiveReceiver.class);
intent.setAction("com.b3nac.injuredandroid.intent.action.CUSTOM_INTENT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import android.text.TextUtils;
import android.util.Base64;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
Expand Down
5 changes: 5 additions & 0 deletions InjuredAndroid/app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="b3nac.injuredandroid.MainActivity">
<item
android:id="@+id/action_home"
android:icon="@mipmap/ic_launcher_foreground"
android:title="fav"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
Expand Down
6 changes: 0 additions & 6 deletions InjuredAndroid/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@
<string name="flag_16">Flag 16</string>
<string name="textview">TextView</string>
<string name="title_activity_flag_seventeen">FlagSeventeenActivity</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>

<string name="hello_first_fragment">Hello first fragment</string>
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
<string name="flag_17_ssl_pinning_bypass">Flag 17 - SSL Pinning Bypass</string>
<string name="flag_fifteen_assembly">Flag Fifteen - Assembly</string>
<string name="flag_sixteen_csp_bypass">Flag Sixteen - CSP Bypass</string>
Expand Down

0 comments on commit fdbdae1

Please sign in to comment.