Jump to content
  • 0

Error en consola JAVAMODs Personal Character Password


spekyone

Question

Buenas gente, tengo un problema con una java MOD que implemente, lo estuve testeando y me tira un error en consola.

el error me lo da cuando pongo mas de 17 caracteres en  PREGUNTA DE SEGURIDAD. 

si pongo pocos caracteres si funciona.

__________________________________________________________________________________________________________________

Personal Character Password

LINK DEL POST

__________________________________________________________________________________________________________________

Cita



Index: /passskey.sql
===================================================================
--- /passskey.sql	(revision 9)
+++ /passskey.sql	(revision 9)
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS passkey (
+`obj_Id` INT UNSIGNED NOT NULL DEFAULT 0,
+`passkey` VARCHAR(45),
+`question` VARCHAR(55) NOT NULL,
+`answer` VARCHAR(35) NOT NULL,
+PRIMARY KEY (obj_Id)
+);
Index: /data/html/passkey/login.htm
===================================================================
--- /data/html/passkey/login.htm	(revision 9)
+++ /data/html/passkey/login.htm	(revision 9)
@@ -0,0 +1,21 @@
+<html>
+<title>Personal Password Manager</title>
+<body>
+<center>
+<img src="L2Font.mini_logo-k" width=250 height=90><br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32><br>
+</center>
+<br>
+Hello, stranger! To continue playing, you have to provide your password.
+<center>
+<table>
+<tr><td><font color="732cde">Enter password: </font></td><td><edit var="pass" width=70 height=10></td></tr><br>
+</table>
+<br>
+<button value="Confirm" action="bypass -h pklogin $pass" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">        
+<button value="Forgot password" action="bypass -h pkrecovery" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
+<br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32>
+</center>
+</body>
+</html>
Index: /data/html/passkey/recovery.htm
===================================================================
--- /data/html/passkey/recovery.htm	(revision 9)
+++ /data/html/passkey/recovery.htm	(revision 9)
@@ -0,0 +1,26 @@
+<html>
+<title>Personal Password Manager</title>
+<body>
+<center>
+<img src="L2Font.mini_logo-k" width=250 height=90><br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32><br>
+</center>
+<br>
+Hello, stranger! You forgot your password? Okay, I'll help you recover it!<br>
+But you have to type the answer to the question, that you've set during registration.<br>
+
+<center><font color="LEVEL">%question%</font></center>
+<br>
+<center>
+<table>
+<tr><td><font color="732cde">Enter the answer: </font></td><td><edit var="answer" width=70 height=10></td></tr><br>
+<tr><td><font color="732cde">Enter the new password: </font></td><td><edit var="pass1" width=70 height=10></td></tr><br>
+<tr><td><font color="732cde">Confirm new password: </font></td><td><edit var="pass2" width=70 height=10></td></tr><br>
+</table>
+<br>
+<button value="Confirm" action="bypass -h pkrec $answer $pass1 $pass2" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">        
+<br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32>
+</center>
+</body>
+</html>
Index: /data/html/passkey/setup.htm
===================================================================
--- /data/html/passkey/setup.htm	(revision 9)
+++ /data/html/passkey/setup.htm	(revision 9)
@@ -0,0 +1,27 @@
+<html>
+<title>Personal Password Manager</title>
+<body>
+<center>
+<img src="L2Font.mini_logo-k" width=250 height=90><br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32><br>
+</center>
+<br>
+Hello, stranger! What i do?! Protect you from hacking.
+I'll help you set a password for the character.
+This way if someone theft your account no one can make any action with the character.
+It is not recommended to enter as password the same as you use in the account.
+The security question is required if you lose or forget your password.
+<center>
+<table>
+<tr><td><font color="732cde">Enter the password: </font></td><td><edit var="pass1" width=70 height=10></td></tr><br>
+<tr><td><font color="732cde">Repeat password: </font></td><td><edit var="pass2" width=70 height=10></td></tr><br>
+<tr><td><font color="732cde">Enter a security question: </font></td><td><edit var="question" width=70 height=10></td></tr><br>
+<tr><td><font color="732cde">Enter the answer: </font></td><td><edit var="answer" width=70 height=10></td></tr><br>
+</table>
+<br>
+<button value="Confirm" action="bypass -h pkset ] $pass1 ] $pass2 ] $question ] $answer" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">        
+<br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32>
+</center>
+</body>
+</html>
Index: /head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- /head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 8)
+++ /head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 9)
@@ -19,9 +19,17 @@
 package com.l2jfrozen.gameserver.network.clientpackets;
 
+import java.security.MessageDigest;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import com.l2jfrozen.Config;
+import com.l2jfrozen.crypt.Base64;
 import com.l2jfrozen.gameserver.ai.CtrlIntention;
