Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

guhfloripa

executar script em php - captcha

Recommended Posts

oi peguei um script na net, em php que consegue descobrir captcha simples, e mostrar o que esta escrito. Consegue ler uma figura e mostra isso numa string.

 

este é a pagina em cache do google do site que encontrei este scritpt:

http://74.125.93.104/search?q=cache:DA_hbt...-BR&ct=clnk

 

e este eh a pagina em q encontrei o script do captcha:

http://www.alixaxel.com/wordpress/2007/06/...aptcha-decoder/

 

Porem a pagina atual esta fora do ar, por isso que passei o captcha para vcs obrigado.

 

O script que eu gostaria de executar é este abaixo:

 

<?php 

/** 
 * OCR 
 * 
 * @author Alix Axel 
 */ 
class OCR 
{ 
	private $im; 

	function Color($x, $y) 
	{ 
		if (!is_resource($this->im)) 
		{ 
			return false; 
		} 

		extract(imagecolorsforindex($this->im, imagecolorat($this->im, $x, $y))); 

		$red = base_convert($red, 10, 16); 

		if (strlen($red) < 2) 
		{ 
			$red = '0' . $red; 
		} 

		$green = base_convert($green, 10, 16); 

		if (strlen($green) < 2) 
		{ 
			$green = '0' . $green; 
		} 

		$blue = base_convert($blue, 10, 16); 

		if (strlen($blue) < 2) 
		{ 
			$blue = '0' . $blue; 
		} 

		return strtoupper($red . $green . $blue); 
	} 

	function Info($image, $flag = null) 
	{ 
		list($width, $height, $type) = getimagesize($image); 

		if (!empty($flag)) 
		{ 
			$flag = strtolower(trim($flag)); 

			if ($flag == 'width') 
			{ 
				return $width; 
			} 

			else if ($flag == 'height') 
			{ 
				return $height; 
			} 

			else if ($flag == 'type') 
			{ 
				switch ($type) 
				{ 
					case 1: 
						return 'gif'; 
					break; 

					case 2: 
						return 'jpg'; 
					break; 

					case 3: 
						return 'png'; 
					break; 
				} 
			} 

			return false; 
		} 

		switch ($type) 
		{ 
			case 1: 
				$type = 'gif'; 
			break; 

			case 2: 
				$type = 'jpg'; 
			break; 

			case 3: 
				$type = 'png'; 
			break; 
		} 

		$result = array 
		( 
			'width' => $width, 
			'height' => $height, 
			'type' => $type 
		); 

		return $result; 
	} 

	function Read($tag, $image, $background_vector = 'FFFFFF') 
	{ 
		$image_info = $this->Info($image); 

		$tag = strtolower($tag); 

		if (!is_dir('OCR/' . $tag . '/')) 
		{ 
			return false; 
		} 

		$characters = array(); 

		$handle = opendir('OCR/' . $tag . '/patterns/'); 

		while (($file = readdir($handle)) !== false) 
		{ 
			if (($file != '.') && ($file != '..')) 
			{ 
				if (!is_dir('OCR/' . $tag . '/patterns/' . $file)) 
				{ 
					$file = str_replace('.ocr', '', $file); 

					$characters[$file] = $file; 
				} 
			} 
		} 

		closedir($handle); 

		$ignore_hash = ''; 

		if (!empty($background_vector)) 
		{ 
			if (strlen($background_vector) == 6) 
			{ 
				$ignore_hash = md5(str_repeat($background_vector, $image_info['height'])); 
			} 

			else 
			{ 
				$ignore_hash = md5($background_vector); 
			} 
		} 

		if ($image_info['type'] == 'gif') 
		{ 
			$this->im = imagecreatefromgif($image); 
		} 

		else if ($image_info['type'] == 'jpg') 
		{ 
			$this->im = imagecreatefromjpeg($image); 
		} 

		else if ($image_info['type'] == 'png') 
		{ 
			$this->im = imagecreatefrompng($image); 
		} 

		$test = array(); 
		$column = 0; 
		$candidates = array(); 
		$result = ''; 

		for ($i = 0; $i < $image_info['width']; $i++) 
		{ 
			$test[$column] = ''; 

			for ($j = 0; $j < $image_info['height']; $j++) 
			{ 
				$test[$column] .= $this->Color($i, $j); 
			} 

			$test[$column] = md5($test[$column]); 

			if ($test[$column] == $ignore_hash) 
			{ 
				$test = array(); 
				$column = 0; 
			} 

			else 
			{ 
				if (empty($candidates[$i - $column])) 
				{ 
					foreach ($characters as $character) 
					{ 
						$pattern = unserialize(file_get_contents('OCR/' . $tag . '/patterns/' . $character . '.ocr')); 

						if ($test[$column] == $pattern[$column]) 
						{ 
							$candidates[$i - $column][] = $character; 
						} 
					} 
				} 

				else 
				{ 
					foreach ($candidates[$i - $column] as $character) 
					{ 
						$pattern = unserialize(file_get_contents('OCR/' . $tag . '/patterns/' . $character . '.ocr')); 

						if ($test[$column] != $pattern[$column]) 
						{ 
							$key = array_search($character, $candidates[$i - $column]); 

							unset($candidates[$i - $column][$key]); 
						} 
					} 
				} 

				if (count($candidates[$i - $column]) == 1) 
				{ 
					$candidates[$i - $column] = array_values($candidates[$i - $column]); 
					$result .= $candidates[$i - $column][0]; 

					$character_width = $this->Info('OCR/' . $tag . '/source/' . $candidates[$i - $column][0] . '.' . $image_info['type'], 'width'); 

					$i = $i - $column + $character_width - 1; 
					$column = 0; 
				} 

				else 
				{ 
					$column++; 
				} 
			} 
		} 

		return $result; 
	} 

