Esempio n. 1
0
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("========================");
//		}
	}
Esempio n. 2
0
uint8_t SetBrightness(uint8_t bri){
	BRIGHTNESS = bri;
	uint8_t err = setPot(BRIGHTNESS);
	return err;
}