Search in sources :

Example 21 with SharedPreferences

use of android.content.SharedPreferences in project android by cSploit.

the class Hijacker method onCreate.

public void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setTitle(System.getCurrentTarget() + " > MITM > " + getString(R.string.session_sniffer));
    setContentView(R.layout.plugin_mitm_hijacker);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mHijackToggleButton = (ToggleButton) findViewById(R.id.hijackToggleButton);
    mHijackProgress = (ProgressBar) findViewById(R.id.hijackActivity);
    ListView mListView = (ListView) findViewById(R.id.listView);
    mAdapter = new SessionListAdapter(R.layout.plugin_mitm_hijacker_list_item);
    mSpoof = new SpoofSession();
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Session session = mAdapter.getByPosition(position);
            if (session != null) {
                new ConfirmDialog(getString(R.string.hijack_session), mRunning ? getString(R.string.start_hijacking) : getString(R.string.start_hijacking2), Hijacker.this, new ConfirmDialogListener() {

                    @Override
                    public void onConfirm() {
                        if (mRunning)
                            setStoppedState();
                        System.setCustomData(session);
                        startActivity(new Intent(Hijacker.this, HijackerWebView.class));
                    }

                    @Override
                    public void onCancel() {
                    }
                }).show();
            }
        }
    });
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final Session session = mAdapter.getByPosition(position);
            if (session != null) {
                new InputDialog(getString(R.string.save_session), getString(R.string.set_session_filename), session.getFileName(), true, false, Hijacker.this, new InputDialogListener() {

                    @Override
                    public void onInputEntered(String name) {
                        if (!name.isEmpty()) {
                            try {
                                String filename = session.save(name);
                                Toast.makeText(Hijacker.this, getString(R.string.session_saved_to) + filename + " .", Toast.LENGTH_SHORT).show();
                            } catch (IOException e) {
                                new ErrorDialog(getString(R.string.error), e.toString(), Hijacker.this).show();
                            }
                        } else
                            new ErrorDialog(getString(R.string.error), getString(R.string.invalid_session), Hijacker.this).show();
                    }
                }).show();
            }
            return true;
        }
    });
    mHijackToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    mRequestListener = new RequestListener();
}
Also used : InputDialog(org.csploit.android.gui.dialogs.InputDialog) OnRequestListener(org.csploit.android.net.http.proxy.Proxy.OnRequestListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) SharedPreferences(android.content.SharedPreferences) SpoofSession(org.csploit.android.plugins.mitm.SpoofSession) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) InputDialogListener(org.csploit.android.gui.dialogs.InputDialog.InputDialogListener) ListView(android.widget.ListView) OnClickListener(android.view.View.OnClickListener) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog) SpoofSession(org.csploit.android.plugins.mitm.SpoofSession)

Example 22 with SharedPreferences

use of android.content.SharedPreferences in project android by cSploit.

