While loop

I have a question, how could I use c++ to try and figure out a password. If you are wandering, yes I am trying to hack a program but to be fair the program I am trying to hack is a simple batch file THAT I MADE.


I am wandering if I could use a while loop to keep inputting numbers until the correct one is hit (something like the c++ program below)

the batch file is below the c++ one


C++

#include <iostream>
using namespace std;

int main() {
system("color 02");
int mine;
int password = 10000000000;
mine = 0;

while (mine != password) {

mine++;
cout << mine << '\n';

}

system("Pause");
return 0;

}


Batch file

@echo off
:login
cls
title Folder Locker
echo Folder Locker
echo ===================
echo.
set /p logname=Username:
if "%logname%"=="DeathAngle" goto login2
goto errorlog
:login2
set /p logpass="Password:"
if "%logpass%"=="1918" goto logingin
goto errorlog
:errorlog
cls
color 0c
echo Username or Password is incorrect.
echo Access Denied.
pause
goto exit

:logingin
cls
echo Welcome
pause

You would launch the batch file with CreateProcess from the WinAPI and append a space and the password you want to guess to the end of the command. As for determining pass\fail, you want to set the %ERRORLEVEL% flag in the batch file and check it with GetExitCodeProcess() from the C\C++ program.

NOTE: You want to use an array of char's, not a single int for this.
Registered users can post here. Sign in or register to post.