Curl Login With aspx Captcha

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Curl Login With aspx Captcha

Post 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...
Newbie The Passion for Learning
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Curl Login With aspx Captcha

Post 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.
(#10850)
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Re: Curl Login With aspx Captcha

Post 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....
Newbie The Passion for Learning
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Curl Login With aspx Captcha

Post 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.
Post Reply