|
@@ -262,6 +262,8 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
attackValues.put(AttackEntry.COLUMN_NAME_REMOTE_PORT, record.getRemotePort()); // Log Remote Port
|
|
|
attackValues.put(AttackEntry.COLUMN_NAME_INTERNAL_ATTACK, record.getWasInternalAttack());
|
|
|
attackValues.put(AttackEntry.COLUMN_NAME_BSSID, record.getBssid());
|
|
|
+ attackValues.put(AttackEntry.COLUMN_NAME_DEVICE, record.getDevice());
|
|
|
+ attackValues.put(AttackEntry.COLUMN_NAME_SYNC_ID, record.getSync_id());
|
|
|
|
|
|
// Inserting Rows
|
|
|
db.insertWithOnConflict(AttackEntry.TABLE_NAME, null, attackValues, SQLiteDatabase.CONFLICT_REPLACE);
|
|
@@ -1252,7 +1254,8 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
record.setWasInternalAttack(Integer.parseInt(cursor.getString(11)) == 1);
|
|
|
|
|
|
record.setBssid(cursor.getString(12));
|
|
|
-
|
|
|
+ record.setDevice(cursor.getString(13));
|
|
|
+ record.setSync_ID(cursor.getLong(14));
|
|
|
record.setSsid(cursor.getString(15));
|
|
|
record.setLatitude(Double.parseDouble(cursor.getString(16)));
|
|
|
record.setLongitude(Double.parseDouble(cursor.getString(17)));
|
|
@@ -1862,49 +1865,6 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
return ids;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns all new {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}s for the given devices (including all missing devices).
|
|
|
- * @param devices {@link de.tudarmstadt.informatik.hostage.logging.SyncDevice}
|
|
|
- * @param includeMissingDevices boolean
|
|
|
- * @return list of {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}s
|
|
|
- */
|
|
|
- public ArrayList<SyncRecord> getUnsyncedAttacksFor(List<SyncDevice> devices, boolean includeMissingDevices){
|
|
|
-
|
|
|
- ArrayList<SyncDevice> updatedDevices = this.getUpdatedDevicesFor(devices, includeMissingDevices);
|
|
|
-
|
|
|
- ArrayList<SyncRecord> recordList = new ArrayList<SyncRecord>();
|
|
|
-
|
|
|
- SQLiteDatabase db = this.getReadableDatabase();
|
|
|
-
|
|
|
- for (SyncDevice sDevice : updatedDevices){
|
|
|
- String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A " + " , " + PacketEntry.TABLE_NAME + " P "
|
|
|
- + " WHERE "
|
|
|
- + " ( "
|
|
|
- + "A." + AttackEntry.COLUMN_NAME_ATTACK_ID + " = " + " P."+ PacketEntry.COLUMN_NAME_ATTACK_ID
|
|
|
- + " AND " + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + sDevice.getDeviceID() + "'"
|
|
|
- + " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + sDevice.getHighest_attack_id()
|
|
|
- + " ) "
|
|
|
- //+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE
|
|
|
- + " ORDER BY " + "A" + "." + AttackEntry.COLUMN_NAME_SYNC_ID + " DESC ";
|
|
|
- Cursor cursor = db.rawQuery(selectQuery, null);
|
|
|
-
|
|
|
- // looping through all rows and adding to list
|
|
|
- if (cursor != null){
|
|
|
- if (cursor.moveToFirst()) {
|
|
|
- do {
|
|
|
- SyncRecord record = createSyncRecord(cursor);
|
|
|
- recordList.add(record);
|
|
|
- } while (cursor.moveToNext());
|
|
|
- }
|
|
|
- cursor.close();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // return record list
|
|
|
- db.close();
|
|
|
- return recordList;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* Returns all new {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}s for the given devices (including all missing devices).
|
|
@@ -1921,12 +1881,14 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
|
|
|
for (SyncDevice sDevice : updatedDevices){
|
|
|
- String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A " + " , " + PacketEntry.TABLE_NAME + " P "
|
|
|
+ String deviceID = sDevice.getDeviceID();
|
|
|
+ Long maxID = deviceMap.get(deviceID);
|
|
|
+ String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A " + " NATURAL JOIN " + PacketEntry.TABLE_NAME + " P "
|
|
|
+ " WHERE "
|
|
|
+" ( "
|
|
|
+ "A." + AttackEntry.COLUMN_NAME_ATTACK_ID + " = " + " P."+ PacketEntry.COLUMN_NAME_ATTACK_ID
|
|
|
- + " AND " + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + sDevice.getDeviceID() + "'"
|
|
|
- + " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + sDevice.getHighest_attack_id()
|
|
|
+ + " AND " + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + deviceID + "'"
|
|
|
+ + " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + maxID
|
|
|
+ " ) "
|
|
|
//+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE
|
|
|
+ " ORDER BY " + " A" + "." + AttackEntry.COLUMN_NAME_SYNC_ID + " DESC ";
|