Advertise

Tuesday, 24 September 2013

Basic Idea of Creating Password Bruteforce tool

Includes 2 Basic Program :-
  1. Basic "C++" program.
  2. BruteForce Script in Python.


Here is Sample Code of CPP Program, that will need Password :-




Codes are messed up because of blogger. So Get a Code from here - https://github.com/krokite/basicBruteforce


PHP Code:
/*
Author: KroKite


Description: Basic Bruteforcing Tools


URI: http://www.fb.me/r0ckysharma
*/

#include 
#include
#include
using namespace std;// When passing char arrays as parameters they must be pointersint main(int argcchar** argv) {
    if (
argc 4) { // Check the value of argc. If not enough parameters than, inform user and exit.
        
cout << "Usage is -f input_filename -p password\n";
        exit(
0);
    } else { 
// if we got enough parameters..
        
int i=1;
        while(
i<=argc) {
                if (
strcmp(argv[i],"-f") == 0) {
                        
cout << "File to Open: " << argv[1] << endl;
                }
                if (
strcmp(argv[i],"-p") == 0) {
                        
cout <<"Password is : " << argv[1] << endl;
                        if(
strcmp(argv[i+1], "KroKite") == 0) {
                                
cout << "File Opening SuccessFul"<< endl;
                        } else {
                                
cout << "Wrong Password"<< endl;
                        }
                }
        
i++;
        }
    }
    return 
0;
}  
Compile above program with g++ 


Code:
root@blackbuntu# g++ blackbuntu.cpp -o blackbuntu
and now run program to understand what it will do, 


Code:
root@blackbuntu# ./blackbuntu 
Usage is -f input_filename -p password
So, Run with Arguments, and it takes password with '-p' arguments :-

Giving Wrong Password as "blackbuntu"


Code:
root@blackbuntu# ./blackbuntu -f blackbuntu.txt -p blackbuntu
File to Open:  blackbuntu.txt
Password is : blackbuntu
Wrong Password
Now Running with Correct Password :-


Code:
root@blackbuntu# ./blackbuntu -f blackbuntu.txt -p KroKite
File to Open:  blackbuntu.txt
Password is : KroKite
File Opening SuccessFul
But, Now what if you don't know the password of program, and you need to open it, how would you do that, here is basic python code that will help you do that :-

Save below file with name "bruteforce.py"


PHP Code:
#!/usr/bin/python
# Author : KroKite
# Description: Basic Password Bruteforcing Tool
# URL: http://www.fb.me/r0ckysharma
# Python Version 2.7
import subprocess
import re

fo 
open("password.txt"'r');
for 
lines in fo:
    
password lines.split('\n')
    
brute subprocess.Popen(["./blackbuntu""-f""foo.txt""-p"password[0]], stdout=subprocess.PIPE)
    if(
re.search("Success"brute.communicate()[0])):
        print 
"Password Cracked and your Password is "password[0]
        exit()
    else:
        print 
password[0], " is not Password"  
Now make another file which has list of password, Write 1 password in 1 line.

password.txt file :-


Code:
abcdef
123456
hacker
bullshit
wtf
blackbuntu
facebook
twitter
metallica
KroKite
shit
password
pass
And now Run your python program :-


Code:
root@blackbuntu# python bruteforce.py 
abcdef  is not Password
123456  is not Password
hacker  is not Password
bullshit  is not Password
wtf  is not Password
blackbuntu  is not Password
facebook  is not Password
twitter  is not Password
metallica  is not Password
Password Cracked and your Password is  KroKite
Note: Please Remember this is just basic idea and does not account exactly to your program, you might have to do more homework for your application with above bruteforce.py tool. With Few Changes above bruteforce.py tool may work with mysql [not tested]

bruteforce.py file reads 1 password at a time and than run your program with fetched password and checks the success of password, if it does, than it simply prints password and exit, so the very last line will be your password if it has successfully cracked it.

Also , all above Code is completely written by me, if you share it or modify it further, do include my credit. Thanks

Got Question ? Ask them below, and i believe this simple demo will clear doubts.
 
World of Hacker © 2011 Creative Commons License
World of Hacker by KroKite is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at http://www.worldofhacker.com.
Permissions beyond the scope of this license may be available at https://groups.google.com/forum/#!newtopic/hackerforum.