質問編集履歴
3
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
????
|
2
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
?
|
body
CHANGED
@@ -1,76 +1,1 @@
|
|
1
|
-
PHPのファイルtest.phpを難読化するphpを書いています。
|
2
|
-
以下のスクリプトだと難読化が弱いので、より複雑に難読化させる方法を教えてください。
|
3
|
-
|
4
|
-
今回はencrypt.phpという以下のファイルを作ります。
|
5
|
-
```PHP
|
6
|
-
<?php
|
7
|
-
$infile = "./test.php";
|
8
|
-
$outfile = "./test_encrypted.php";
|
9
|
-
$data="ob_end_clean();?>";
|
10
|
-
$data.=php_strip_whitespace($infile);
|
11
|
-
$data=gzcompress($data,9);
|
12
|
-
$data=base64_encode($data);
|
13
|
-
$out='<?ob_start();$a=\''.$data.'\';eval(gzuncompress(base64_decode($a)));$v=ob_get_contents();ob_end_clean();?>';
|
14
|
-
file_put_contents($outfile,$out);
|
15
|
-
?>
|
16
|
-
|
1
|
+
sss
|
17
|
-
|
18
|
-
test.phpをより複雑に難読化させられるのでしたら、encrypt.phpの手法はどのような方法でもかまいません。
|
19
|
-
test.phpという通常のphpファイルをtest_encrypted.phpという難読化されたファイルを生成させられるよう
|
20
|
-
encrypt.phpを改良してください。
|
21
|
-
|
22
|
-
追記:
|
23
|
-
openssl_encryptというものがあると知り、導入してみましたが実行後のtest_encrypted.phpが動作しません。
|
24
|
-
どこが問題でしょうか。
|
25
|
-
|
26
|
-
```PHP
|
27
|
-
<?php
|
28
|
-
$infile = "./test.php";
|
29
|
-
$outfile = "./test_encrypted.php";
|
30
|
-
$data="ob_end_clean();?>";
|
31
|
-
$data.=php_strip_whitespace($infile);
|
32
|
-
// compress data
|
33
|
-
$data=gzcompress($data,9);
|
34
|
-
// encode in base64
|
35
|
-
$data=base64_encode($data);
|
36
|
-
// generate output text
|
37
|
-
|
38
|
-
//与えられた文字を16進数に変換
|
39
|
-
function strtohex($x)
|
40
|
-
{
|
41
|
-
$s='';
|
42
|
-
foreach (str_split($x) as $c) $s.=sprintf("%02X",ord($c));
|
43
|
-
return($s);
|
44
|
-
}
|
45
|
-
|
46
|
-
//生成条件
|
47
|
-
//passとなっているところはopensslコマンド的にはkeyとなる
|
48
|
-
$iv = "1234567890123456";
|
49
|
-
$pass = '1234567890123456';
|
50
|
-
$method = 'aes-256-cbc';
|
51
|
-
|
52
|
-
$endata = openssl_encrypt ($data, $method, $pass, true, $iv);
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
$out='<?
|
58
|
-
ob_start();
|
59
|
-
$a = \'
|
60
|
-
'.$endata.'
|
61
|
-
\';
|
62
|
-
$b = openssl_decrypt($data, $method, $pass, true, $iv);
|
63
|
-
eval(gzuncompress(base64_decode($b)));
|
64
|
-
$v=ob_get_contents();
|
65
|
-
ob_end_clean();
|
66
|
-
?>
|
67
|
-
';
|
68
|
-
// write output text
|
69
|
-
var_dump(file_put_contents($outfile,$out));
|
70
|
-
?>
|
71
|
-
```
|
72
|
-
|
73
|
-
※PHPのファイルは直接見られることはないといった回答やセキュリティがどうのこうの
|
74
|
-
といった回答がありました。そのような回答は必要ありません。ただ難読化させるということにのみ焦点を当てた回答をお願い致します。
|
75
|
-
趣味でやっているため、なんのためにこのようなことをするのかといった回答もご遠慮お願い致します。
|
76
|
-
難読化に関する回答のみお願い致します
|
1
openssl_encryptを使ってみましたが、動作しません。
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,6 +19,57 @@
|
|
19
19
|
test.phpという通常のphpファイルをtest_encrypted.phpという難読化されたファイルを生成させられるよう
|
20
20
|
encrypt.phpを改良してください。
|
21
21
|
|
22
|
+
追記:
|
23
|
+
openssl_encryptというものがあると知り、導入してみましたが実行後のtest_encrypted.phpが動作しません。
|
24
|
+
どこが問題でしょうか。
|
25
|
+
|
26
|
+
```PHP
|
27
|
+
<?php
|
28
|
+
$infile = "./test.php";
|
29
|
+
$outfile = "./test_encrypted.php";
|
30
|
+
$data="ob_end_clean();?>";
|
31
|
+
$data.=php_strip_whitespace($infile);
|
32
|
+
// compress data
|
33
|
+
$data=gzcompress($data,9);
|
34
|
+
// encode in base64
|
35
|
+
$data=base64_encode($data);
|
36
|
+
// generate output text
|
37
|
+
|
38
|
+
//与えられた文字を16進数に変換
|
39
|
+
function strtohex($x)
|
40
|
+
{
|
41
|
+
$s='';
|
42
|
+
foreach (str_split($x) as $c) $s.=sprintf("%02X",ord($c));
|
43
|
+
return($s);
|
44
|
+
}
|
45
|
+
|
46
|
+
//生成条件
|
47
|
+
//passとなっているところはopensslコマンド的にはkeyとなる
|
48
|
+
$iv = "1234567890123456";
|
49
|
+
$pass = '1234567890123456';
|
50
|
+
$method = 'aes-256-cbc';
|
51
|
+
|
52
|
+
$endata = openssl_encrypt ($data, $method, $pass, true, $iv);
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
$out='<?
|
58
|
+
ob_start();
|
59
|
+
$a = \'
|
60
|
+
'.$endata.'
|
61
|
+
\';
|
62
|
+
$b = openssl_decrypt($data, $method, $pass, true, $iv);
|
63
|
+
eval(gzuncompress(base64_decode($b)));
|
64
|
+
$v=ob_get_contents();
|
65
|
+
ob_end_clean();
|
66
|
+
?>
|
67
|
+
';
|
68
|
+
// write output text
|
69
|
+
var_dump(file_put_contents($outfile,$out));
|
70
|
+
?>
|
71
|
+
```
|
72
|
+
|
22
73
|
※PHPのファイルは直接見られることはないといった回答やセキュリティがどうのこうの
|
23
74
|
といった回答がありました。そのような回答は必要ありません。ただ難読化させるということにのみ焦点を当てた回答をお願い致します。
|
24
75
|
趣味でやっているため、なんのためにこのようなことをするのかといった回答もご遠慮お願い致します。
|