Category Archives: Software

Brute-Force Password Generator / permutations

Generator of all possible N symbols strings

After searching the net for a solution to generate of all possible combination of N symbols from given strings, I decide to write one in python.

This is an algorithm for Permutation Generation you can run it from the beginning of the permutation or start it in the middle.

The algorithm is flexible and can handle any password length for given an “alphabet”

The variables:

characters = “abc” #  this will define the alphabet to generate the combination
letter = 3 # This will define how many combination of letters you want to have? the algorithm will start from 1 to the number you choose here.

Download the source-code

Run Example:

characters = “ab12”
letter = 2;

Output:

a
b
1
2
aa
ba
1a
2a
ab
bb
1b
2b
a1
b1
11
21
a2
b2
12
22
aaa
baa
1aa
2aa
aba
bba
1ba
2ba
a1a
b1a
11a
21a
a2a
b2a
12a
22a
aab
bab
1ab
2ab
abb
bbb
1bb
2bb
a1b
b1b
11b
21b
a2b
b2b
12b
22b
aa1
ba1
1a1
2a1
ab1
bb1
1b1
2b1
a11
b11
111
211
a21
b21
121
221
aa2
ba2
1a2
2a2
ab2
bb2
1b2
2b2
a12
b12
112
212
a22
b22
122
222

Run Example:

characters = “abc123”
letter = 3;

Output:

a
b
1
2
aa
ba
1a
2a
ab
bb
1b
2b
a1
b1
11
21
a2
b2
12
22
aaa
baa
1aa
2aa
aba
bba
1ba
2ba
a1a
b1a
11a
21a
a2a
b2a
12a
22a
aab
bab
1ab
2ab
abb
bbb
1bb
2bb
a1b
b1b
11b
21b
a2b
b2b
12b
22b
aa1
ba1
1a1
2a1
ab1
bb1
1b1
2b1
a11
b11
111
211
a21
b21
121
221
aa2
ba2
1a2
2a2
ab2
bb2
1b2
2b2
a12
b12
112
212
a22
b22
122
222

 

Benchmark Between to Methods that Resize Array in C#

Prob: There is two methods to change size of array in C#. Using a template of a Benchmark program from this informative site, I checked the two ways:

Array.Resize  VS  Array.CopyTo VS Loop

Conclusion: sometime build it your self is not that better then using the build-in commands…

Array.Resize took 30253 ms
Arryay.CopyTo took 29649 ms
Loop took 58323 ms

Solution:

Here is the code that I use

class Program
{
public static void AddCell1(ref double[] vector,int num)
{
int size = vector.Length;
Array.Resize(ref vector,size+1);
vector[size] = num;
}
//————————————————-

public static void AddCell2(ref double[] vector,int num)
{
double[] tempVec = new double[vector.Length+1];
vector.CopyTo(tempVec,0);
tempVec[vector.Length] = num;
vector = tempVec;
}
//————————————————-

public static void AddCell3(ref double[] vector,int num)
{
double[] tempVec = new double[vector.Length+1];
for (int i = 0; i < vector.Length ; i++) {
tempVec[i] = vector[i];
}
tempVec[vector.Length] = num;
vector = tempVec;
}
//————————————————-

public static void Main(string[] args)
{
Console.WriteLine(“Hello World!”);

double[] arr1 = new double[]{};
double[] arr2 = new double[]{};
double[] arr3 = new double[]{};

Stopwatch s1 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
AddCell1(ref arr1,i);
s1.Stop();

Stopwatch s2 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
AddCell2(ref arr2,i);
s2.Stop();

Stopwatch s3 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
AddCell3(ref arr3,i);
s3.Stop();

// TODO: Implement Functionality Here
Console.WriteLine(“{0},{1},{2}”,
s1.ElapsedMilliseconds,
s2.ElapsedMilliseconds,
s3.ElapsedMilliseconds);
Console.Write(“Press any key to continue . . . “);
Console.ReadKey(true);
}
}

How to temporary erase file in Windows 7 with NTFS without pressing delete button

Weird thing in Windows 7 with NTFS, here is what I accidentally found: If you rename file and add in its end a dot, the file is temporary vanish!!

here is how it happened:

First go to file that you want to delete, in my case the file name is: “win7.ld”
Second: press F2 to rename the file

Windows will ask if you sure, and of-course you say YES!

Then Windows will not trust you and ask again, and again you will say YES!

Result

The file as been vanish!!

But, if you want to go back, just press F5 (refresh) the the file will appear again…

Brute-Force Truecrypt Password

Did you forget your Truecrypt password?

Not to worry, using simple search in Google I found a script in this site, and I adapt it for my needs, I post it  here because it could be helpful to other.

To succesful run the script you will required to install AutoITscript, that is AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

The script will use all the character or words that in the variable $Array, to run on all the possibilities and combination of any order, from 2 combination to 7 combination and try to open the container. The script will run until it will find a match or it will exhaust any of your given possibilities.

Note:

  • $truecryptPath is the path of your TrueCrypt program
  • $containerPath is the path to the container that you wont to open
  • If the script find the right password it automatically mount the container to one of the free drive letters and open explorer to it.
  • The path to the TrueCrypt program and to your container MUST be in DOS-8 characters format, to get it you need to use “dir /x” and CMD.
  • you also can save time by eliminate character that you absolutely sure that you didn’t use in your password oryou can change every place in the array to possible combination of your passwordfor example: if I have same patterns for my password and I am using only combination of it
    • date of my child = 1308200
    • ID number = 123456789
    • name of the neighbor = moshe
    • family name = ofnick

