Skip to content

Commit

Permalink
Merge branch 'ver-2.4(major)' into permission-update
Browse files Browse the repository at this point in the history
  • Loading branch information
zafodB committed Jul 13, 2021
2 parents 99f2bc2 + bec4573 commit 88e81d3
Show file tree
Hide file tree
Showing 38 changed files with 285 additions and 55 deletions.
2 changes: 1 addition & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Description: Unable to support higher version of SDK
Solution: Use SDK 19.1.0

## API key
Description: Ensure the correct API key and save both debug and release SHA- fingerprint
Description: Ensure the correct API key and save both debug and release SHA- fingeprint

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
![alt text](https://github.com/aau-network-security/HosTaGe/blob/master/jekyll/ic_launcher.png "Logo Title Text 1")
![alt text](https://github.com/aau-network-security/HosTaGe/blob/master/jekyll/ic_launcher.png "Logo Title Text 1")

[<img src="https://github.com/aau-network-security/HosTaGe/blob/ver-2.3.4/jekyll/gsoc.png" width="250" height="200">](https://www.honeynet.org/2020/09/29/gsoc-2020-project-summary-hostage/) [<img src="https://github.com/aau-network-security/HosTaGe/blob/ver-2.3.4/jekyll/bh_eu_2020.jpg" width="400" height="200">](https://www.youtube.com/watch?v=uMR76HTm9M0)




HosTaGe - Honeypot-To-Go
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ android {
compileSdkVersion 30
defaultConfig {
versionCode 11
versionName "2.3.4"
versionName "2.4"
minSdkVersion 24
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Binary file added jekyll/bh_eu_2020.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jekyll/gsoc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "dk.aau.netsec.hostage",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 11,
"versionName": "2.4",
"outputFile": "HosTaGe-release.apk"
}
]
}
2 changes: 1 addition & 1 deletion src/main/java/com/echo/holographlibrary/LineGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ private void drawAxis(Canvas canvas){

float yPixels = getHeight() - (bottomPadding - (10));

// DRAW SEPARATOR
// DRAW SEPERATOR
paint.setColor(Color.BLACK);
paint.setAlpha(50);
paint.setAntiAlias(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public static String getSSID(Context context) {
}

/**
* Gets the mac address of the device.
* Gets the mac address of the devicek.
*
* @param context
* Needs a context to get system recourses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public void deleteProfile(int id) {
}

public void updateNetworkInformation(ArrayList<HashMap<String, Object>> networkInformation) {
Log.i("DatabaseHandler", "Starts updating");
Log.i("DatabaseHandler", "Starte updating");
for (HashMap<String, Object> values : networkInformation) {
updateNetworkInformation(values);
}
Expand Down
208 changes: 208 additions & 0 deletions src/main/java/dk/aau/netsec/hostage/location/MyLocationManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
package dk.aau.netsec.hostage.location;

import java.util.Timer;
import java.util.TimerTask;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

import androidx.core.app.ActivityCompat;

import dk.aau.netsec.hostage.ui.activity.MainActivity;


/**
* This Class is used to get Location data. You can get the last found Location or start searching for new hostage.location data.
* @author Lars Pandikow
*/
public class MyLocationManager {
private Context context;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 100;

/**
* TimerTask to stop updates after a given time.
*/
class StopTask extends TimerTask {
@Override
public void run() {
stopUpdates();
}
}

private LocationManager locationManager;
/**
* Static variable that always holds the newest hostage.location update.
*/
private static Location newestLocation = null;

private static final int TWO_MINUTES = 1000 * 60 * 2;

public static Location getNewestLocation() {
return newestLocation;
}

// Define a listener that responds to hostage.location updates
LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
// Called when a new hostage.location is found by the network hostage.location
// provider.
if (isBetterLocation(location, newestLocation)) {
newestLocation = location;
}
}

@Override
public void onProviderDisabled(String provider) {
}

@Override
public void onProviderEnabled(String provider) {
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};

public MyLocationManager(Context context) {
// Acquire a reference to the system Location Manager
this.context = context;
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.getInstance(), new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_PERMISSION_REQUEST_CODE);

return;
}
newestLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

}

public void initializeNewestLocation() {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
newestLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

}


/**
* Starts updating the hostage.location data for the given amount of time. Calls
* itself recursive if no hostage.location data has been found yet and there are
* still attempts left.
*
* @param time
* Time to update hostage.location data
* @param attempts
* Remaining attempts for recieving hostage.location data
*/
public void getUpdates(long time, int attempts, Context context) {
startUpdates(context);

attempts--;
Timer timer1 = new Timer();
timer1.schedule(new StopTask(), time);
if (newestLocation == null && attempts > 0)
getUpdates(time, attempts, context);
}

/**
* Start updating
* {@link MyLocationManager#newestLocation
* newestLocation} if a hostage.location provider is enabled and available.
*/

public void startUpdates(Context context) {
boolean gpsEnabled = false;
boolean networkEnabled = false;
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
// exceptions will be thrown if provider is not permitted.
try {
gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception ex) {
ex.printStackTrace();
}
try {
networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (Exception ex) {
ex.printStackTrace();
}

// don't start listeners if no provider is enabled
if (!gpsEnabled && !networkEnabled)
return;

// Register the listener with the Location Manager to receive hostage.location updates
if (gpsEnabled)
requestLocationUpdates( networkEnabled, context);
}

private void requestLocationUpdates(boolean networkEnabled,Context context) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

return;
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
if (networkEnabled)
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

}

/**
* Stop updating the hostage.location.
*/
public void stopUpdates() {
locationManager.removeUpdates(locationListener);
}

/**
* Determines whether one Location reading is better than the current
* Location fix
*
* @param location
* The new Location that you want to evaluate
* @param currentBestLocation
* The current Location fix, to which you want to compare the new
* one
*/
private boolean isBetterLocation(Location location,
Location currentBestLocation) {
if (currentBestLocation == null) {
// A new hostage.location is always better than no hostage.location
return true;
}

// Check whether the new hostage.location fix is newer or older
long timeDelta = location.getTime() - currentBestLocation.getTime();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;

// If it's been more than two minutes since the current hostage.location, use
// the new hostage.location
// because the user has likely moved
if (isSignificantlyNewer) {
return true;
// If the new hostage.location is more than two minutes older, it must be
// worse
} else if (isSignificantlyOlder) {
return false;
}

// Check whether the new hostage.location fix is more or less accurate
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation
.getAccuracy());

// Determine hostage.location quality using a combination of timeliness and
// accuracy
return accuracyDelta < 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public synchronized int getAttackPerProtocolCount(String protocol, long attack_i
}

/**
* Determines the number of recorded attacks for a specific protocol and access point since the given attack_id.
* Determines the number of recorded attacks for a specific protocol and accesss point since the given attack_id.
*
* @param protocol
* The String representation of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public synchronized ArrayList<String> getUniqueBSSIDRecordsForProtocol(String pr
}

/**
* Returns PlotComparisonItems for attacks per bssid.
* Returns PlotComparisionItems for attacks per bssid.
* @param filter (LogFilter) filter object
*
* @return ArrayList<PlotComparisonItem>
Expand Down Expand Up @@ -379,7 +379,7 @@ public synchronized ArrayList<PlotComparisonItem> attacksPerBSSID(LogFilter filt
}

/**
* Returns PlotComparisonItems for attacks per bssid.
* Returns PlotComparisionItems for attacks per bssid.
* @param filter (LogFilter) filter object
*
* @return ArrayList<PlotComparisonItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ public synchronized int getAttackPerProtocolCount(String protocol, int attack_id
}

/**
* Determines the number of recorded attacks for a specific protocol and access point since the given attack_id.
* Determines the number of recorded attacks for a specific protocol and accesss point since the given attack_id.
*
* @param protocol
* The String representation of the
Expand Down Expand Up @@ -1882,7 +1882,7 @@ public synchronized ArrayList<Record> getAllReceivedRecordsOfEachAttack() {
}

/**
* Returns PlotComparisonItems for attacks per essid.
* Returns PlotComparisionItems for attacks per essid.
* @param filter (LogFilter) filter object
*
* @return ArrayList<PlotComparisonItem>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dk/aau/netsec/hostage/protocol/GHOST.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
/**
* Ghost Protocol. This protocol mirrors an incoming connection back to the
* attacker on the same port, that it is running on. It will send all incoming
* requests back to the attacker on the mirrored connection and will reply with
* the responses it gets from this mirrored connection.
* requests back to the attacker on the mirrored connection and will relpy with
* the responses it get's from this mirrored connection.
*
* @author Wulf Pfeiffer
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dk/aau/netsec/hostage/protocol/HTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private Packet buildPacket(String code, String type) {
}

/**
* Task for acquiring a qotd from one of four possible servers.
* Task for accuiring a qotd from one of four possible servers.
*
* @author Wulf Pfeiffer
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dk/aau/netsec/hostage/protocol/SSH.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private String initSshType() {
.nextInt(possibleSshTypes[majorVersion][1].length)];
}

// server info
// server infos
private static final String serverVersion = "SSH-2.0-";
private String serverType = initSshType();
private String serverName = HelperUtils.getRandomString(16, false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dk/aau/netsec/hostage/protocol/TELNET.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private String initLogin() {
}

/**
* Checks a byte array for occurrence of one byte.
* Checks a byte array for occurence of one byte.
*
* @param bytes
* byte array that is checked.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* NetBIOS.
* Used to register computers and workgroups in a windows network.
* Used to registrate computers and workgroups in a windows network.
* @author Wulf Pfeiffer
*/
public class NMB extends Thread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static byte[] encodeNBNSName(byte[] name) {
}

/**
* Wraps a NetBIOS name with the required start and end bytes and some more information.
* Wraps a NetBIOS name with the required start and end bytes and some more informations.
* @param name netbios name.
* @param service NBNDSService.
* @return wrapped content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public SmtpRequest(SmtpActionType actionType, String params, SmtpState state) {

/**
* Execute the SMTP request returning a response. This method models the state transition table for the SMTP server.
* @return response to the request
* @return reponse to the request
*/
public SmtpResponse execute() {
SmtpResponse response;
Expand Down
Loading

0 comments on commit 88e81d3

Please sign in to comment.