use of android.webkit.CookieManager in project android by cSploit.
the class HijackerWebView method onResume.
@Override
protected void onResume() {
super.onResume();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager cm = CookieManager.getInstance();
cm.flush();
} else {
CookieSyncManager.getInstance().startSync();
}
}
use of android.webkit.CookieManager 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();
}
}
use of android.webkit.CookieManager in project android by cSploit.
the class HijackerWebView method onPause.
@Override
protected void onPause() {
super.onPause();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager cm = CookieManager.getInstance();
cm.flush();
} else {
CookieSyncManager.getInstance().startSync();
}
}
use of android.webkit.CookieManager in project Klyph by jonathangerbaud.
the class Util method clearCookies.
public static void clearCookies(Context context) {
// Edge case: an illegal state exception is thrown if an instance of
// CookieSyncManager has not be created. CookieSyncManager is normally
// created by a WebKit view, but this might happen if you start the
// app, restore saved state, and click logout before running a UI
// dialog in a WebView -- in which case the app crashes
@SuppressWarnings("unused") CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
use of android.webkit.CookieManager in project weiciyuan by qii.
the class OAuthActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.oauthactivity_layout);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setTitle(getString(R.string.login));
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WeiboWebViewClient());
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSaveFormData(false);
settings.setSavePassword(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
Aggregations