added basic function for checking and calculating hash (Need to work out how to do this though!
This commit is contained in:
parent
e622a6194d
commit
fd7219c884
|
@ -18,10 +18,11 @@ namespace USB_Lockdown
|
||||||
|
|
||||||
internal static void beginAuthentication()
|
internal static void beginAuthentication()
|
||||||
{
|
{
|
||||||
|
deviceScan.calculateHash();
|
||||||
Thread deviceScanner = new Thread(deviceScan.scanDevices);
|
Thread deviceScanner = new Thread(deviceScan.scanDevices);
|
||||||
deviceScanner.Join(); //the thread will exit when a valid drive has been found
|
deviceScanner.Join(); //the thread will exit when a valid drive has been found
|
||||||
|
|
||||||
//code here to unlock computer and
|
//code here to unlock computer and stuff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class deviceScan
|
class deviceScan
|
||||||
|
@ -29,14 +30,21 @@ namespace USB_Lockdown
|
||||||
internal static DriveInfo validDrive;
|
internal static DriveInfo validDrive;
|
||||||
internal static DriveInfo[] driveListing;
|
internal static DriveInfo[] driveListing;
|
||||||
private static bool driveFound = false;
|
private static bool driveFound = false;
|
||||||
|
internal static string originalHash;
|
||||||
|
|
||||||
|
internal static void calculateHash()
|
||||||
|
{
|
||||||
|
//decide how to do this!
|
||||||
|
|
||||||
|
}
|
||||||
internal static void scanDevices()
|
internal static void scanDevices()
|
||||||
{
|
{
|
||||||
while (!driveFound) {
|
while (!driveFound) {
|
||||||
driveListing = DriveInfo.GetDrives();
|
driveListing = DriveInfo.GetDrives();
|
||||||
foreach (DriveInfo currentDrive in driveListing)
|
foreach (DriveInfo currentDrive in driveListing)
|
||||||
{
|
{
|
||||||
|
try { string driveName = currentDrive.VolumeLabel; string driveLabel = currentDrive.Name; }
|
||||||
|
catch { }
|
||||||
if (File.Exists(currentDrive.Name + "\\LockDown.config")) // the first check for a valid drive. Could be something else, but this is a lightweight test to be done first!
|
if (File.Exists(currentDrive.Name + "\\LockDown.config")) // the first check for a valid drive. Could be something else, but this is a lightweight test to be done first!
|
||||||
{
|
{
|
||||||
if (driveValidate(currentDrive)) //runs the full validation of the drive
|
if (driveValidate(currentDrive)) //runs the full validation of the drive
|
||||||
|
@ -51,10 +59,26 @@ namespace USB_Lockdown
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool driveValidate(DriveInfo drive){
|
internal static bool driveValidate(DriveInfo drive){
|
||||||
|
if (!checkHash(drive)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool checkHash(DriveInfo drive)
|
||||||
|
{
|
||||||
|
string fileName = drive.Name + "";
|
||||||
|
if (!File.Exists(fileName)) { return false; }
|
||||||
|
|
||||||
|
using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
|
||||||
|
{
|
||||||
|
string hashFromDrive = reader.ReadString();
|
||||||
|
if (hashFromDrive != )
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static void resetValues()
|
internal static void resetValues()
|
||||||
{
|
{
|
||||||
validDrive = null;
|
validDrive = null;
|
||||||
|
|
Reference in New Issue