Page 1 of 1

Curl Login With aspx Captcha

Posted: Wed Jan 13, 2016 10:48 am
by Grandong
Hi...
i try login to:

Code: Select all

https://agent.lionair.co.id/LionAirAgentsPortal/Default.aspx
but.. this page have a captcha..
so how i can bypass this captcha ?
captcha genrate from this url:

Code: Select all

https://agent.lionair.co.id/lionairagentsportal/CaptchaGenerator.aspx
i try using this php code, but not work:

Code: Select all

		function  imageconverttruecolor(&$image)
		{ 
			$width = imagesx($image); 
			$height = imagesy($image);    
			$final = imagecreatetruecolor($width, $height); 
			imagecopy($final, $image, 0, 0, 0, 0, $width, $height); 
			imagedestroy($image);   $image = $final;
		}

		// load images

		$background = imagecreatefrompng(asset('dist/img/captcha')."/captcha.png");
		$lettersimg = imagecreatefrompng(asset('dist/img/captcha')."/letters.png");
		$captcha = imagecreatefrompng("https://agent.lionair.co.id/lionairagentsportal/CaptchaGenerator.aspx");
		imageconverttruecolor($background);imageconverttruecolor($lettersimg);
		imageconverttruecolor($captcha);
		// first parse - difference test and pixel save
		$pixels = array();
		for($x = 0; $x < imagesx($captcha); $x++)
		{    
			for($y = 0; $y < imagesy($captcha); $y++)
			{       
				$src = imagecolorat($background, $x, $y);       
				$dst = imagecolorat($captcha, $x, $y);      
				if(!($src == 0 && $dst == 0) && ($src == $dst))          
				$pixels[$x][$y] = 0xFFFFFF;        
				else $pixels[$x][$y] = 0x000000; 	   
			}
		}
		imagedestroy($background);

		// second parse - filter out pixel noise

		for($p = 0; $p < 3; $p++)
		{ 
			// 3 noise parses 
			for($x = 0; $x <  imagesx($captcha); $x++)
			{       
				for($y = 0; $y < imagesy($captcha); $y++)
				{           
					$filterpixel = true;            
					if(!$pixels[$x-1][$y-1] && !$pixels[$x+0][$y-1] && !$pixels[$x+1][$y-1]) 
					$filterpixel = false; 
					// top           
					if(!$pixels[$x+1][$y-1] && !$pixels[$x+1][$y+0] && !$pixels[$x+1][$y+1]) 
					$filterpixel = false; 
					// right         
					if(!$pixels[$x-1][$y+1] && !$pixels[$x+0][$y+1] && !$pixels[$x+1][$y+1]) 
					$filterpixel = false; 
					// bottom            
					if(!$pixels[$x-1][$y-1] && !$pixels[$x-1][$y+0] && !$pixels[$x-1][$y+1]) 
					$filterpixel = false; 
					// left          
					if($filterpixel) $pixels[$x][$y] = 0xFFFFFF;        
				}   
			}
		}
		for($x = 0; $x < imagesx($captcha); $x++)
		{ 
			$pixels[$x][0] = 0xFFFFFF;  
			$pixels[$x][1] = 0xFFFFFF;  
			$pixels[$x][imagesy($captcha) - 1] = 0xFFFFFF;  
			$pixels[$x][imagesy($captcha) - 2] = 0xFFFFFF;
		}
		for($y = 0; $y < imagesy($captcha); $y++)
		{    
			$pixels[0][$y] = 0xFFFFFF;  $pixels[1][$y] = 0xFFFFFF;  
			$pixels[imagesx($captcha) - 1][$y] = 0xFFFFFF;  
			$pixels[imagesx($captcha) - 2][$y] = 0xFFFFFF;
		}
		for($x = 50; $x < 54; $x++)
		{  
			for($y = 2; $y < 5; $y++)
			{       
				$pixels[$x][$y] = 0xFFFFFF; 
			}
		}
		// third parse - rebuild image (just for show)
		for($x = 0; $x < imagesx($captcha); $x++)
		{   
			for($y = 0; $y < imagesy($captcha); $y++)
			{       
				imagesetpixel($captcha, $x, $y, 0xFFFFFF);      
				if(($x % 3) == 0 && ($y % 3) == 0 && $pixels[$x][$y] == 0)
				{         
					imagesetpixel($captcha, $x, $y, 0xFF0000);      
				}   
			}
		}
		// fourth parse - basic ocr (slow) :-(
		$letters = 'ABCE'; 
		$ocr = '';
		for($x1 = 0; $x1 < imagesx($captcha) - 25; $x1++)
		{  
			for($y1 = 0; $y1 < imagesy($captcha) - 27; $y1++)
			{       
				$score = array();       
				for($letter = 0; $letter < 4; $letter++)
				{            
					for($x2 = 0; $x2 <  25; $x2++)
					{              
						for($y2 = 0; $y2 < 27; $y2++)
						{                   
							$color = imagecolorat($lettersimg, ($letter * 25) + $x2, $y2);                  
							if($pixels[$x1 + $x2][$y1 + $y2] == $color && $color == 0) 
							$score[$letter][0]++;                    
							if($color == 0) $score[$letter][1]++;               
						}           
					}       
				}       
				$found = -1; $highest = 0;      
				for($letter = 0; $letter < 4; $letter++)
				{            
					$result = (($score[$letter][1] / 100) * 90);           
					if($score[$letter][0] >= $result)
					{               
						$result = ($score[$letter][0] - $result);               
						if($result > $highest)
						{                  
							$highest = $result;                 
							$found = $letter;               
						}           
					}       
				}       
				if($found > -1)
				{         
					$ocr .= $letters[$found];           
					$x1  += 10;     
				}       
				unset($score);  
			}
		}
		imagedestroy($lettersimg);unset($pixels);
		// last of all output 
		header('Content-Type: image/png');
		imagestring($captcha, 2, 0, 0, $ocr, 0);
		imagepng($captcha);
		imagedestroy($captcha);
......
if u can solved this problem, please PM me, this serious...

Re: Curl Login With aspx Captcha

Posted: Wed Jan 13, 2016 11:45 am
by Christopher
Obviously lionair.co.id does not want scripts like this logging into their system. Depending on the jurisdiction, this may not be legal. Have you contacted lionair.co.id to see if they have an API that allows the access you want.

Re: Curl Login With aspx Captcha

Posted: Wed Jan 13, 2016 11:48 am
by Grandong
Christopher wrote:Obviously lionair.co.id does not want scripts like this logging into their system. Depending on the jurisdiction, this may not be legal. Have you contacted lionair.co.id to see if they have an API that allows the access you want.
Lionair don't have a API ...
===
please, tell me if u can bypass this captcha....

Re: Curl Login With aspx Captcha

Posted: Wed Jan 13, 2016 12:32 pm
by Celauran
I'm sure there are ways around it but, as Christopher mentioned, it's there for a reason. A CAPTCHA and no API is a pretty good indicator that they don't want you doing whatever it is you're trying to do.