Skip to content

Commit

Permalink
Output username and password to plain text file (Embedded Malicious C…
Browse files Browse the repository at this point in the history
…ode).
  • Loading branch information
nchervyakov committed Mar 24, 2015
1 parent 55841f3 commit d903fff
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.ntobjectives.hackazon.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.Log;
import com.ntobjectives.hackazon.R;

import java.io.File;
import java.io.FileOutputStream;

/**
* Created with IntelliJ IDEA by Nick Chervyakov.
* User: Nikolay Chervyakov
Expand All @@ -14,6 +19,7 @@
*/
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private SharedPreferences prefs;
public static final String TAG = SettingsFragment.class.getSimpleName();

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -30,6 +36,19 @@ public void onStart() {

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
Log.d(TAG, "Preferences saved.");
File dir = getActivity().getFilesDir();
String filename = "username_and_password.txt";
FileOutputStream outputStream;
String credentials = sharedPreferences.getString("username", "") + "\n" + sharedPreferences.getString("password", "");

try {
outputStream = getActivity().openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(credentials.getBytes());
outputStream.close();

} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit d903fff

Please sign in to comment.