Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //g++ -Wall -static-libstdc++ -std=c++11 -Wunused-but-set-variable `wx-config --cxxflags` -o crackme crackme.cpp `wx-config --libs`
- //g++ -Wall -static-libstdc++ -std=c++11 -Wunused-but-set-variable `wx-config --cxxflags` -o crackme crackme.cpp `wx-config --static=yes --libs`
- #include <wx/wx.h>
- class PasswordDialog : public wxDialog {
- public:
- PasswordDialog(const wxString& title) : wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(350, 150)), m_attemptsRemaining(5) {
- wxPanel *panel = new wxPanel(this, wxID_ANY);
- wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
- panel->SetSizer(vbox); // Aquí se establece el sizer en el panel
- wxStaticText *text = new wxStaticText(panel, wxID_ANY, "Introduce el password:", wxDefaultPosition, wxDefaultSize, 0);
- vbox->Add(text, 0, wxALL, 5);
- m_passwordTextCtrl = new wxTextCtrl(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
- vbox->Add(m_passwordTextCtrl, 0, wxALL | wxEXPAND, 5);
- wxButton *confirmButton = new wxButton(panel, wxID_OK, "Confirma", wxDefaultPosition, wxDefaultSize, 0);
- vbox->Add(confirmButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
- wxButton *cancelButton = new wxButton(panel, wxID_CANCEL, "Cancelar", wxDefaultPosition, wxDefaultSize, 0);
- vbox->Add(cancelButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
- // Manejar el evento de hacer clic en el botón de cancelar
- Bind(wxEVT_BUTTON, &PasswordDialog::OnCancel, this, wxID_CANCEL);
- }
- wxString GetPassword() const {
- return m_passwordTextCtrl->GetValue();
- }
- int GetAttemptsRemaining() const {
- return m_attemptsRemaining;
- }
- void DecrementAttempts() {
- m_attemptsRemaining--;
- }
- private:
- wxTextCtrl *m_passwordTextCtrl;
- int m_attemptsRemaining;
- void OnCancel(wxCommandEvent& event) {
- EndModal(wxID_CANCEL);
- }
- };
- class MyApp : public wxApp {
- public:
- virtual bool OnInit() {
- PasswordDialog dialog("Crackme v3 por Antonio Villanueva");
- wxString clave = "4560407Tony";
- while (true) {
- int result = dialog.ShowModal();
- if (result == wxID_OK) {
- wxString password = dialog.GetPassword();
- if (password == clave) {
- wxMessageBox("Felicidades has crackeado el password " + password, "Info", wxOK | wxICON_INFORMATION);
- break;
- } else {
- dialog.DecrementAttempts();
- int attemptsRemaining = dialog.GetAttemptsRemaining();
- if (attemptsRemaining > 0) {
- wxMessageBox("El password " + password + " no es correcto. Te quedan " + wxString::Format("%d", attemptsRemaining) + " posibilidades", "Info", wxOK | wxICON_INFORMATION);
- } else {
- wxMessageBox("Te has quedado sin intentos. El programa se cerrará.", "Info", wxOK | wxICON_INFORMATION);
- break;
- }
- }
- } else if (result == wxID_CANCEL) {
- // Si se hace clic en Cancelar o se cierra la ventana, salir del bucle
- break;
- }
- }
- // Salir del programa después de cerrar la ventana de diálogo
- return false;
- }
- };
- wxIMPLEMENT_APP(MyApp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement