Aqui esta el codigo del Jar con el Proxy de la Skin ahora voy a testear cambiando el host, y despues ver si me deja volver a compilar el jar con los cambios ya que al descompilarlo se pierde parte infima pero ensencial del codigo.
[shcode=java]package net.minecraft.proxy;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProxyHandler
implements HttpProxyHandler, SocksProxyHandler
{
public static Pattern SKIN_URL = Pattern.compile("http://skins\\.minecraft\\.net/MinecraftSkins/(.+?)\\.png");
public static Pattern CLOAK_URL = Pattern.compile("http://skins\\.minecraft\\.net/MinecraftCloaks/(.+?)\\.png");
public static Pattern AUTHSERVER_URL = Pattern.compile("http://authserver\\.mojang\\.com/(.*)");
private Map skinCache = new Hashtable();
private Map cloakCache = new Hashtable();
public boolean onConnect(InputStream var1, OutputStream var2, SocksMessage var3)
{
var1.mark(65535);
String var4 = readUntil(var1, '\n');
String[] var5 = var4.split(" ");
if (var5.length != 3)
{
System.out.println("Not an HTTP request: " + var4);
try
{
var1.reset();
}
catch (IOException var12)
{
var12.printStackTrace();
}
return false;
}
String var6 = var5[0].toUpperCase();
String var7 = var5[1];
HashMap var8 = new HashMap();
String var9;
do {
var9 = readUntil(var1, '\n');
var9 = var9.trim();
int var10 = var9.indexOf(58);
if (var10 != -1)
{
var8.put(var9.substring(0, var10).toLowerCase().trim(), var9.substring(var10 + 1).trim());
}
}
while (var9.length() > 0);
String var14 = "http://" + (String)var8.get("host") + var7;
System.out.println("Proxy - onConnect - url: " + var14);
if (var6.equals("GET"))
{
if (onGET(var14, var8, var1, var2))
{
return true;
}
}
else if (var6.equals("POST"))
{
if (onPOST(var14, var8, var1, var2))
{
return true;
}
}
else if ((var6.equals("HEAD")) && (onHEAD(var14, var8, var1, var2)))
{
return true;
}
try
{
var1.reset();
}
catch (IOException var13)
{
var13.printStackTrace();
}
return false;
}
public boolean onBind()
{
return false;
}
public boolean onGET(String var1, Map var2, InputStream var3, OutputStream var4)
{
System.out.println("Proxy - onGET: " + var1);
Matcher var5 = SKIN_URL.matcher(var1);
Matcher var6 = CLOAK_URL.matcher(var1);
byte[] var7 = (byte[])null;
if (var5.matches())
{
System.out.println("Proxy: Skin");
String var8 = var5.group(1);
if (!skinCache.containsKey(var8))
{
String usertorequest = var1.replace("http://skins.minecraft.net/MinecraftSkins/", "").replace(".png", "");
var1 = "http://darklbp.tk/launcher/launcher.php?function=1&username=" + usertorequest + "&request=skin";
System.out.println("To: " + var1);
var7 = getRequest(var1);
System.out.println("Response length: " + var7.length);
skinCache.put(var8, var7);
sendResponse(var4, "image/png", var7);
return true;
}
var7 = (byte[])skinCache.get(var8);
}
else if (var6.matches())
{
System.out.println("Proxy: Cloak");
String var8 = var6.group(1);
if (!cloakCache.containsKey(var8))
{
String usertorequest = var1.replace("http://skins.minecraft.net/MinecraftCloaks/", "").replace(".png", "");
var1 = "http://darklbp.tk/launcher/launcher.php?function=1&username=" + usertorequest + "&request=cloak";
System.out.println("To: " + var1);
var7 = getRequest(var1);
System.out.println("Response length: " + var7.length);
cloakCache.put(var8, var7);
sendResponse(var4, "image/png", var7);
return true;
}
var7 = (byte[])cloakCache.get(var8);
}
return false;
}
public boolean onPOST(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
public boolean onHEAD(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
public boolean onCONNECT(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
private void sendResponse(OutputStream var1, String var2, String var3)
{
sendResponse(var1, var2, var3.getBytes());
}
private void sendResponse(OutputStream var1, String var2, byte[] var3)
{
OutputStreamWriter var4 = new OutputStreamWriter(var1);
try
{
var4.append("HTTP/1.0 200 OK\r\nConnection: close\r\nProxy-Connection: close\r\n");
var4.append("Content-Length: " + Integer.toString(var3.length) + "\r\n");
if (var2 != null)
{
var4.append("Content-Type: " + var2 + "\r\n\r\n");
}
var4.flush();
var1.write(var3);
var1.flush();
var1.close();
}
catch (IOException var6)
{
System.out.println("Proxy - sendResponse error:");
var6.printStackTrace();
}
}
public static byte[] getRequest(String var0)
{
try
{
HttpURLConnection var1 = (HttpURLConnection)new URL(var0).openConnection(Proxy.NO_PROXY);
var1.setUseCaches(false);
var1.setDefaultUseCaches(false);
var1.setRequestProperty("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0");
var1.setRequestProperty("Expires", "0");
var1.setRequestProperty("Pragma", "no-store, no-cache");
var1.setInstanceFollowRedirects(true);
Map var2 = var1.getRequestProperties();
int var3 = var1.getResponseCode();
if (var3 / 100 == 3)
{
System.out.println("Java didn't redirect automatically, going manual: " + Integer.toString(var3));
String var4 = var1.getHeaderField("location").trim();
System.out.println("Manual redirection to: " + var4);
return getRequest(var4);
}
System.out.println("Response: " + var3);
if (var3 == 403)
{
String var4 = "403 from req to " + var0 + "\nRequest headers:\n";
Iterator var6 = var2.keySet().iterator();
while (var6.hasNext())
{
String var5 = (String)var6.next();
if (var5 != null)
{
List var7 = (List)var2.get(var5);
String var8;
for (Iterator var9 = var7.iterator(); var9.hasNext(); var4 = var4 + var5 + ": " + var8 + "\n")
{
var8 = (String)var9.next();
}
}
}
var4 = var4 + "Response headers:\n";
Map var13 = var1.getHeaderFields();
Iterator var16 = var13.keySet().iterator();
while (var16.hasNext())
{
String var15 = (String)var16.next();
if (var15 != null)
{
List var17 = (List)var13.get(var15);
String var18;
for (Iterator var10 = var17.iterator(); var10.hasNext(); var4 = var4 + var15 + ": " + var18 + "\n")
{
var18 = (String)var10.next();
}
}
}
System.out.println(var4);
System.out.println("Contents:\n" + new String(grabData(var1.getErrorStream())));
}
if (var3 / 100 == 4)
{
return new byte[0];
}
BufferedInputStream var14 = new BufferedInputStream(var1.getInputStream());
return grabData(var14);
}
catch (MalformedURLException var11)
{
System.out.println("Bad URL in getRequest:");
var11.printStackTrace();
}
catch (IOException var12)
{
System.out.println("IO error during a getRequest:");
var12.printStackTrace();
}
return new byte[0];
}
public static byte[] postRequest(String var0, String var1, String var2)
{
ByteArrayOutputStream var3 = new ByteArrayOutputStream();
OutputStreamWriter var4 = new OutputStreamWriter(var3);
try
{
var4.write(var1);
var4.flush();
}
catch (IOException var6)
{
var6.printStackTrace();
}
byte[] var5 = postRequest(var0, var3.toByteArray(), var2);
return var5;
}
public static byte[] postRequest(String var0, byte[] var1, String var2)
{
try
{
URL var3 = new URL(var0);
HttpURLConnection var4 = (HttpURLConnection)new URL(var0).openConnection(Proxy.NO_PROXY);
var4.setDoOutput(true);
var4.setRequestMethod("POST");
var4.setRequestProperty("Host", var3.getHost());
var4.setRequestProperty("Content-Length", Integer.toString(var1.length));
var4.setRequestProperty("Content-Type", var2);
BufferedOutputStream var5 = new BufferedOutputStream(var4.getOutputStream());
var5.write(var1);
var5.flush();
var5.close();
return grabData(new BufferedInputStream(var4.getInputStream()));
}
catch (UnknownHostException var7)
{
System.out.println("Unable to resolve remote host, returning null");
}
catch (MalformedURLException var8)
{
System.out.println("Bad URL when doing postRequest:");
var8.printStackTrace();
}
catch (IOException var9)
{
var9.printStackTrace();
}
return null;
}
public static byte[] grabData(InputStream var0)
{
ByteArrayOutputStream var1 = new ByteArrayOutputStream();
byte[] var2 = new byte[1024];
while (true)
{
int var3;
try
{
var3 = var0.read(var2);
if (var3 == -1)
{
break;
}
}
catch (IOException var5)
{
break;
}
var1.write(var2, 0, var3);
}
return var1.toByteArray();
}
public static String readUntil(InputStream var0, String var1)
{
return readUntil(var0, var1.getBytes());
}
public static String readUntil(InputStream var0, char var1)
{
return readUntil(var0, new byte[] { (byte)var1 });
}
public static String readUntil(InputStream var0, byte var1)
{
return readUntil(var0, new byte[] { var1 });
}
public static String readUntil(InputStream var0, byte[] var1)
{
ByteArrayOutputStream var2 = new ByteArrayOutputStream();
try
{
int var3 = 0;
boolean var4;
do
{
var4 = false;
byte var5;
try
{
var5 = (byte)var0.read();
}
catch (EOFException var8)
{
break;
}
if (var5 == var1[var3])
{
if (var3 == var1.length - 1)
{
var4 = true;
}
var3++;
}
else
{
var3 = 0;
}
var2.write(var5);
}
while (!var4);
}
catch (IOException var9)
{
System.out.println("readUntil unable to read from InputStream, endSeq: " + new String(var1));
var9.printStackTrace();
}
try
{
return var2.toString("UTF-8");
}
catch (UnsupportedEncodingException var7) {
}
return null;
}
}[/shcode]
[shcode=java]package net.minecraft.proxy;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProxyHandler
implements HttpProxyHandler, SocksProxyHandler
{
public static Pattern SKIN_URL = Pattern.compile("http://skins\\.minecraft\\.net/MinecraftSkins/(.+?)\\.png");
public static Pattern CLOAK_URL = Pattern.compile("http://skins\\.minecraft\\.net/MinecraftCloaks/(.+?)\\.png");
public static Pattern AUTHSERVER_URL = Pattern.compile("http://authserver\\.mojang\\.com/(.*)");
private Map skinCache = new Hashtable();
private Map cloakCache = new Hashtable();
public boolean onConnect(InputStream var1, OutputStream var2, SocksMessage var3)
{
var1.mark(65535);
String var4 = readUntil(var1, '\n');
String[] var5 = var4.split(" ");
if (var5.length != 3)
{
System.out.println("Not an HTTP request: " + var4);
try
{
var1.reset();
}
catch (IOException var12)
{
var12.printStackTrace();
}
return false;
}
String var6 = var5[0].toUpperCase();
String var7 = var5[1];
HashMap var8 = new HashMap();
String var9;
do {
var9 = readUntil(var1, '\n');
var9 = var9.trim();
int var10 = var9.indexOf(58);
if (var10 != -1)
{
var8.put(var9.substring(0, var10).toLowerCase().trim(), var9.substring(var10 + 1).trim());
}
}
while (var9.length() > 0);
String var14 = "http://" + (String)var8.get("host") + var7;
System.out.println("Proxy - onConnect - url: " + var14);
if (var6.equals("GET"))
{
if (onGET(var14, var8, var1, var2))
{
return true;
}
}
else if (var6.equals("POST"))
{
if (onPOST(var14, var8, var1, var2))
{
return true;
}
}
else if ((var6.equals("HEAD")) && (onHEAD(var14, var8, var1, var2)))
{
return true;
}
try
{
var1.reset();
}
catch (IOException var13)
{
var13.printStackTrace();
}
return false;
}
public boolean onBind()
{
return false;
}
public boolean onGET(String var1, Map var2, InputStream var3, OutputStream var4)
{
System.out.println("Proxy - onGET: " + var1);
Matcher var5 = SKIN_URL.matcher(var1);
Matcher var6 = CLOAK_URL.matcher(var1);
byte[] var7 = (byte[])null;
if (var5.matches())
{
System.out.println("Proxy: Skin");
String var8 = var5.group(1);
if (!skinCache.containsKey(var8))
{
String usertorequest = var1.replace("http://skins.minecraft.net/MinecraftSkins/", "").replace(".png", "");
var1 = "http://darklbp.tk/launcher/launcher.php?function=1&username=" + usertorequest + "&request=skin";
System.out.println("To: " + var1);
var7 = getRequest(var1);
System.out.println("Response length: " + var7.length);
skinCache.put(var8, var7);
sendResponse(var4, "image/png", var7);
return true;
}
var7 = (byte[])skinCache.get(var8);
}
else if (var6.matches())
{
System.out.println("Proxy: Cloak");
String var8 = var6.group(1);
if (!cloakCache.containsKey(var8))
{
String usertorequest = var1.replace("http://skins.minecraft.net/MinecraftCloaks/", "").replace(".png", "");
var1 = "http://darklbp.tk/launcher/launcher.php?function=1&username=" + usertorequest + "&request=cloak";
System.out.println("To: " + var1);
var7 = getRequest(var1);
System.out.println("Response length: " + var7.length);
cloakCache.put(var8, var7);
sendResponse(var4, "image/png", var7);
return true;
}
var7 = (byte[])cloakCache.get(var8);
}
return false;
}
public boolean onPOST(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
public boolean onHEAD(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
public boolean onCONNECT(String var1, Map var2, InputStream var3, OutputStream var4)
{
return false;
}
private void sendResponse(OutputStream var1, String var2, String var3)
{
sendResponse(var1, var2, var3.getBytes());
}
private void sendResponse(OutputStream var1, String var2, byte[] var3)
{
OutputStreamWriter var4 = new OutputStreamWriter(var1);
try
{
var4.append("HTTP/1.0 200 OK\r\nConnection: close\r\nProxy-Connection: close\r\n");
var4.append("Content-Length: " + Integer.toString(var3.length) + "\r\n");
if (var2 != null)
{
var4.append("Content-Type: " + var2 + "\r\n\r\n");
}
var4.flush();
var1.write(var3);
var1.flush();
var1.close();
}
catch (IOException var6)
{
System.out.println("Proxy - sendResponse error:");
var6.printStackTrace();
}
}
public static byte[] getRequest(String var0)
{
try
{
HttpURLConnection var1 = (HttpURLConnection)new URL(var0).openConnection(Proxy.NO_PROXY);
var1.setUseCaches(false);
var1.setDefaultUseCaches(false);
var1.setRequestProperty("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0");
var1.setRequestProperty("Expires", "0");
var1.setRequestProperty("Pragma", "no-store, no-cache");
var1.setInstanceFollowRedirects(true);
Map var2 = var1.getRequestProperties();
int var3 = var1.getResponseCode();
if (var3 / 100 == 3)
{
System.out.println("Java didn't redirect automatically, going manual: " + Integer.toString(var3));
String var4 = var1.getHeaderField("location").trim();
System.out.println("Manual redirection to: " + var4);
return getRequest(var4);
}
System.out.println("Response: " + var3);
if (var3 == 403)
{
String var4 = "403 from req to " + var0 + "\nRequest headers:\n";
Iterator var6 = var2.keySet().iterator();
while (var6.hasNext())
{
String var5 = (String)var6.next();
if (var5 != null)
{
List var7 = (List)var2.get(var5);
String var8;
for (Iterator var9 = var7.iterator(); var9.hasNext(); var4 = var4 + var5 + ": " + var8 + "\n")
{
var8 = (String)var9.next();
}
}
}
var4 = var4 + "Response headers:\n";
Map var13 = var1.getHeaderFields();
Iterator var16 = var13.keySet().iterator();
while (var16.hasNext())
{
String var15 = (String)var16.next();
if (var15 != null)
{
List var17 = (List)var13.get(var15);
String var18;
for (Iterator var10 = var17.iterator(); var10.hasNext(); var4 = var4 + var15 + ": " + var18 + "\n")
{
var18 = (String)var10.next();
}
}
}
System.out.println(var4);
System.out.println("Contents:\n" + new String(grabData(var1.getErrorStream())));
}
if (var3 / 100 == 4)
{
return new byte[0];
}
BufferedInputStream var14 = new BufferedInputStream(var1.getInputStream());
return grabData(var14);
}
catch (MalformedURLException var11)
{
System.out.println("Bad URL in getRequest:");
var11.printStackTrace();
}
catch (IOException var12)
{
System.out.println("IO error during a getRequest:");
var12.printStackTrace();
}
return new byte[0];
}
public static byte[] postRequest(String var0, String var1, String var2)
{
ByteArrayOutputStream var3 = new ByteArrayOutputStream();
OutputStreamWriter var4 = new OutputStreamWriter(var3);
try
{
var4.write(var1);
var4.flush();
}
catch (IOException var6)
{
var6.printStackTrace();
}
byte[] var5 = postRequest(var0, var3.toByteArray(), var2);
return var5;
}
public static byte[] postRequest(String var0, byte[] var1, String var2)
{
try
{
URL var3 = new URL(var0);
HttpURLConnection var4 = (HttpURLConnection)new URL(var0).openConnection(Proxy.NO_PROXY);
var4.setDoOutput(true);
var4.setRequestMethod("POST");
var4.setRequestProperty("Host", var3.getHost());
var4.setRequestProperty("Content-Length", Integer.toString(var1.length));
var4.setRequestProperty("Content-Type", var2);
BufferedOutputStream var5 = new BufferedOutputStream(var4.getOutputStream());
var5.write(var1);
var5.flush();
var5.close();
return grabData(new BufferedInputStream(var4.getInputStream()));
}
catch (UnknownHostException var7)
{
System.out.println("Unable to resolve remote host, returning null");
}
catch (MalformedURLException var8)
{
System.out.println("Bad URL when doing postRequest:");
var8.printStackTrace();
}
catch (IOException var9)
{
var9.printStackTrace();
}
return null;
}
public static byte[] grabData(InputStream var0)
{
ByteArrayOutputStream var1 = new ByteArrayOutputStream();
byte[] var2 = new byte[1024];
while (true)
{
int var3;
try
{
var3 = var0.read(var2);
if (var3 == -1)
{
break;
}
}
catch (IOException var5)
{
break;
}
var1.write(var2, 0, var3);
}
return var1.toByteArray();
}
public static String readUntil(InputStream var0, String var1)
{
return readUntil(var0, var1.getBytes());
}
public static String readUntil(InputStream var0, char var1)
{
return readUntil(var0, new byte[] { (byte)var1 });
}
public static String readUntil(InputStream var0, byte var1)
{
return readUntil(var0, new byte[] { var1 });
}
public static String readUntil(InputStream var0, byte[] var1)
{
ByteArrayOutputStream var2 = new ByteArrayOutputStream();
try
{
int var3 = 0;
boolean var4;
do
{
var4 = false;
byte var5;
try
{
var5 = (byte)var0.read();
}
catch (EOFException var8)
{
break;
}
if (var5 == var1[var3])
{
if (var3 == var1.length - 1)
{
var4 = true;
}
var3++;
}
else
{
var3 = 0;
}
var2.write(var5);
}
while (!var4);
}
catch (IOException var9)
{
System.out.println("readUntil unable to read from InputStream, endSeq: " + new String(var1));
var9.printStackTrace();
}
try
{
return var2.toString("UTF-8");
}
catch (UnsupportedEncodingException var7) {
}
return null;
}
}[/shcode]