Advertisement
AntonioVillanueva

Cracking edb-debugger

May 16th, 2024
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.46 KB | None | 0 0
  1. //g++ -Wall -static-libstdc++ -std=c++11 -Wunused-but-set-variable `wx-config --cxxflags` -o crackme crackme.cpp `wx-config --libs`
  2. //g++ -Wall -static-libstdc++ -std=c++11 -Wunused-but-set-variable `wx-config --cxxflags` -o crackme crackme.cpp `wx-config --static=yes --libs`
  3.  
  4. #include <wx/wx.h>
  5.  
  6. class PasswordDialog : public wxDialog {
  7. public:
  8.     PasswordDialog(const wxString& title) : wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(350, 150)), m_attemptsRemaining(5) {
  9.         wxPanel *panel = new wxPanel(this, wxID_ANY);
  10.        
  11.         wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
  12.         panel->SetSizer(vbox); // Aquí se establece el sizer en el panel
  13.        
  14.         wxStaticText *text = new wxStaticText(panel, wxID_ANY, "Introduce el  password:", wxDefaultPosition, wxDefaultSize, 0);
  15.         vbox->Add(text, 0, wxALL, 5);
  16.        
  17.         m_passwordTextCtrl = new wxTextCtrl(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
  18.         vbox->Add(m_passwordTextCtrl, 0, wxALL | wxEXPAND, 5);
  19.        
  20.         wxButton *confirmButton = new wxButton(panel, wxID_OK, "Confirma", wxDefaultPosition, wxDefaultSize, 0);
  21.         vbox->Add(confirmButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
  22.  
  23.         wxButton *cancelButton = new wxButton(panel, wxID_CANCEL, "Cancelar", wxDefaultPosition, wxDefaultSize, 0);
  24.         vbox->Add(cancelButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
  25.        
  26.         // Manejar el evento de hacer clic en el botón de cancelar
  27.         Bind(wxEVT_BUTTON, &PasswordDialog::OnCancel, this, wxID_CANCEL);
  28.     }
  29.    
  30.     wxString GetPassword() const {
  31.         return m_passwordTextCtrl->GetValue();
  32.     }
  33.  
  34.     int GetAttemptsRemaining() const {
  35.         return m_attemptsRemaining;
  36.     }
  37.  
  38.     void DecrementAttempts() {
  39.         m_attemptsRemaining--;
  40.     }
  41.  
  42. private:
  43.     wxTextCtrl *m_passwordTextCtrl;
  44.     int m_attemptsRemaining;
  45.  
  46.     void OnCancel(wxCommandEvent& event) {
  47.         EndModal(wxID_CANCEL);
  48.     }
  49. };
  50.  
  51. class MyApp : public wxApp {
  52. public:
  53.     virtual bool OnInit() {
  54.         PasswordDialog dialog("Crackme v3 por Antonio Villanueva");
  55.         wxString clave = "4560407Tony";
  56.         while (true) {
  57.             int result = dialog.ShowModal();
  58.             if (result == wxID_OK) {
  59.                 wxString password = dialog.GetPassword();
  60.                 if (password == clave) {
  61.                     wxMessageBox("Felicidades has crackeado el password  " + password, "Info", wxOK | wxICON_INFORMATION);
  62.                     break;
  63.                 } else {
  64.                     dialog.DecrementAttempts();
  65.                     int attemptsRemaining = dialog.GetAttemptsRemaining();
  66.                     if (attemptsRemaining > 0) {
  67.                         wxMessageBox("El password " + password + " no es correcto. Te quedan " + wxString::Format("%d", attemptsRemaining) + " posibilidades", "Info", wxOK | wxICON_INFORMATION);
  68.                     } else {
  69.                         wxMessageBox("Te has quedado sin intentos. El programa se cerrará.", "Info", wxOK | wxICON_INFORMATION);
  70.                         break;
  71.                     }
  72.                 }
  73.             } else if (result == wxID_CANCEL) {
  74.                 // Si se hace clic en Cancelar o se cierra la ventana, salir del bucle
  75.                 break;
  76.             }
  77.         }
  78.         // Salir del programa después de cerrar la ventana de diálogo
  79.         return false;
  80.     }
  81. };
  82.  
  83. wxIMPLEMENT_APP(MyApp);
  84.  
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement