FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ExplodingPE/tests/preprocessor/PreProcessor.php at master · ExplodingPE/ExplodingPE · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ExplodingPE
/
ExplodingPE
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ExplodingPE
/
tests
/
preprocessor
/
PreProcessor.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (68 loc) · 3.25 KB
Breadcrumbs
ExplodingPE
/
tests
/
preprocessor
/
PreProcessor.php
Copy path
File metadata and controls
82 lines (68 loc) · 3.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
define
(
"
THIS_PATH
"
,
realpath
(
dirname
(
__FILE__
)));
$
opts
=
getopt
(
""
, [
"
path:
"
,
"
multisize
"
]);
if
(!
isset
(
$
opts
[
"
path
"
])){
exit
(
1
);
}
$
isMultiSize
=
isset
(
$
opts
[
"
multisize
"
]);
$
path
=
realpath
(
$
opts
[
"
path
"
]);
function
process
(
$
code
,
array
$
extraDefine
= []){
$
descriptor
= [
0
=> [
"
pipe
"
,
"
r
"
],
1
=> [
"
pipe
"
,
"
w
"
],
2
=> [
"
pipe
"
,
"
pipe
"
,
"
a
"
]
];
$
extra
=
""
;
foreach
(
$
extraDefine
as
$
k
=>
$
v
){
$
extra
.=
"
-D
$
k
=
$
v
"
;
}
$
process
=
proc_open
(
"
cpp -traditional-cpp -nostdinc -include '
"
.
THIS_PATH
.
"
/processed/rules/PocketMine.h' -I '
"
.
THIS_PATH
.
"
/processed'
"
.
$
extra
.
"
-E -C -P -D FULL - -o -
"
,
$
descriptor
,
$
pipes
);
fwrite
(
$
pipes
[
0
],
$
code
);
fclose
(
$
pipes
[
0
]);
$
out
=
stream_get_contents
(
$
pipes
[
1
]);
fclose
(
$
pipes
[
1
]);
$
error
=
stream_get_contents
(
$
pipes
[
2
]);
if
(
trim
(
$
error
) !=
""
){
fwrite
(
STDERR
,
$
error
);
}
fclose
(
$
pipes
[
2
]);
proc_close
(
$
process
);
return
substr
(
$
out
,
strpos
(
$
out
,
"
<?php
"
));
}
@
mkdir
(
THIS_PATH
.
"
/processed/rules/
"
,
0777
,
true
);
foreach
(
glob
(
THIS_PATH
.
"
/rules/*.h
"
)
as
$
file
){
if
(
substr
(
$
file
, -
2
) !==
"
.h
"
){
continue
;
}
$
code
=
str_replace
([
"
::
"
,
"
->
"
,
'
$
'
], [
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
],
file_get_contents
(
$
file
));
file_put_contents
(
THIS_PATH
.
"
/processed/rules/
"
.
substr
(
$
file
,
strrpos
(
$
file
,
"
/
"
)),
$
code
);
}
foreach
(
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$
path
))
as
$
path
=>
$
f
){
if
(
substr
(
$
path
, -
4
) !==
"
.php
"
){
continue
;
}
$
oldCode
=
file_get_contents
(
$
path
);
$
code
=
str_replace
([
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
], [
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
],
process
(
str_replace
([
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
], [
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
],
$
oldCode
))
);
if
(
trim
(
$
oldCode
) !==
trim
(
$
code
)){
echo
"
Processed
$
path
\n"
;
file_put_contents
(
$
path
,
$
code
);
if
(
$
isMultiSize
){
$
bit64code
=
str_replace
([
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
], [
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
],
process
(
str_replace
([
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
], [
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
],
$
oldCode
), [
"
COMPILE_64
"
=>
1
])
);
if
(
trim
(
$
code
) ===
trim
(
$
bit64code
)){
continue
;
}
$
bit32code
=
str_replace
([
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
], [
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
],
process
(
str_replace
([
"
::
"
,
"
->
"
,
'
$
'
,
"
* | _
\\
___ ___| | _____| |_|
\\
/ (_)_ __ ___ |
\\
/ | _
\\"
], [
"
__STATIC_CALL__
"
,
"
__METHOD_CALL__
"
,
"
__VARIABLE_DOLLAR__
"
,
"
__STARTING_COMMENT_BADLINE__
"
],
$
oldCode
), [
"
COMPILE_32
"
=>
1
])
);
if
(
trim
(
$
bit32code
) !==
trim
(
$
bit64code
)){
echo
"
Processed multisize
$
path
\n"
;
file_put_contents
(
substr
(
$
path
,
0
, -
4
) .
"
__64bit.php
"
,
$
bit64code
);
file_put_contents
(
substr
(
$
path
,
0
, -
4
) .
"
__32bit.php
"
,
$
bit32code
);
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL