Hostage.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. package de.tudarmstadt.informatik.hostage;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.net.Socket;
  5. import java.security.SecureRandom;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.LinkedList;
  9. import java.util.List;
  10. import org.apache.http.HttpEntity;
  11. import org.apache.http.HttpResponse;
  12. import org.apache.http.client.HttpClient;
  13. import org.apache.http.client.methods.HttpGet;
  14. import org.apache.http.impl.client.DefaultHttpClient;
  15. import org.apache.http.util.EntityUtils;
  16. import org.json.JSONObject;
  17. import android.app.NotificationManager;
  18. import android.app.PendingIntent;
  19. import android.app.Service;
  20. import android.content.BroadcastReceiver;
  21. import android.content.Context;
  22. import android.content.Intent;
  23. import android.content.IntentFilter;
  24. import android.content.SharedPreferences;
  25. import android.content.SharedPreferences.Editor;
  26. import android.net.ConnectivityManager;
  27. import android.net.Uri;
  28. import android.os.AsyncTask;
  29. import android.os.Binder;
  30. import android.os.IBinder;
  31. import android.preference.PreferenceManager;
  32. import android.support.v4.app.NotificationCompat;
  33. import android.support.v4.app.TaskStackBuilder;
  34. import android.support.v4.content.LocalBroadcastManager;
  35. import android.util.Log;
  36. import android.widget.Toast;
  37. import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
  38. import de.tudarmstadt.informatik.hostage.location.MyLocationManager;
  39. import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
  40. import de.tudarmstadt.informatik.hostage.protocol.HTTP;
  41. import de.tudarmstadt.informatik.hostage.protocol.Protocol;
  42. import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
  43. /**
  44. * Background service running as long as at least one protocol is active.
  45. * Service controls start and stop of protocol listener. Notifies GUI about
  46. * events happening in the background. Creates Notifications to inform the user
  47. * what it happening.
  48. *
  49. * @author Mihai Plasoianu
  50. * @author Lars Pandikow
  51. * @author Wulf Pfeiffer
  52. */
  53. public class Hostage extends Service {
  54. private HashMap<String, Boolean> mProtocolActiveAttacks;
  55. public class LocalBinder extends Binder {
  56. public Hostage getService() {
  57. return Hostage.this;
  58. }
  59. }
  60. /**
  61. * Task for accuiring a qotd from one of four possible servers.
  62. *
  63. * @author Wulf Pfeiffer
  64. */
  65. private class QotdTask extends AsyncTask<String, Void, String> {
  66. @Override
  67. protected String doInBackground(String... unused) {
  68. String[] sources = new String[] { "djxmmx.net", "ota.iambic.com", "alpha.mike-r.com", "electricbiscuit.org" };
  69. SecureRandom rndm = new SecureRandom();
  70. StringBuffer sb = new StringBuffer();
  71. try {
  72. Socket client = new Socket(sources[rndm.nextInt(4)], 17);
  73. BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
  74. while (!in.ready())
  75. ;
  76. while (in.ready()) {
  77. sb.append(in.readLine());
  78. }
  79. in.close();
  80. client.close();
  81. } catch (Exception e) {
  82. e.printStackTrace();
  83. }
  84. return sb.toString();
  85. }
  86. @Override
  87. protected void onPostExecute(String result) {
  88. if (result != null)
  89. HTTP.setHtmlDocumentContent(result);
  90. }
  91. }
  92. /**
  93. * Task to find out the external IP.
  94. *
  95. * @author Lars Pandikow
  96. */
  97. private class SetExternalIPTask extends AsyncTask<String, Void, String> {
  98. @Override
  99. protected String doInBackground(String... url) {
  100. String ipAddress = null;
  101. try {
  102. HttpClient httpclient = new DefaultHttpClient();
  103. HttpGet httpget = new HttpGet(url[0]);
  104. HttpResponse response;
  105. response = httpclient.execute(httpget);
  106. HttpEntity entity = response.getEntity();
  107. entity.getContentLength();
  108. String str = EntityUtils.toString(entity);
  109. JSONObject json_data = new JSONObject(str);
  110. ipAddress = json_data.getString("ip");
  111. } catch (Exception e) {
  112. e.printStackTrace();
  113. }
  114. return ipAddress;
  115. }
  116. @Override
  117. protected void onPostExecute(String result) {
  118. connectionInfoEditor.putString(getString(R.string.connection_info_external_ip), result);
  119. connectionInfoEditor.commit();
  120. notifyUI(this.getClass().getName(), new String[] { getString(R.string.broadcast_connectivity) });
  121. }
  122. }
  123. private static Context context;
  124. /**
  125. * Returns the application context.
  126. *
  127. * @return context.
  128. */
  129. public static Context getContext() {
  130. return Hostage.context;
  131. }
  132. private LinkedList<Protocol> implementedProtocols;
  133. private ArrayList<Listener> listeners = new ArrayList<Listener>();
  134. private NotificationCompat.Builder builder;
  135. private SharedPreferences connectionInfo;
  136. private Editor connectionInfoEditor;
  137. private final IBinder mBinder = new LocalBinder();
  138. /**
  139. * Receiver for connectivity change broadcast.
  140. *
  141. * @see MainActivity#BROADCAST
  142. */
  143. private BroadcastReceiver netReceiver = new BroadcastReceiver() {
  144. @Override
  145. public void onReceive(Context context, Intent intent) {
  146. String bssid_old = connectionInfo.getString(getString(R.string.connection_info_bssid), "");
  147. String bssid_new = HelperUtils.getBSSID(context);
  148. if (bssid_new == null || !bssid_new.equals(bssid_old)) {
  149. deleteConnectionData();
  150. updateConnectionInfo();
  151. getLocationData();
  152. notifyUI(this.getClass().getName(), new String[] { getString(R.string.broadcast_connectivity) });
  153. }
  154. }
  155. };
  156. public List<Listener> getListeners() {
  157. return listeners;
  158. }
  159. /**
  160. * Determines the number of active connections for a protocol running on its
  161. * default port.
  162. *
  163. * @param protocolName
  164. * The protocol name
  165. * @return Number of active connections
  166. */
  167. public int getNumberOfActiveConnections(String protocolName) {
  168. int port = getDefaultPort(protocolName);
  169. return getNumberOfActiveConnections(protocolName, port);
  170. }
  171. /**
  172. * Determines the number of active connections for a protocol running on the
  173. * given port.
  174. *
  175. * @param protocolName
  176. * The protocol name
  177. * @param port
  178. * Specific port
  179. * @return Number of active connections
  180. */
  181. public int getNumberOfActiveConnections(String protocolName, int port) {
  182. for (Listener listener : listeners) {
  183. if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
  184. return listener.getHandlerCount();
  185. }
  186. }
  187. return 0;
  188. }
  189. /**
  190. * Determines if there any listener is currently running.
  191. *
  192. * @return True if there is a running listener, else false.
  193. */
  194. public boolean hasRunningListeners() {
  195. for (Listener listener : listeners) {
  196. if (listener.isRunning())
  197. return true;
  198. }
  199. return false;
  200. }
  201. /**
  202. * Determines if a protocol with the given name is running on its default
  203. * port.
  204. *
  205. * @param protocolName
  206. * The protocol name
  207. * @return True if protocol is running, else false.
  208. */
  209. public boolean isRunning(String protocolName) {
  210. int port = getDefaultPort(protocolName);
  211. return isRunning(protocolName, port);
  212. }
  213. public boolean isRunningAnyPort(String protocolName){
  214. for(Listener listener: listeners){
  215. if(listener.getProtocolName().equals(protocolName)){
  216. if(listener.isRunning()) return true;
  217. }
  218. }
  219. return false;
  220. }
  221. /**
  222. * Determines if a protocol with the given name is running on the given
  223. * port.
  224. *
  225. * @param protocolName
  226. * The protocol name
  227. * @param port
  228. * Specific port
  229. * @return True if protocol is running, else false.
  230. */
  231. public boolean isRunning(String protocolName, int port) {
  232. for (Listener listener : listeners) {
  233. if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
  234. return listener.isRunning();
  235. }
  236. }
  237. return false;
  238. }
  239. /**
  240. * Notifies the GUI about a event.
  241. *
  242. * @param sender
  243. * Source where the event took place.
  244. * @param key
  245. * Detailed information about the event.
  246. */
  247. public void notifyUI(String sender, String[] values) {
  248. createNotification();
  249. // Send Notification
  250. if (sender.equals(Handler.class.getName()) && values[0].equals(getString(R.string.broadcast_started))) {
  251. this.mProtocolActiveAttacks.put(values[1], true);
  252. attackNotification();
  253. }
  254. // Inform UI of Preference Change
  255. Intent intent = new Intent(getString(R.string.broadcast));
  256. intent.putExtra("SENDER", sender);
  257. intent.putExtra("VALUES", values);
  258. Log.i("Sender", sender);
  259. LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
  260. }
  261. @Override
  262. public IBinder onBind(Intent intent) {
  263. return mBinder;
  264. }
  265. @Override
  266. public void onCreate() {
  267. super.onCreate();
  268. Hostage.context = getApplicationContext();
  269. implementedProtocols = getImplementedProtocols();
  270. connectionInfo = getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
  271. connectionInfoEditor = connectionInfo.edit();
  272. mProtocolActiveAttacks = new HashMap<String, Boolean>();
  273. createNotification();
  274. registerNetReceiver();
  275. updateConnectionInfo();
  276. getLocationData();
  277. boolean useQotd = context.getSharedPreferences(getString(R.string.shared_preference_path), Hostage.MODE_PRIVATE).getBoolean("useQotd", true);
  278. if (useQotd) {
  279. new QotdTask().execute(new String[] {});
  280. }
  281. }
  282. @Override
  283. public void onDestroy() {
  284. cancelNotification();
  285. unregisterNetReceiver();
  286. super.onDestroy();
  287. }
  288. @Override
  289. public int onStartCommand(Intent intent, int flags, int startId) {
  290. // We want this service to continue running until it is explicitly
  291. // stopped, so return sticky.
  292. return START_STICKY;
  293. }
  294. /**
  295. * Starts the listener for the specified protocol. Creates a new
  296. * HoneyService if no matching HoneyListener is found.
  297. *
  298. * @param protocolName
  299. * Name of the protocol that should be started.
  300. */
  301. public boolean startListener(String protocolName) {
  302. return startListener(protocolName, getDefaultPort(protocolName));
  303. }
  304. /**
  305. * Starts the listener for the specified protocol and port. Creates a new
  306. * HoneyService if no matching HoneyListener is found.
  307. *
  308. * @param protocolName
  309. * Name of the protocol that should be started.
  310. * @param port
  311. * The port number in which the listener should run.
  312. */
  313. public boolean startListener(String protocolName, int port) {
  314. for (Listener listener : listeners) {
  315. if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
  316. if (!listener.isRunning()) {
  317. if (listener.start()) {
  318. // Toast.makeText(getApplicationContext(), protocolName
  319. // + " SERVICE STARTED!", Toast.LENGTH_SHORT).show();
  320. return true;
  321. }
  322. Toast.makeText(getApplicationContext(), protocolName + " SERVICE COULD NOT BE STARTED!", Toast.LENGTH_SHORT).show();
  323. return false;
  324. }
  325. }
  326. }
  327. Listener listener = createListener(protocolName, port);
  328. if (listener != null) {
  329. if (listener.start()) {
  330. // Toast.makeText(getApplicationContext(), protocolName +
  331. // " SERVICE STARTED!", Toast.LENGTH_SHORT).show();
  332. return true;
  333. }
  334. }
  335. Toast.makeText(getApplicationContext(), protocolName + " SERVICE COULD NOT BE STARTED!", Toast.LENGTH_SHORT).show();
  336. return false;
  337. }
  338. /**
  339. * Starts all listeners which are not already running.
  340. */
  341. public void startListeners() {
  342. for (Listener listener : listeners) {
  343. if (!listener.isRunning()) {
  344. listener.start();
  345. }
  346. }
  347. // Toast.makeText(getApplicationContext(), "SERVICES STARTED!",
  348. // Toast.LENGTH_SHORT).show();
  349. }
  350. /**
  351. * Stops the listener for the specified protocol.
  352. *
  353. * @param protocolName
  354. * Name of the protocol that should be stopped.
  355. */
  356. public void stopListener(String protocolName) {
  357. stopListener(protocolName, getDefaultPort(protocolName));
  358. }
  359. /**
  360. * Stops the listener for the specified protocol.
  361. *
  362. * @param protocolName
  363. * Name of the protocol that should be stopped.
  364. * @param port
  365. * The port number in which the listener is running.
  366. */
  367. public void stopListener(String protocolName, int port) {
  368. for (Listener listener : listeners) {
  369. if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
  370. if (listener.isRunning()) {
  371. listener.stop();
  372. mProtocolActiveAttacks.remove(protocolName);
  373. }
  374. }
  375. }
  376. // Toast.makeText(getApplicationContext(), protocolName +
  377. // " SERVICE STOPPED!", Toast.LENGTH_SHORT).show();
  378. }
  379. public void stopListenerAllPorts(String protocolName){
  380. for(Listener listener: listeners){
  381. if(listener.getProtocolName().equals(protocolName)){
  382. if(listener.isRunning()){
  383. listener.stop();
  384. mProtocolActiveAttacks.remove(protocolName);
  385. }
  386. }
  387. }
  388. }
  389. /**
  390. * Stops all running listeners.
  391. */
  392. public void stopListeners() {
  393. for (Listener listener : listeners) {
  394. if (listener.isRunning()) {
  395. listener.stop();
  396. mProtocolActiveAttacks.remove(listener.getProtocolName());
  397. }
  398. }
  399. // Toast.makeText(getApplicationContext(), "SERVICES STOPPED!",
  400. // Toast.LENGTH_SHORT).show();
  401. }
  402. /**
  403. * Updates the notification when a attack is registered.
  404. */
  405. private void attackNotification() {
  406. SharedPreferences defaultPref = PreferenceManager.getDefaultSharedPreferences(this);
  407. String strRingtonePreference = defaultPref.getString("pref_notification_sound", "content://settings/system/notification_sound");
  408. builder = new NotificationCompat.Builder(this).setContentTitle(getString(R.string.app_name)).setTicker("Honeypot under attack!")
  409. .setContentText("Honeypot under attack!").setSmallIcon(R.drawable.ic_service_red).setAutoCancel(true).setWhen(System.currentTimeMillis())
  410. .setSound(Uri.parse(strRingtonePreference));
  411. Intent launchIntent = new Intent(getApplicationContext(), MainActivity.class);
  412. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
  413. stackBuilder.addParentStack(MainActivity.class);
  414. Intent intent = MainActivity.getInstance().getIntent();
  415. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  416. intent.setAction("SHOW_HOME");
  417. stackBuilder.addNextIntent(intent);
  418. PendingIntent resultPendingIntent = PendingIntent.getActivity(MainActivity.context, 0, intent, 0);
  419. builder.setContentIntent(resultPendingIntent);
  420. if (defaultPref.getBoolean("pref_vibration", false)) {
  421. builder.setVibrate(new long[] { 100, 200, 100, 200 });
  422. }
  423. NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  424. mNotificationManager.notify(1, builder.build());
  425. }
  426. /**
  427. * Cancels the Notification
  428. */
  429. private void cancelNotification() {
  430. NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  431. mNotificationManager.cancel(1);
  432. }
  433. /**
  434. * Creates a HoneyListener for a given protocol on a specific port. After
  435. * creation the HoneyListener is not started. Checks if the protocol is
  436. * implemented first.
  437. *
  438. * @param protocolName
  439. * Name of the protocol
  440. * @param port
  441. * Port on which to start the HoneyListener
  442. * @return Returns the created HoneyListener, if creation failed returns
  443. * null.
  444. */
  445. private Listener createListener(String protocolName, int port) {
  446. for (Protocol protocol : implementedProtocols) {
  447. if (protocolName.equals(protocol.toString())) {
  448. Listener listener = new Listener(this, protocol, port);
  449. listeners.add(listener);
  450. return listener;
  451. }
  452. }
  453. return null;
  454. }
  455. /**
  456. * Creates a Notification in the notification bar.
  457. */
  458. private void createNotification() {
  459. HostageDBOpenHelper dbh = new HostageDBOpenHelper(this);
  460. boolean activeHandlers = false;
  461. boolean bssidSeen = false;
  462. boolean listening = false;
  463. for (Listener listener : listeners) {
  464. if (listener.isRunning())
  465. listening = true;
  466. if (listener.getHandlerCount() > 0) {
  467. activeHandlers = true;
  468. }
  469. if (dbh.bssidSeen(listener.getProtocolName(), HelperUtils.getBSSID(getApplicationContext()))) {
  470. bssidSeen = true;
  471. }
  472. }
  473. builder = new NotificationCompat.Builder(this).setContentTitle(getString(R.string.app_name)).setWhen(System.currentTimeMillis());
  474. if (!listening) {
  475. builder.setSmallIcon(R.drawable.ic_launcher);
  476. builder.setContentText("HosTaGe is not active.");
  477. } else if (activeHandlers) {
  478. builder.setSmallIcon(R.drawable.ic_service_red);
  479. builder.setContentText("Network is infected!");
  480. } else if (bssidSeen) {
  481. builder.setSmallIcon(R.drawable.ic_service_yellow);
  482. builder.setContentText("Network has been infected in previous session!");
  483. } else {
  484. builder.setSmallIcon(R.drawable.ic_service_green);
  485. builder.setContentText("Everything looks fine!");
  486. }
  487. Intent launchIntent = new Intent(getApplicationContext(), MainActivity.class);
  488. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
  489. stackBuilder.addParentStack(MainActivity.class);
  490. Intent intent = MainActivity.getInstance().getIntent();
  491. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  492. intent.setAction("SHOW_HOME");
  493. stackBuilder.addNextIntent(intent);
  494. PendingIntent resultPendingIntent = PendingIntent.getActivity(MainActivity.context, 0, intent, 0); //stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
  495. builder.setContentIntent(resultPendingIntent);
  496. builder.setOngoing(true);
  497. NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  498. mNotificationManager.notify(1, builder.build());
  499. }
  500. /**
  501. * Deletes all session related data.
  502. */
  503. private void deleteConnectionData() {
  504. connectionInfoEditor.clear();
  505. connectionInfoEditor.commit();
  506. }
  507. /**
  508. * Returns the default port number, if the protocol is implemented.
  509. *
  510. * @param protocolName
  511. * The name of the protocol
  512. * @return Returns the default port number, if the protocol is implemented.
  513. * Else returns -1.
  514. */
  515. private int getDefaultPort(String protocolName) {
  516. for (Protocol protocol : implementedProtocols) {
  517. if (protocolName.equals(protocol.toString())) {
  518. return protocol.getPort();
  519. }
  520. }
  521. return -1;
  522. };
  523. /**
  524. * Returns an LinkedList<String> with the names of all implemented
  525. * protocols.
  526. *
  527. * @return ArrayList of
  528. * {@link de.tudarmstadt.informatik.hostage.protocol.Protocol
  529. * Protocol}
  530. */
  531. private LinkedList<Protocol> getImplementedProtocols() {
  532. String[] protocols = getResources().getStringArray(R.array.protocols);
  533. String packageName = Protocol.class.getPackage().getName();
  534. LinkedList<Protocol> implementedProtocols = new LinkedList<Protocol>();
  535. for (String protocol : protocols) {
  536. try {
  537. implementedProtocols.add((Protocol) Class.forName(String.format("%s.%s", packageName, protocol)).newInstance());
  538. } catch (Exception e) {
  539. e.printStackTrace();
  540. }
  541. }
  542. return implementedProtocols;
  543. }
  544. /**
  545. * Starts an Instance of MyLocationManager to set the location within this
  546. * class.
  547. */
  548. private void getLocationData() {
  549. MyLocationManager locationManager = new MyLocationManager(this);
  550. locationManager.getUpdates(60 * 1000, 3);
  551. };
  552. // Notifications
  553. /**
  554. * Register broadcast receiver for connectivity changes
  555. */
  556. private void registerNetReceiver() {
  557. // register BroadcastReceiver on network state changes
  558. IntentFilter intent = new IntentFilter();
  559. intent.addAction(ConnectivityManager.CONNECTIVITY_ACTION); // "android.net.conn.CONNECTIVITY_CHANGE"
  560. registerReceiver(netReceiver, intent);
  561. }
  562. /**
  563. * Unregister broadcast receiver for connectivity changes
  564. */
  565. private void unregisterNetReceiver() {
  566. unregisterReceiver(netReceiver);
  567. }
  568. public boolean hasProtocolActiveAttacks(String protocol){
  569. if(!mProtocolActiveAttacks.containsKey(protocol)) return false;
  570. return mProtocolActiveAttacks.get(protocol);
  571. }
  572. public boolean hasActiveAttacks(){
  573. for(boolean b: mProtocolActiveAttacks.values()){
  574. if(b) return true;
  575. }
  576. return false;
  577. }
  578. /**
  579. * Updates the connection info and saves them in the the SharedPreferences
  580. * for session data.
  581. *
  582. * @param context
  583. * Needs a context to get system recourses.
  584. * @see MainActivity#CONNECTION_INFO
  585. */
  586. private void updateConnectionInfo() {
  587. SharedPreferences pref = context.getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
  588. Editor editor = pref.edit();
  589. editor.putString(getString(R.string.connection_info_ssid), HelperUtils.getSSID(context));
  590. editor.putString(getString(R.string.connection_info_bssid), HelperUtils.getBSSID(context));
  591. editor.putString(getString(R.string.connection_info_internal_ip), HelperUtils.getInternalIP(context));
  592. editor.commit();
  593. SetExternalIPTask async = new SetExternalIPTask();
  594. async.execute(new String[] { "http://ip2country.sourceforge.net/ip2c.php?format=JSON" });
  595. this.mProtocolActiveAttacks.clear();
  596. }
  597. }