the class HijackerWebView method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    supportRequestWindowFeature(Window.FEATURE_PROGRESS);
    setTitle(System.getCurrentTarget() + " > MITM > Session Hijacker");
    setContentView(R.layout.plugin_mitm_hijacker_webview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mWebView = (WebView) findViewById(R.id.webView);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mProgressBar = (ProgressBar) findViewById(R.id.webprogress);
    mURLet = (EditText) findViewById(R.id.url);
    mProgressBar.setVisibility(View.GONE);
    mProgressBar.setMax(100);
    mSettings = mWebView.getSettings();
    mSettings.setJavaScriptEnabled(true);
    mSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    mSettings.setBuiltInZoomControls(true);
    mSettings.setAppCacheEnabled(false);
    mSettings.setUserAgentString(DEFAULT_USER_AGENT);
    mSettings.setUseWideViewPort(true);
    mURLet.setOnEditorActionListener(new EditText.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) {
                mWebView.loadUrl(mURLet.getText().toString());
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
                mWebView.requestFocus();
                return true;
            }
            return false;
        }
    });
    mURLet.setOnKeyListener(new EditText.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                mWebView.loadUrl(mURLet.getText().toString());
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
                mWebView.requestFocus();
                return true;
            }
            return false;
        }
    });
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            mURLet.setText(url);
            return true;
        }
    });
    mWebView.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView view, int progress) {
            if ((mWebView != null) && (mURLet != null) && (progress == 0))
                ;
            {
                getSupportActionBar().setSubtitle(mWebView.getUrl());
                mURLet.setText(mWebView.getUrl());
            }
            if (mProgressBar != null) {
                mProgressBar.setVisibility(View.VISIBLE);
                // Normalize our progress along the progress bar's scale
                mProgressBar.setProgress(progress);
                if (progress == 100) {
                    mProgressBar.setVisibility(View.GONE);
                }
            }
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        CookieManager cm = CookieManager.getInstance();
        cm.flush();
    } else {
        CookieSyncManager.createInstance(this);
        CookieManager.getInstance().removeAllCookie();
    }
    Session session = (Session) System.getCustomData();
    if (session != null) {
        String domain = null, rawcookie = null;
        for (HttpCookie cookie : session.mCookies.values()) {
            domain = cookie.getDomain();
            rawcookie = cookie.getName() + "=" + cookie.getValue() + "; domain=" + domain + "; path=/" + (session.mHTTPS ? ";secure" : "");
            CookieManager.getInstance().setCookie(domain, rawcookie);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            CookieManager cm = CookieManager.getInstance();
            cm.flush();
        } else {
            CookieSyncManager.getInstance().startSync();
        }
        if (session.mUserAgent != null && session.mUserAgent.isEmpty() == false)
            mSettings.setUserAgentString(session.mUserAgent);
        String url = (session.mHTTPS ? "https" : "http") + "://";
        if (domain != null && !Patterns.IP_ADDRESS.matcher(domain).matches())
            url += "www.";
        url += domain;
        mWebView.loadUrl(url);
        mWebView.requestFocus();
    }
}
Also used : EditText(android.widget.EditText) SharedPreferences(android.content.SharedPreferences) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) WebChromeClient(android.webkit.WebChromeClient) TextView(android.widget.TextView) WebView(android.webkit.WebView) HttpCookie(java.net.HttpCookie) CookieManager(android.webkit.CookieManager) WebViewClient(android.webkit.WebViewClient)

Example 23 with SharedPreferences

use of android.content.SharedPreferences in project UltimateAndroid by cymcsg.

the class PreferencesUtils method putInt.

/**
     * Put int to preferences with custom preference
     *
     * @param context
     * @param preferenceName The custom preference name
     * @param key            The name of the preference to modify
     * @param value          The new value for the preference
     * @return Returns true if the new values were successfully written to persistent storage.
     */
public static boolean putInt(Context context, String preferenceName, String key, int value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putInt(key, value);
    return editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 24 with SharedPreferences

use of android.content.SharedPreferences in project UltimateAndroid by cymcsg.

the class PreferencesUtils method putFloat.

/**
     * Put float to preferences with custom preference
     *
     * @param context
     * @param preferenceName The custom preference name
     * @param key            The name of the preference to modify
     * @param value          The new value for the preference
     * @return Returns true if the new values were successfully written to persistent storage.
     */
public static boolean putFloat(Context context, String preferenceName, String key, float value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putFloat(key, value);
    return editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 25 with SharedPreferences

use of android.content.SharedPreferences in project UltimateAndroid by cymcsg.

the class PreferencesUtils method putString.

/**
     * Put string to preferences with custom preference
     *
     * @param context
     * @param preferenceName The custom preference name
     * @param key            The name of the preference to modify
     * @param value          The new value for the preference
     * @return Returns true if the new values were successfully written to persistent storage.
     */
public static boolean putString(Context context, String preferenceName, String key, String value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    return editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Aggregations

SharedPreferences (android.content.SharedPreferences)1653 Intent (android.content.Intent)206 View (android.view.View)101 Editor (android.content.SharedPreferences.Editor)100 TextView (android.widget.TextView)64 Context (android.content.Context)56 File (java.io.File)56 PendingIntent (android.app.PendingIntent)55 IOException (java.io.IOException)55 ArrayList (java.util.ArrayList)52 Bundle (android.os.Bundle)40 JSONObject (org.json.JSONObject)40 JSONException (org.json.JSONException)39 DialogInterface (android.content.DialogInterface)37 SuppressLint (android.annotation.SuppressLint)33 AdapterView (android.widget.AdapterView)32 ImageView (android.widget.ImageView)32 ListView (android.widget.ListView)32 ComponentName (android.content.ComponentName)31 AlertDialog (android.app.AlertDialog)26