List of usage examples for org.apache.http.impl.cookie BasicClientCookie getName
public String getName()
From source file:com.oinux.lanmitm.util.RequestParser.java
public static ArrayList<BasicClientCookie> getCookiesFromHeaders(ArrayList<String> headers) { ArrayList<String> values = getHeaderValues("Cookie", headers); if (values != null && values.size() > 0) { ArrayList<BasicClientCookie> cookies = new ArrayList<BasicClientCookie>(); for (String value : values) { ArrayList<BasicClientCookie> lineCookies = parseRawCookie(value); if (lineCookies != null && lineCookies.size() > 0) { cookies.addAll(lineCookies); }/*from w w w. j ava 2s .c om*/ } Iterator<BasicClientCookie> it = cookies.iterator(); while (it.hasNext()) { BasicClientCookie cookie = (BasicClientCookie) it.next(); if (cookie.getName().startsWith("__utm") || cookie.getName().equals("__cfduid")) it.remove(); } return cookies.size() > 0 ? cookies : new ArrayList<BasicClientCookie>(); } return new ArrayList<BasicClientCookie>(); }
From source file:it.evilsocket.dsploit.net.http.RequestParser.java
public static ArrayList<BasicClientCookie> getCookiesFromHeaders(ArrayList<String> headers) { ArrayList<String> values = getHeaderValues("Cookie", headers); if (values != null && values.size() > 0) { ArrayList<BasicClientCookie> cookies = new ArrayList<BasicClientCookie>(); for (String value : values) { ArrayList<BasicClientCookie> lineCookies = parseRawCookie(value); if (lineCookies != null && lineCookies.size() > 0) { cookies.addAll(lineCookies); }//from w ww . j av a2s . c o m } // remove google and cloudflare cookies Iterator<BasicClientCookie> it = cookies.iterator(); while (it.hasNext()) { BasicClientCookie cookie = (BasicClientCookie) it.next(); if (cookie.getName().startsWith("__utm") || cookie.getName().equals("__cfduid")) it.remove(); } return cookies.size() > 0 ? cookies : null; } return null; }
From source file:it.evilsocket.dsploit.core.System.java
public static String saveHijackerSession(String sessionName, Session session) throws IOException { StringBuilder builder = new StringBuilder(); String filename = mStoragePath + '/' + sessionName + ".dhs", buffer = null; builder.append(SESSION_MAGIC + "\n"); builder.append((session.mUserName == null ? "null" : session.mUserName) + "\n"); builder.append(session.mHTTPS + "\n"); builder.append(session.mAddress + "\n"); builder.append(session.mDomain + "\n"); builder.append(session.mUserAgent + "\n"); builder.append(session.mCookies.size() + "\n"); for (BasicClientCookie cookie : session.mCookies.values()) { builder.append(cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; path=/" + (session.mHTTPS ? ";secure" : "") + "\n"); }/*ww w .ja v a 2 s. co m*/ buffer = builder.toString(); FileOutputStream ostream = new FileOutputStream(filename); GZIPOutputStream gzip = new GZIPOutputStream(ostream); gzip.write(buffer.getBytes()); gzip.close(); mSessionName = sessionName; return filename; }
From source file:it.evilsocket.dsploit.core.System.java
public static Session loadHijackerSession(String filename) throws Exception { Session session = null;//from w w w.j ava 2 s. c o m File file = new File(mStoragePath + '/' + filename); if (file.exists() && file.length() > 0) { BufferedReader reader = new BufferedReader( new InputStreamReader(new GZIPInputStream(new FileInputStream(file)))); String line = null; // begin decoding procedure try { line = reader.readLine(); if (line == null || line.equals(SESSION_MAGIC) == false) throw new Exception("Not a dSploit hijacker session file."); session = new Session(); session.mUserName = reader.readLine(); session.mUserName = session.mUserName.equals("null") ? null : session.mUserName; session.mHTTPS = Boolean.parseBoolean(reader.readLine()); session.mAddress = reader.readLine(); session.mDomain = reader.readLine(); session.mUserAgent = reader.readLine(); int ncookies = Integer.parseInt(reader.readLine()); for (int i = 0; i < ncookies; i++) { ArrayList<BasicClientCookie> cookies = RequestParser.parseRawCookie(reader.readLine()); for (BasicClientCookie cookie : cookies) { session.mCookies.put(cookie.getName(), cookie); } } reader.close(); } catch (Exception e) { if (reader != null) reader.close(); throw e; } } else throw new Exception(filename + " does not exists or is empty."); return session; }
From source file:com.jaeksoft.searchlib.crawler.web.database.CookieItem.java
public CookieItem(BasicClientCookie basicClientCookie) { this.pattern = null; this.name = basicClientCookie.getName(); this.value = basicClientCookie.getValue(); this.basicClientCookie = basicClientCookie; }
From source file:it.evilsocket.dsploit.plugins.mitm.hijacker.HijackerWebView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setTitle(System.getCurrentTarget() + " > MITM > Session Hijacker"); setContentView(R.layout.plugin_mitm_hijacker_webview); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setSupportProgressBarIndeterminateVisibility(false); mWebView = (WebView) findViewById(R.id.webView); mSettings = mWebView.getSettings();/*from w w w. jav a 2s . c o m*/ mSettings.setJavaScriptEnabled(true); mSettings.setBuiltInZoomControls(true); mSettings.setAppCacheEnabled(false); mSettings.setUserAgentString(DEFAULT_USER_AGENT); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); mWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { if (mWebView != null) getSupportActionBar().setSubtitle(mWebView.getUrl()); setSupportProgressBarIndeterminateVisibility(true); // Normalize our progress along the progress bar's scale int mmprogress = (Window.PROGRESS_END - Window.PROGRESS_START) / 100 * progress; setSupportProgress(mmprogress); if (progress == 100) setSupportProgressBarIndeterminateVisibility(false); } }); CookieSyncManager.createInstance(this); CookieManager.getInstance().removeAllCookie(); Session session = (Session) System.getCustomData(); if (session != null) { String domain = null, rawcookie = null; for (BasicClientCookie cookie : session.mCookies.values()) { domain = cookie.getDomain(); rawcookie = cookie.getName() + "=" + cookie.getValue() + "; domain=" + domain + "; path=/" + (session.mHTTPS ? ";secure" : ""); CookieManager.getInstance().setCookie(domain, rawcookie); } CookieSyncManager.getInstance().sync(); if (session.mUserAgent != null && session.mUserAgent.isEmpty() == false) mSettings.setUserAgentString(session.mUserAgent); mWebView.loadUrl((session.mHTTPS ? "https" : "http") + "://www." + domain); } }
From source file:org.thomnichols.android.gmarks.WebViewCookiesDB.java
List<Cookie> getCookies() { List<Cookie> cookies = new ArrayList<Cookie>(); SQLiteDatabase db = openDatabase(SQLiteDatabase.OPEN_READONLY); if (db == null) return cookies; try {/*from w w w. j a v a 2s . c om*/ db.execSQL("PRAGMA read_uncommitted = true;"); Cursor cursor = db.query(TABLE_NAME, COLUMNS, null, null, null, null, null); while (cursor.moveToNext()) { BasicClientCookie c = new BasicClientCookie(cursor.getString(COL_NAME), cursor.getString(COL_VALUE)); c.setDomain(cursor.getString(COL_DOMAIN)); c.setPath(cursor.getString(COL_PATH)); Long expiry = cursor.getLong(COL_EXPIRES); if (expiry != null) c.setExpiryDate(new Date(expiry)); c.setSecure(cursor.getShort(COL_SECURE) == 1); Log.d(TAG, "Got cookie: " + c.getName()); cookies.add(c); } cursor.close(); // cursor = db.query(TABLE_NAME, new String[] {"count(name)"}, null, null, null, null, null); // cursor.moveToFirst(); // Log.d("WEBVIEW DB QUERY", "COunt: " + cursor.getLong(0) ); // cursor.close(); return cookies; } finally { db.close(); } }
From source file:com.feigdev.webcom.PersistentCookieStore.java
public void addCookie(String rawCookie, String url) throws Exception { ArrayList<BasicClientCookie> cookies = parseRawCookie(rawCookie, url); for (BasicClientCookie cookie : cookies) { if (Constants.VERBOSE) { Log.d("PersistentCookieStore", "adding cookie: " + cookie.getName() + "=" + cookie.getValue()); }/*from www . j a v a 2 s .co m*/ addCookie(cookie); } }
From source file:ti.modules.titanium.network.NetworkModule.java
/** * Adds a cookie to the system cookie store. Any existing cookie with the same domain, path and name will be replaced with * the new cookie. The cookie being set must not have expired, otherwise it will be ignored. * @param cookieProxy the cookie to add// w w w.j a v a 2s . com */ @Kroll.method public void addSystemCookie(CookieProxy cookieProxy) { BasicClientCookie cookie = cookieProxy.getHTTPCookie(); String cookieString = cookie.getName() + "=" + cookie.getValue(); String domain = cookie.getDomain(); if (domain == null) { Log.w(TAG, "Unable to add system cookie. Need to provide domain."); return; } cookieString += "; domain=" + domain; String path = cookie.getPath(); Date expiryDate = cookie.getExpiryDate(); boolean secure = cookie.isSecure(); boolean httponly = TiConvert.toBoolean(cookieProxy.getProperty(TiC.PROPERTY_HTTP_ONLY), false); if (path != null) { cookieString += "; path=" + path; } if (expiryDate != null) { cookieString += "; expires=" + CookieProxy.systemExpiryDateFormatter.format(expiryDate); } if (secure) { cookieString += "; secure"; } if (httponly) { cookieString += " httponly"; } CookieSyncManager.createInstance(TiApplication.getInstance().getRootOrCurrentActivity()); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie(domain, cookieString); CookieSyncManager.getInstance().sync(); }
From source file:immf.StatusManager.java
public void load() throws IOException { Properties prop = new Properties(); FileInputStream fis = null;//from w ww .j ava 2 s . c o m try { fis = new FileInputStream(this.f); prop.load(fis); this.lastMailId = prop.getProperty("lastmailid"); this.pushCredentials = prop.getProperty("push_credentials"); String nc = prop.getProperty("needconnect"); if (this.needConnect == null) { this.needConnect = nc; } if (this.needConnect != null && !this.needConnect.equals("1")) { this.needConnect = nc; } Enumeration<Object> enu = prop.keys(); List<Cookie> list = new ArrayList<Cookie>(); while (enu.hasMoreElements()) { String key = (String) enu.nextElement(); if (key.startsWith("cookie_")) { String cookieName = key.substring(7); String val = prop.getProperty(key); String[] params = val.split(";"); BasicClientCookie c = new BasicClientCookie(cookieName, params[0]); for (int i = 1; i < params.length; i++) { String[] nameval = params[i].split("="); if (nameval[0].equalsIgnoreCase("path")) { c.setPath(nameval[1]); } else if (nameval[0].equalsIgnoreCase("domain")) { c.setDomain(nameval[1]); } } c.setSecure(true); log.debug("Load Cookie [" + c.getName() + "]=[" + c.getValue() + "]"); list.add(c); } } this.cookies = list; } finally { Util.safeclose(fis); } }