Skip to content

Commit 51420f0

Browse files
committed
Added CRLF filter
1 parent 9f8c6bc commit 51420f0

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Filter/CRLF.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace PhpWaf\Filter;
3+
4+
use PhpWaf\BaseFilter;
5+
6+
/**
7+
* Class CRLF
8+
*
9+
* @package PhpWaf\Filter
10+
*/
11+
class CRLF extends BaseFilter
12+
{
13+
/**
14+
* @var string
15+
*/
16+
protected $payloads_file = "crlf.txt";
17+
18+
/**
19+
* Check given string
20+
*
21+
* @param string $value
22+
* @return bool
23+
*/
24+
public function safe(string $value): bool
25+
{
26+
foreach ($this->payloads as $payload)
27+
{
28+
$payload = trim($payload);
29+
30+
if (empty($payload) || strpos($payload, '#') === 0)
31+
{
32+
continue;
33+
}
34+
35+
if ($payload == $value || stripos($value, $payload) !== false)
36+
{
37+
return false;
38+
}
39+
}
40+
41+
return true;
42+
}
43+
}

src/payloads/crlf.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Add cookie
2+
%0D%0ASet-Cookie:mycookie=myvalue
3+
4+
# CRLF - Add a cookie - XSS Bypass
5+
%0d%0aContent-Length:35%0d%0aX-XSS-Protection:0%0d%0a%0d%0a23%0d%0a<svg%20onload=alert(document.domain)>%0d%0a0%0d%0a/%2f%2e%2e
6+
7+
# CRLF - Write HTML
8+
%0D%0AContent-Length%3A%200%0A%20%0AHTTP/1.1%20200%20OK%0AContent-Type%3A%20text/html%0ALast-Modified%3A%20Mon%2C%2027%20Oct%202060%2014%3A50%3A18%20GMT%0AContent-Length%3A%2034%0A%20%0A%3Chtml%3EYou%20have%20been%20Phished%3C/html%3E
9+
10+
# CRLF - Filter Bypass
11+
%E5%98%8A%E5%98%8Dcontent-type:text/html%E5%98%8A%E5%98%8Dlocation:%E5%98%8A%E5%98%8D%E5%98%8A%E5%98%8D%E5%98%BCsvg/onload=alert%28innerHTML%28%29%E5%98%BE

0 commit comments

Comments
 (0)