Created
January 27, 2011 17:15
-
-
Save f/798834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Security.php'; | |
class SecurityTest extends PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @var Security | |
*/ | |
protected $object; | |
protected function setUp() | |
{ | |
$this->object = new Security; | |
} | |
protected function tearDown() | |
{ | |
} | |
public function testCheckInjection() | |
{ | |
$response = $this->object->checkInjection('\' or 1=1'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('\' or \''); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("anything' OR 'x'='x"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("x' AND email IS NULL; --"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("x' AND 1=(SELECT COUNT(*) FROM tabname); --"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("x' AND members.email IS NULL; --"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("x' OR full_name LIKE '%Bob%"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("[email protected]' AND passwd = 'hello123"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("x'; DROP TABLE members; --"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("23 OR 1=1"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("\'; DROP TABLE users; --"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('\';alert(String . fromCharCode(88, 83, 83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("'';!--\" < XSS>=&{()}"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=\"javascript:alert('XSS');\">"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=JaVaScRiPt:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert("XSS")>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=`javascript:alert(\"RSnake says, 'XSS'\")`>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('<IMG SRC="jav ascript:alert(\'XSS\');">'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('<IMG SRC="jav	ascript:alert(\'XSS\');">'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('<IMG SRC="jav
ascript:alert(\'XSS\');">'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG\nSRC\n=\n\"\nj\na\nv\na\ns\nc\nr\ni\np\nt\n:\na\nl\ne\nr\nt\n(\n \n\'\nX\nS\nS\n\'\n)\n\"\n>\n"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection("<IMG SRC=javascript:alert('XSS')>"); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('<HEAD><META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-7"> </HEAD>+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-'); | |
$this->assertTrue($response); | |
$response = $this->object->checkInjection('fatih'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('or'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('and'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('union'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('drop table'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('12 or'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('-'); | |
$this->assertFalse($response); | |
$response = $this->object->checkInjection('\"'); | |
$this->assertFalse($response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment