[BLEEDING] Refine logging on logout. Actually set-back on logout.

* Always log location of logout if debug is set.
* Also check inconsistent logout if manahattan distance is > 0.
* Only perform "passable check" only if enabled and not dead/sleeping.
* Try to actually set-back.
This commit is contained in:
asofold 2014-10-29 01:09:26 +01:00
parent e12c2a2bfc
commit b57d7745e4
4 changed files with 54 additions and 17 deletions

View File

@ -1353,28 +1353,42 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
@Override @Override
public void playerLeaves(final Player player) { public void playerLeaves(final Player player) {
final MovingConfig cc = MovingConfig.getConfig(player);
final MovingData data = MovingData.getData(player); final MovingData data = MovingData.getData(player);
// Check for missed moves.
final Location loc = player.getLocation(useLoc); final Location loc = player.getLocation(useLoc);
// Debug logout.
if (cc.debug) {
LogUtil.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString());
}
if (!player.isSleeping() && !player.isDead()) {
// Check for missed moves.
// TODO: Consider to catch all, at least (debug-) logging-wise.
if (!BlockProperties.isPassable(loc)) { if (!BlockProperties.isPassable(loc)) {
boolean warn = false;
if (data.toX != Double.MAX_VALUE) { if (data.toX != Double.MAX_VALUE) {
final Location refLoc = new Location(loc.getWorld(), data.toX, data.toY, data.toZ); final Location refLoc = new Location(loc.getWorld(), data.toX, data.toY, data.toZ);
final double d = refLoc.distanceSquared(loc); final double d = refLoc.distanceSquared(loc);
if (d > 0.0) { if (d > 0.0) {
if (BlockProperties.isPassable(refLoc)) { // TODO: Consider to always set back here. Might skip on big distances.
warn = true; if (TrigUtil.manhattan(loc, refLoc) > 0 || BlockProperties.isPassable(refLoc)) {
StringBuilder builder = new StringBuilder(128); if (passable.isEnabled(player)) {
DebugUtil.addMove(refLoc, loc, null, builder); LogUtil.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " leaves, having moved into a block (not tracked by moving checks): " + player.getWorld().getName() + " / " + DebugUtil.formatMove(refLoc, loc));
LogUtil.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " logs out having moved into a block: " + builder.toString()); // TODO: Actually trigger a passable violation (+tag).
if (d > 1.25) {
LogUtil.logWarning("[NoCheatPlus] SKIP set-back for " + player.getName() + ", because distance is too high (risk of false positives): " + d);
} else {
LogUtil.logInfo("[NoCheatPlus] Set back player " + player.getName() + ": " + DebugUtil.formatLocation(refLoc));
data.prepareSetBack(refLoc);
if (!player.teleport(refLoc)) {
LogUtil.logWarning("[NoCheatPlus] FAILED to set back player " + player.getName());
}
}
} }
} }
} }
if (warn) {
// TODO: Additional debug info. Might include full moving trace ?
} }
} }
useLoc.setWorld(null); useLoc.setWorld(null);
}
// Adjust data. // Adjust data.
survivalFly.setReallySneaking(player, false); survivalFly.setReallySneaking(player, false);
noFall.onLeave(player); noFall.onLeave(player);

View File

@ -103,6 +103,7 @@ public class Passable extends Check {
loc = null; loc = null;
tags += "into"; tags += "into";
} else if (BlockProperties.isPassable(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) { } else if (BlockProperties.isPassable(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {
// Keep loc.
tags += "into_shift"; tags += "into_shift";
} }
// } else if (BlockProperties.isPassableExact(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) { // } else if (BlockProperties.isPassableExact(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {

View File

@ -21,6 +21,29 @@ public class DebugUtil {
// TODO: Add useLoc1 and useLoc2. // TODO: Add useLoc1 and useLoc2.
/**
* Just the coordinates.
* @param loc
* @return
*/
public static String formatLocation(final Location loc) {
StringBuilder b = new StringBuilder(128);
addLocation(loc, b);
return b.toString();
}
/**
* Just the coordinates.
* @param from
* @param to
* @return
*/
public static String formatMove(Location from, Location to) {
StringBuilder builder = new StringBuilder(128);
DebugUtil.addMove(from, to, null, builder);
return builder.toString();
}
public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){ public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return x1 == x2 && y1 == y2 && z1 == z2; return x1 == x2 && y1 == y2 && z1 == z2;
} }

View File

@ -5,7 +5,6 @@ import java.io.StringWriter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;