1818 */
1919package org .csploit .android .plugins .mitm .hijacker ;
2020
21+ import android .content .Context ;
2122import android .content .SharedPreferences ;
23+ import android .os .Build ;
2224import android .os .Bundle ;
2325import android .support .v7 .app .AppCompatActivity ;
2426import android .util .Patterns ;
27+ import android .view .KeyEvent ;
2528import android .view .Menu ;
2629import android .view .MenuInflater ;
2730import android .view .MenuItem ;
31+ import android .view .View ;
2832import android .view .Window ;
33+ import android .view .inputmethod .EditorInfo ;
34+ import android .view .inputmethod .InputMethodManager ;
2935import android .webkit .CookieManager ;
3036import android .webkit .CookieSyncManager ;
3137import android .webkit .WebChromeClient ;
3238import android .webkit .WebSettings ;
3339import android .webkit .WebView ;
3440import android .webkit .WebViewClient ;
41+ import android .widget .EditText ;
42+ import android .widget .ProgressBar ;
43+ import android .widget .TextView ;
3544
3645import org .csploit .android .R ;
3746import org .csploit .android .core .System ;
@@ -43,6 +52,8 @@ public class HijackerWebView extends AppCompatActivity {
4352
4453 private WebSettings mSettings = null ;
4554 private WebView mWebView = null ;
55+ private ProgressBar mProgressBar = null ;
56+ private EditText mURLet = null ;
4657
4758 @ Override
4859 protected void onCreate (Bundle savedInstanceState ) {
@@ -58,42 +69,88 @@ protected void onCreate(Bundle savedInstanceState) {
5869 setTitle (System .getCurrentTarget () + " > MITM > Session Hijacker" );
5970 setContentView (R .layout .plugin_mitm_hijacker_webview );
6071 getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
61- setSupportProgressBarIndeterminateVisibility (false );
6272
6373 mWebView = (WebView ) findViewById (R .id .webView );
74+ mWebView .setScrollBarStyle (View .SCROLLBARS_INSIDE_OVERLAY );
75+ mProgressBar = (ProgressBar ) findViewById (R .id .webprogress );
76+ mURLet = (EditText ) findViewById (R .id .url );
77+ mProgressBar .setVisibility (View .GONE );
78+ mProgressBar .setMax (100 );
6479 mSettings = mWebView .getSettings ();
6580
6681 mSettings .setJavaScriptEnabled (true );
82+ mSettings .setJavaScriptCanOpenWindowsAutomatically (true );
6783 mSettings .setBuiltInZoomControls (true );
6884 mSettings .setAppCacheEnabled (false );
6985 mSettings .setUserAgentString (DEFAULT_USER_AGENT );
86+ mSettings .setUseWideViewPort (true );
87+
88+ mURLet .setOnEditorActionListener (new EditText .OnEditorActionListener () {
89+ @ Override
90+ public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
91+ if (actionId == EditorInfo .IME_ACTION_DONE || actionId == EditorInfo .IME_ACTION_NEXT ) {
92+ mWebView .loadUrl (mURLet .getText ().toString ());
93+ InputMethodManager imm = (InputMethodManager )getSystemService (Context .INPUT_METHOD_SERVICE );
94+ imm .hideSoftInputFromWindow (mWebView .getWindowToken (), 0 );
95+ mWebView .requestFocus ();
96+ return true ;
97+ }
98+ return false ;
99+ }
100+ });
101+
102+ mURLet .setOnKeyListener (new EditText .OnKeyListener () {
103+ @ Override
104+ public boolean onKey (View v , int keyCode , KeyEvent event ) {
105+ if (event .getAction () == KeyEvent .ACTION_DOWN
106+ && event .getKeyCode () == KeyEvent .KEYCODE_ENTER ) {
107+ mWebView .loadUrl (mURLet .getText ().toString ());
108+ InputMethodManager imm = (InputMethodManager )getSystemService (Context .INPUT_METHOD_SERVICE );
109+ imm .hideSoftInputFromWindow (mWebView .getWindowToken (), 0 );
110+ mWebView .requestFocus ();
111+ return true ;
112+ }
113+ return false ;
114+ }
115+ });
70116
71117 mWebView .setWebViewClient (new WebViewClient () {
72118 @ Override
73119 public boolean shouldOverrideUrlLoading (WebView view , String url ) {
74120 view .loadUrl (url );
121+ mURLet .setText (url );
75122 return true ;
76123 }
77124 });
78125
79126 mWebView .setWebChromeClient (new WebChromeClient () {
127+
80128 public void onProgressChanged (WebView view , int progress ) {
81- if (mWebView != null )
129+ if (( mWebView != null ) && ( mURLet != null ) && ( progress == 0 )); {
82130 getSupportActionBar ().setSubtitle (mWebView .getUrl ());
131+ mURLet .setText (mWebView .getUrl ());
132+ }
83133
84- setSupportProgressBarIndeterminateVisibility (true );
85- // Normalize our progress along the progress bar's scale
86- int mmprogress = (Window .PROGRESS_END - Window .PROGRESS_START )
87- / 100 * progress ;
88- setProgress (mmprogress );
134+ if (mProgressBar != null ) {
135+ mProgressBar .setVisibility (View .VISIBLE );
136+ // Normalize our progress along the progress bar's scale
89137
90- if (progress == 100 )
91- setSupportProgressBarIndeterminateVisibility (false );
138+ mProgressBar .setProgress (progress );
139+
140+ if (progress == 100 ) {
141+ mProgressBar .setVisibility (View .GONE );
142+ }
143+ }
92144 }
93145 });
94146
95- CookieSyncManager .createInstance (this );
96- CookieManager .getInstance ().removeAllCookie ();
147+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
148+ CookieManager cm = CookieManager .getInstance ();
149+ cm .flush ();
150+ } else {
151+ CookieSyncManager .createInstance (this );
152+ CookieManager .getInstance ().removeAllCookie ();
153+ }
97154
98155 Session session = (Session ) System .getCustomData ();
99156 if (session != null ) {
@@ -108,7 +165,12 @@ public void onProgressChanged(WebView view, int progress) {
108165 CookieManager .getInstance ().setCookie (domain , rawcookie );
109166 }
110167
111- CookieSyncManager .getInstance ().sync ();
168+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
169+ CookieManager cm = CookieManager .getInstance ();
170+ cm .flush ();
171+ } else {
172+ CookieSyncManager .getInstance ().startSync ();
173+ }
112174
113175 if (session .mUserAgent != null
114176 && session .mUserAgent .isEmpty () == false )
@@ -122,21 +184,32 @@ public void onProgressChanged(WebView view, int progress) {
122184 url += domain ;
123185
124186 mWebView .loadUrl (url );
187+ mWebView .requestFocus ();
125188 }
126189 }
127190
128191 @ Override
129192 protected void onResume () {
130193 super .onResume ();
131194
132- CookieSyncManager .getInstance ().startSync ();
195+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
196+ CookieManager cm = CookieManager .getInstance ();
197+ cm .flush ();
198+ } else {
199+ CookieSyncManager .getInstance ().startSync ();
200+ }
133201 }
134202
135203 @ Override
136204 protected void onPause () {
137205 super .onPause ();
138206
139- CookieSyncManager .getInstance ().stopSync ();
207+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
208+ CookieManager cm = CookieManager .getInstance ();
209+ cm .flush ();
210+ } else {
211+ CookieSyncManager .getInstance ().startSync ();
212+ }
140213 }
141214
142215 @ Override
0 commit comments