Skip to content

Commit 676cbb8

Browse files
author
Ch0pin
committed
added file motitoring modules
1 parent b4b7ead commit 676cbb8

File tree

3 files changed

+149
-0
lines changed

3 files changed

+149
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"Name": "file_system/context_file_input_output",
3+
"Description": "Use this module to monitor file input output operations associated with Context application package",
4+
"Help": "https://developer.android.com/reference/android/content/Context#openFileInput(java.lang.String)",
5+
"Code": "
6+
console.log('-------App context file input output operations monitor by @chopin--------------');
7+
8+
var contextWrapper= Java.use('android.content.ContextWrapper');
9+
10+
11+
if (contextWrapper.openFileInput) {
12+
// Ref: https://developer.android.com/reference/android/content/ContextWrapper.html#openFileInput(java.lang.String)
13+
contextWrapper.openFileInput.overload(\"java.lang.String\").implementation = function(fileName) {
14+
15+
colorLog('[+] App is opening the file: '+fileName + ' for reading',{c: Color.Red} );
16+
return this.openFileInput.overload(\"java.lang.String\").apply(this, arguments);
17+
18+
};
19+
}
20+
21+
if (contextWrapper.openFileOutput) {
22+
// Ref: https://developer.android.com/reference/android/content/ContextWrapper.html#openFileOutput(java.lang.String, int)
23+
contextWrapper.openFileOutput.overload(\"java.lang.String\", \"int\").implementation = function(fileName, mode) {
24+
25+
colorLog('[+] App is opening the file: '+fileName + ' using mode: '+mode,{c: Color.Red});
26+
return this.openFileOutput.overload(\"java.lang.String\", \"int\").apply(this, arguments);
27+
};
28+
}
29+
30+
if (contextWrapper.deleteFile) {
31+
// Ref: https://developer.android.com/reference/android/content/ContextWrapper.html#deleteFile(java.lang.String)
32+
contextWrapper.deleteFile.overload(\"java.lang.String\").implementation = function(fileName) {
33+
34+
/* --- Payload Header --- */
35+
colorLog('[+] App is deleting the file: '+fileName,{c: Color.Red});
36+
37+
return this.deleteFile.overload(\"java.lang.String\").apply(this, arguments);
38+
};
39+
}
40+
"
41+
}
42+
43+
44+
45+
46+
47+
48+
49+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"Name": "file_system/file_input_stream",
3+
"Description": "Use this module to monitor file input stream operations",
4+
"Help": "https://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html",
5+
"Code": "
6+
console.log('-------file input stream operations monitor by @chopin--------------');
7+
8+
var fileInputStream= Java.use('java.io.FileInputStream');
9+
10+
11+
fileInputStream.$init.overload('java.io.File').implementation = function(file){
12+
var fname = file.getAbsolutePath();
13+
colorLog('[+] App is opening: '+fname + ' for READ',{c: Color.Green} );
14+
15+
return this.$init(file);
16+
}
17+
fileInputStream.$init.overload('java.io.FileDescriptor').implementation = function(fd){
18+
var fname = fd.toString();
19+
colorLog('[+] App is opening: '+fname + ' for READ',{c: Color.Green} );
20+
21+
return this.$init(fd);
22+
}
23+
fileInputStream.$init.overload('java.lang.String').implementation = function(name){
24+
var fname = name;
25+
colorLog('[+] App is opening: '+fname + ' for READ',{c: Color.Green} );
26+
27+
return this.$init(name);
28+
}
29+
"
30+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"Name": "file_system/file_output_stream",
3+
"Description": "Use this module to monitor file output stream operations",
4+
"Help": "https://docs.oracle.com/javase/7/docs/api/java/io/FileOutputStream.html",
5+
"Code": "
6+
console.log('-------file output stream operations monitor by @chopin--------------');
7+
8+
var fileOutputStream = Java.use('java.io.FileOutputStream');
9+
10+
11+
fileOutputStream.$init.overload('java.io.File').implementation = function(name){
12+
var fname = name.getAbsolutePath();
13+
colorLog('[+] App is opening: '+fname + ' for WRITE',{c: Color.Red} );
14+
15+
return this.$init(name);
16+
}
17+
18+
fileOutputStream.$init.overload('java.io.File','boolean').implementation = function(name, append){
19+
var fname = name.getAbsolutePath();
20+
let mode = '';
21+
if(append==true)
22+
mode = 'APPEND';
23+
else
24+
mode = 'WRITE'
25+
26+
27+
colorLog('[+] App is opening: '+fname + ' for '+mode,{c: Color.Red} );
28+
29+
return this.$init(name,append);
30+
}
31+
32+
33+
fileOutputStream.$init.overload('java.io.FileDescriptor').implementation = function(fd){
34+
var fname = fd.toString();
35+
36+
colorLog('[+] App is opening: '+fname + ' for WRITE',{c: Color.Red} );
37+
38+
return this.$init(fd);
39+
}
40+
41+
fileOutputStream.$init.overload('java.lang.String').implementation = function(filename){
42+
43+
colorLog('[+] App is opening: '+filename + ' for WRITE',{c: Color.Red} );
44+
45+
return this.$init(filename);
46+
}
47+
48+
fileOutputStream.$init.overload('java.lang.String','boolean').implementation = function(filename,append){
49+
let mode = '';
50+
if(append==true)
51+
mode = 'APPEND';
52+
else
53+
mode = 'WRITE'
54+
55+
56+
colorLog('[+] App is opening: '+filename + ' for '+mode,{c: Color.Red} );
57+
58+
return this.$init(filename,append);
59+
60+
}
61+
62+
"
63+
}
64+
65+
66+
67+
68+
69+
70+

0 commit comments

Comments
 (0)