	function Train($tag, $character, $image) 
	{ 
		if (!file_exists($image)) 
		{ 
			return false; 
		} 

		else 
		{ 
			$image_info = $this->Info($image); 
		} 

		$tag = strtolower($tag); 

		if (!is_dir('OCR/' . $tag . '/')) 
		{ 
			mkdir('OCR/' . $tag . '/'); 
		} 

		if (!is_dir('OCR/' . $tag . '/source/')) 
		{ 
			mkdir('OCR/' . $tag . '/source/'); 
		} 

		if (file_exists('OCR/' . $tag . '/source/' . $character . '.' . $image_info['type'])) 
		{ 
			@unlink('OCR/' . $tag . '/source/' . $character . '.' . $image_info['type']); 
		} 

		@copy($image, 'OCR/' . $tag . '/source/' . $character . '.' . $image_info['type']); 

		$image = 'OCR/' . $tag . '/source/' . $character . '.' . $image_info['type']; 

		if ($image_info['type'] == 'gif') 
		{ 
			$this->im = imagecreatefromgif($image); 
		} 

		else if ($image_info['type'] == 'jpg') 
		{ 
			$this->im = imagecreatefromjpeg($image); 
		} 

		else if ($image_info['type'] == 'png') 
		{ 
			$this->im = imagecreatefrompng($image); 
		} 

		$result = array(); 

		for ($i = 0; $i < $image_info['width']; $i++) 
		{ 
			$result[$i] = ''; 

			for ($j = 0; $j < $image_info['height']; $j++) 
			{ 
				$result[$i] .= $this->Color($i, $j); 
			} 

			$result[$i] = md5($result[$i]); 
		} 

		if (!is_dir('OCR/' . $tag . '/patterns/')) 
		{ 
			mkdir('OCR/' . $tag . '/patterns/'); 
		} 

		if (file_exists('OCR/' . $tag . '/patterns/' . $character . '.ocr')) 
		{ 
			@unlink('OCR/' . $tag . '/patterns/' . $character . '.ocr'); 
		} 

		$handle = @fopen('OCR/' . $tag . '/patterns/' . $character . '.ocr', 'wb'); 

		flock($handle, LOCK_EX); 
		fwrite($handle, serialize($result)); 
		flock($handle, LOCK_UN); 
		fclose($handle); 
	} 
} 

highlight_file(__FILE__); 

?>

 

FELIZ PASCOA A TODOS, QUALQUER AJUDA OU COMENTARIO EH SEMPRE BEM VINDO VALEU RAÇAAAA!!!

se alguem souber como faz para utilizar ele deixa um comentario ai valeu .

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.