|
@@ -1,15 +1,12 @@
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
-import android.app.Fragment;
|
|
|
|
import android.app.FragmentManager;
|
|
import android.app.FragmentManager;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
-import android.view.Menu;
|
|
|
|
-import android.view.MenuInflater;
|
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ExpandableListView;
|
|
import android.widget.ExpandableListView;
|
|
@@ -29,7 +26,6 @@ import java.util.Random;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
-import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
|
|
|
|
import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
|
|
import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
|
|
@@ -102,6 +98,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
|
|
|
|
dbh = new UglyDbHelper(this.getActivity().getBaseContext());
|
|
dbh = new UglyDbHelper(this.getActivity().getBaseContext());
|
|
|
|
|
|
|
|
+ //this.addRecordToDB(5, 2);
|
|
|
|
+
|
|
// Get the message from the intent
|
|
// Get the message from the intent
|
|
|
|
|
|
if (this.filter == null){
|
|
if (this.filter == null){
|
|
@@ -170,16 +168,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return rootView;
|
|
return rootView;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns the Fragment layout ID
|
|
|
|
+ * @return int The fragment layout ID
|
|
|
|
+ * */
|
|
public int getLayoutId(){
|
|
public int getLayoutId(){
|
|
return R.layout.fragment_record_list;
|
|
return R.layout.fragment_record_list;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
- super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Gets called if the user clicks on item in the filter menu.
|
|
|
|
+ *
|
|
|
|
+ * @param AbstractPopupItem item
|
|
|
|
+ * */
|
|
public void onFilterMenuItemSelected(AbstractPopupItem item) {
|
|
public void onFilterMenuItemSelected(AbstractPopupItem item) {
|
|
String title = item.getTitle();
|
|
String title = item.getTitle();
|
|
|
|
|
|
@@ -260,6 +261,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
*
|
|
*
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Reloads the data in the ExpandableListView for the given filter object.
|
|
|
|
+ * @param ExpandableListView listview
|
|
|
|
+ * */
|
|
private void populateListViewFromDB(ExpandableListView mylist) {
|
|
private void populateListViewFromDB(ExpandableListView mylist) {
|
|
|
|
|
|
HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
|
|
HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
|
|
@@ -320,25 +325,41 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
mylist.setAdapter(adapter);
|
|
mylist.setAdapter(adapter);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Thsi will open a section in the ExpandableListView with the same title as the parameter s.
|
|
|
|
+ *
|
|
|
|
+ * @param String s (the section title to open)
|
|
|
|
+ *
|
|
|
|
+ * */
|
|
private void setSectionToOpen(String s){
|
|
private void setSectionToOpen(String s){
|
|
this.sectionToOpen = s;
|
|
this.sectionToOpen = s;
|
|
if (this.sectionToOpen != null && this.sectionToOpen.length() != 0){
|
|
if (this.sectionToOpen != null && this.sectionToOpen.length() != 0){
|
|
- if (this.getGroupTitle().contains(this.sectionToOpen)){
|
|
|
|
- int section = this.getGroupTitle().indexOf(this.sectionToOpen);
|
|
|
|
|
|
+ if (this.getGroupTitles().contains(this.sectionToOpen)){
|
|
|
|
+ int section = this.getGroupTitles().indexOf(this.sectionToOpen);
|
|
this.expListView.expandGroup(section);
|
|
this.expListView.expandGroup(section);
|
|
this.sectionToOpen = "";
|
|
this.sectionToOpen = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns the base context.
|
|
|
|
+ * @return Context baseContext
|
|
|
|
+ * */
|
|
private Context getBaseContext(){
|
|
private Context getBaseContext(){
|
|
return this.getActivity().getBaseContext();
|
|
return this.getActivity().getBaseContext();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Returns the application context.
|
|
|
|
+ * @return Context application context
|
|
|
|
+ * */
|
|
private Context getApplicationContext(){
|
|
private Context getApplicationContext(){
|
|
return this.getActivity().getApplicationContext();
|
|
return this.getActivity().getApplicationContext();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Sets the list view listener on the given ExpandableListView.
|
|
|
|
+ *
|
|
|
|
+ * @param ExpandableListView listview
|
|
|
|
+ * */
|
|
private void registerListClickCallback(ExpandableListView mylist) {
|
|
private void registerListClickCallback(ExpandableListView mylist) {
|
|
mylist.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
|
mylist.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
|
@Override
|
|
@Override
|
|
@@ -378,6 +399,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
|
|
|
|
|
|
+ /*Returns the date format "H:mm d.M.yy" for the given timestamp (long)
|
|
|
|
+ * @param Long timestamp*/
|
|
@SuppressLint("SimpleDateFormat")
|
|
@SuppressLint("SimpleDateFormat")
|
|
private String getDateAsString(long timeStamp) {
|
|
private String getDateAsString(long timeStamp) {
|
|
|
|
|
|
@@ -414,26 +437,31 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
*
|
|
*
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
|
|
+ /*Opens the grouping dialog*/
|
|
private void openGroupingDialog(){
|
|
private void openGroupingDialog(){
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens the bssid filter dialog*/
|
|
private void openBSSIDFilterDialog(){
|
|
private void openBSSIDFilterDialog(){
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens the essid filter dialog*/
|
|
private void openESSIDFilterDialog(){
|
|
private void openESSIDFilterDialog(){
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens the protocol filter dialog*/
|
|
private void openProtocolsFilterDialog(){
|
|
private void openProtocolsFilterDialog(){
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens the timestamp filter dialog (minimal timestamp required)*/
|
|
private void openTimestampFromFilterDialog(){
|
|
private void openTimestampFromFilterDialog(){
|
|
this.wasBelowTimePicker = false;
|
|
this.wasBelowTimePicker = false;
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
@@ -441,6 +469,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
|
|
if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens time timestamp filter dialog (maximal timestamp required)*/
|
|
private void openTimestampToFilterDialog(){
|
|
private void openTimestampToFilterDialog(){
|
|
this.wasBelowTimePicker = true;
|
|
this.wasBelowTimePicker = true;
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
@@ -448,6 +477,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
|
|
if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*opens the sorting dialog*/
|
|
private void openSortingDialog(){
|
|
private void openSortingDialog(){
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTiles(), this.selectedSorttype(), false , this);
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTiles(), this.selectedSorttype(), false , this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
|
|
@@ -459,6 +489,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
*
|
|
*
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
|
|
+ /*returns the group title for the given record. Uses the groupingKey to decied which value of the record should be used.
|
|
|
|
+ * @param Record rec
|
|
|
|
+ * @return String grouptitle*/
|
|
public String getGroupValue(Record rec){
|
|
public String getGroupValue(Record rec){
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
switch (index){
|
|
switch (index){
|
|
@@ -473,7 +506,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public ArrayList<String> getGroupTitle(){
|
|
|
|
|
|
+ /*Returns the Group titles for the specified grouping key. e.g. groupingKey is "ESSID" it returns all available essids.
|
|
|
|
+ * @return ArrayList<String> grouptitles*/
|
|
|
|
+ public ArrayList<String> getGroupTitles(){
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
switch (index){
|
|
switch (index){
|
|
case 0:
|
|
case 0:
|
|
@@ -494,6 +529,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
*
|
|
*
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
|
|
+ /*Opens the filter menu on a anchor view. The filter menu will always be on top of the anchor.
|
|
|
|
+ * @param View anchorView*/
|
|
private void openFilterPopupMenuOnView(View v){
|
|
private void openFilterPopupMenuOnView(View v){
|
|
|
|
|
|
SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
@@ -529,6 +566,11 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
filterMenu.showOnView(v);
|
|
filterMenu.showOnView(v);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Returns true if the filter object is set for the given title otherwise false. e.g. the filter object has protocols,
|
|
|
|
+ * so the method will return for the title FILTER_MENU_TITLE_PROTOCOLS TRUE.
|
|
|
|
+ * @param String title
|
|
|
|
+ * @return boolean value
|
|
|
|
+ * */
|
|
private boolean isFilterSetForTitle(String title){
|
|
private boolean isFilterSetForTitle(String title){
|
|
if (title.equals(FILTER_MENU_TITLE_BSSID)){
|
|
if (title.equals(FILTER_MENU_TITLE_BSSID)){
|
|
return this.filter.hasBSSIDs();
|
|
return this.filter.hasBSSIDs();
|
|
@@ -548,11 +590,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*clears the filter. Does not invoke populatelistview!*/
|
|
private void clearFilter(){
|
|
private void clearFilter(){
|
|
if(filter == null) this.filter = new LogFilter();
|
|
if(filter == null) this.filter = new LogFilter();
|
|
this.filter.clear();
|
|
this.filter.clear();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Returns all grouping titles
|
|
|
|
+ * @param Context context
|
|
|
|
+ * @return ArrayList<String> titles*/
|
|
public ArrayList<String> groupingTitles(Context context){
|
|
public ArrayList<String> groupingTitles(Context context){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
for (String groupTitle : context.getResources().getStringArray(
|
|
for (String groupTitle : context.getResources().getStringArray(
|
|
@@ -561,6 +607,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
|
|
+ /*Returns all grouping titles.
|
|
|
|
+ * @return ArrayList<String> tiles*/
|
|
public ArrayList<String> groupingTitles(){
|
|
public ArrayList<String> groupingTitles(){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
for (String groupTitle : this.getResources().getStringArray(
|
|
for (String groupTitle : this.getResources().getStringArray(
|
|
@@ -569,6 +617,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
|
|
+ /*Returns a bool array. This array is true at the index of the groupingKey in groupingTitles(), otherwise false.
|
|
|
|
+ * @return boolean[] selection
|
|
|
|
+ * */
|
|
public boolean[] selectedGroup(){
|
|
public boolean[] selectedGroup(){
|
|
ArrayList<String> groups = this.groupingTitles();
|
|
ArrayList<String> groups = this.groupingTitles();
|
|
boolean[] selected = new boolean[groups.size()];
|
|
boolean[] selected = new boolean[groups.size()];
|
|
@@ -580,6 +631,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return selected;
|
|
return selected;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*Returns all protocol titles / names.
|
|
|
|
+ * @return ArrayList<String> protocolTitles
|
|
|
|
+ * */
|
|
public ArrayList<String> protocolTitles(){
|
|
public ArrayList<String> protocolTitles(){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
for (String protocol : this.getResources().getStringArray(
|
|
for (String protocol : this.getResources().getStringArray(
|
|
@@ -588,6 +642,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
|
|
+ /*Return a boolean array of the selected / filtered protocols. If the filter object has
|
|
|
|
+ * an protocol from the protocolTitles() array, the index of it will be true, otherwise false.
|
|
|
|
+ * @return boolean[] protocol selection
|
|
|
|
+ * */
|
|
public boolean[] selectedProtocols(){
|
|
public boolean[] selectedProtocols(){
|
|
ArrayList<String> protocols = this.protocolTitles();
|
|
ArrayList<String> protocols = this.protocolTitles();
|
|
boolean[] selected = new boolean[protocols.size()];
|
|
boolean[] selected = new boolean[protocols.size()];
|
|
@@ -600,18 +658,23 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return selected;
|
|
return selected;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns the Sorttype Titles
|
|
|
|
+ * @return ArayList<String> Sort type titles
|
|
|
|
+ * */
|
|
public ArrayList<String> sortTypeTiles(){
|
|
public ArrayList<String> sortTypeTiles(){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_time));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_time));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
|
|
- titles.add("BSSID");
|
|
|
|
- titles.add("ESSID");
|
|
|
|
- //titles.add("Remote Host Name");
|
|
|
|
- //titles.add("Local Host Name");
|
|
|
|
- //titles.add("Attack ID");
|
|
|
|
- //titles.add("ID");
|
|
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.BSSID));
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.ESSID));
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
|
|
+ /*
|
|
|
|
+ * Returns an boolean array. The array is true at the index of the selected sort type..
|
|
|
|
+ * The index of the selected sort type is the same index in the sortTypeTiles array.
|
|
|
|
+ * @return boolean array, length == sortTypeTiles().length
|
|
|
|
+ * */
|
|
public boolean[] selectedSorttype(){
|
|
public boolean[] selectedSorttype(){
|
|
ArrayList<String> types = this.sortTypeTiles();
|
|
ArrayList<String> types = this.sortTypeTiles();
|
|
boolean[] selected = new boolean[types.size()];
|
|
boolean[] selected = new boolean[types.size()];
|
|
@@ -623,10 +686,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return selected;
|
|
return selected;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns all unique bssids.
|
|
|
|
+ * @return ArrayList<String>
|
|
|
|
+ * */
|
|
public ArrayList<String> bssids(){
|
|
public ArrayList<String> bssids(){
|
|
ArrayList<String> records = dbh.getUniqueBSSIDRecords();
|
|
ArrayList<String> records = dbh.getUniqueBSSIDRecords();
|
|
return records;
|
|
return records;
|
|
}
|
|
}
|
|
|
|
+ /*
|
|
|
|
+ * Returns an boolean array. The array is true at the indices of the selected bssids.
|
|
|
|
+ * The index of the selected bssid is the same index in the bssids() array.
|
|
|
|
+ * @return boolean array, length == bssids().length
|
|
|
|
+ * */
|
|
public boolean[] selectedBSSIDs(){
|
|
public boolean[] selectedBSSIDs(){
|
|
ArrayList<String> bssids = this.bssids();
|
|
ArrayList<String> bssids = this.bssids();
|
|
boolean[] selected = new boolean[bssids.size()];
|
|
boolean[] selected = new boolean[bssids.size()];
|
|
@@ -639,11 +711,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return selected;
|
|
return selected;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns all unique essids.
|
|
|
|
+ * @return ArrayList<String>
|
|
|
|
+ * */
|
|
public ArrayList<String> essids(){
|
|
public ArrayList<String> essids(){
|
|
ArrayList<String> records = dbh.getUniqueESSIDRecords();
|
|
ArrayList<String> records = dbh.getUniqueESSIDRecords();
|
|
return records;
|
|
return records;
|
|
}
|
|
}
|
|
|
|
+ /*
|
|
|
|
+ * Returns an boolean array. The array is true at the indices of the selected essids.
|
|
|
|
+ * The index of the selected essid is the same index in the essids() array.
|
|
|
|
+ * @return boolean array, length == essids().length
|
|
|
|
+ * */
|
|
public boolean[] selectedESSIDs(){
|
|
public boolean[] selectedESSIDs(){
|
|
ArrayList<String> essids = this.essids();
|
|
ArrayList<String> essids = this.essids();
|
|
boolean[] selected = new boolean[essids.size()];
|
|
boolean[] selected = new boolean[essids.size()];
|
|
@@ -656,7 +736,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
return selected;
|
|
return selected;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Returns all filter menu titles.
|
|
|
|
+ * @return ArrayList<String>
|
|
|
|
+ * */
|
|
private ArrayList<String> filterMenuTitles(){
|
|
private ArrayList<String> filterMenuTitles(){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
titles.add(FILTER_MENU_TITLE_BSSID);
|
|
titles.add(FILTER_MENU_TITLE_BSSID);
|
|
@@ -733,9 +816,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
this.populateListViewFromDB(this.expListView);
|
|
this.populateListViewFromDB(this.expListView);
|
|
}
|
|
}
|
|
|
|
|
|
- public void onDialogNegativeClick(ChecklistDialog dialog) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ public void onDialogNegativeClick(ChecklistDialog dialog) {}
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
/*****************************
|
|
@@ -744,8 +825,13 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
*
|
|
*
|
|
* ***************************/
|
|
* ***************************/
|
|
|
|
|
|
- private void addRecordToDB() {
|
|
|
|
- if ((dbh.getRecordCount() > 0)) return;
|
|
|
|
|
|
+ /*
|
|
|
|
+ * This will clear the database at first and than add new attacks.
|
|
|
|
+ * @param int number of networks to create
|
|
|
|
+ * @param int maximal number of attack per network
|
|
|
|
+ * */
|
|
|
|
+ private void addRecordToDB( int createNetworks, int attacksPerNetwork) {
|
|
|
|
+ if ((dbh.getRecordCount() > 0)) dbh.clearData();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
@@ -756,44 +842,59 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
|
|
|
|
LatLng tudarmstadtLoc = new LatLng(49.86923, 8.6632768);
|
|
LatLng tudarmstadtLoc = new LatLng(49.86923, 8.6632768);
|
|
|
|
|
|
- final int numSSIDs = 10;
|
|
|
|
- final int numUniqueSSIDs = 6;
|
|
|
|
|
|
+
|
|
final double ssidRadius = 0.1;
|
|
final double ssidRadius = 0.1;
|
|
final double bssidRadius = 0.004;
|
|
final double bssidRadius = 0.004;
|
|
- int id = 0; // global id
|
|
|
|
- for (int ssid = 0; ssid < numSSIDs; ssid++) {
|
|
|
|
- LatLng ssidLocation = new LatLng(tudarmstadtLoc.latitude - ssidRadius + 2.0 * ssidRadius * Math.random(), tudarmstadtLoc.longitude - ssidRadius + 2.0 * ssidRadius * Math.random());
|
|
|
|
|
|
|
|
- String ssidName = "WiFi" + ((ssid % numUniqueSSIDs) + 1);
|
|
|
|
|
|
+ int id = 0;
|
|
|
|
|
|
- int numBSSIDs = (Math.abs(random.nextInt()) % 20) + 1;
|
|
|
|
- for (int bssid = 0; bssid < numBSSIDs; bssid++) {
|
|
|
|
- Record record = new Record();
|
|
|
|
- record.setId(id);
|
|
|
|
- record.setAttack_id(id);
|
|
|
|
- record.setBssid("BSSID" + id);
|
|
|
|
- id++;
|
|
|
|
|
|
+ for (int numOfNetworks = 0; numOfNetworks < createNetworks; numOfNetworks++){
|
|
|
|
+ String ssidName = "WiFi" + ((numOfNetworks) + 1);
|
|
|
|
+ String bssidName = "127.0.0." + ((numOfNetworks) + 1);
|
|
|
|
|
|
- record.setSsid(ssidName);
|
|
|
|
- record.setTimestamp(cal.getTimeInMillis()
|
|
|
|
- + ((id * 60 * 60 * 60 * 24) * 1000));
|
|
|
|
|
|
+ int protocolIndex = numOfNetworks % maxProtocolsIndex;
|
|
|
|
+ String protocolName = this.getResources().getStringArray(
|
|
|
|
+ R.array.protocols)[protocolIndex];
|
|
|
|
|
|
- int index = id % maxProtocolsIndex;
|
|
|
|
- String protocolName = this.getResources().getStringArray(
|
|
|
|
- R.array.protocols)[index];
|
|
|
|
|
|
+ int numOfAttackPerNetwork = (Math.abs(random.nextInt()) % attacksPerNetwork) + 1;
|
|
|
|
|
|
- record.setProtocol(protocolName);
|
|
|
|
|
|
+ // ATTACKS PER NETWORK
|
|
|
|
+ for (int attack = 0; attack < numOfAttackPerNetwork; attack++) {
|
|
|
|
+ LatLng ssidLocation = new LatLng(tudarmstadtLoc.latitude - ssidRadius + 2.0 * ssidRadius * Math.random(), tudarmstadtLoc.longitude - ssidRadius + 2.0 * ssidRadius * Math.random());
|
|
|
|
|
|
- record.setLocalIP("127.0.0.1");
|
|
|
|
- record.setType(TYPE.SEND);
|
|
|
|
|
|
+ int numRecordsPerAttack = (Math.abs(random.nextInt()) % 5) + 1;
|
|
|
|
|
|
- record.setLatitude(
|
|
|
|
- ssidLocation.latitude - bssidRadius + 2.0 * bssidRadius * Math.random());
|
|
|
|
- record.setLongitude(ssidLocation.longitude - bssidRadius + 2.0 * bssidRadius * Math.random());
|
|
|
|
|
|
+ double latitude = ssidLocation.latitude - bssidRadius + 2.0 * bssidRadius * Math.random();
|
|
|
|
+ double longitude = ssidLocation.longitude - bssidRadius + 2.0 * bssidRadius * Math.random();
|
|
|
|
|
|
- dbh.addRecord(record);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // RECORDS PER ATTACK
|
|
|
|
+ for (int recC = id; recC < id + numRecordsPerAttack; recC++) {
|
|
|
|
+ Record record = new Record();
|
|
|
|
+ record.setId(recC);
|
|
|
|
+ record.setAttack_id(id);
|
|
|
|
+
|
|
|
|
+ record.setSsid(ssidName);
|
|
|
|
+ record.setBssid(bssidName);
|
|
|
|
+
|
|
|
|
+ // GO BACK IN TIME
|
|
|
|
+ record.setTimestamp(cal.getTimeInMillis()
|
|
|
|
+ - ((recC * 60 * 60 * 24) * 1000) + (1000 * ((recC - id) + 1)));
|
|
|
|
+
|
|
|
|
+ record.setProtocol(protocolName);
|
|
|
|
+ record.setLocalIP(bssidName);
|
|
|
|
+ record.setType(Record.TYPE.SEND);
|
|
|
|
+
|
|
|
|
+ record.setLatitude(latitude);
|
|
|
|
+ record.setLongitude(longitude);
|
|
|
|
+
|
|
|
|
+ dbh.addRecord(record);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ id+=numRecordsPerAttack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
int countAllLogs = dbh.getAllRecords().size();
|
|
int countAllLogs = dbh.getAllRecords().size();
|
|
int countRecords = dbh.getRecordCount();
|
|
int countRecords = dbh.getRecordCount();
|
|
@@ -803,14 +904,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
Record rec = dbh.getRecordOfAttackId(0);
|
|
Record rec = dbh.getRecordOfAttackId(0);
|
|
Record rec2 = dbh.getRecord(0);
|
|
Record rec2 = dbh.getRecord(0);
|
|
|
|
|
|
-
|
|
|
|
System.out.println("" + "Could not create logs!");
|
|
System.out.println("" + "Could not create logs!");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /*Navigation*/
|
|
|
|
|
|
+ /*Navigation. Shows the record detail view for the given record
|
|
|
|
+ * @param Record record to show
|
|
|
|
+ * */
|
|
private void pushRecordDetailViewForRecord(Record record){
|
|
private void pushRecordDetailViewForRecord(Record record){
|
|
|
|
|
|
FragmentManager fm = this.getActivity().getFragmentManager();
|
|
FragmentManager fm = this.getActivity().getFragmentManager();
|