elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Temas
Páginas: [1]
1  Programación / Java / Alguien me puede ayudar a interpretar la funcion de este codigo en: 16 Agosto 2016, 05:22 am
Esto es java es parte de una apk de android y estoy confudido en su interpretacion, agradezco cualquier orientacion resumida o detallada, saludos..

Código
  1. package anywheresoftware.b4a.http;
  2.  
  3. import android.os.Handler;
  4. import android.util.Log;
  5. import anywheresoftware.b4a.BA;
  6. import anywheresoftware.b4a.BA.CheckForReinitialize;
  7. import anywheresoftware.b4a.BA.Hide;
  8. import anywheresoftware.b4a.BA.ShortName;
  9. import anywheresoftware.b4a.BA.Version;
  10. import anywheresoftware.b4a.objects.collections.Map;
  11. import anywheresoftware.b4a.objects.streams.File.InputStreamWrapper;
  12. import java.io.IOException;
  13. import java.io.InputStream;
  14. import java.io.OutputStream;
  15. import java.lang.reflect.Constructor;
  16. import java.lang.reflect.InvocationTargetException;
  17. import java.lang.reflect.Method;
  18. import java.security.KeyManagementException;
  19. import java.security.NoSuchAlgorithmException;
  20. import java.security.SecureRandom;
  21. import java.security.cert.CertificateException;
  22. import java.security.cert.X509Certificate;
  23. import java.util.HashMap;
  24. import javax.net.ssl.KeyManager;
  25. import javax.net.ssl.SSLContext;
  26. import javax.net.ssl.TrustManager;
  27. import javax.net.ssl.X509TrustManager;
  28. import org.apache.http.Header;
  29. import org.apache.http.HttpEntity;
  30. import org.apache.http.HttpHost;
  31. import org.apache.http.HttpResponse;
  32. import org.apache.http.ParseException;
  33. import org.apache.http.StatusLine;
  34. import org.apache.http.auth.AuthScope;
  35. import org.apache.http.auth.UsernamePasswordCredentials;
  36. import org.apache.http.client.ClientProtocolException;
  37. import org.apache.http.client.CredentialsProvider;
  38. import org.apache.http.client.methods.HttpDelete;
  39. import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
  40. import org.apache.http.client.methods.HttpGet;
  41. import org.apache.http.client.methods.HttpHead;
  42. import org.apache.http.client.methods.HttpPost;
  43. import org.apache.http.client.methods.HttpPut;
  44. import org.apache.http.client.methods.HttpRequestBase;
  45. import org.apache.http.client.methods.HttpUriRequest;
  46. import org.apache.http.conn.ConnectionPoolTimeoutException;
  47. import org.apache.http.conn.params.ConnManagerParams;
  48. import org.apache.http.conn.params.ConnPerRoute;
  49. import org.apache.http.conn.routing.HttpRoute;
  50. import org.apache.http.conn.scheme.PlainSocketFactory;
  51. import org.apache.http.conn.scheme.Scheme;
  52. import org.apache.http.conn.scheme.SchemeRegistry;
  53. import org.apache.http.entity.AbstractHttpEntity;
  54. import org.apache.http.entity.ByteArrayEntity;
  55. import org.apache.http.entity.InputStreamEntity;
  56. import org.apache.http.impl.auth.BasicScheme;
  57. import org.apache.http.impl.auth.DigestScheme;
  58. import org.apache.http.impl.client.DefaultHttpClient;
  59. import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
  60. import org.apache.http.params.BasicHttpParams;
  61. import org.apache.http.params.HttpConnectionParams;
  62. import org.apache.http.params.HttpParams;
  63. import org.apache.http.util.EntityUtils;
  64.  
  65. @BA.ShortName("HttpClient")
  66. @BA.Version(1.36F)
  67. public class HttpClientWrapper
  68.  implements BA.CheckForReinitialize
  69. {
  70.  private static final int maxConnectionToRoute = 5;
  71.  @BA.Hide
  72.  public DefaultHttpClient client;
  73.  private String eventName;
  74.  
  75.  public static void LIBRARY_DOC() {}
  76.  
  77.  private HttpResponse executeWithTimeout(final Runnable paramRunnable, HttpUriRequest paramHttpUriRequest, BA paramBA, final int paramInt)
  78.    throws ClientProtocolException, IOException
  79.  {
  80.    try
  81.    {
  82.      HttpResponse localHttpResponse = this.client.execute(paramHttpUriRequest);
  83.      return localHttpResponse;
  84.    }
  85.    catch (ConnectionPoolTimeoutException localConnectionPoolTimeoutException)
  86.    {
  87.      BA.handler.postDelayed(new Runnable()
  88.      {
  89.        public void run()
  90.        {
  91.          BA.submitRunnable(paramRunnable, HttpClientWrapper.this, paramInt);
  92.        }
  93.      }, 2000L);
  94.    }
  95.    return null;
  96.  }
  97.  
  98.  private void initializeShared(String paramString, org.apache.http.conn.ssl.SSLSocketFactory paramSSLSocketFactory)
  99.  {
  100.    this.eventName = paramString.toLowerCase(BA.cul);
  101.    SchemeRegistry localSchemeRegistry = new SchemeRegistry();
  102.    localSchemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  103.    localSchemeRegistry.register(new Scheme("https", paramSSLSocketFactory, 443));
  104.    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
  105.    ConnManagerParams.setMaxConnectionsPerRoute(localBasicHttpParams, new ConnPerRoute()
  106.    {
  107.      public int getMaxForRoute(HttpRoute paramAnonymousHttpRoute)
  108.      {
  109.        return 5;
  110.      }
  111.    });
  112.    ConnManagerParams.setTimeout(localBasicHttpParams, 100L);
  113.    this.client = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, localSchemeRegistry), localBasicHttpParams);
  114.  }
  115.  
  116.  public boolean Execute(BA paramBA, HttpUriRequestWrapper paramHttpUriRequestWrapper, int paramInt)
  117.    throws ClientProtocolException, IOException
  118.  {
  119.    return ExecuteCredentials(paramBA, paramHttpUriRequestWrapper, paramInt, null, null);
  120.  }
  121.  
  122.  public boolean ExecuteCredentials(BA paramBA, HttpUriRequestWrapper paramHttpUriRequestWrapper, int paramInt, String paramString1, String paramString2)
  123.    throws ClientProtocolException, IOException
  124.  {
  125.    if (BA.isTaskRunning(this, paramInt)) {
  126.      return false;
  127.    }
  128.    BA.submitRunnable(new ExecuteHelper(paramBA, paramHttpUriRequestWrapper, paramInt, paramString1, paramString2), this, paramInt);
  129.    return true;
  130.  }
  131.  
  132.  public void Initialize(String paramString)
  133.    throws ClientProtocolException, IOException
  134.  {
  135.    initializeShared(paramString, org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory());
  136.  }
  137.  
  138.  public void InitializeAcceptAll(String paramString)
  139.    throws KeyManagementException, NoSuchAlgorithmException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
  140.  {
  141.    TrustManager[] arrayOfTrustManager = new TrustManager[1];
  142.    arrayOfTrustManager[0] = new NaiveTrustManager(null);
  143.    SSLContext localSSLContext = SSLContext.getInstance("TLS");
  144.    localSSLContext.init(new KeyManager[0], arrayOfTrustManager, new SecureRandom());
  145.    Constructor localConstructor = org.apache.http.conn.ssl.SSLSocketFactory.class.getConstructor(new Class[] { javax.net.ssl.SSLSocketFactory.class });
  146.    Object[] arrayOfObject = new Object[1];
  147.    arrayOfObject[0] = localSSLContext.getSocketFactory();
  148.    org.apache.http.conn.ssl.SSLSocketFactory localSSLSocketFactory = (org.apache.http.conn.ssl.SSLSocketFactory)localConstructor.newInstance(arrayOfObject);
  149.    localSSLSocketFactory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  150.    initializeShared(paramString, localSSLSocketFactory);
  151.  }
  152.  
  153.  public boolean IsInitialized()
  154.  {
  155.    return this.client != null;
  156.  }
  157.  
  158.  public void SetHttpParameter(String paramString, Object paramObject)
  159.  {
  160.    this.client.getParams().setParameter(paramString, paramObject);
  161.  }
  162.  
  163.  public void SetProxy(String paramString1, int paramInt, String paramString2)
  164.  {
  165.    HttpHost localHttpHost = new HttpHost(paramString1, paramInt, paramString2);
  166.    this.client.getParams().setParameter("http.route.default-proxy", localHttpHost);
  167.  }
  168.  
  169.  public void SetProxy2(String paramString1, int paramInt, String paramString2, String paramString3, String paramString4)
  170.  {
  171.    HttpHost localHttpHost = new HttpHost(paramString1, paramInt, paramString2);
  172.    this.client.getCredentialsProvider().setCredentials(new AuthScope(paramString1, paramInt), new UsernamePasswordCredentials(paramString3, paramString4));
  173.    this.client.getParams().setParameter("http.route.default-proxy", localHttpHost);
  174.  }
  175.  
  176.  class ExecuteHelper
  177.    implements Runnable
  178.  {
  179.    private HttpClientWrapper.HttpUriRequestWrapper HttpRequest;
  180.    private String Password;
  181.    private int TaskId;
  182.    private String UserName;
  183.    private BA ba;
  184.  
  185.    public ExecuteHelper(BA paramBA, HttpClientWrapper.HttpUriRequestWrapper paramHttpUriRequestWrapper, int paramInt, String paramString1, String paramString2)
  186.    {
  187.      this.ba = paramBA;
  188.      this.HttpRequest = paramHttpUriRequestWrapper;
  189.      this.TaskId = paramInt;
  190.      this.UserName = paramString1;
  191.      this.Password = paramString2;
  192.    }
  193.  
  194.    public void run()
  195.    {
  196.      HttpResponse localHttpResponse = null;
  197.      for (;;)
  198.      {
  199.        int i2;
  200.        try
  201.        {
  202.          if (((this.HttpRequest.req instanceof HttpEntityEnclosingRequestBase)) && (this.UserName != null) && (this.UserName.length() > 0))
  203.          {
  204.            HttpEntityEnclosingRequestBase localHttpEntityEnclosingRequestBase = (HttpEntityEnclosingRequestBase)this.HttpRequest.req;
  205.            HttpEntity localHttpEntity = localHttpEntityEnclosingRequestBase.getEntity();
  206.            localHttpResponse = null;
  207.            if (localHttpEntity != null)
  208.            {
  209.              boolean bool = localHttpEntityEnclosingRequestBase.getEntity().isRepeatable();
  210.              localHttpResponse = null;
  211.              if (!bool)
  212.              {
  213.                UsernamePasswordCredentials localUsernamePasswordCredentials2 = new UsernamePasswordCredentials(this.UserName, this.Password);
  214.                Header localHeader3 = new BasicScheme().authenticate(localUsernamePasswordCredentials2, this.HttpRequest.req);
  215.                this.HttpRequest.req.addHeader(localHeader3);
  216.              }
  217.            }
  218.          }
  219.          localHttpResponse = HttpClientWrapper.this.executeWithTimeout(this, this.HttpRequest.req, this.ba, this.TaskId);
  220.          if (localHttpResponse == null) {
  221.            return;
  222.          }
  223.          if ((localHttpResponse.getStatusLine().getStatusCode() == 401) && (this.UserName != null) && (this.UserName.length() > 0))
  224.          {
  225.            m = 0;
  226.            n = 0;
  227.            localObject = null;
  228.            arrayOfHeader = localHttpResponse.getHeaders("WWW-Authenticate");
  229.            int i1 = arrayOfHeader.length;
  230.            i2 = 0;
  231.            if (i2 < i1) {
  232.              continue;
  233.            }
  234.            localUsernamePasswordCredentials1 = new UsernamePasswordCredentials(this.UserName, this.Password);
  235.            if (localHttpResponse.getEntity() != null) {
  236.              localHttpResponse.getEntity().consumeContent();
  237.            }
  238.            if (n == 0) {
  239.              continue;
  240.            }
  241.            DigestScheme localDigestScheme = new DigestScheme();
  242.            localDigestScheme.processChallenge((Header)localObject);
  243.            this.HttpRequest.req.addHeader(localDigestScheme.authenticate(localUsernamePasswordCredentials1, this.HttpRequest.req));
  244.            localHttpResponse = HttpClientWrapper.this.executeWithTimeout(this, this.HttpRequest.req, this.ba, this.TaskId);
  245.            if (localHttpResponse == null) {
  246.              break label950;
  247.            }
  248.          }
  249.        }
  250.        catch (Exception localException1)
  251.        {
  252.          int m;
  253.          int n;
  254.          Object localObject;
  255.          Header[] arrayOfHeader;
  256.          UsernamePasswordCredentials localUsernamePasswordCredentials1;
  257.          if (localHttpResponse == null) {
  258.            continue;
  259.          }
  260.          String str1 = localHttpResponse.getStatusLine().getReasonPhrase();
  261.          int i = localHttpResponse.getStatusLine().getStatusCode();
  262.          Method localMethod = (Method)this.ba.htSubs.get(HttpClientWrapper.this.eventName + "_responseerror");
  263.          int j = 1;
  264.          if (localMethod == null) {
  265.            continue;
  266.          }
  267.          if ((localMethod.getParameterTypes().length != 4) && (!BA.shellMode)) {
  268.            continue;
  269.          }
  270.          HttpClientWrapper.HttpResponeWrapper localHttpResponeWrapper1 = null;
  271.          if (localHttpResponse == null) {
  272.            continue;
  273.          }
  274.          localHttpResponeWrapper1 = new HttpClientWrapper.HttpResponeWrapper();
  275.          HttpClientWrapper localHttpClientWrapper1 = HttpClientWrapper.this;
  276.          HttpClientWrapper.HttpResponeWrapper.access$0(localHttpResponeWrapper1, localHttpClientWrapper1);
  277.          HttpClientWrapper.HttpResponeWrapper.access$1(localHttpResponeWrapper1, localHttpResponse);
  278.          try
  279.          {
  280.            ByteArrayEntity localByteArrayEntity = new ByteArrayEntity(EntityUtils.toByteArray(localHttpResponse.getEntity()));
  281.            localHttpResponse.setEntity(localByteArrayEntity);
  282.            arrayOfObject1 = new Object[4];
  283.            arrayOfObject1[0] = localHttpResponeWrapper1;
  284.            arrayOfObject1[1] = str1;
  285.            arrayOfObject1[2] = Integer.valueOf(i);
  286.            arrayOfObject1[3] = Integer.valueOf(this.TaskId);
  287.            j = 0;
  288.            this.ba.raiseEventFromDifferentThread(HttpClientWrapper.this.client, HttpClientWrapper.this, this.TaskId, HttpClientWrapper.this.eventName + "_responseerror", false, arrayOfObject1);
  289.            if ((j == 0) || (localHttpResponse == null) || (localHttpResponse.getEntity() == null)) {
  290.              break label950;
  291.            }
  292.            try
  293.            {
  294.              localHttpResponse.getEntity().consumeContent();
  295.              return;
  296.            }
  297.            catch (IOException localIOException)
  298.            {
  299.              Log.w("B4A", localIOException);
  300.              return;
  301.            }
  302.            Header localHeader2 = arrayOfHeader[i2];
  303.            String str3 = localHeader2.getValue().toLowerCase(BA.cul);
  304.            if (str3.contains("basic"))
  305.            {
  306.              m = 1;
  307.              break label951;
  308.            }
  309.            if (!str3.contains("digest")) {
  310.              break label951;
  311.            }
  312.            n = 1;
  313.            localObject = localHeader2;
  314.            break label951;
  315.            if (m == 0) {
  316.              continue;
  317.            }
  318.            Header localHeader1 = new BasicScheme().authenticate(localUsernamePasswordCredentials1, this.HttpRequest.req);
  319.            this.HttpRequest.req.addHeader(localHeader1);
  320.            localHttpResponse = HttpClientWrapper.this.executeWithTimeout(this, this.HttpRequest.req, this.ba, this.TaskId);
  321.            if (localHttpResponse != null) {
  322.              continue;
  323.            }
  324.            return;
  325.            HttpClientWrapper.HttpResponeWrapper localHttpResponeWrapper2 = new HttpClientWrapper.HttpResponeWrapper();
  326.            HttpClientWrapper.HttpResponeWrapper.access$0(localHttpResponeWrapper2, HttpClientWrapper.this);
  327.            HttpClientWrapper.HttpResponeWrapper.access$1(localHttpResponeWrapper2, localHttpResponse);
  328.            BA localBA = this.ba;
  329.            DefaultHttpClient localDefaultHttpClient = HttpClientWrapper.this.client;
  330.            HttpClientWrapper localHttpClientWrapper2 = HttpClientWrapper.this;
  331.            int k = this.TaskId;
  332.            String str2 = HttpClientWrapper.this.eventName + "_responsesuccess";
  333.            Object[] arrayOfObject2 = new Object[2];
  334.            arrayOfObject2[0] = localHttpResponeWrapper2;
  335.            arrayOfObject2[1] = Integer.valueOf(this.TaskId);
  336.            localBA.raiseEventFromDifferentThread(localDefaultHttpClient, localHttpClientWrapper2, k, str2, true, arrayOfObject2);
  337.            return;
  338.            localException1.printStackTrace();
  339.            str1 = localException1.toString();
  340.            i = -1;
  341.          }
  342.          catch (Exception localException2)
  343.          {
  344.            localException2.printStackTrace();
  345.            continue;
  346.          }
  347.          Object[] arrayOfObject1 = new Object[3];
  348.          arrayOfObject1[0] = str1;
  349.          arrayOfObject1[1] = Integer.valueOf(i);
  350.          arrayOfObject1[2] = Integer.valueOf(this.TaskId);
  351.          continue;
  352.        }
  353.        if (localHttpResponse.getStatusLine().getStatusCode() / 100 != 2) {
  354.          throw new Exception();
  355.        }
  356.        label950:
  357.        return;
  358.        label951:
  359.        i2++;
  360.      }
  361.    }
  362.  }
  363.  
  364.  @BA.ShortName("HttpResponse")
  365.  public static class HttpResponeWrapper
  366.  {
  367.    private HttpClientWrapper parent;
  368.    private HttpResponse response;
  369.  
  370.    static Map convertHeaders(Header[] paramArrayOfHeader)
  371.    {
  372.      Map localMap = new Map();
  373.      localMap.Initialize();
  374.      int i = paramArrayOfHeader.length;
  375.      for (int j = 0;; j++)
  376.      {
  377.        if (j >= i) {
  378.          return localMap;
  379.        }
  380.        Header localHeader = paramArrayOfHeader[j];
  381.        java.util.List localList = (java.util.List)localMap.Get(localHeader.getName());
  382.        if (localList == null)
  383.        {
  384.          anywheresoftware.b4a.objects.collections.List localList1 = new anywheresoftware.b4a.objects.collections.List();
  385.          localList1.Initialize();
  386.          localList = (java.util.List)localList1.getObject();
  387.          localMap.Put(localHeader.getName(), localList);
  388.        }
  389.        localList.add(localHeader.getValue());
  390.      }
  391.    }
  392.  
  393.    private void innerInitialize(HttpClientWrapper paramHttpClientWrapper)
  394.    {
  395.      this.parent = paramHttpClientWrapper;
  396.    }
  397.  
  398.    public boolean GetAsynchronously(final BA paramBA, final String paramString, final OutputStream paramOutputStream, final boolean paramBoolean, final int paramInt)
  399.      throws IOException
  400.    {
  401.      if (BA.isTaskRunning(this.parent, paramInt))
  402.      {
  403.        Release();
  404.        return false;
  405.      }
2  Programación / Ingeniería Inversa / Ayuda descubrir tipo de proteccion ! en: 28 Julio 2016, 03:00 am
Hola Saludos, soy nuevo en esta agradable comunidad, la cual visito con frecuencia buscando aprender algo nuevo.
bueno el tema en el que desearia un poco de ayuda y orientacion es porque eventualmente asumo retos en modificacion de uno que otro programita  :rolleyes:
pero ahora me siento frustrado porque di con uno que despues de 3 semanas no logro  ni tan solo conocer que tipo de proteccion es que tiene, los datos son estos:
-programa hecho en visual basic 5 segun RDG packer, tipo gestion- ventas.

-lo analize peid y dice lo mismo, nada de packer ni proteccion

- con olly activando todas la excepciones logro correlo pero en los puntos o apis
que a mi parecer son mas sospechosas al poner HBP o BP nunca para ni me pasa informacion en un condicional.

- lo curioso que veo es que en la zona de codigo mas caliente en el momento que se ejecuta aparecen lineas de codigo nuevo y luego cuando termina la rutina desaparecen que sera????

- en la carpeta donde esta el exe solo hay 2 archivos el exe y la base de datos,
porque solo 2??????? :o
cualquier consejo es bien recibido gracias..
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines