-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputcheck.php
executable file
·141 lines (127 loc) · 6.19 KB
/
inputcheck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* @package Joomla - > Site and Administrator payment info
* @subpackage com_Guru
* @subpackage nextpay_gateway
* @copyright https://nextpay.ir
* @license GNU General Public License
*/
defined('_JEXEC') or die;
use Joomla\Filter\InputFilter;
use Joomla\String\StringHelper;
class checkHack extends InputFilter {
public static function checkNum ($input) {
if (is_numeric($input)){
if (preg_match('/[0-9]/',htmlspecialchars($input, ENT_QUOTES, 'UTF-8'))){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
public static function checkString ($input) {
if (strlen(utf8_decode($input)) <= 60){
$newInput = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
$source = (string) (new InputFilter)->remove($newInput);
if(!preg_match('/[\~\!\@\#\$\%\^\&\*\)\(\_\-\=\+\/\::\|\'\"\;\:\?\`\]\[\}\{]/',$source)){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
public static function checkUUID($input) {
if (!is_string($input) || (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $input) !== 1)) {
return false;
}else return true;
}
public static function checkEmail ($input) {
$newInput = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
if (preg_match('/\b[A-Z0-9\._-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}\b/i', (string) $newInput)){
if(!preg_match('/\beval\b\s*(.*)\(\s*base64_decode/i',$newInput)){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
public static function checkMobile ($input) {
if (is_numeric($input)){
$source = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
if ((strlen($source) === 11)){
if (preg_match('/[0]{1}\d{10}/i', (string) $source)){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
public static function checkAlphaNumberic ($input) {
$newInput = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
$source = (string) (new InputFilter)->remove($newInput);
if(!preg_match('/[\~\!\@\#\$\%\^\&\*\)\(\_\-\=\+\/\::\|\'\"\;\:\?\`\]\[\}\{]/', $source)){
if(!preg_match('/\beval\b\s*(.*)\(\s*base64_decode/i',$source)){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
public static function strip($val) {
$val = preg_replace('/([\x00-\x08][\x0b-\x0c][\x0e-\x20])/', '', $val);
$search = 'abcdefghijklmnopqrstuvwxyz';
$search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$search .= '1234567890!@#$%^&*()';
$search .= '~`";:?+/={}[]-_|\'\\';
for ($i = 0; $i < strlen($search); $i++) {
$val = preg_replace('/(&#[x|X]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ;
$val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ;
}
$ra1 = Array('\/([ \t\r\n]+)?javascript', '\/([ \t\r\n]+)?vbscript', ':([ \t\r\n]+)?expression', '<([ \t\r\n]+)?applet', '<([ \t\r\n]+)?meta', '<([ \t\r\n]+)?xml', '<([ \t\r\n]+)?blink', '<([ \t\r\n]+)?link', '<([ \t\r\n]+)?style', '<([ \t\r\n]+)?script', '<([ \t\r\n]+)?embed', '<([ \t\r\n]+)?object', '<([ \t\r\n]+)?iframe', '<([ \t\r\n]+)?frame', '<([ \t\r\n]+)?frameset', '<([ \t\r\n]+)?ilayer', '<([ \t\r\n]+)?layer', '<([ \t\r\n]+)?bgsound', '<([ \t\r\n]+)?title', '<([ \t\r\n]+)?base');
$ra2 = Array('onabort([ \t\r\n]+)?=', 'onactivate([ \t\r\n]+)?=', 'onafterprint([ \t\r\n]+)?=', 'onafterupdate([ \t\r\n]+)?=', 'onbeforeactivate([ \t\r\n]+)?=', 'onbeforecopy([ \t\r\n]+)?=', 'onbeforecut([ \t\r\n]+)?=', 'onbeforedeactivate([ \t\r\n]+)?=', 'onbeforeeditfocus([ \t\r\n]+)?=', 'onbeforepaste([ \t\r\n]+)?=', 'onbeforeprint([ \t\r\n]+)?=', 'onbeforeunload([ \t\r\n]+)?=', 'onbeforeupdate([ \t\r\n]+)?=', 'onblur([ \t\r\n]+)?=', 'onbounce([ \t\r\n]+)?=', 'oncellchange([ \t\r\n]+)?=', 'onchange([ \t\r\n]+)?=', 'onclick([ \t\r\n]+)?=', 'oncontextmenu([ \t\r\n]+)?=', 'oncontrolselect([ \t\r\n]+)?=', 'oncopy([ \t\r\n]+)?=', 'oncut([ \t\r\n]+)?=', 'ondataavailable([ \t\r\n]+)?=', 'ondatasetchanged([ \t\r\n]+)?=', 'ondatasetcomplete([ \t\r\n]+)?=', 'ondblclick([ \t\r\n]+)?=', 'ondeactivate([ \t\r\n]+)?=', 'ondrag([ \t\r\n]+)?=', 'ondragend([ \t\r\n]+)?=', 'ondragenter([ \t\r\n]+)?=', 'ondragleave([ \t\r\n]+)?=', 'ondragover([ \t\r\n]+)?=', 'ondragstart([ \t\r\n]+)?=', 'ondrop([ \t\r\n]+)?=', 'onerror([ \t\r\n]+)?=', 'onerrorupdate([ \t\r\n]+)?=', 'onfilterchange([ \t\r\n]+)?=', 'onfinish([ \t\r\n]+)?=', 'onfocus([ \t\r\n]+)?=', 'onfocusin([ \t\r\n]+)?=', 'onfocusout([ \t\r\n]+)?=', 'onhelp([ \t\r\n]+)?=', 'onkeydown([ \t\r\n]+)?=', 'onkeypress([ \t\r\n]+)?=', 'onkeyup([ \t\r\n]+)?=', 'onlayoutcomplete([ \t\r\n]+)?=', 'onload([ \t\r\n]+)?=', 'onlosecapture([ \t\r\n]+)?=', 'onmousedown([ \t\r\n]+)?=', 'onmouseenter([ \t\r\n]+)?=', 'onmouseleave([ \t\r\n]+)?=', 'onmousemove([ \t\r\n]+)?=', 'onmouseout([ \t\r\n]+)?=', 'onmouseover([ \t\r\n]+)?=', 'onmouseup([ \t\r\n]+)?=', 'onmousewheel([ \t\r\n]+)?=', 'onmove([ \t\r\n]+)?=', 'onmoveend([ \t\r\n]+)?=', 'onmovestart([ \t\r\n]+)?=', 'onpaste([ \t\r\n]+)?=', 'onpropertychange([ \t\r\n]+)?=', 'onreadystatechange([ \t\r\n]+)?=', 'onreset([ \t\r\n]+)?=', 'onresize([ \t\r\n]+)?=', 'onresizeend([ \t\r\n]+)?=', 'onresizestart([ \t\r\n]+)?=', 'onrowenter([ \t\r\n]+)?=', 'onrowexit([ \t\r\n]+)?=', 'onrowsdelete([ \t\r\n]+)?=', 'onrowsinserted([ \t\r\n]+)?=', 'onscroll([ \t\r\n]+)?=', 'onselect([ \t\r\n]+)?=', 'onselectionchange([ \t\r\n]+)?=', 'onselectstart([ \t\r\n]+)?=', 'onstart([ \t\r\n]+)?=', 'onstop([ \t\r\n]+)?=', 'onsubmit([ \t\r\n]+)?=', 'onunload([ \t\r\n]+)?=');
$ra = array_merge($ra1, $ra2);
foreach ($ra as $tag)
{
$pattern = '#'.$tag.'#i';
preg_match_all($pattern, $val, $matches);
foreach ($matches[0] as $match)
$val = str_replace($match, substr($match, 0, 2).'-'.substr($match, 2), $val);
}
return $val;
}
public static function joinStrip ($data) {
for ($i= 0 ; $i < count($data) ; $i++) {
$newInput[]= checkHack::strip($data[$i]);
}
$input = implode('_value_',$newInput);
$stripSpace = preg_replace('/\s/','_SPACE_',$input);
$stripDot = preg_replace('/\./','_DOT_',$stripSpace);
$stripSlash = preg_replace('/\./','_SLASH_',$stripDot);
return base64_encode($stripSpace);
}
}
?>