This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-- Update package.xml to V2, added CHANGELOG and a simple script "blencode.php" to encode sources in tools/ directory. Tagged sources as 1.1.0b
- Loading branch information
Giuseppe Chiesa
committed
May 30, 2013
1 parent
53ebe83
commit d854ead
Showing
6 changed files
with
231 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
2013-05-30 | ||
-- | ||
Update package.xml to V2, added CHANGELOG and a simple script "blencode.php" to encode sources in tools/ directory. Tagged sources as 1.1.0b | ||
|
||
|
||
2013-05-29 | ||
-- | ||
Blenc now compile and works with PHP latest versions (tested with PHP <= 5.4.6) | ||
Implemented support for date expiration of module and key encryption with hardcoded main key (see blenc_protect.h.dist for examples of usage) | ||
Some minor bug fixes |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
blenc | ||
John Coggeshall | ||
Giuseppe Chiesa | ||
;; blenc | ||
John Coggeshall <[email protected]> (lead) | ||
Giuseppe Chiesa <[email protected]> (lead) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
+----------------------------------------------------------------------+ | ||
| PHP Version 5 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2004 The PHP Group | | ||
| Copyright (c) 1997-2013 The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.0 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
|
@@ -13,7 +13,7 @@ | |
| [email protected] so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Author: John Coggeshall <[email protected]> | | ||
| Giuseppe Chiesa <[email protected]> | | ||
| Giuseppe Chiesa <[email protected]> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,73 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1" ?> | ||
<!DOCTYPE package SYSTEM "../pear/package.dtd"> | ||
<package> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 | ||
http://pear.php.net/dtd/tasks-1.0.xsd | ||
http://pear.php.net/dtd/package-2.0 | ||
http://pear.php.net/dtd/package-2.0.xsd"> | ||
<name>blenc</name> | ||
<channel>pecl.php.net</channel> | ||
<summary>Transparent PHP Script Encryption using Blowfish</summary> | ||
<maintainers> | ||
<maintainer> | ||
<user>john</user> | ||
<name>John Coggeshall</name> | ||
<email>[email protected]</email> | ||
<role>lead</role> | ||
</maintainer> | ||
<maintainer> | ||
<user>gchiesa</user> | ||
<name>Giuseppe Chiesa</name> | ||
<email>[email protected]</email> | ||
<role>lead</role> | ||
</maintainer> | ||
</maintainers> | ||
<description> | ||
BLENC is an extension which hooks into the Zend Engine, allowing for | ||
<description>BLENC is an extension which hooks into the Zend Engine, allowing for | ||
transparent encryption and execution of PHP scripts using the blowfish | ||
algorithm. It is not designed for complete security (it is still | ||
possible to disassemble the script into op codes using a package such | ||
as XDebug), however it does keep people out of your code and make | ||
reverse engineering difficult. | ||
|
||
</description> | ||
<license>PHP</license> | ||
<release> | ||
<state>beta</state> | ||
<version>1.1.0b</version> | ||
<date>2013-05-29</date> | ||
<notes> | ||
Upgraded to works with latest PHP version | ||
</notes> | ||
<configureoptions> | ||
<configureoption name="enable-blenc" default="autodetect" prompt="Enable BLENC?"/> | ||
</configureoptions> | ||
<filelist> | ||
<file role="src" name="config.m4"/> | ||
<file role="src" name="config.w32"/> | ||
<file role="src" name="blenc.c"/> | ||
<file role="src" name="php_blenc.h"/> | ||
<file role="src" name="blenc_protect.h"/> | ||
<file role="src" name="bf_algo.c"/> | ||
<file role="src" name="bf_algo.h"/> | ||
|
||
<file role="doc" name="CREDITS"/> | ||
|
||
<file role="test" name="tests/001.phpt"/> | ||
</filelist> | ||
<deps> | ||
<dep type="php" rel="ge" version="4.3.0" /> | ||
</deps> | ||
</release> | ||
<lead> | ||
<name>John Coggeshall</name> | ||
<user>john</user> | ||
<email>[email protected]</email> | ||
<active>yes</active> | ||
</lead> | ||
<lead> | ||
<name>Giuseppe Chiesa</name> | ||
<user>gchiesa</user> | ||
<email>[email protected]</email> | ||
<active>yes</active> | ||
</lead> | ||
<date>2013-05-30</date> | ||
<time>16:18:09</time> | ||
<version> | ||
<release>1.1.0b</release> | ||
<api>1.1.0b</api> | ||
</version> | ||
<stability> | ||
<release>beta</release> | ||
<api>beta</api> | ||
</stability> | ||
<license uri="http://www.php.net/license">PHP</license> | ||
<notes> | ||
Upgraded to works with latest PHP version | ||
</notes> | ||
<contents> | ||
<dir name="/"> | ||
<dir name="tests"> | ||
<file name="001.phpt" role="test" /> | ||
</dir> <!-- //tests --> | ||
<file name="bf_algo.c" role="src" /> | ||
<file name="bf_algo.h" role="src" /> | ||
<file name="blenc.c" role="src" /> | ||
<file name="blenc_protect.h.dist" role="src" /> | ||
<file name="config.m4" role="src" /> | ||
<file name="config.w32" role="src" /> | ||
<file name="CREDITS" role="doc" /> | ||
<file name="php_blenc.h" role="src" /> | ||
<file name="tools/blencode.php" role="src" /> | ||
</dir> <!-- / --> | ||
</contents> | ||
<dependencies> | ||
<required> | ||
<php> | ||
<min>4.3.0</min> | ||
</php> | ||
<pearinstaller> | ||
<min>1.4.0b1</min> | ||
</pearinstaller> | ||
</required> | ||
</dependencies> | ||
<providesextension>blenc</providesextension> | ||
<extsrcrelease> | ||
<configureoption default="autodetect" name="enable-blenc" prompt="Enable BLENC?" /> | ||
</extsrcrelease> | ||
</package> | ||
<!-- | ||
vim:et:ts=1:sw=1 | ||
--> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
+----------------------------------------------------------------------+ | ||
| PHP Version 5 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2004 The PHP Group | | ||
| Copyright (c) 1997-2013 The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.0 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
|
@@ -13,7 +13,7 @@ | |
| [email protected] so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Author: John Coggeshall <[email protected]> | | ||
| Giuseppe Chiesa <[email protected]> | | ||
| Giuseppe Chiesa <[email protected]> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
|
@@ -35,7 +35,7 @@ | |
#define ZEND_ENGINE_2_1 | ||
#endif | ||
|
||
#define BLENC_VERSION "1.1.0-dev" | ||
#define BLENC_VERSION "1.1.0b" | ||
#define BLENC_IDENT "BLENC" | ||
#define BLENC_BUFSIZE 4092 | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| PHP Version 5 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2013 The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.0 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| http://www.php.net/license/3_0.txt. | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| [email protected] so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Author: Giuseppe Chiesa <[email protected]> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* blencode.php | ||
* Encode a php source file with BLENC | ||
* | ||
* This script will create an encoded version of SOURCEFILE.php with extension .phpenc | ||
* and link the old SOURCEFILE.php to the encoded version. | ||
* blencode.php also will create some other files: | ||
* blenc.key with the unencrypted blowfish encryption key | ||
* key_file.blenc with the encrypted version of blowfish key, in order to redistribute | ||
* them with your encoded sources. | ||
* ./backup directory where original SOURCE files will be saved. | ||
* | ||
*/ | ||
function usage($prg) | ||
{ | ||
echo "Usage : php -f $prg SOURCE "; | ||
echo "\n". | ||
"It will create a encoded version of SOURCE with extension .phpenc \n". | ||
"and will replace the code in SOURCE with a include request for the \n". | ||
"new encoded file.\n". | ||
"$prg also will create some other files:\n". | ||
" blenc.key with the unencrypted blowfish encryption key\n". | ||
" key_file.blenc with the encrypted version of blowfish key, in order to\n". | ||
" redistribute them with your encoded sources.\n". | ||
" ./backup directory where original SOURCE files will be saved\n\n"; | ||
|
||
} | ||
|
||
function minify($fname) | ||
{ | ||
$retval = ''; | ||
$fdata = file($fname); | ||
|
||
foreach($fdata as $row) { | ||
|
||
$retval .= ' '.trim($row).' '; | ||
|
||
} | ||
|
||
return $retval; | ||
} | ||
|
||
|
||
|
||
/* | ||
+----------------------------------------------------------------------+ | ||
| MAIN | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
ini_set("output_buffering", "16000"); | ||
|
||
if($argc < 2) { | ||
|
||
usage(basename($argv[0])); | ||
die(); | ||
|
||
} | ||
|
||
$B1=@system('tput smso'); | ||
$B0=@system('tput rmso'); | ||
|
||
if(!file_exists($argv[1])) { | ||
|
||
echo "$B1 BLENC $B0 file $argv[1] not found.\n"; | ||
die(); | ||
|
||
} | ||
|
||
if(file_exists('blenc.key')) | ||
$key_prev = $key = file_get_contents('blenc.key'); | ||
else { | ||
|
||
$key_prev = $key = md5(time()); | ||
file_put_contents('blenc.key', $key); | ||
} | ||
|
||
echo "$B1 BLENC $B0 blenc_protect starts...\n"; | ||
echo "$B1 BLENC $B0 blowfish unencrypted key: $key\n"; | ||
echo "$B1 BLENC $B0 file to encode: ".$argv[1]."\n"; | ||
|
||
if(file_exists($argv[1])) { | ||
|
||
if(!is_dir('backup')) { | ||
|
||
mkdir('backup'); | ||
|
||
} | ||
|
||
if(!file_exists('backup/'.basename($argv[1]))) { | ||
|
||
$backup_file = 'backup/'.basename($argv[1]); | ||
|
||
} else { | ||
|
||
$backup_file = 'backup/'.basename($argv[1]).'.'.date('Y_m_d_H_i_s', time()); | ||
|
||
} | ||
|
||
copy($argv[1], $backup_file); | ||
echo "$B1 BLENC $B0 backup file : $backup_file\n"; | ||
|
||
$contents = php_strip_whitespace($argv[1]); | ||
file_put_contents('/tmp/blencode-txt', $contents); | ||
$contents = minify('/tmp/blencode-txt'); | ||
$aS = array('<?php', '?>', '<?'); | ||
$aR = array('', '', ''); | ||
$contents = trim(str_replace($aS, $aR, $contents)); | ||
echo "$B1 BLENC $B0 size of content: ".strlen($contents)."\n"; | ||
echo "$B1 BLENC $B0 MD5: ".md5($contents)."\n"; | ||
file_put_contents('/tmp/blencode-log', "---\nFILE: $argv[1]\nSIZE: ".strlen($contents)."\nMD5: ".md5($contents)."\n", FILE_APPEND); | ||
|
||
if($key != '') | ||
$key = blenc_encrypt($contents, $argv[1].'enc', $key); | ||
else | ||
$key = blenc_encrypt($contents, $argv[1].'enc'); | ||
|
||
echo "$B1 BLENC $B0 redistributable key: $key\n"; | ||
|
||
file_put_contents('key_file.blenc', $key."\n", FILE_APPEND); | ||
|
||
unlink($argv[1]); | ||
symlink($argv[1].'enc', $argv[1]); | ||
|
||
$result = @system('sort -k1 -u -o key_file.blenc key_file.blenc'); | ||
echo "$B1 BLENC $B0 redistributable key file key_file.blenc updated.\n"; | ||
echo "$B1 BLENC $B0 done.\n"; | ||
|
||
} | ||
?> |