|
@@ -237,7 +237,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
* @param record
|
|
* @param record
|
|
* The added {@link MessageRecord} .
|
|
* The added {@link MessageRecord} .
|
|
*/
|
|
*/
|
|
- public void addMessageRecord(MessageRecord record) {
|
|
|
|
|
|
+ synchronized public void addMessageRecord(MessageRecord record) {
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
|
|
|
|
this.insertMessageRecordWithOnConflict(record, db);
|
|
this.insertMessageRecordWithOnConflict(record, db);
|
|
@@ -250,7 +250,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
* @param records {@link List}<MessageRecord>
|
|
* @param records {@link List}<MessageRecord>
|
|
* The added {@link de.tudarmstadt.informatik.hostage.logging.MessageRecord}s .
|
|
* The added {@link de.tudarmstadt.informatik.hostage.logging.MessageRecord}s .
|
|
*/
|
|
*/
|
|
- public void insertMessageRecords(List<MessageRecord> records){
|
|
|
|
|
|
+ synchronized public void insertMessageRecords(List<MessageRecord> records){
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
db.beginTransaction();
|
|
db.beginTransaction();
|
|
|
|
|
|
@@ -270,7 +270,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void insertMessageRecordWithOnConflict(MessageRecord record, SQLiteDatabase db){
|
|
|
|
|
|
+ synchronized private void insertMessageRecordWithOnConflict(MessageRecord record, SQLiteDatabase db){
|
|
ContentValues recordValues = new ContentValues();
|
|
ContentValues recordValues = new ContentValues();
|
|
recordValues.put(PacketEntry.COLUMN_NAME_ID, record.getId()); // Log Message Number
|
|
recordValues.put(PacketEntry.COLUMN_NAME_ID, record.getId()); // Log Message Number
|
|
recordValues.put(PacketEntry.COLUMN_NAME_ATTACK_ID, record.getAttack_id()); // Log Attack ID
|
|
recordValues.put(PacketEntry.COLUMN_NAME_ATTACK_ID, record.getAttack_id()); // Log Attack ID
|
|
@@ -288,7 +288,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
* @param record
|
|
* @param record
|
|
* The added {@link AttackRecord} .
|
|
* The added {@link AttackRecord} .
|
|
*/
|
|
*/
|
|
- public void addAttackRecord(AttackRecord record) {
|
|
|
|
|
|
+ synchronized public void addAttackRecord(AttackRecord record) {
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
this.insertAttackRecordWithOnConflict(record,db);
|
|
this.insertAttackRecordWithOnConflict(record,db);
|
|
@@ -304,7 +304,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
* @param records {@link List}<AttackRecord>
|
|
* @param records {@link List}<AttackRecord>
|
|
* The added {@link AttackRecord}s .
|
|
* The added {@link AttackRecord}s .
|
|
*/
|
|
*/
|
|
- public void insertAttackRecords(List<AttackRecord> records) {
|
|
|
|
|
|
+ synchronized public void insertAttackRecords(List<AttackRecord> records) {
|
|
|
|
|
|
|
|
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
@@ -325,7 +325,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
this.updateSyncDevices(devices);
|
|
this.updateSyncDevices(devices);
|
|
}
|
|
}
|
|
|
|
|
|
- private void insertAttackRecordWithOnConflict(AttackRecord record, SQLiteDatabase db){
|
|
|
|
|
|
+ synchronized private void insertAttackRecordWithOnConflict(AttackRecord record, SQLiteDatabase db){
|
|
ContentValues attackValues = new ContentValues();
|
|
ContentValues attackValues = new ContentValues();
|
|
attackValues.put(AttackEntry.COLUMN_NAME_ATTACK_ID, record.getAttack_id()); // Log Attack ID
|
|
attackValues.put(AttackEntry.COLUMN_NAME_ATTACK_ID, record.getAttack_id()); // Log Attack ID
|
|
attackValues.put(AttackEntry.COLUMN_NAME_PROTOCOL, record.getProtocol().toString());
|
|
attackValues.put(AttackEntry.COLUMN_NAME_PROTOCOL, record.getProtocol().toString());
|
|
@@ -349,7 +349,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
* @param records {@link List}<AttackRecord>
|
|
* @param records {@link List}<AttackRecord>
|
|
* The added {@link SyncRecord}s .
|
|
* The added {@link SyncRecord}s .
|
|
*/
|
|
*/
|
|
- public void insertSyncRecords(List<SyncRecord> records) {
|
|
|
|
|
|
+ synchronized public void insertSyncRecords(List<SyncRecord> records) {
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
//Log.i("DBHelper", "Add Attack Record with id: " + record.getAttack_id());
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
db.beginTransaction();
|
|
db.beginTransaction();
|
|
@@ -373,7 +373,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
/**
|
|
/**
|
|
* Updates the sync devices max sync id.
|
|
* Updates the sync devices max sync id.
|
|
*/
|
|
*/
|
|
- public void updateSyncDevicesMaxID(SQLiteDatabase db){
|
|
|
|
|
|
+ synchronized public void updateSyncDevicesMaxID(SQLiteDatabase db){
|
|
HashMap<String, Long> deviceIDmap = new HashMap<String, Long>();
|
|
HashMap<String, Long> deviceIDmap = new HashMap<String, Long>();
|
|
|
|
|
|
String selectQuery = "SELECT "+AttackEntry.COLUMN_NAME_DEVICE+ ","+ AttackEntry.COLUMN_NAME_SYNC_ID+" FROM " + AttackEntry.TABLE_NAME + " A " + " GROUP BY " + AttackEntry.COLUMN_NAME_DEVICE + " HAVING " + AttackEntry.COLUMN_NAME_SYNC_ID + " = MAX( " + AttackEntry.COLUMN_NAME_SYNC_ID + " )";
|
|
String selectQuery = "SELECT "+AttackEntry.COLUMN_NAME_DEVICE+ ","+ AttackEntry.COLUMN_NAME_SYNC_ID+" FROM " + AttackEntry.TABLE_NAME + " A " + " GROUP BY " + AttackEntry.COLUMN_NAME_DEVICE + " HAVING " + AttackEntry.COLUMN_NAME_SYNC_ID + " = MAX( " + AttackEntry.COLUMN_NAME_SYNC_ID + " )";
|
|
@@ -402,8 +402,8 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void updateSyncAttackCounter(AttackRecord record){
|
|
|
|
|
|
+
|
|
|
|
+ synchronized public void updateSyncAttackCounter(AttackRecord record){
|
|
|
|
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
|
|
|
|
@@ -500,7 +500,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public int numBssidSeen(String protocol, String BSSID) {
|
|
|
|
|
|
+ synchronized public int numBssidSeen(String protocol, String BSSID) {
|
|
String countQuery = "SELECT COUNT(*) FROM " + AttackEntry.TABLE_NAME
|
|
String countQuery = "SELECT COUNT(*) FROM " + AttackEntry.TABLE_NAME
|
|
+ " WHERE " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_PROTOCOL + " = " + "'" + protocol + "'"
|
|
+ " WHERE " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_PROTOCOL + " = " + "'" + protocol + "'"
|
|
+ " AND " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_BSSID + " = " + "'" + BSSID + "'";
|
|
+ " AND " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_BSSID + " = " + "'" + BSSID + "'";
|
|
@@ -1218,7 +1218,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
public synchronized void deleteByBSSID(String bssid) {
|
|
public synchronized void deleteByBSSID(String bssid) {
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
db.delete(NetworkEntry.TABLE_NAME, NetworkEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
|
|
db.delete(NetworkEntry.TABLE_NAME, NetworkEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
|
|
- db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
|
|
|
|
|
|
+ db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_BSSID + " = ?", new String[]{bssid});
|
|
db.close();
|
|
db.close();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1244,8 +1244,8 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
*/
|
|
*/
|
|
public synchronized void deleteByAttackID(long attackID) {
|
|
public synchronized void deleteByAttackID(long attackID) {
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
- db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[] { String.valueOf(attackID) });
|
|
|
|
- db.delete(PacketEntry.TABLE_NAME, PacketEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[] { String.valueOf(attackID) });
|
|
|
|
|
|
+ db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[]{String.valueOf(attackID)});
|
|
|
|
+ db.delete(PacketEntry.TABLE_NAME, PacketEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[]{String.valueOf(attackID)});
|
|
db.close();
|
|
db.close();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1991,7 +1991,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A "
|
|
String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A "
|
|
+ " WHERE "
|
|
+ " WHERE "
|
|
+" ( "
|
|
+" ( "
|
|
- + " AND " + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + deviceID + "'"
|
|
|
|
|
|
+ + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + deviceID + "'"
|
|
+ " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + maxID
|
|
+ " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + maxID
|
|
+ " ) "
|
|
+ " ) "
|
|
//+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE
|
|
//+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE
|