+import com.l2jfrozen.gameserver.cache.HtmCache;
 import com.l2jfrozen.gameserver.communitybbs.CommunityBoard;
 import com.l2jfrozen.gameserver.datatables.SkillTable;
@@ -46,4 +54,5 @@
 import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
 import com.l2jfrozen.gameserver.util.GMAudit;
+import com.l2jfrozen.util.database.L2DatabaseFactory;
 
 public final class RequestBypassToServer extends L2GameClientPacket
@@ -396,4 +405,228 @@
 					activeChar.sendMessage("Нельзя повторно выбрать статус нуба!");
 			}
+			else if (_command.equalsIgnoreCase("pkrecovery"))
+			{
+				String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/recovery.htm");
+				NpcHtmlMessage html = new NpcHtmlMessage(1);
+				html.setHtml(htmContent);
+				html.replace("%question%", getPassKeyQuestion(activeChar));
+				activeChar.sendPacket(html);
+				html = null;
+			}
+			else if (_command.startsWith("pkset"))
+			{
+				StringTokenizer st = new StringTokenizer(_command, "]");
+				
+				if (st.countTokens() != 5)
+				{
+					activeChar.sendMessage("You have not entered all the data!");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/setup.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				
+				String newCommand = st.nextToken();
+				String pass1 = st.nextToken();
+				pass1 = pass1.substring(1, pass1.length() - 1);
+				String pass2 = st.nextToken();
+				pass2 = pass2.substring(1, pass2.length() - 1);
+				String question = st.nextToken();
+				question = question.substring(1, question.length() - 1);
+				String answer = st.nextToken();
+				answer = answer.substring(1, answer.length());
+				
+				if (pass1 == null || pass2 == null || question == null || answer == null)
+				{
+					activeChar.sendMessage("Input error");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/setup.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				
+				if (!pass1.equals(pass2))
+				{
+					activeChar.sendMessage("You entered different passwords");
+					activeChar.sendMessage("pass1 = " + pass1);
+					activeChar.sendMessage("pass2 = " + pass2);
+					activeChar.sendMessage("Question = " + question);
+					activeChar.sendMessage("answer = " + answer);
+					
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/setup.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				insertPassKeyInformation(activeChar, pass1, question, answer);
+				
+				String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/login.htm");
+				NpcHtmlMessage html = new NpcHtmlMessage(1);
+				html.setHtml(htmContent);
+				activeChar.sendPacket(html);
+				html = null;
+			}
+			else if (_command.startsWith("pklogin"))
+			{
+				StringTokenizer st = new StringTokenizer(_command, " ");
+				if (st.countTokens() != 2)
+				{
+					activeChar.sendMessage("You make a mistake when entering the password!");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/login.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				String newCommand = st.nextToken();
+				String pass = st.nextToken();
+				
+				Connection con = null;
+				String query = "SELECT passkey FROM passkey WHERE obj_Id = ?";
+				String pwdindb = "error";
+				try
+				{
+					con = L2DatabaseFactory.getInstance().getConnection();
+					PreparedStatement ps = con.prepareStatement(query);
+					ps.setInt(1, activeChar.getObjectId());
+					ResultSet rs = ps.executeQuery();
+					
+					while (rs.next())
+						pwdindb = rs.getString(1);
+					
+					rs.close();
+					ps.close();
+					ps = null;
+					rs = null;
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+				}
+				finally
+				{
+					try
+					{
+						con.close();
+					}
+					catch (SQLException e)
+					{
+						e.printStackTrace();
+					}
+					con = null;
+				}
+				
+				if (pwdindb.equals(encodePass(pass)))
+				{
+					activeChar.setIsParalyzed(false);
+				}
+				else
+				{
+					activeChar.sendMessage("You have not entered the correct password");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/login.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+			}
+			else if (_command.startsWith("pkrec"))
+			{
+				StringTokenizer st = new StringTokenizer(_command, " ");
+				if (st.countTokens() != 4)
+				{
+					activeChar.sendMessage("You make a mistake when entering data!");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/recovery.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					html.replace("%question%", getPassKeyQuestion(activeChar));
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				
+				String newCommand = st.nextToken();
+				String answer = st.nextToken();
+				String pass1 = st.nextToken();
+				String pass2 = st.nextToken();
+				
+				if (!pass1.equals(pass2))
+				{
+					activeChar.sendMessage("Вы ввели разные пароли");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/recovery.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					html.replace("%question%", getPassKeyQuestion(activeChar));
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				
+				Connection con = null;
+				String query = "SELECT answer FROM passkey WHERE obj_Id = ?";
+				String anwindb = "error";
+				try
+				{
+					con = L2DatabaseFactory.getInstance().getConnection();
+					PreparedStatement ps = con.prepareStatement(query);
+					ps.setInt(1, activeChar.getObjectId());
+					ResultSet rs = ps.executeQuery();
+					
+					while (rs.next())
+						anwindb = rs.getString(1);
+					
+					rs.close();
+					ps.close();
+					ps = null;
+					rs = null;
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+				}
+				finally
+				{
+					try
+					{
+						con.close();
+					}
+					catch (SQLException e)
+					{
+						e.printStackTrace();
+					}
+					con = null;
+				}
+				
+				if (anwindb.equals(answer))
+				{
+					updPassKey(activeChar, pass1);
+					activeChar.sendMessage("You have successfully changed your password.");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/login.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					activeChar.sendPacket(html);
+					html = null;
+				}
+				else
+				{
+					activeChar.sendMessage("You entered the wrong answer to your question");
+					String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/recovery.htm");
+					NpcHtmlMessage html = new NpcHtmlMessage(1);
+					html.setHtml(htmContent);
+					html.replace("%question%", getPassKeyQuestion(activeChar));
+					activeChar.sendPacket(html);
+					html = null;
+					return;
+				}
+				
+			}
 		}
 		catch(Exception e)
@@ -409,4 +642,171 @@
 		//		}
 	}
+	
+	private void updPassKey(L2PcInstance player, String pass)
+	{
+		Connection con = null;
+		String query = "UPDATE passkey SET passkey = ? WHERE obj_Id = ?";
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement st = con.prepareStatement(query);
+			st.setString(1, encodePass(pass));
+			st.setInt(2, player.getObjectId());
+			st.executeUpdate();
+			st.close();
+			st = null;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			try
+			{
+				con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+			con = null;
+		}
+	}
+	
+	private String encodePass(String password)
+	{
+		String pass = "error";
+		try
+		{
+			MessageDigest md = MessageDigest.getInstance("SHA");
+			byte[] raw = password.getBytes("UTF-8");
+			byte[] hash = md.digest(raw);
+			pass = Base64.encodeBytes(hash);
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		return pass;
+	}
+	
+	private void insertPassKeyInformation(L2PcInstance player, String pass, String question, String answer)
+	{
+		Connection con = null;
+		String query = "INSERT INTO passkey (obj_Id, passkey, question, answer) VALUES (?,?,?,?)";
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement st = con.prepareStatement(query);
+			st.setInt(1, player.getObjectId());
+			st.setString(2, encodePass(pass));
+			st.setString(3, question);
+			st.setString(4, answer);
+			st.execute();
+			st.close();
+			st = null;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			try
+			{
+				con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+			con = null;
+		}
+	}
+	
+	private String getPassKeyQuestion(L2PcInstance player)
+	{
+		Connection con = null;
+		String query = "SELECT question FROM passkey WHERE obj_Id = ?";
+		String question = "error";
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement st = con.prepareStatement(query);
+			st.setInt(1, player.getObjectId());
+			ResultSet rs = st.executeQuery();
+			
+			while (rs.next())
+				question = rs.getString(1);
+			
+			rs.close();
+			st.close();
+			st = null;
+			rs = null;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			try
+			{
+				con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+			con = null;
+		}
+		
+		return question;
+	}
+	
+	public static boolean getPassKeyEnable(L2PcInstance player)
+	{
+		Connection con = null;
+		String query = "SELECT COUNT(*) FROM passkey WHERE obj_Id = ?";
+		int count = 0;
+		
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement st = con.prepareStatement(query);
+			st.setInt(1, player.getObjectId());
+			ResultSet rs = st.executeQuery();
+			
+			while (rs.next())
+				count = rs.getInt(1);
+			
+			rs.close();
+			st.close();
+			st = null;
+			rs = null;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			try
+			{
+				con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+			con = null;
+		}
+		
+		if (count == 1)
+			return true;
+		else
+			return false;
+	}
 
 	/**
Index: /head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- /head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(revision 8)
+++ /head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(revision 9)
@@ -669,4 +669,22 @@
 		if (Config.SERVER_TIME_ON_START)
 			activeChar.sendMessage("SVR time is " + fmt.format(new Date(System.currentTimeMillis())));
+		
+		activeChar.setIsParalyzed(true);
+		if (RequestBypassToServer.getPassKeyEnable(activeChar))
+		{
+			String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/login.htm");
+			NpcHtmlMessage html = new NpcHtmlMessage(1);
+			html.setHtml(htmContent);
+			activeChar.sendPacket(html);
+			html = null;
+		}
+		else
+		{
+			String htmContent = HtmCache.getInstance().getHtm("data/html/passkey/setup.htm");
+			NpcHtmlMessage html = new NpcHtmlMessage(1);
+			html.setHtml(htmContent);
+			activeChar.sendPacket(html);
+			html = null;
+		}
 	}

 

SOY NUEVO EN MODS JAVA, USO LA REV 1132 DE JFROZEN.

POR LO QUE ESTUBE VIENDO EL PROBLEMA ES ESN ESTA PARTE 

	String newCommand = st.nextToken();
+				String pass1 = st.nextToken();
+				pass1 = pass1.substring(1, pass1.length() - 1);
+				String pass2 = st.nextToken();
+				pass2 = pass2.substring(1, pass2.length() - 1);
+				String question = st.nextToken();
+				question = question.substring(1, question.length() - 1);
+				String answer = st.nextToken();
+				answer = answer.substring(1, answer.length());

 

error codigo.png

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...



  • Recently Browsing

    • No registered users viewing this page.
  • Similar Content

  • Posts

    • Poh passa pra mim, eu não tenho interesse em nada sobre essas coisas, apenas estou rodando o forum que nem louco pra achar uma rev boa pra jogar só eu e minha esposa 😕 Dou minha palavra que não tenho vontade nenhuma de repassar ja que esse tipo de coisa anda rolando na comunidade 😕 Se puder eu agradeço,senao nao tem problema eu entendo completamente ^^ Meu Discord: xii_gaia_iix
    • Olá a todos gostaria de informa que demos um tempo no projeto mais já estamos voltando ativa com uma revisão estável e 100% limpa de mods. Não iremos disponibilizar a soucer do projeto devido a uns caras malandros aqui que já esta vendendo a revisão sem nem esta estável.
    • podes subir denuevo la data por favor 
    • UP!!! Vou Reupar em breve, tive que recriar o app... 
    • Sobre o rate limit. Antes de tudo, é importante entender o seguinte: o SphereAPI é um cluster — não é apenas um único servidor. Existe um servidor público por padrão, mas os outros IPs dos servidores da Sphere são ocultos por questões de segurança e são adicionados manualmente no painel de administração, especificando o IP e a PORTA. Dessa forma, evitamos ataques DDoS. O SphereAPI trabalha de forma paralela, mesmo que os servidores não estejam diretamente conectados entre si. Se alguém tentar fazer um ataque DDoS a um dos servidores da Sphere, isso não afetará os clientes do SphereWeb que estão em outros servidores. O próprio SphereAPI foi escrito na linguagem Golang para distribuir ao máximo a carga, utilizar concorrência e multiprocessamento. Atualmente, no servidor público, tenho dezenas e dezenas de sites conectados, e a cada segundo o Sphere executa requisições e gerencia conexões, enquanto o SphereAPI consome apenas 27MB de RAM. Eu considero isso um bom resultado do meu trabalho. Dos sites SphereWeb, só recebo requisições quando realmente necessário. Se algum site de servidor for alvo de um ataque DDoS, isso não afeta a Sphere de forma alguma.  
    • obg pelas, informações.  desculpe o excesso de perguntas. normalmente as pessoas nao fazem perguntas tao tecnicas, e acabam por desconherem o nivel grande do projeto que estao usando. gosto de fazer essas perguntas, para que fique registrado e as pessoas possam ver depois. sem precisar perguntar novamente : D vc fez algum tipo de ratelimit ?
    • SphereAPI (ela processa todas as conexões) faz consultas ao banco de dados somente quando necessário. Nós armazenamos todos os dados em cache, assim as consultas só são feitas quando o cache está desatualizado. Simplificando: se 100 pessoas acessarem sua página de estatísticas em 1 minuto, a consulta para obter os dados será feita apenas uma vez. E o resultado da consulta é armazenado tanto na memória da SphereAPI quanto da SphereWeb.
    • quais foram as tecnicas que vc usou para evitar excesso de consultas, tais como tops e afins que fazem JOIN nas tabelas, e podem causar lentidão ?
    • Se o servidor da Sphere não conseguir se conectar ou perder a conexão com o banco de dados do servidor de jogo, ou não conseguir executar uma consulta SQL, então o SphereWeb mostrará que o servidor está indisponível no painel de lista de servidores da administração. Na área administrativa será exibida a mensagem de erro, indicando a causa do problema. E se for um erro de consulta SQL, a consulta será pausada para evitar novas tentativas com erro no banco de dados do servidor. A Sphere aguardará até que o problema seja resolvido – ou seja, até que o erro seja corrigido. Depois disso, será possível limpar a lista de erros, e a Sphere tentará se conectar novamente.   Vale destacar que, para otimização, a API da Sphere mantém uma conexão permanente com o banco de dados do servidor de jogo enquanto o site estiver sendo acessado. Se ninguém acessar seu site por mais de 15 minutos, a Sphere se desconectará do banco de dados do jogo e só se reconectará quando alguém acessar novamente.   Provavelmente não expliquei tudo de forma clara, pois há muitos detalhes que não mencionei.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.