diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91991f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Software Source/.vs +Software Source/x64 +x64 +Software Source/RFIDCredentialProvider/Debug diff --git a/Firmware/RFIDuino_windows_unlock/RFIDuino_windows_unlock.ino b/Firmware/RFIDuino_windows_unlock/RFIDuino_windows_unlock.ino index 6ad7b17..e66fa57 100644 --- a/Firmware/RFIDuino_windows_unlock/RFIDuino_windows_unlock.ino +++ b/Firmware/RFIDuino_windows_unlock/RFIDuino_windows_unlock.ino @@ -1,104 +1,72 @@ -/*************************************************************************** - * RFIDuino Windows Unlock - * - * This demo uses the RFIDuino sheild, a Geekduino (or other Arduino Board) - * to send an RFID to a Windows Vista/7/8/10 PC. See the link below for - * windows software and instructions. - * - * Links - * RFIDUino Windows Login Instructions - * http://learn.robotgeek.com/getting-started/41-rfiduino/181-rfiduino-windows-login.html - * RFIDUino Getting Started Guide - * http://learn.robotgeek.com/getting-started/41-rfiduino/142-rfiduino-getting-started-guide.html - * RFIDUino Library Documentation - * http://learn.robotgeek.com/41-rfiduino/144-rfiduino-library-documentation.html - * RFIDUino Shield Product Page - * http://www.robotgeek.com/rfiduino - * - * Notes - * The RFIDuino library is compatible with both versions of the RFIDuino shield - * (1.1 and 1.2), but the user must initialize the library correctly. See - * 'HARDWARE VERSION' instructions near the beginning of the code. - * - * The RFIDuino Shield is designed to be used with 125khz EM4100 family tags. - * This includes any of the EM4102 tags sold by Trossen Robotics/ RobotGeek. - * The RFIDuino shield may not work with tags outside the EM4100 family - * - * User Output pins - * myRFIDuino.led1 - Red LED - * myRFIDuino.led2 - Green LED - * myRFIDuino.buzzer - Buzzer - * - ***************************************************************************/ - -#include //include the RFIDuino Library - -#define SERIAL_PORT Serial //Serial port definition for Geekduino, Arduino Uno, and most Arduino Boards -//#define SERIAL_PORT Serial1 //Serial port defintion for Arduino Leonardo and other ATmega32u4 based boards - -/*************** -* HARDWARE VERSION - MAKE SURE YOU HAVE SET THE CORRECT HARDWARE VERSION BELOW -* Version 1.1 has a 4-pin antenna port and no version marking -* Version 1.2 has a 2-pin antenna port and is marked 'Rev 1.2' -*****************/ -//RFIDuino myRFIDuino(1.1); //initialize an RFIDuino object for hardware version 1.1 -RFIDuino myRFIDuino(1.2); //initialize an RFIDuino object for hardware version 1.2 - -byte tagData[5]; //Holds the ID numbers from the tag - -int melody[] = { - 666, 1444, 666}; //holds notes to be played on tone -int noteDurations[] = { - 4, 8, 8 }; //holds duration of notes: 4 = quarter note, 8 = eighth note, etc. - -void setup() -{ - //begin serial communicatons at 9600 baud and print a startup message - SERIAL_PORT.begin(9600); - SERIAL_PORT.print(">"); - - //Comment out to turn off Debug Mode Buzzer START - for (int thisNote = 0; thisNote < 3; thisNote++) - { - int noteDuration = 1000/noteDurations[thisNote]; - tone(myRFIDuino.buzzer, melody[thisNote],noteDuration); - int pauseBetweenNotes = noteDuration * 1.30; - delay(pauseBetweenNotes); - noTone(myRFIDuino.buzzer); - } - //Comment out to turn off Debug Mode Buzzer END - - //The RFIDUINO hardware pins and user outputs(Buzzer / LEDS) are all initialized via pinMode() in the library initialization, so you don not need to to that manually -} - -void loop() -{ - //scan for a tag - if a tag is sucesfully scanned, return a 'true' and proceed - if(myRFIDuino.scanForTag(tagData) == true) - { - digitalWrite(myRFIDuino.led2,HIGH); //turn green LED on - - SERIAL_PORT.print("ID:"); //print a header to the Serial port. - //loop through the byte array - for(int n=0;n<5;n++) - { - SERIAL_PORT.print(tagData[n],DEC); //print the byte in Decimal format - if(n<4)//only print the comma on the first 4 nunbers - { - SERIAL_PORT.print(" "); - } - } - SERIAL_PORT.print("\r\n>");//return character for next line and the prompt characer '>' for the next line - - delay(500); //wait for .5 second - digitalWrite(myRFIDuino.led2,LOW); //turn the green LED off - - - } - - }// end loop() - - - - - +/*************************************************************************** + * RFIDuino Windows Unlock + * + * This demo uses the RFIDuino sheild, a Geekduino (or other Arduino Board) + * to send an RFID to a Windows Vista/7/8/10 PC. See the link below for + * windows software and instructions. + * + * Typical pin layout used: + * ----------------------------------------------------------------------------------------- + * MFRC522 Arduino Arduino Arduino Arduino Arduino + * Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro + * Signal Pin Pin Pin Pin Pin Pin + * ----------------------------------------------------------------------------------------- + * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST + * SPI SS SDA(SS) 10 53 D10 10 10 + * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 + * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 + * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 + */ + +#include +#include + +#define RST_PIN 9 // Configurable, see typical pin layout above +#define SS_PIN 10 // Configurable, see typical pin layout above +#define READ_LED 2 // LED used to display card read + +MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance + +void setup() +{ + while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) + SPI.begin(); // Init SPI bus + mfrc522.PCD_Init(); // Init MFRC522 + mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details + //begin serial communicatons at 9600 baud and print a startup message + Serial.begin(9600); + Serial.print(">"); + pinMode(READ_LED, OUTPUT); +} + +void loop() +{ + delay(10); + // Look for new cards + if ( ! mfrc522.PICC_IsNewCardPresent()) + { + return; + } + // Select one of the cards + if ( ! mfrc522.PICC_ReadCardSerial()) + { + return; + } + + Serial.print("ID:"); //print a header to the Serial port. + for (byte i = 0; i < mfrc522.uid.size; i++) + { + Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); + Serial.print(mfrc522.uid.uidByte[i], HEX); + + } + Serial.print("\r\n>");//return character for next line + digitalWrite(READ_LED, HIGH); + delay(1000); + digitalWrite(READ_LED, LOW); + +} + + + + diff --git a/Software Source/Old Documentation/Windows Login.jpg b/Software Source/Old Documentation/Windows Login.jpg deleted file mode 100644 index 0f7802b..0000000 Binary files a/Software Source/Old Documentation/Windows Login.jpg and /dev/null differ diff --git a/Software Source/Old Documentation/Windows Login.pdf b/Software Source/Old Documentation/Windows Login.pdf deleted file mode 100644 index 6c75ef3..0000000 Binary files a/Software Source/Old Documentation/Windows Login.pdf and /dev/null differ diff --git a/Software Source/RFIDCredentialProvider.sln b/Software Source/RFIDCredentialProvider.sln index 3404224..efb0713 100644 --- a/Software Source/RFIDCredentialProvider.sln +++ b/Software Source/RFIDCredentialProvider.sln @@ -1,7 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RFIDCredentialProvider", "RFIDCredentialProvider\RFIDCredentialProvider.vcproj", "{7348AEE0-1F4A-4436-B782-6ABB694911AE}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RFIDCredentialProvider", "RFIDCredentialProvider\RFIDCredentialProvider.vcxproj", "{7348AEE0-1F4A-4436-B782-6ABB694911AE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,8 +15,8 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|Win32.ActiveCfg = Debug|Win32 {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|Win32.Build.0 = Debug|Win32 - {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|x64.ActiveCfg = Debug|Win32 - {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|x64.Build.0 = Debug|Win32 + {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|x64.ActiveCfg = Debug|x64 + {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Debug|x64.Build.0 = Debug|x64 {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Release|Win32.ActiveCfg = Release|Win32 {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Release|Win32.Build.0 = Release|Win32 {7348AEE0-1F4A-4436-B782-6ABB694911AE}.Release|x64.ActiveCfg = Release|x64 diff --git a/Software Source/RFIDCredentialProvider/RFIDCredSettings.txt b/Software Source/RFIDCredentialProvider/RFIDCredSettings.txt new file mode 100644 index 0000000..c3cd102 --- /dev/null +++ b/Software Source/RFIDCredentialProvider/RFIDCredSettings.txt @@ -0,0 +1,3 @@ +COM=4 +LEAD=ID: +TERM=\r\n diff --git a/Software Source/RFIDCredentialProvider/RFIDCredential.cpp b/Software Source/RFIDCredentialProvider/RFIDCredential.cpp index 14d925e..d4b1756 100644 --- a/Software Source/RFIDCredentialProvider/RFIDCredential.cpp +++ b/Software Source/RFIDCredentialProvider/RFIDCredential.cpp @@ -17,6 +17,9 @@ #include "guid.h" #include "RFIDListener.h" +#define DEBUG 0 + + // CRFIDCredential //////////////////////////////////////////////////////// CRFIDCredential::CRFIDCredential(): @@ -379,7 +382,7 @@ HRESULT CRFIDCredential::GetSerialization( else bResult = GetComputerNameW(wsz, &cch); // get computer name for local login - if (0) // change (0) to (1) for debug purposes + if (DEBUG) // change (0) to (1) for debug purposes { CString msg; msg.Format(_T("User = %s\r\nDomain = %s\r\nPassword = %s"), sUserName, wsz, _rgFieldStrings[SFI_PASSWORD]); diff --git a/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcproj.TROSSEN-ALEX.Alex.user b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcproj.TROSSEN-ALEX.Alex.user deleted file mode 100644 index 19ccd48..0000000 --- a/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcproj.TROSSEN-ALEX.Alex.user +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj new file mode 100644 index 0000000..256fc51 --- /dev/null +++ b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {7348AEE0-1F4A-4436-B782-6ABB694911AE} + SampleCredentialProvider + v4.5.2 + 8.1 + + + + DynamicLibrary + v140 + Unicode + + + DynamicLibrary + v140 + Unicode + true + + + DynamicLibrary + v140 + Unicode + + + DynamicLibrary + v140 + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + + Disabled + Default + C:\Program Files\Microsoft SDKs\Windows\v1.0\Include;%(AdditionalIncludeDirectories) + Level4 + EditAndContinue + + + secur32.lib;shlwapi.lib;gdi32.lib;ole32.lib;user32.lib;advapi32.lib;credui.lib;%(AdditionalDependencies) + C:\program Files\microsoft sdKs\Windows\v1.0\Lib;%(AdditionalLibraryDirectories) + RFIDCredentialProvider.def + %(AddModuleNamesToAssembly) + true + true + $(TargetDir)$(TargetName).pdb + false + false + false + + + + + + + + + C:\Program Files\Microsoft SDKs\Windows\v1.0\Include;%(AdditionalIncludeDirectories) + Level4 + ProgramDatabase + + + secur32.lib;shlwapi.lib;gdi32.lib;ole32.lib;user32.lib;advapi32.lib;credui.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + C:\program Files\microsoft sdKs\Windows\v1.0\Lib;%(AdditionalLibraryDirectories) + RFIDcredentialprovider.def + secur32.lib;%(AddModuleNamesToAssembly) + true + false + + + + + + X64 + + + Disabled + Default + C:\Program Files\Microsoft SDKs\Windows\v1.0\Include;%(AdditionalIncludeDirectories) + Level4 + ProgramDatabase + + + secur32.lib;shlwapi.lib;gdi32.lib;ole32.lib;user32.lib;advapi32.lib;credui.lib;%(AdditionalDependencies) + C:\program Files\microsoft sdKs\Windows\v1.0\Lib;%(AdditionalLibraryDirectories) + RFIDCredentialProvider.def + %(AddModuleNamesToAssembly) + true + true + $(TargetDir)$(TargetName).pdb + false + false + false + + MachineX64 + + + + + + + + X64 + + + C:\Program Files\Microsoft SDKs\Windows\v1.0\Include;%(AdditionalIncludeDirectories) + Level4 + ProgramDatabase + + + secur32.lib;shlwapi.lib;gdi32.lib;ole32.lib;user32.lib;advapi32.lib;credui.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + C:\program Files\microsoft sdKs\Windows\v1.0\Lib;%(AdditionalLibraryDirectories) + RFIDcredentialprovider.def + secur32.lib;%(AddModuleNamesToAssembly) + true + false + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bee4bfec-6683-3e67-9167-3c0cbc68f40a + 2 + 4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.filters b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.filters new file mode 100644 index 0000000..8fd2525 --- /dev/null +++ b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.filters @@ -0,0 +1,113 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {656f7be1-e4a9-4ffe-93e0-44a03be791e1} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Source Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + Utilities + + + Utilities + + + + + Resource Files + + + + + Utilities + + + Utilities + + + \ No newline at end of file diff --git a/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.user b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.user new file mode 100644 index 0000000..6fb136b --- /dev/null +++ b/Software Source/RFIDCredentialProvider/RFIDCredentialProvider.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Software Source/RFIDCredentialProvider/RFIDCredentials.txt b/Software Source/RFIDCredentialProvider/RFIDCredentials.txt new file mode 100644 index 0000000..773ee5f --- /dev/null +++ b/Software Source/RFIDCredentialProvider/RFIDCredentials.txt @@ -0,0 +1,2 @@ + 12 23 45 66|||domain\user|||password1 + 2 13 30 0|||user2|||password2 diff --git a/Software Source/RFIDCredentialProvider/RFIDListener.cpp b/Software Source/RFIDCredentialProvider/RFIDListener.cpp index e85b3a5..14d6251 100644 --- a/Software Source/RFIDCredentialProvider/RFIDListener.cpp +++ b/Software Source/RFIDCredentialProvider/RFIDListener.cpp @@ -9,6 +9,18 @@ #include "RFIDListener.h" #include +#include // For std::wstring +#include "crypt.h" + +#include +#include + +#define DEBUG 0 + + + +using namespace System; +using namespace System::IO; // length of RFID data in badge const int RFID_Length = 50; // maximum RFID message length @@ -65,26 +77,52 @@ void CRFIDListener::ReadCredentials() char *pText = new char[size+1]; ZeroMemory(pText, size+1); ReadFile(hFile, pText, size, &size, NULL); - CloseHandle(hFile); - // TODO: If entire file is encrypted, this is where decryption should occur + CString text = pText; delete []pText; + std::size_t found = text.Find(_T("|||")); + CloseHandle(hFile); + + if (found != std::string::npos) { + //MessageBox(NULL, _T("Not Encrypted"), _T(__FUNCTION__), MB_OK | MB_TOPMOST); + //Not encrypted so we need to encrypt the data first time + std::string stext = CW2A(text.GetString()); + //MessageBox(NULL, _T("Not Encrypted: "), _T(__FUNCTION__), MB_OK | MB_TOPMOST); + std::ofstream out("C:/Windows/System32/RFIDCredentials.txt"); + out << encrypt(stext, std::string("Jnmd3fdd1daa!#k")); + out.close(); + } + else { + std::string stext = CW2A(text.GetString()); + //MessageBox(NULL, _T("Encrypted: "), _T(__FUNCTION__), MB_OK | MB_TOPMOST); + text = decrypt(stext, std::string("Jnmd3fdd1daa!#k")).c_str(); + if (DEBUG) + MessageBox(NULL, "DECRYPTED: " + text, _T(__FUNCTION__), MB_OK | MB_TOPMOST); + } + + + // parse text file by lines CString sLine; int line = 0; for (sLine = text.Tokenize(_T("\r\n"), line); line != -1; sLine = text.Tokenize(_T("\r\n"), line)) { - // add each credential, parsing the line by pipe characters '|' + // add each credential, parsing the line by pipe characters '|||' int nIndex = Credentials.Add(); int field = 0; - Credentials[nIndex].sID = sLine.Tokenize(_T("|"), field); - Credentials[nIndex].sUserName = sLine.Tokenize(_T("|"), field); - Credentials[nIndex].sPassword = sLine.Tokenize(_T("|"), field); + Credentials[nIndex].sID = sLine.Tokenize(_T("|||"), field); + Credentials[nIndex].sUserName = sLine.Tokenize(_T("|||"), field); + Credentials[nIndex].sPassword = sLine.Tokenize(_T("|||"), field); + if (DEBUG) + MessageBox(NULL, "[" + Credentials[nIndex].sID + "], "+ "[" + Credentials[nIndex].sUserName + "], " + "[" + Credentials[nIndex].sPassword + "]", _T(__FUNCTION__), MB_OK | MB_TOPMOST); } } + } + + // Read the settings file C:\Windows\System32\RFIDCredSettings.txt // The file is formated with one setting per line. // The fields are separated by an = character. @@ -122,7 +160,7 @@ void CRFIDListener::ReadSettings() } } - if (0) // change (0) to (1) for debugging purposes + if (DEBUG) // change (0) to (1) for debugging purposes { CString msg; msg = CString(_T("Port: ")) + RFID_Port + CString(_T("\r\nLead: ")) + RFID_Lead + CString(_T("!!!\r\nTerm: ")) + RFID_Term; @@ -255,7 +293,7 @@ void CRFIDListener::WaitForSerialData() // add it to our buffer _RFID[nIndex++] = buffer; - if (0) // change (0) to (1) for debugging purposes + if (DEBUG) // change (0) to (1) for debugging purposes { CString msg; msg.Format(_T("Reading COM data:\r\nstate = %d\r\nnIndex = %d\r\nRFID = %s"), state, nIndex, _RFID); @@ -301,16 +339,20 @@ void CRFIDListener::WaitForSerialData() ZeroMemory(_UserName, sizeof(_UserName)); ZeroMemory(_Password, sizeof(_Password)); //state = Lead_in; - + // find ID in our credentials file for (size_t i = 0; i < Credentials.GetCount(); ++i) { // when found, set the user name and password // and signal the provider + if (DEBUG) + MessageBox(NULL, Credentials[i].sID + "?=" + _RFID, _T(__FUNCTION__), MB_OK | MB_TOPMOST); if (Credentials[i].sID == _RFID) { + if (DEBUG) + MessageBox(NULL, _T("YES"), _T(__FUNCTION__), MB_OK | MB_TOPMOST); lstrcpy(_UserName, Credentials[i].sUserName); - lstrcpy(_Password, Credentials[i].sPassword); + lstrcpy(_Password, Credentials[i].sPassword); _pProvider->OnConnectStatusChanged(); break; } diff --git a/Software Source/RFIDCredentialProvider/b64.h b/Software Source/RFIDCredentialProvider/b64.h new file mode 100644 index 0000000..1ecb7b3 --- /dev/null +++ b/Software Source/RFIDCredentialProvider/b64.h @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +using namespace std; + + +static std::string base64_encode(const std::string &in) { + + std::string out; + + int val = 0, valb = -6; + for (int jj = 0; jj < in.size(); jj++) { + char c = in[jj]; + val = (val << 8) + c; + valb += 8; + while (valb >= 0) { + out.push_back("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(val >> valb) & 0x3F]); + valb -= 6; + } + } + if (valb>-6) out.push_back("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[((val << 8) >> (valb + 8)) & 0x3F]); + while (out.size() % 4) out.push_back('='); + return out; +} + +static std::string base64_decode(const std::string &in) { + + std::string out; + + std::vector T(256, -1); + for (int i = 0; i<64; i++) T["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]] = i; + + int val = 0, valb = -8; + for (int jj = 0; jj < in.size(); jj++) { + char c = in[jj]; + if (T[c] == -1) break; + val = (val << 6) + T[c]; + valb += 6; + if (valb >= 0) { + out.push_back(char((val >> valb) & 0xFF)); + valb -= 8; + } + } + return out; +} \ No newline at end of file diff --git a/Software Source/RFIDCredentialProvider/crypt.h b/Software Source/RFIDCredentialProvider/crypt.h new file mode 100644 index 0000000..33a026d --- /dev/null +++ b/Software Source/RFIDCredentialProvider/crypt.h @@ -0,0 +1,17 @@ +#include "b64.h" +#include "vigenere.h" + +std::string encrypt(std::string& msg, std::string& key) { + std::string b64_str = base64_encode(msg); + std::string vigenere_msg = encrypt_vigenere(b64_str, key); + // std::cout << vigenere_msg << std::endl; + return vigenere_msg; +} + + +std::string decrypt(std::string& encrypted_msg, std::string& key) { + std::string newKey = extend_key(encrypted_msg, key); + std::string b64_encoded_str = decrypt_vigenere(encrypted_msg, newKey); + std::string b64_decode_str = base64_decode(b64_encoded_str); + return b64_decode_str; +} \ No newline at end of file diff --git a/Software Source/RFIDCredentialProvider/vigenere.h b/Software Source/RFIDCredentialProvider/vigenere.h new file mode 100644 index 0000000..2cf91d9 --- /dev/null +++ b/Software Source/RFIDCredentialProvider/vigenere.h @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; + +std::string AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "; + +int index(char c) { + for (int ii = 0; ii < AVAILABLE_CHARS.size(); ii++) { + if (AVAILABLE_CHARS[ii] == c) { + // std::cout << ii << " " << c << std::endl; + return ii; + } + } + return -1; +} + + +std::string extend_key(std::string& msg, std::string& key) { + //generating new key + int msgLen = msg.size(); + std::string newKey(msgLen, 'x'); + int keyLen = key.size(), i, j; + for (i = 0, j = 0; i < msgLen; ++i, ++j) { + if (j == keyLen) + j = 0; + + newKey[i] = key[j]; + } + newKey[i] = '\0'; + return newKey; +} + + +std::string encrypt_vigenere(std::string& msg, std::string& key) { + int msgLen = msg.size(), keyLen = key.size(), i, j; + std::string encryptedMsg(msgLen, 'x'); + // char newKey[msgLen], encryptedMsg[msgLen], decryptedMsg[msgLen]; + + std::string newKey = extend_key(msg, key); + + //encryption + for (i = 0; i < msgLen; ++i) { + // std::cout << msg[i] << " " << isalnum(msg[i]) << std::endl; + if (isalnum(msg[i]) || msg[i] == ' ') { + encryptedMsg[i] = AVAILABLE_CHARS[((index(msg[i]) + index(newKey[i])) % AVAILABLE_CHARS.size())]; + } + else { + encryptedMsg[i] = msg[i]; + } + } + + encryptedMsg[i] = '\0'; + return encryptedMsg; +} + +std::string decrypt_vigenere(std::string& encryptedMsg, std::string& newKey) { + // decryption + int msgLen = encryptedMsg.size(); + std::string decryptedMsg(msgLen, 'x'); + int i; + for (i = 0; i < msgLen; ++i) { + if (isalnum(encryptedMsg[i]) || encryptedMsg[i] == ' ') { + decryptedMsg[i] = AVAILABLE_CHARS[(((index(encryptedMsg[i]) - index(newKey[i])) + AVAILABLE_CHARS.size()) % AVAILABLE_CHARS.size())]; + } + else { + decryptedMsg[i] = encryptedMsg[i]; + } + } + decryptedMsg[i] = '\0'; + return decryptedMsg; +} diff --git a/readme.md b/readme.md index db3c2ba..9107188 100644 --- a/readme.md +++ b/readme.md @@ -13,3 +13,12 @@ This project is based on / uses code from the original Windows Login Project fro http://amal.net Thank you to Eric Jastram for compilation and editing support. + +======= + +updated by haimiko: + +Added basic file encryption so that the credentials aren't in clear text. This isn't fool proof but will have to do for now until I have more time to work on it. It will keep someone from casually stumbling on the password in the text file. Use at your own risk. + +The first time it detects that the file is not encrypted, it encrypts it. Whenever you change your password, you will need to replace with the cleartext file with the updated password. + diff --git a/x64 bin/RFIDCredSettings.txt b/x64 bin/RFIDCredSettings.txt new file mode 100644 index 0000000..c3cd102 --- /dev/null +++ b/x64 bin/RFIDCredSettings.txt @@ -0,0 +1,3 @@ +COM=4 +LEAD=ID: +TERM=\r\n diff --git a/x64 bin/RFIDCredentialProvider.dll b/x64 bin/RFIDCredentialProvider.dll new file mode 100644 index 0000000..63fc9ff Binary files /dev/null and b/x64 bin/RFIDCredentialProvider.dll differ diff --git a/x64 bin/RFIDCredentials.txt b/x64 bin/RFIDCredentials.txt new file mode 100644 index 0000000..fa98ede --- /dev/null +++ b/x64 bin/RFIDCredentials.txt @@ -0,0 +1,2 @@ + 12 34 56 78|||domain\user|||password1 + 23 34 34 34|||user2|||password2 diff --git a/x64 bin/Register_RFIDCredentialProvider.reg b/x64 bin/Register_RFIDCredentialProvider.reg new file mode 100644 index 0000000..7a9b12f Binary files /dev/null and b/x64 bin/Register_RFIDCredentialProvider.reg differ diff --git a/x64 bin/Unregister_RFIDCredentialProvider.reg b/x64 bin/Unregister_RFIDCredentialProvider.reg new file mode 100644 index 0000000..c07d7f3 Binary files /dev/null and b/x64 bin/Unregister_RFIDCredentialProvider.reg differ