// 2007September02 MerlinCorey Added C++ object and methods // 2007August31 MerlinCorey Removed deprecated headers, namespaced std members; main returns integer // http://reverse.israeltorres.org/ITwin32LevelA-unpacked.cpp // tempgen v1.0 tools.israeltorres.org // #include #include #include #include namespace itwin { class keeper // as in the Crypt { private: std::vector m_vKey; public: keeper(); ~keeper(); bool InitKey(int nSize, ...); std::string IndexSubstitution(std::string sSource); std::string IndexSubstitution(std::string sSource, std::vector& vIndices); }; keeper::keeper() { } keeper::~keeper() { } // I'm kinda curious how the variadic function does in assembly... // In fact, we're gonna call it with random values JUST CAUSE bool keeper::InitKey(int nSize, ...) { va_list va; int nCur; m_vKey.resize(nSize); va_start(va, nSize); for (nCur = 0; nCur < nSize; ++nCur) { m_vKey[nCur] = va_arg(va, int); } va_end(va); return (m_vKey.size()); } std::string keeper::IndexSubstitution(std::string sSource) { return (IndexSubstitution(sSource, m_vKey)); } // Pre: Receives source string and vector of indices; assumes each indice is in bounds of source // Post: Returns source string substituted by key indices std::string keeper::IndexSubstitution(std::string sSource, std::vector& vIndices) { std::string::iterator itS; std::vector::iterator itV; std::string::size_type nMaxIndex; std::string sResult(sSource); nMaxIndex = sSource.length(); for (itS = sResult.begin(), itV = vIndices.begin(); itS != sResult.end(), itV != vIndices.end(); ++itS, ++itV) { if (*itV < nMaxIndex) { *itS = sSource[*itV]; } } // each source character, each key indice return (sResult); } } // itwin int main(int argc, char* argv []) { std::string sB; std::cout << "[ MCLnxLevelA-unpacked ]" << std::endl; std::cout << "What is the password?" << std::endl; std::getline(std::cin, sB); std::string sA(" ", 26); std::string sC(" ", 666); sC = "Seriouly - this should be REALLY simple >_> - Shoutz to DC949 ; twisted for learning"; sA = "this is the real password"; //0123456789012345678901234 //..........1111111111 //....................22222 //israel torres // iselite //2, 3, 12, 14, 13, 15, 0, 22, 23, 12, 13, 6, 5, 6, 13, 15, 2, 8, 13 itwin::keeper Keeper; Keeper.InitKey(3, 9, 4, 9); Keeper.InitKey(12, 2, 3, 12, 14, 13, 15, 0, 22, 23, 12, 13, 6); Keeper.InitKey(19, 2, 3, 12, 14, 13, 15, 0, 22, 23, 12, 13, 6, 5, 6, 13, 15, 2, 8, 13); std::string sZ; sZ = Keeper.IndexSubstitution(sA); std::string::iterator itZ, itB; int infon = 0; for (itZ = sZ.begin(), itB = sB.begin(); itZ != sZ.end(), itB != sB.end(); ++itZ, ++itB) { if (*itZ == *itB) { std::cout << "+"; ++infon; } else { std::cout << "-"; --infon; } } std::cout << std::endl; if (infon == 25) { std::cout << "This is the correct password. Congratulations! \n- [MCLnxLevelA-unpacked]" << std::endl; } else { std::cout << "This is not the correct password. Figure out why." << std::endl; } return (0); }