int Ngn_Hashcat::run () { Application& app = Application::instance(); DJob *job = DJob::Instance(); string cmd; string hashcat(dengine->getBinaryPath("hashcat")); int eCode(-1); // clean results _results = string(""); // grab settings from job setAttackMode(job->getAttackMode()); setHashType(job->getHashType()); setMask(job->getMask()); setRules(job->getRules()); setDictionary(job->getDictionary()); setPot("disthc.pot"); // clean pot before working File f(getPot()); if(f.exists()) { f.remove(); } // setup command prefix (format command takes 7 args max) cmd = format("%s -o %s -s %lu -l %u", hashcat, getPot(), job->getChunk(), job->getChunkSize() ); // Attack modes: // 0 = Straight // 1 = Combination // 2 = Toggle-Case // 3 = Brute-force // 4 = Permutation // 5 = Table-Lookup // if mask minimum set, apply it if(job->getMaskMin()) { cmd = format("%s --pw-min %d", cmd, job->getMaskMin() ); } // if mask maximum set, apply it if(job->getMaskMax()) { cmd = format("%s --pw-min %d", cmd, job->getMaskMax() ); } // discover attack mode and create command to execute switch(getAttackMode()) { case 3: cmd = format("%s -a3 -m %d %s %s %s", cmd, getHashType(), getFlags(), getHashFile(), getMask() ); break; default: // default command uses attack mode 0 cmd = format("%s -m %d %s %s %s %s", cmd, getHashType(), getFlags(), getHashFile(), getDictionary(), getRules() ); } if(DEBUG) app.logger().information(format("%%Running command: %s", cmd)); // check for ghosts, and run as appropriate if(isGhost()) { app.logger().information("~~~ A ghost is loose! ~~~"); app.logger().information(" .-."); app.logger().information(" (o o) boo!"); app.logger().information(" \\| O \\/"); app.logger().information(" \\ \\ "); app.logger().information(" `~~~' "); } else { // run hashcat! :) // TODO change this over to use Poco Processes eCode = system(cmd.c_str()); // check for results if(f.exists()) { FileInputStream fis(getPot()); //std::ifstream in(pot,std::ios::in); string line; while(fis >> line) { _results.append(line + "\n"); } } // TODO might take this out? // see if it's worth it to just display hashcout output during // execution // if enabled, print pot to screen // if(false) { // app.logger().information("\n=== Recovered Hashes ==="); // if(!_results.empty()) app.logger().information(_results); // app.logger().information("========================"); // } }
void ZrtpPacketHello::configureHello(ZrtpConfigure* config) { // The NumSupported* data is in ZrtpTextData.h nHash = config->getNumConfiguredAlgos(HashAlgorithm); nCipher = config->getNumConfiguredAlgos(CipherAlgorithm); nPubkey = config->getNumConfiguredAlgos(PubKeyAlgorithm); nSas = config->getNumConfiguredAlgos(SasType); nAuth = config->getNumConfiguredAlgos(AuthLength); // length is fixed Header plus HMAC size (2*ZRTP_WORD_SIZE) int32_t length = sizeof(HelloPacket_t) + (2 * ZRTP_WORD_SIZE); length += nHash * ZRTP_WORD_SIZE; length += nCipher * ZRTP_WORD_SIZE; length += nPubkey * ZRTP_WORD_SIZE; length += nSas * ZRTP_WORD_SIZE; length += nAuth * ZRTP_WORD_SIZE; // Don't change order of this sequence oHash = sizeof(Hello_t); oCipher = oHash + (nHash * ZRTP_WORD_SIZE); oAuth = oCipher + (nCipher * ZRTP_WORD_SIZE); oPubkey = oAuth + (nAuth * ZRTP_WORD_SIZE); oSas = oPubkey + (nPubkey * ZRTP_WORD_SIZE); oHmac = oSas + (nSas * ZRTP_WORD_SIZE); // offset to HMAC void* allocated = &data; memset(allocated, 0, sizeof(data)); zrtpHeader = (zrtpPacketHeader_t *)&((HelloPacket_t *)allocated)->hdr; // the standard header helloHeader = (Hello_t *)&((HelloPacket_t *)allocated)->hello; setZrtpId(); // minus 1 for CRC size setLength(length / ZRTP_WORD_SIZE); setMessageType((uint8_t*)HelloMsg); setVersion((uint8_t*)zrtpVersion); uint32_t lenField = nHash << 16; for (int32_t i = 0; i < nHash; i++) { AlgorithmEnum& hash = config->getAlgoAt(HashAlgorithm, i); setHashType(i, (int8_t*)hash.getName()); } lenField |= nCipher << 12; for (int32_t i = 0; i < nCipher; i++) { AlgorithmEnum& cipher = config->getAlgoAt(CipherAlgorithm, i); setCipherType(i, (int8_t*)cipher.getName()); } lenField |= nAuth << 8; for (int32_t i = 0; i < nAuth; i++) { AlgorithmEnum& length = config->getAlgoAt(AuthLength, i); setAuthLen(i, (int8_t*)length.getName()); } lenField |= nPubkey << 4; for (int32_t i = 0; i < nPubkey; i++) { AlgorithmEnum& pubKey = config->getAlgoAt(PubKeyAlgorithm, i); setPubKeyType(i, (int8_t*)pubKey.getName()); } lenField |= nSas; for (int32_t i = 0; i < nSas; i++) { AlgorithmEnum& sas = config->getAlgoAt(SasType, i); setSasType(i, (int8_t*)sas.getName()); } *((uint32_t*)&helloHeader->flags) = zrtpHtonl(lenField); }