Quantcast
Channel: RaGEZONE - MMO Development Forums
Viewing all articles
Browse latest Browse all 14581

[Release] Cleaned Up LoginCrypto.Java

$
0
0
well this is based on public v117 that was released got bored and decided to play around with it :P so cleaned it up to my liking and remove all useless stuff :ott1: I have also tweaked my login class to hash second password hash to SHA 512 and not random bytes (which I will not release).. not really into helping but once in awhile will be okay as long it does not harm anybody..

also I decided to play abit with netbeans and found something useless as you can see what I removed and added

Code:

Index: LoginCrypto.java
--- LoginCrypto.java Base (BASE)
+++ LoginCrypto.java Locally Modified (Based On LOCAL)
@@ -1,8 +1,5 @@
 /*
-This file is part of the OdinMS Maple Story Server
-Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc>
-Matthias Butz <matze@odinms.de>
-Jan Christian Meyer <vimes@odinms.de>
+    Copyright (C) 2008 OdinMS Development Team
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License version 3
@@ -18,48 +15,22 @@
 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
 package client;
 
-import java.util.Random;
 import java.io.UnsupportedEncodingException;
-import java.math.BigInteger;
-import java.security.KeyFactory;
 import java.security.MessageDigest;
-import java.security.InvalidKeyException;
-import java.security.NoSuchProviderException;
 import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Security;
-import java.security.spec.RSAPrivateKeySpec;
-import javax.crypto.Cipher;
-
+import server.Randomizer;
 import tools.HexTool;
 
 public class LoginCrypto {
 
-    protected final static int extralength = 6;
-    private final static String[] Alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
-    private final static String[] Number = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
-    private final static Random rand = new Random();
-    private static KeyFactory RSAKeyFactory;
-
-    public static final String Generate_13DigitAsiasoftPassport() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(Alphabet[rand.nextInt(Alphabet.length)]); // First Letter
-
-        for (int i = 0; i < 11; i++) {
-            sb.append(Number[rand.nextInt(Number.length)]); // 11 Numbers
-        }
-        sb.append(Alphabet[rand.nextInt(Alphabet.length)]); // Last Letter
-
-        return sb.toString();
-    }
-
-    private static final String toSimpleHexString(final byte[] bytes) {
+    private static String toSimpleHexString(final byte[] bytes) {
        return HexTool.toString(bytes).replace(" ", "").toLowerCase();
    }
 
-    private static final String hashWithDigest(final String in, final String digest) {
+    private static String hashWithDigest(final String in, final String digest) {
        try {
            MessageDigest Digester = MessageDigest.getInstance(digest);
            Digester.update(in.getBytes("UTF-8"), 0, in.length());
@@ -73,41 +44,29 @@
 
    }
 
-    private static final String hexSha1(final String in) {
+    public static String hexSha1(final String in) {
        return hashWithDigest(in, "SHA-1");
    }
 
-    private static final String hexSha512(final String in) {
+    private static String hexSha512(final String in) {
        return hashWithDigest(in, "SHA-512");
    }
 
-    public static final boolean checkSha1Hash(final String hash, final String password) {
+    public static boolean checkSha1Hash(final String hash, final String password) {
        return hash.equals(hexSha1(password));
    }
 
-    public static final boolean checkSaltedSha512Hash(final String hash, final String password, final String salt) {
+    public static boolean checkSaltedSha512Hash(final String hash, final String password, final String salt) {
        return hash.equals(makeSaltedSha512Hash(password, salt));
    }
 
-    public static final String makeSaltedSha512Hash(final String password, final String salt) {
+    public static String makeSaltedSha512Hash(final String password, final String salt) {
        return hexSha512(password + salt);
    }
 
-    public static final String makeSalt() {
+    public static String makeSalt() {
        byte[] salt = new byte[16];
-        rand.nextBytes(salt);
+        Randomizer.nextBytes(salt);
        return toSimpleHexString(salt);
    }
-
-    public final static String rand_s(final String in) {
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < extralength; i++) {
-            sb.append(rand.nextBoolean() ? Alphabet[rand.nextInt(Alphabet.length)] : Number[rand.nextInt(Number.length)]);
        }
-        return sb.toString() + in;
-    }
-
-    public final static String rand_r(final String in) {
-        return in.substring(extralength, extralength + 128);
-    }
-}

I will not give a clue on how to get this it working but I can give a clue it is something to do with patching..

please dont ask me for anything like source ? as it is public thank that guy who released it Im just cleaning up.. so I dont sniff or do anything if it is a bug in the source I can fix it as long as sniffing or any other stuff is concern sorry I cant..

Viewing all articles
Browse latest Browse all 14581