사이트 로그인
2016.06.29 12:05
자바이름은 제 주관적인 이름입니다
l1j/server/model // 추가
자바 파일 ssibak.java [다른거 하실라면 다른거하세요.]
일단. 서버방어 자료 기다리시는분많은데 하나하나 올려드릴게요 하나하나 테스트중입니다.
일단 제가 시간적여유가 되는대로 올려드릴게요
기타문의사항 쪽지주세요
제가 올리는자료는 제팩 기준으로 에바는 사용할라면 자바이름들을 몇몇가지 바꿔주셔야...
자료 하나하나 씩 올리는중입니다.. ㅠㅠ 기다려주세요
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package l1j.server.model;
import java.util.EnumMap;
import java.util.logging.Logger;
import l1j.configure.Config;
import l1j.server.datatables.ssibakLogTable;
import l1j.server.datatables.SprTable;
import l1j.server.model.instance.L1PcInstance;
import l1j.server.packets.server.S_Disconnect;
import l1j.server.packets.server.S_Paralysis;
import l1j.server.packets.server.S_SystemMessage;
// 어떤놈인지 한번잡아보자 한번해보자
public class ssibak {
private static Logger _log =
Logger.getLogger(ssibak.class.getName());
private final L1PcInstance _pc;
private int _injusticeCount;
private int _justiceCount;
private static final int INJUSTICE_COUNT_LIMIT = Config.INJUSTICE_COUNT;
private static final int JUSTICE_COUNT_LIMIT = Config.JUSTICE_COUNT;
// 이동과 공격 간격은 달라. 착각하면안되겟지?
// 일단 테스트니 나의임의로 5를 내려주어야징
private static final double CHECK_STRICTNESS =
(Config.CHECK_STRICTNESS - 5) / 100D;
private static final double HASTE_RATE = 0.75; // 속도 * 1.33
private static final double WAFFLE_RATE = 0.87; // 속도 * 1.15
private static final double STANDARD_RATE = 1.00;
private final EnumMap<ACT_TYPE, Long> _actTimers =
new EnumMap<ACT_TYPE, Long>(ACT_TYPE.class);
private final EnumMap<ACT_TYPE, Long> _checkTimers =
new EnumMap<ACT_TYPE, Long>(ACT_TYPE.class);
public static enum ACT_TYPE {
MOVE, ATTACK, SPELL_DIR, SPELL_NODIR
}
// 결과
public static final int R_OK = 0;
public static final int R_DETECTED = 1;
public static final int R_DISPOSED = 2;
public ssibak(L1PcInstance pc) {
_pc = pc;
_injusticeCount = 0;
_justiceCount = 0;
long now = System.currentTimeMillis();
for (ACT_TYPE each : ACT_TYPE.values()) {
_actTimers.put(each, now);
_checkTimers.put(each, now);
}
}
// 서버 폭격으로인한 잘못된 판단으로 프레임으로 추방할수도있다.
// 0 1 2
public int checkInterval(ACT_TYPE type) {
int result = R_OK;
long now = System.currentTimeMillis();
long interval = now - _actTimers.get(type);
int rightInterval = getRightInterval(type);
interval *= CHECK_STRICTNESS;
double rate = (double) interval / rightInterval;
if (0 < rate && rate < STANDARD_RATE) {
_injusticeCount++;
_justiceCount = 0;
if (_injusticeCount >= INJUSTICE_COUNT_LIMIT) {
doPunishment();
return R_DISPOSED;
}
result = R_DETECTED;
} else if (rate >= STANDARD_RATE) {
_justiceCount++;
if (_justiceCount >= JUSTICE_COUNT_LIMIT) {
_injusticeCount = 0;
_justiceCount = 0;
}
}
_actTimers.put(type, now);
return result;
}
// 네이놈 걸렷구나
private void doPunishment() {
int punishment_type = Math.abs(Config.PUNISHMENT_TYPE);
int punishment_time = Math.abs(Config.PUNISHMENT_TIME);
int punishment_mapid = Math.abs(Config.PUNISHMENT_MAP_ID);
if (!_pc.isGm()) {
int x = _pc.getX() ,y = _pc.getY() ,mapid = _pc.getMapId();// 위치확인
switch (punishment_type) {
case 0: // 꺼져버려 종료시키자
_pc.sendPackets(new S_SystemMessage(String.format(I18N_ssibak_DISCONNECT_THE_CONNECTION, punishment_time)));
// 너는 걸렷으니 게임을 종료시킬거야
try {
Thread.sleep(punishment_time * 1000);
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
_pc.saveInventory();
_pc.sendPackets(new S_Disconnect());
break;
case 1:// 못움직이게
_pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_BIND, true));
_pc.sendPackets(new S_SystemMessage(String.format(I18N_ssibak_STOP_THE_ACTION, punishment_time)));
// 너는 걸렷으니 게임을 종료시킬거야
try {
Thread.sleep(punishment_time * 1000);
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
_pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_BIND, false));
break;
case 2:// 조용히시키자
L1Teleport.teleport(_pc, 32737, 32796, (short) punishment_mapid, 5, false);
_pc.sendPackets(new S_SystemMessage(String.format(I18N_ssibak_MOVE_TO_THE_ISOLATION_MAP, punishment_time)));
// 걸렷으니 해당맵으로 강제로 보내버려 슝~
try {
Thread.sleep(punishment_time * 1000);
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
L1Teleport.teleport(_pc, x, y, (short) mapid, 5, false);
break;
}
} else {
// 나는 운영자이니깐 안되지요
if (Config.DEBUG_MODE) {
_pc.sendPackets(new S_SystemMessage("네이놈 잘걸렸다."));
_pc.sendPackets(new S_SystemMessage(I18N_ssibak_OVERSPEED_DETECTED));
//너걸렷다.
}
}
_injusticeCount = 0;
_justiceCount = 0;
if (Config.LOGGING_ssibak) {
ssibakLogTable logssibak = new ssibakLogTable();
logssibak.storeLogssibak(_pc);// 일단 어떤놈인지 기록을
}
}
//디도스나 서버폭격으로 프레임이나 패킷때문에 임의로 할수있으니 올바르게
// 공격 이동 등.
private int getRightInterval(ACT_TYPE type) {
int interval;
switch (type) {
case ATTACK:
interval = SprTable.getInstance().getAttackSpeed(_pc.getTempCharGfx(),
_pc.getCurrentWeapon() + 1);
break;
case MOVE:
interval = SprTable.getInstance().getMoveSpeed(_pc.getTempCharGfx(),
_pc.getCurrentWeapon());
break;
case SPELL_DIR:
interval = SprTable.getInstance().getDirSpellSpeed(_pc.getTempCharGfx());
break;
case SPELL_NODIR:
interval = SprTable.getInstance().getNodirSpellSpeed(_pc.getTempCharGfx());
break;
default:
return 0;
}
if (_pc.isHaste()) { //헤이
interval *= HASTE_RATE;
}
if (_pc.isSlow()) { //슬로우
interval /= HASTE_RATE;
}
if (_pc.isBrave()) { // 용기
interval *= HASTE_RATE;
}
if (_pc.isElfBrave()) { // 와퍼
interval *= WAFFLE_RATE;
}
if (type.equals(ACT_TYPE.MOVE) && _pc.isFastMovable()) { // 홀리 윈드 무빙
interval *= HASTE_RATE;
}
if (type.equals(ACT_TYPE.ATTACK) && _pc.isFastAttackable()) { // 블러드
interval *= HASTE_RATE * WAFFLE_RATE;
}
if (type.equals(ACT_TYPE.MOVE) && _pc.isRIBRAVE()) { // 유그드라
interval *= WAFFLE_RATE;
}
if (_pc.isThirdSpeed()) { // 3단
interval *= WAFFLE_RATE;
}
if (_pc.isWindShackle()) { // 윈드
interval /= 2;
}
if(_pc.getMapId() == 5143) { // 펫레이징부분
interval *= 0.1;
}
return interval;
}
}
//////////////////////////////////////////////////////////////////////////////
import l1j.server.datatables폴더
ssibakLogTable 자바 생성
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package l1j.server.datatables;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import l1j.server.model.instance.L1PcInstance;
import l1j.server.utils.L1DatabaseFactory;
import l1j.server.utils.SqlUtil;
public class ssibakLogTable {
private static Logger _log = Logger.getLogger(ssibakTable.class.getName());
public void storessibak(L1PcInstance pc) {
java.sql.Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con.prepareStatement("INSERT INTO ssibak_logs SET account_id=?, char_id=?, clan_id=?, map_id=?, loc_x=?, loc_y=?, datetime=SYSDATE()");
pstm.setInt(1, pc.getAccountId());
pstm.setInt(2, pc.getId());
pstm.setInt(3, pc.getClanId());
pstm.setInt(4, pc.getMapId());
pstm.setInt(5, pc.getX());
pstm.setInt(6, pc.getY());
pstm.execute();
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} finally {
SqlUtil.close(pstm);
SqlUtil.close(con);
}
}
}
[출처] [서버방어프로젝트1] 너 스핵쓰냐? 잡아줄게 (비공개 카페)