Add  those to the $Array  and run all combination of your favorites password to save you time by running the script only on your your combination password

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

So here is the script:

dim $one, $two, $three, $four, $five, $six, $seven, $eight, $pw, $pp, $count, $truecryptPath, $containerPath
$truecryptPath = "C:PROGRA~1TrueCryptTrueCrypt.exe /q background /s "
$containerPath = "d:cscs2.tre"
dim $numberOfCharacters = 92
dim $Array[$numberOfCharacters+1]
$Array[0]="a"
$Array[1]="b"
$Array[2]="c"
$Array[3]="d"
$Array[4]="e"
$Array[5]="f"
$Array[6]="g"
$Array[7]="h"
$Array[8]="i"
$Array[9]="j"
$Array[10]="k"
$Array[11]="l"
$Array[12]="m"
$Array[13]="n"
$Array[14]="o"
$Array[15]="p"
$Array[16]="q"
$Array[17]="r"
$Array[18]="s"
$Array[19]="t"
$Array[20]="u"
$Array[21]="v"
$Array[22]="w"
$Array[23]="x"
$Array[24]="y"
$Array[25]="z"
$Array[26]="A"
$Array[27]="B"
$Array[28]="C"
$Array[29]="D"
$Array[30]="E"
$Array[31]="F"
$Array[32]="G"
$Array[33]="H"
$Array[34]="I"
$Array[35]="J"
$Array[36]="K"
$Array[37]="L"
$Array[38]="M"
$Array[39]="N"
$Array[40]="O"
$Array[41]="P"
$Array[42]="Q"
$Array[43]="R"
$Array[44]="S"
$Array[45]="T"
$Array[46]="U"
$Array[47]="V"
$Array[48]="W"
$Array[49]="X"
$Array[50]="Y"
$Array[51]="Z"
$Array[52]="!"
$Array[53]="@"
$Array[54]="#"
$Array[55]="$"
$Array[56]="%"
$Array[57]="^"
$Array[58]="&"
$Array[59]="*"
$Array[60]="("
$Array[61]=")"
$Array[62]="_"
$Array[63]="+"
$Array[64]="~"
$Array[65]="`"
$Array[66]="1"
$Array[67]="2"
$Array[68]="3"
$Array[69]="4"
$Array[70]="5"
$Array[71]="6"
$Array[72]="7"
$Array[73]="8"
$Array[74]="9"
$Array[75]="0"
$Array[76]="-"
$Array[77]="="
$Array[78]="["
$Array[79]="]"
$Array[80]=""
$Array[81]="{"
$Array[82]="}"
$Array[83]="|"
$Array[84]=";"
$Array[85]=":"
$Array[86]="'"
$Array[87]=""""
$Array[88]=","
$Array[89]="."
$Array[90]="/"
$Array[91]="?"
$count = 0
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
Wend
EndIf
Next
Next
While ProcessExists($pp)>0
Wend
$count = 0
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
$count = 0
Wend
EndIf
Next
Next
Next
While ProcessExists($pp)>0
Wend
$count = 0
for $four = 0 to $numberOfCharacters
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$pw &= $Array[$four]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
$count = 0
Wend
EndIf
Next
Next
Next
Next
While ProcessExists($pp)>0
Wend
$count = 0
for $five = 0 to $numberOfCharacters
for $four = 0 to $numberOfCharacters
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$pw &= $Array[$four]
$pw &= $Array[$five]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
Wend
$count = 0
EndIf
Next
Next
Next
Next
Next
While ProcessExists($pp)>0
Wend
$count = 0
FOR $six = 0 to $numberOfCharacters
for $five = 0 to $numberOfCharacters
for $four = 0 to $numberOfCharacters
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$pw &= $Array[$four]
$pw &= $Array[$five]
$pw &= $Array[$six]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
Wend
$count = 0
EndIf
Next
Next
Next
Next
Next
Next
While ProcessExists($pp)>0
Wend
$count = 0
for $seven = 0 to $numberOfCharacters
FOR $six = 0 to $numberOfCharacters
for $five = 0 to $numberOfCharacters
for $four = 0 to $numberOfCharacters
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$pw &= $Array[$four]
$pw &= $Array[$five]
$pw &= $Array[$six]
$pw &= $Array[$seven]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
Wend
$count = 0
EndIf
Next
Next
Next
Next
Next
Next
Next
While ProcessExists($pp)>0
Wend
for $eight = 0 to $numberOfCharacters
for $seven = 0 to $numberOfCharacters
FOR $six = 0 to $numberOfCharacters
for $five = 0 to $numberOfCharacters
for $four = 0 to $numberOfCharacters
for $three = 0 to $numberOfCharacters
for $two = 0 to $numberOfCharacters
for $one = 0 to $numberOfCharacters
$pw = $Array[$one]
$pw &= $Array[$two]
$pw &= $Array[$three]
$pw &= $Array[$four]
$pw &= $Array[$five]
$pw &= $Array[$six]
$pw &= $Array[$seven]
$pw &= $Array[$eight]
$count = $count+1
$pp  = Run(@COMSPEC & " /c " & $truecryptPath & " /p "& $pw & " /e /m ro /m rm /v " &$containerPath )
ProcessSetPriority($pp, 0)
if $count>25 then
While ProcessExists($pp)>0
Wend
$count = 0
EndIf
Next
Next
Next
Next
Next
Next
Next
Next