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


#include <iostream>
using namespace std;

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

while (mine != password) {

cout << mine << '\n';


return 0;


Batch file

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

echo Welcome

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.
Topic archived. No new replies allowed.