Created
May 30, 2017 19:36
-
-
Save ukaszjankowski/984119503fec86ca2720201f8234479e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace BruteMission004 | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var mission = new Mission004(); | |
mission.Brute(); | |
Console.WriteLine(mission.Check(new byte[] { 0x47, 0xA8, 0x47, 0x57, 0xDE })); // disconnect3d | |
Console.WriteLine(mission.Check(new byte[] { 0x47, 0x57, 0x47, 0x57, 0x21 })); | |
mission.Brute(0, 255); | |
Console.ReadLine(); | |
} | |
} | |
internal class Mission004 | |
{ | |
private const UInt64 magicValue = 0x1451723121264133; | |
internal bool Check(byte[] chars) | |
{ | |
UInt64 ch = magicValue; | |
for (int i = 0; i < 5; i++) | |
ch = ((ch << 9) | (ch >> 55)) ^ chars[i]; | |
return 14422328074577807877 == ch; | |
} | |
internal void Brute(int startValue = 32, int stopValue = 128) | |
{ | |
Parallel.For(startValue, stopValue, (i) => | |
{ | |
byte[] chars = new byte[5]; | |
chars[0] = (byte)i; | |
for (int j = startValue; j < stopValue; j++) | |
{ | |
chars[1] = (byte)j; | |
for (int k = startValue; k < stopValue; k++) | |
{ | |
chars[2] = (byte)k; | |
for (int l = startValue; l < stopValue; l++) | |
{ | |
chars[3] = (byte)l; | |
for (int m = startValue; m < stopValue; m++) | |
{ | |
chars[4] = (byte)m; | |
if (Check(chars)) | |
lock (this) | |
{ | |
Console.WriteLine(string.Join(" ", chars.Select(c => String.Format("0x{0:X}", (int)c)))); | |
} | |
} | |
} | |
} | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment