├── tools
├── zencode.c
├── php_screwim.h
├── autogen.sh
├── configure.ac
├── Makefile.am
├── screw.c
└── Makefile.in
├── screwim.ini
├── .editorconfig
├── .gitignore
├── tests
├── 001.phpt
├── 002.phpt
└── 003.phpt
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── LICENSE
├── config.m4
├── php_screwim.h
├── manage.sh
├── package.xml.tmpl
├── zencode.c
├── README.ko.md
├── README.md
└── php_screwim.c
/tools/zencode.c:
--------------------------------------------------------------------------------
1 | ../zencode.c
--------------------------------------------------------------------------------
/tools/php_screwim.h:
--------------------------------------------------------------------------------
1 | ../php_screwim.h
--------------------------------------------------------------------------------
/screwim.ini:
--------------------------------------------------------------------------------
1 | extension=screwim.so
2 |
3 | [screwim]
4 | screwim.enable = 0
5 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # top-most EditorConfig file
2 | root = true
3 |
4 | [*]
5 | indent_style = tab
6 | indent_size = 4
7 |
8 | [*.{c,h,cpp,php,json,xml,patch}]
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/tools/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | export LIBTOOL=/usr/bin/libtool
4 | export AUTOMAKE=/usr/bin/automake
5 | export ACLOCAL=/usr/bin/aclocal
6 |
7 | # chekc config.h of mod_screwim
8 | if [ ! -f ../config.h ]; then
9 | echo "ERROR: Not found ../config.h" >& /dev/stderr
10 | echo " First, move location to \"../\" and run \"./configure\""
11 | exit 1
12 | fi
13 |
14 | rm -f configure autotool/{config.guess,config.sub,ltmain.sh}
15 | autoreconf --install
16 | rm -rf autom4te* *~
17 |
18 | exit 0
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .deps
2 | .libs
3 | *.swp
4 | ac*.m4
5 | autom4te.cache
6 | configure
7 | configure.in
8 | config.guess
9 | config.h*
10 | config.log
11 | config.nice
12 | config.status
13 | config.sub
14 | install-sh
15 | libtool
16 | ltmain.sh
17 | missing
18 | mkinstalldirs
19 | run-tests.php
20 | *.la
21 | *.lo
22 | *.so
23 | *.screw
24 | *.discrew
25 | *.o
26 | stamp-h1
27 | build
28 | modules
29 | *~
30 | Makefile
31 | Makefile.g*
32 | Makefile.f*
33 | Makefile.o*
34 | tools/screwim
35 | tools/test*
36 | tags
37 | z
38 |
--------------------------------------------------------------------------------
/tests/001.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Check encrypt test
3 | --SKIPIF--
4 |
9 | --POST--
10 | --GET--
11 | --INI--
12 | --FILE--
13 |
29 | --EXPECT--
30 | I'm OK
31 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: suggest
6 | assignees: Joungkyun
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: Joungkyun
7 |
8 | ---
9 |
10 | ## Bug Environments
11 | - [x] Product Version :
12 | - [x] PHP Version:
13 | - [x] PHP SAPI:
14 | - [x] OS : (ex CentOS 8.3, Ubuntu 12.04)
15 |
16 | ## Describe the bug
17 | A clear and concise description of what the bug is.
18 |
19 | ## To Reproduce
20 | Steps to reproduce the behavior:
21 | 1. Go to '...'
22 | 2. Click on '....'
23 | 3. Scroll down to '....'
24 | 4. See error
25 |
26 | ## Expected behavior
27 | A clear and concise description of what you expected to happen.
28 |
29 | ## Screenshots
30 | If applicable, add screenshots to help explain your problem.
31 |
32 | ## Additional context
33 | Add any other context about the problem here.
34 |
--------------------------------------------------------------------------------
/tests/002.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Check screwim_seed test
3 | --SKIPIF--
4 |
9 | --POST--
10 | --GET--
11 | --INI--
12 | --FILE--
13 | keystr == $ckey )
43 | echo 'yes';
44 | else
45 | echo 'no';
46 |
47 | ?>
48 | --EXPECT--
49 | yes
50 | yes
51 |
--------------------------------------------------------------------------------
/tests/003.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Check decrypt test
3 | --SKIPIF--
4 |
9 | --POST--
10 | --GET--
11 | --INI--
12 | --FILE--
13 | )\s*$/m', '', $code);
50 | eval ($code);
51 |
52 | @unlink ('tests/001-sub.php');
53 | ?>
54 | --EXPECT--
55 | I'm OK
56 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | mod_screwim
2 |
3 | Copyright 2022. JoungKyun.Kim All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification,
6 | are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/tools/configure.ac:
--------------------------------------------------------------------------------
1 | # Process this file with autoconf to produce a configure script.
2 | # Configure template for screwim
3 |
4 | AC_PREREQ(2.63)
5 | AC_INIT([screwim], [1.0.6], [https://github.com/OOPS-ORG-PHP/mod_screwim])
6 |
7 | #AC_CONFIG_AUX_DIR([build])
8 | AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override foreign no-dependencies])
9 |
10 | AC_CONFIG_SRCDIR([screw.c])
11 | AC_CONFIG_HEADER([config.h])
12 | AC_PREFIX_DEFAULT([/usr/local])
13 |
14 | AC_DEFUN([AC_DATAROOTDIR_CHECKED])
15 |
16 | AC_ARG_ENABLE(
17 | [decode],
18 | AC_HELP_STRING([--enable-decode], [enable decode option [Default: yes]])
19 | [],[]
20 | )
21 |
22 | #AC_REQUIRE_AUX_FILE([tap-driver.sh])
23 |
24 | # Checks for programs.
25 | AC_PROG_CC
26 | AC_PROG_INSTALL
27 | AC_PROG_MKDIR_P
28 | AC_PROG_MAKE_SET
29 |
30 | # Checks for header files.
31 | AC_HEADER_STDC
32 | AC_CHECK_HEADERS([getopt.h])
33 |
34 | # Checks for library functions
35 | AC_CHECK_LIB(z, deflate,, [AC_MSG_ERROR(z not found!)])
36 | AC_CHECK_FUNCS(getopt_long,, [AC_LIBOBJ(getopt) AC_LIBOBJ(getopt1)])
37 |
38 | AC_DEFINE(NO_PHP_MOD, 1, [No php module build])
39 |
40 | AC_MSG_CHECKING(checking for support decoding mode)
41 | if test "$enable_decode" != "no"; then
42 | AC_DEFINE([SUPPORT_DECODE], [1], [support decode mode])
43 | AC_MSG_RESULT([yes])
44 | else
45 | AC_MSG_RESULT([no])
46 | fi
47 |
48 | AC_CONFIG_FILES([Makefile])
49 |
50 | AC_OUTPUT
51 |
--------------------------------------------------------------------------------
/tools/Makefile.am:
--------------------------------------------------------------------------------
1 | # Process this file with automake to produce Makefile.in
2 | # Copyright 2022. JoungKyun.Kim All rights reserved.
3 | #
4 | # This file is part of mod_screwim
5 | #
6 | # Redistribution and use in source and binary forms, with or without modification,
7 | # are permitted provided that the following conditions are met:
8 | #
9 | # 1. Redistributions of source code must retain the above copyright notice, this
10 | # list of conditions and the following disclaimer.
11 | #
12 | # 2. Redistributions in binary form must reproduce the above copyright notice,
13 | # this list of conditions and the following disclaimer in the documentation
14 | # and/or other materials provided with the distribution.
15 | #
16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
20 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | #
27 |
28 | DISTCLEANFILES =
29 | #EXTRA_DIST = README.md LICENSE
30 |
31 | SUBDIRS = .
32 |
33 | AM_CFLAGS = -Wall
34 |
35 | bin_PROGRAMS = screwim
36 | screwim_SOURCES = screw.c zencode.c
37 |
38 | distclean-local:
39 | -rm -rf autom4te.cache test-install z *.bz2 *.gz
40 | -rm -f tests/*.php.*
41 |
42 | test-install: all-recursive
43 | $(MAKE) DESTDIR=`pwd`/z install
44 |
45 |
--------------------------------------------------------------------------------
/config.m4:
--------------------------------------------------------------------------------
1 | dnl config.m4 for extension mod_screwim
2 |
3 | PHP_ARG_WITH(screwim, for screwim support,
4 | dnl Make sure that the comment is aligned:
5 | [ --with-screwim Include screwim support])
6 |
7 | PHP_ARG_ENABLE(screwim-decrypt, whether to enable ScrewIm decrypt api support,
8 | [ --enable-screwim-decrypt Support screwim_decrypt function [[default=no]]], no, no)
9 |
10 | AC_DEFINE_UNQUOTED(SCREWIM_NAME, "ScrewIm", [Define to ScrewIm Name])
11 | AC_DEFINE_UNQUOTED(SCREWIM_STRING, "PHP Screw Improved", [Define to ScrewIm Full Name])
12 | AC_DEFINE_UNQUOTED(SCREWIM_VERSION, "1.0.6", [Define to ScrewIm version])
13 |
14 | dnl {{{ +-- function config_screwim_random ()
15 | function config_screwim_random () {
16 | if test $# -ne 3 ; then
17 | echo "ERROR: sreandom start_range end_range var_name" >& /dev/sterr
18 | exit 1
19 | fi
20 |
21 | local start=$1
22 | local end=$2
23 | local vname=$3
24 | local r
25 |
26 | r=$RANDOM
27 | r=$(( $r % $end + $start ))
28 | if test $r -gt $end ; then
29 | r=$(( $r - $end + $start ))
30 | fi
31 |
32 | eval "$vname=$r"
33 | }
34 | dnl }}}
35 |
36 | dnl {{{ +-- function config_screwim_seq() {
37 | function config_screwim_seq() {
38 | local start=$1
39 | local end=$2
40 |
41 | while test true
42 | do
43 | echo $start
44 | let start+=1
45 | test $start -gt $end && break
46 | done
47 | }
48 | dnl }}}
49 |
50 | config_screwim_random 5 10 seed_no
51 |
52 | SCREWIM_ENC_DATA=
53 | for i in `config_screwim_seq 1 $seed_no`
54 | do
55 | config_screwim_random 500 32767 rand_no
56 | SCREWIM_ENC_DATA="$SCREWIM_ENC_DATA, $rand_no"
57 | done
58 | SCREWIM_ENC_DATA="$(echo $SCREWIM_ENC_DATA | sed 's/^,[ ]\+//g')"
59 |
60 | AC_DEFUN([AC_SCREWIM_UNDEFINE], [
61 | cp confdefs.h confdefs.h.tmp
62 | grep -v $1 < confdefs.h.tmp > confdefs.h
63 | rm confdefs.h.tmp
64 | ])
65 |
66 |
67 | if test "$PHP_SCREWIM" != "no"; then
68 | CFLAGS="${CFLAGS} -Wall"
69 | AC_DEFINE_UNQUOTED(SCREWIM_ENC_DATA, $SCREWIM_ENC_DATA, [Define to ScrewIm encrypt SEED key])
70 | PHP_NEW_EXTENSION(screwim, php_screwim.c zencode.c, $ext_shared,, \\$(CFALGS))
71 |
72 | if test "$PHP_SCREWIM_DECRYPT" = "yes"; then
73 | AC_DEFINE(SCREWIM_DECRYPT, 1, [define to support ScrewIm decrypt api ])
74 | fi
75 |
76 | if test "$PHP_SCREWIM_SHARED" = "yes"; then
77 | AC_SCREWIM_UNDEFINE(PACKAGE_BUGREPORT)
78 | AC_SCREWIM_UNDEFINE(PACKAGE_NAME)
79 | AC_SCREWIM_UNDEFINE(PACKAGE_STRING)
80 | AC_SCREWIM_UNDEFINE(PACKAGE_TARNAME)
81 | AC_SCREWIM_UNDEFINE(PACKAGE_URL)
82 | AC_SCREWIM_UNDEFINE(PACKAGE_VERSION)
83 | fi
84 | fi
85 |
--------------------------------------------------------------------------------
/php_screwim.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022. JoungKyun.Kim All rights reserved.
3 | *
4 | * This file is part of mod_screwim
5 | *
6 | * This program is forked from PHP screw who made by Kunimasa Noda in
7 | * PM9.com, Inc. and, his information is follows:
8 | * http://www.pm9.com
9 | * kuni@pm9.com
10 | * https://sourceforge.net/projects/php-screw/
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice, this
16 | * list of conditions and the following disclaimer.
17 | *
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
19 | * this list of conditions and the following disclaimer in the documentation
20 | * and/or other materials provided with the distribution.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef PHP_SCREWIM_H
35 | #define PHP_SCREWIM_H
36 |
37 | #define SCREWIM "\tSCREWIM DATA\t"
38 | #define SCREWIM_LEN 14
39 |
40 | /* If build PHP module {{{
41 | */
42 | #ifndef NO_PHP_MOD
43 |
44 | //extern zend_module_entry screwim_module_entry;
45 | //#define phpext_screwim_ptr &screwim_module_entry
46 |
47 | PHP_MINIT_FUNCTION (screwim);
48 | PHP_MSHUTDOWN_FUNCTION (screwim);
49 | PHP_MINFO_FUNCTION (screwim);
50 |
51 | PHP_FUNCTION(screwim_encrypt);
52 | #ifdef SCREWIM_DECRYPT
53 | PHP_FUNCTION(screwim_decrypt);
54 | PHP_FUNCTION(screwim_seed);
55 | #endif
56 |
57 | ZEND_BEGIN_MODULE_GLOBALS(screwim)
58 | zend_bool enabled;
59 | ZEND_END_MODULE_GLOBALS(screwim)
60 |
61 | #ifdef ZTS
62 | # define SCREWIM_G(v) TSRMG(screwim_globals_id, zend_screwim_globals *, v)
63 | # ifdef COMPILE_DL_SCREWIM
64 | ZEND_TSRMLS_CACHE_EXTERN()
65 | # endif
66 | #else
67 | # define SCREWIM_G(v) (screwim_globals.v)
68 | #endif
69 |
70 | /* for <= PHP 5 {{{ */
71 | #if PHP_VERSION_ID < 60000
72 | typedef struct _zend_string {
73 | size_t len;
74 | char * val;
75 | } zend_string;
76 | typedef long zend_long;
77 |
78 | #define ZSTR_VAL(zstr) (zstr)->val
79 | #define ZSTR_LEN(zstr) (zstr)->len
80 | #define RETURN_STR(str) RETURN_STRINGL(ZSTR_VAL(str),ZSTR_LEN(str),1)
81 | #define RETVAL_STR(str) RETVAL_STRINGL(ZSTR_VAL(str),ZSTR_LEN(str),1)
82 | #define RETVAL_SCREWDATA(z) RETVAL_STRINGL(z.buf, z.len, 1)
83 | #define screwim_add_property_string(rvalue, str, strlength) add_property_string(rvalue, str, strlength, 1)
84 | #else
85 | #define RETVAL_SCREWDATA(z) RETVAL_STRINGL(z.buf, z.len)
86 | #define screwim_add_property_string add_property_string
87 | #endif /* }}} */
88 |
89 | /* for >= PHP8 {{{
90 | *
91 | * Since PHP 8, TSRMLS_DC, TSRMLS_CC, and TSRMLS_C constants have been removed.
92 | */
93 | #if PHP_VERSION_ID > 79999
94 | #define TSRMLS_DC
95 | #define TSRMLS_CC
96 | #define TSRMLS_C
97 | #endif /* }}} */
98 |
99 | #endif // }}} end of build PHP module
100 |
101 | char * zdecode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len);
102 | char * zencode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len);
103 | unsigned short revert_endian (size_t x);
104 | short * generate_key (char * p, int no);
105 |
106 | #endif
107 |
108 | /*
109 | * Local variables:
110 | * tab-width: 4
111 | * c-basic-offset: 4
112 | * End:
113 | * vim600: noet sw=4 ts=4 fdm=marker
114 | * vim<600: noet sw=4 ts=4
115 | */
116 |
--------------------------------------------------------------------------------
/manage.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /usr/share/annyung-release/functions.d/bash/functions
4 | setAnsi
5 | tcolor="${bblack}${bgwhite}"
6 |
7 | errmsg () {
8 | echo "$*" 1>&2
9 | }
10 |
11 | usage () {
12 | echo "${bwhite}Usage:${normal} $0 [clean|pack|test [php-version]]"
13 | exit 1
14 | }
15 |
16 | mod_name="$( grep "^ZEND_GET_MODULE" *.c | grep -Po '(?<=\()[a-z]+(?=\))' )"
17 |
18 | opts=$(getopt -u -o h -l help -- "$@")
19 | [ $? != 0 ] && usage
20 |
21 | set -- ${opts}
22 | for i
23 | do
24 | case "$i" in
25 | -h|--help)
26 | usage
27 | shift
28 | ;;
29 | --)
30 | shift
31 | break
32 | ;;
33 | esac
34 | done
35 |
36 | mode="${1}"
37 |
38 | case "${mode}" in
39 | clean)
40 | cat <<-EOL
41 | ${bwhite}[ -f Makefile ] && make distclean
42 | rm -rf autom4te.cache build include modules
43 | rm -f .deps Makefile* ac*.m4 dyn*.m4 compile *.loT
44 | rm -f config.h* config.nice configure* config.sub config.guess
45 | rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
46 |
47 | rm -f package.xml
48 | rm -f tests/*.{diff,exp,log,out,php,sh,mem}
49 | #rm -f *${mod_name}_arginfo.h && git checkout -- php_${mod_name}_arginfo.h
50 | ${normal}----->
51 | EOL
52 |
53 | [ -f Makefile ] && make distclean
54 | rm -rf autom4te.cache build include modules
55 | rm -f .deps Makefile* ac*.m4 dyn*.m4 compile *.loT
56 | rm -f config.h* config.nice configure* config.sub config.guess
57 | rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
58 |
59 | rm -f package.xml
60 | rm -f tests/*.{diff,exp,log,out,php,sh,mem}
61 | #rm -f *${mod_name}_arginfo.h && git checkout -- php_${mod_name}_arginfo.h
62 | ;;
63 | pack)
64 | cp -af package.xml.tmpl package.xml
65 | list=$(grep "md5sum" ./package.xml | sed -r 's/.*"@|@".*//g')
66 |
67 | for i in ${list}
68 | do
69 | md5s=$(md5sum "$i" | awk '{print $1}')
70 | perl -pi -e "s!\@${i}\@!${md5s}!g" ./package.xml
71 | done
72 |
73 | curdate=$(date +'%Y-%m-%d')
74 | curtime=$(date +'%H:%M:%S')
75 |
76 | perl -pi -e "s!\@curdate\@!${curdate}!g" ./package.xml
77 | perl -pi -e "s!\@curtime\@!${curtime}!g" ./package.xml
78 |
79 | pecl package
80 | rm -f package.xml
81 | ;;
82 | test)
83 | PHPBIN=/opt/php-qa/php${2}/bin/php
84 | PHPIZE=/opt/php-qa/php${2}/bin/phpize
85 | PHPCONFIG=/opt/php-qa/php${2}/bin/php-config
86 | PHP_OPT="-n "
87 | CONFIG_OPT="--enable-screwim-decrypt"
88 |
89 | if [[ $# == 2 ]]; then
90 | ./manage.sh clean
91 | echo "${PHPIZE} && ./configure ${CONFIG_OPT}"
92 | ${PHPIZE} && ./configure ${CONFIG_OPT} && make -j8 || exit 0
93 | fi
94 |
95 | PHP_OPT+=" -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
96 |
97 | if [[ -f tests/${3}.php ]]; then
98 | cat <<-EOL
99 | ${bgreen}------------------------------------------------------------------------
100 | Sample code execution:
101 |
102 | ${bcyan}${PHPBIN} ${PHP_OPT} test/${3}.php
103 | ${bgreen}------------------------------------------------------------------------${normal}
104 |
105 | EOL
106 |
107 | ${PHPBIN} ${PHP_OPT} test/${3}.php
108 | exit $?
109 | elif [[ -f ${3} ]]; then
110 | cat <<-EOL
111 | ${bgreen}------------------------------------------------------------------------
112 | Sample code execution:
113 |
114 | ${bcyan}${PHPBIN} ${PHP_OPT} ${3}
115 | ${bgreen}------------------------------------------------------------------------${normal}
116 |
117 | EOL
118 |
119 | eval "${PHPBIN} ${PHP_OPT} ${3}"
120 | exit $?
121 | fi
122 |
123 | grep "^PHP_DEPRECATED_DIRECTIVES_REGEX =" Makefile | grep -q "safe_mode"
124 | [[ $? == 0 ]] && {
125 | perl -pi -e 's/safe_mode\|//g' Makefile
126 | }
127 |
128 | cat <<-EOL
129 | ${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 | ${tcolor}** MAKE test:: ${normal}
131 | ${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132 |
133 | ${bcyan}make test PHP_EXECUTABLE=${PHPBIN}
134 | ${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${normal}
135 |
136 | EOL
137 |
138 | make test PHP_EXECUTABLE=${PHPBIN} <<< n
139 |
140 | exit $?
141 | ;;
142 | stub)
143 | # stub tagging
144 | # /** @generate-function-entries **/ build with function entryies
145 | # /** @generate-legacy-arginfo **/ build with legacy style
146 | if [[ ! -f build/gen_stub.php ]]; then
147 | cat <<-EOL
148 | ERROR: execute before PHP 8 build environment or before execute phpize
149 | EOL
150 | exit 1
151 | fi
152 | phpcmd="/usr/bin/php80"
153 | perl -pi -e 's/ext_functions/chardet_functions/g' build/gen_stub.php
154 | ${phpcmd} build/gen_stub.php -f *.stub.php
155 | ;;
156 | *)
157 | errmsg "Unsupport mode '${1}'"
158 | exit 1
159 | esac
160 |
161 | exit 0
162 |
--------------------------------------------------------------------------------
/package.xml.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 | screwim
4 | pecl.php.net
5 | screwim - PHP Screw Improved
6 |
7 | PHP Screw Imporved(ScrewIm) is a PHP script encryption tool. When you are developing a commercial package using PHP, the script can be distributed as encrypted up until just before execution. This preserves your intellectual property.
8 |
9 | This extension is based from PHP screw who made by Kunimasa Noda in PM9.com, Inc.
10 | See also, https://github.com/OOPS-ORG-PHP/mod_screwim/
11 |
12 |
13 | JoungKyun.Kim
14 | joungkyun
15 | joungkyun@daum.net
16 | yes
17 |
18 | @curdate@
19 |
20 |
21 | 1.0.6
22 | 1.0.0
23 |
24 |
25 | stable
26 | stable
27 |
28 | BSD 2-Clause
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 | 5.0.0
62 |
63 |
64 | 1.4.3
65 |
66 |
67 |
68 | screwim
69 |
70 |
71 |
72 | stablestable
73 | 1.0.61.0.0
74 | @curdate@
75 |
76 | -
77 |
78 |
79 |
80 | stablestable
81 | 1.0.51.0.0
82 | 2022-02-13
83 |
84 | - fixed #18 Encode only binary or decode with key/password binary
85 | - fixed #22 screwim_encrypt returns wrong data on PHP 8.1
86 |
87 |
88 |
89 | stablestable
90 | 1.0.41.0.0
91 | 2021-05-01
92 |
93 | - fixed #17 screwim_seed () works even without --enable-screwim-decrypt
94 |
95 |
96 |
97 | stablestable
98 | 1.0.31.0.0
99 | 2021-03-10
100 |
101 | - fixed #13 Do you also support php8.0
102 | - fixed #14 screwim_decrypt integer overflow
103 | - fixed #15 arginfo casting type support
104 |
105 |
106 |
107 | stablestable
108 | 1.0.21.0.0
109 | 2020-05-24
110 |
111 | - Support PHP 7.4
112 | - fixed #11 php7.4.5 complie error
113 |
114 |
115 |
116 | stablestable
117 | 1.0.11.0.0
118 | 2017-10-29
119 |
120 | - fixed #5 fixed compile error "add_property_string requires 4 arguments" on PHP 5.x
121 |
122 |
123 |
124 | stablestable
125 | 1.0.01.0.0
126 | 2016-11-28
127 |
128 | - Initial release based on PHP screw v1.5.
129 | - Improved performance by processing in memory rather than creating temporary files during decoding.
130 | - Improved performance by changing memory reallocation logic when encoding or decoding large files.
131 | - Only works if 'screwim.enable' option is on.
132 | - Improved performance by don't check magic key under normal environment(regular php script). (issue #3)
133 | - Remove global variables. Maybe thread safe.
134 | - Preventing problems that can be decompiled with php_unscrew
135 | - support runtime encrypt function (screwim_encrypt())
136 | - support runtime decrypt function (screwim_decrypt(), screwim_seed())
137 | - And so on..
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/zencode.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022. JoungKyun.Kim All rights reserved.
3 | *
4 | * This file is part of mod_screwim
5 | *
6 | * This program is forked from PHP screw who made by Kunimasa Noda in
7 | * PM9.com, Inc. and, his information is follows:
8 | * http://www.pm9.com
9 | * kuni@pm9.com
10 | * https://sourceforge.net/projects/php-screw/
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice, this
16 | * list of conditions and the following disclaimer.
17 | *
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
19 | * this list of conditions and the following disclaimer in the documentation
20 | * and/or other materials provided with the distribution.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 | #ifdef HAVE_CONFIG_H
34 | #include "config.h"
35 | #endif
36 |
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | /* {{{ for no PHP Build environments
43 | */
44 | #ifndef NO_PHP_MOD
45 | // for emalloc and erealloc
46 | #include "php.h"
47 | #else
48 | #define erealloc realloc
49 | #define emalloc malloc
50 | #define efree free
51 |
52 | #define php_error_docref(a,b,c,...) \
53 | fprintf (stderr, c, __VA_ARGS__); exit (1)
54 | #endif
55 | /* }}} */
56 |
57 | #define OUTBUFSIZ 100000
58 |
59 | typedef uLong ULong; /* 32 bits or more */
60 |
61 | // {{{ +-- char * zcodecom (int mode, char * inbuf, ULong inbuf_len, ULong * resultbuf_len)
62 | char * zcodecom (int mode, char * inbuf, ULong inbuf_len, ULong * resultbuf_len) {
63 | z_stream z;
64 | char outbuf[OUTBUFSIZ];
65 |
66 | int count, status;
67 | char * resultbuf, * rbuf_new = NULL;
68 | ULong outbuf_size = OUTBUFSIZ + 1;
69 | ULong lastbuf_size = 0;
70 |
71 | z.zalloc = Z_NULL;
72 | z.zfree = Z_NULL;
73 | z.opaque = Z_NULL;
74 |
75 | z.next_in = Z_NULL;
76 | z.avail_in = 0;
77 |
78 | if ( mode == 0 ) {
79 | deflateInit (&z, 1);
80 | } else {
81 | inflateInit (&z);
82 | }
83 |
84 | z.next_out = (unsigned char *) outbuf;
85 | z.avail_out = OUTBUFSIZ;
86 | z.total_out = 0;
87 | z.next_in = (unsigned char *) inbuf;
88 | z.avail_in = inbuf_len;
89 |
90 | if ( (resultbuf = emalloc (OUTBUFSIZ + 1)) == NULL ) {
91 | php_error_docref (
92 | NULL, E_COMPILE_ERROR,
93 | "ScrewIm %scode error. Memory allocation failed.",
94 | mode ? "de" : "en"
95 | );
96 | return NULL;
97 | }
98 |
99 | while ( 1 ) {
100 | lastbuf_size = z.total_out;
101 | if ( mode == 0 ) {
102 | status = deflate (&z, Z_FINISH);
103 | } else {
104 | status = inflate (&z, Z_NO_FLUSH);
105 | }
106 | count = OUTBUFSIZ - z.avail_out;
107 |
108 | if ( status == Z_STREAM_END ) {
109 | if ( count > 0 ) {
110 | if ( outbuf_size <= z.total_out ) {
111 | if ( (rbuf_new = erealloc (resultbuf, z.total_out + 1)) != NULL ) {
112 | resultbuf = rbuf_new;
113 | } else {
114 | efree (resultbuf);
115 | php_error_docref (
116 | NULL, E_COMPILE_ERROR,
117 | "ScrewIm %scode error. Memory allocation failed.",
118 | mode ? "de" : "en"
119 | );
120 | return NULL;
121 | }
122 | }
123 | memcpy (resultbuf + lastbuf_size, outbuf, count);
124 | }
125 | break;
126 | }
127 |
128 | if ( status != Z_OK ) {
129 | char * errmsg;
130 |
131 | if ( mode == 0 ) {
132 | deflateEnd (&z);
133 | } else {
134 | inflateEnd (&z);
135 | }
136 |
137 | *resultbuf_len = 0;
138 |
139 | if ( resultbuf != NULL )
140 | efree (resultbuf);
141 |
142 | switch (status) {
143 | case Z_BUF_ERROR :
144 | errmsg = "No progress is possible; either avail_in or avail_out was zero.";
145 | break;
146 | case Z_MEM_ERROR :
147 | errmsg = "Insufficient memory.";
148 | break;
149 | case Z_STREAM_ERROR :
150 | errmsg = "The state (as represented in stream) is inconsistent, or stream was NULL.";
151 | break;
152 | default : // Z_NEED_DICT
153 | errmsg = "A preset dictionary is required. The adler field shall be set to the Adler-32 checksum of the dictionary chosen by the compressor. In this case, you should suspect that ScrewIm's encode key is not correct.";
154 | }
155 |
156 | php_error_docref (NULL, E_COMPILE_ERROR, "ScrewIm %scode error. %s", mode ? "de" : "en", errmsg);
157 | return NULL;
158 | }
159 |
160 | if ( z.avail_out < OUTBUFSIZ ) {
161 | if ( outbuf_size <= z.total_out ) {
162 | if ( (rbuf_new = erealloc (resultbuf, z.total_out + OUTBUFSIZ + 1)) != NULL ) {
163 | resultbuf = rbuf_new;
164 | } else {
165 | efree (resultbuf);
166 | php_error_docref (
167 | NULL, E_COMPILE_ERROR,
168 | "ScrewIm %scode error. Memory allocation failed.",
169 | mode ? "de" : "en"
170 | );
171 | return NULL;
172 | }
173 | outbuf_size = z.total_out + OUTBUFSIZ + 1;
174 | //printf ("realloc %d bytes!!\n", outbuf_size + 1);
175 | }
176 | memcpy (resultbuf+lastbuf_size, outbuf, count);
177 | memset (outbuf, 0, OUTBUFSIZ);
178 | z.next_out = (unsigned char *) outbuf;
179 | z.avail_out = OUTBUFSIZ;
180 | }
181 | }
182 |
183 | if ( mode == 0 ) {
184 | deflateEnd (&z);
185 | } else {
186 | inflateEnd (&z);
187 | }
188 |
189 | *resultbuf_len = z.total_out;
190 | resultbuf[z.total_out] = 0;
191 |
192 | return resultbuf;
193 | } // }}}
194 |
195 | // {{{ +-- char * zencode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len)
196 | char * zencode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len) {
197 | return zcodecom (0, inbuf, inbuf_len, resultbuf_len);
198 | } // }}}
199 |
200 | // {{{ +-- char * zdecode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len)
201 | char * zdecode (char * inbuf, ULong inbuf_len, ULong * resultbuf_len) {
202 | return zcodecom (1, inbuf, inbuf_len, resultbuf_len);
203 | }
204 | // }}}
205 |
206 | // {{{ +-- unsigned short revert_endian (size_t x)
207 | unsigned short revert_endian (size_t x) {
208 | int a, b;
209 |
210 | a = ((x & 0xff00) >> 8) & 0x000000ff;
211 | b = (x & 0x00ff) << 8;
212 | //printf ("\n#### %x - %x - %x\n", a, b, a ^ b);
213 |
214 | return a ^ b;
215 | }
216 | // }}}
217 |
218 | // {{{ +-- short * generate_key (char * p, int no)
219 | short * generate_key (char * p, int no) {
220 | int len = strlen (p);
221 | int i, j = 0;
222 | char buf[5] = { 0, };
223 | short * r;
224 | char * endptr;
225 |
226 | r = (short *) emalloc (sizeof (short) * no);
227 |
228 | for ( i=0; i 4 )
233 | n = 4;
234 | else if ( n < 2 )
235 | break;
236 | else if ( n == 3 )
237 | n--;
238 |
239 | strncpy (buf, p + i, n);
240 |
241 | r[j] = (short) revert_endian (strtoul (buf, &endptr, 16));
242 | //printf ("%s %d %d\n", buf, n, r[j]);
243 | j++;
244 | }
245 |
246 | return r;
247 | }
248 | // }}}
249 |
250 | /*
251 | * Local variables:
252 | * tab-width: 4
253 | * c-basic-offset: 4
254 | * End:
255 | * vim600: noet sw=4 ts=4 fdm=marker
256 | * vim<600: noet sw=4 ts=4
257 | */
258 |
--------------------------------------------------------------------------------
/tools/screw.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022. JoungKyun.Kim All rights reserved.
3 | *
4 | * This file is part of mod_screwim
5 | *
6 | * This program is forked from PHP screw who made by Kunimasa Noda in
7 | * PM9.com, Inc. and, his information is follows:
8 | * http://www.pm9.com
9 | * kuni@pm9.com
10 | * https://sourceforge.net/projects/php-screw/
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice, this
16 | * list of conditions and the following disclaimer.
17 | *
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
19 | * this list of conditions and the following disclaimer in the documentation
20 | * and/or other materials provided with the distribution.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifdef HAVE_CONFIG_H
35 | #include "config.h"
36 | #endif
37 |
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | #ifdef HAVE_GETOPT_H
48 | #include
49 | #endif
50 |
51 | typedef unsigned long ULong; /* 32 bits or more */
52 |
53 | #include "php_screwim.h"
54 |
55 | // include encryption key. this key is generated by configure of mod_screwim
56 | #include "../config.h"
57 | short screwim_mycryptkey[] = {
58 | //11152, 368, 192, 1281, 62
59 | SCREWIM_ENC_DATA
60 | };
61 |
62 | #ifdef HAVE_GETOPT_LONG
63 | static struct option long_options[] = { // {{{
64 | /* Options without arguments: */
65 | #ifdef SUPPORT_DECODE
66 | { "decode", no_argument, NULL, 'd' },
67 | #endif
68 | { "help", no_argument, NULL, 'h' },
69 | { "view", no_argument, NULL, 'v' },
70 |
71 | /* Options accepting an argument: */
72 | { "convert", required_argument, NULL, 'c' },
73 | #ifdef SUPPORT_DECODE
74 | { "hlen", required_argument, NULL, 'H' },
75 | { "key", required_argument, NULL, 'k' },
76 | #endif
77 | { 0, 0, 0, 0 }
78 | }; // }}}
79 | #endif
80 |
81 | // {{{ +-- void usage (void)
82 | void usage (void) {
83 | fprintf (
84 | stderr,
85 | "%s : encode or decode php file\n"
86 | "Usage: %s [OPTION] PHP_FILE\n"
87 | " -c VAL, --convert=VAL convert key byte to digits\n"
88 | #ifdef SUPPORT_DECODE
89 | " -d, --decode decrypt encrypted php script\n"
90 | #endif
91 | " -h, --help this help messages\n"
92 | #ifdef SUPPORT_DECODE
93 | " -H VAL, --hlen=VAL length of magic key(SCREWIM_LEN or PM9SCREW_LEN).\n"
94 | " use -d mode\n"
95 | " -k VAL, --key=VAL key bytes. use with -d mode\n"
96 | " -v, --view print head length and key byte of this file\n",
97 | #endif
98 | PACKAGE_STRING, PACKAGE_NAME
99 | );
100 | exit (1);
101 | }
102 | // }}}
103 |
104 | #ifdef SUPPORT_DECODE
105 | #define SHORT_OPTIONS "c:dhH:k:v"
106 | #else
107 | #define SHORT_OPTIONS "c:h"
108 | #endif
109 |
110 | // {{{ +-- int main (int argc, char ** argv)
111 | int main (int argc, char ** argv) {
112 | FILE * fp;
113 | struct stat stat_buf;
114 | char * datap, * newdatap;
115 | ULong datalen, newdatalen;
116 | int cryptkey_len = sizeof (screwim_mycryptkey) / sizeof (short);
117 | char newfilename[256];
118 | int i;
119 |
120 | // for getopt
121 | int opt;
122 | int mode = 0; // not 0, decode mode
123 | int hlen = 0; // given magic key length
124 | char * key = NULL;
125 |
126 | #ifdef HAVE_GETOPT_LONG
127 | while ( (opt = getopt_long (argc, (char *const *)argv, SHORT_OPTIONS, long_options, (int *) 0)) != EOF )
128 | #else
129 | while ( (opt = getopt (argc, (char *const *)argv, SHORT_OPTIONS)) != EOF )
130 | #endif
131 | {
132 | switch (opt) {
133 | case 'c' :
134 | hlen = strlen (optarg) / 4;
135 | if ( (strlen (optarg) % 4) != 0 )
136 | hlen++;
137 |
138 | {
139 | short * key;
140 | key = generate_key (optarg, hlen);
141 |
142 | for ( i=0; i %d\n", ckey[i%4]);
247 | ndatap[i] = (char) ckey[(datalen - i) % clen] ^ (~(ndatap[i]));
248 | }
249 |
250 | if ( user_key != NULL )
251 | free (user_key);
252 |
253 | newdatap = zdecode (ndatap, datalen, &newdatalen);
254 | free (ndatap);
255 | } else {
256 | if ( memcmp (datap, SCREWIM, SCREWIM_LEN) == 0 ) {
257 | fprintf (stderr, "Already Crypted(%s)\n", argv[optind]);
258 | return 0;
259 | }
260 |
261 | newdatap = zencode (datap, datalen, &newdatalen);
262 |
263 | for( i=0; i
54 | ```
55 | * Unix 계열 OS
56 |
57 | ## 설치
58 |
59 | ### 1. 암호화 복호화 사용자 정의
60 | * ~~___my_screw.h___ 의 암호화 SEED키(```screwim_mcryptkey```)를 원하는 값으로 변경을 합니다.~~
61 | * ~~암호화 SEED 배열의 크기를 늘리면 암호화 강도를 더 높일 수 있습니다.~~
62 | * ~~암호화 SEED 배열의 크기는 복고화 처리 시간에 영향을 주지 않습니다.~~
63 | * 이제 ___configure___ 시에 암호화 SEED키는 5~8개의 배열로 자동 생성이 됩니다. 더이상 ___my_screw.h___ 를 사용하지 않습니다. (config.h의 ___SCREWIM_ENC_DATA___ 상수로 생성이 됩니다.)
64 | * 암호화된 스크립트는 파일의 처음 부분에 Magic key를 추가 합니다. 빌드를 하기 전, 이 magic key를 꼭 변경 하여야 합니다. ___php_screwim.h___ 에서 ___SCREWIM___ 과 ___SCREWIM_LEN___ 의 값을 변경하면 됩니다. ___SCREWIM_LEN___ 값은 ___SCREWIM___ 에 지정된 문자열의 길이와 같거나 작아야 합니다.
65 | * 2017.11 zend_compile_file API를 mod_screwim 보다 먼저 hooking 하여 암호화된 파일을 탈취하는 [php extension](https://github.com/jc-lab/php_screwhook) 이 나왔습니다. 이 모듈을 방지 하기 위하여, ___SCREWIM___ 과 ___SCREWIM_LEN___ 의 값은 반드시 변경이 되어야 하며, 길면 길수록 좋습니다.
66 | * 아무리 길게 변경을 하더라도 mod_screwim 이 사용하는 logic 상 100% 탈취를 막을 수는 없습니다. 암호화된 코드 배포용으로는 적합하지 않습니다.
67 | * Magic key를 변경할 경우, 기존의 암호화 되어진 파일과는 호환이 되지 않습니다. 새로 암호화를 하여야 합니다.
68 |
69 |
70 | ### 2. 빌드 및 설치
71 | ```bash
72 | [root@host mod_screwim]$ phpize
73 | [root@host mod_screwim]$ ./configure
74 | [root@host mod_screwim]$ make install
75 | ```
76 |
77 | configure 시에, ___--enable-screwim-decrypt___ 옵션을 주면, 복호화 기능(```screwim_decrypt(), screwim_seed()```)이 추가 됩니다. 즉, ___암호화된 PHP 파일을 복호화 할 수 있다___ 는 의미입니다.
78 |
79 | ___--enable-screwim-decrypt___ 옵션은 배포용으로 빌드를 할 경우에는 절대 추가하면 안됩니다!
80 |
81 | 빌드 후, config.h 파일의 ```SCREWIM_ENC_DATA``` 상수의 값과 php_screwim.h의 ```SCREWIM``` 상수 값을 잘 백업 해 놓도록 합니다. 혹시 나중에 원본 소스를 잊어 버렸을 경우, 이 값을 알면 복구를 할 수 있습니다.
82 |
83 | ```bash
84 | [root@an3 mod_screwim]$ grep SCREWIM_ENC_DATA < config.h
85 | #define SCREWIM_ENC_DATA 26501, 21882, 15211, 24181, 15060, 13145
86 | [root@an3 mod_screwim]$ grep "define SCREWIM " < php_screwim.h
87 | #define SCREWIM "\tSCREWIM DATA\t"
88 | ```
89 |
90 | ```SCREWIM_ENC_DATA``` 값은 빌드 시 마다 달라지므로, 꼭 별도로 백업을 해 놓는 것을 권장 합니다.
91 |
92 | ### 3. 테스트
93 |
94 | PHP 는 빌드된 모듈이 잘 작동하는지 test 를 할 수 있습니다.
95 |
96 | ```bash
97 | [root@host mod_screwim]$ make test PHP_EXECUTABLE=/usr/bin/php
98 | ```
99 |
100 | 또는, install 전에 빌드한 extension을 직접 테스트 하려면 다음과 같이 가능 합니다.
101 |
102 | ```bash
103 | [root@host mod_screwim]$ php -d "extension_dir=./modules/" -d "extension=screwim.so" some.php
104 | ```
105 |
106 | ### 4. 설정
107 | 다음 라인을 ___php 설정 파일(php.ini 등)___ 에 추가를 합니다.
108 |
109 | ```ini
110 | extension=screwim.so
111 | screwim.enable = 1
112 | ```
113 |
114 | 기본적으로 ___screwim.enable___ 설정을 활성화 시키지 않으면, ___mod_screwim___ 은 복호화를 시도하지 않습니다. 이 의미는 ___screwim.enable___ 의 기본값이 0 이라는 의미 입니다. 이는 복호화를 할 필요가 없는 파일이 더 많은 환경을 위하여 선택적으로 복호화 로직을 처리할 수 있도록 설계가 되어 있습니다. 이에 대해서는 [#3 add screwim.enable ini option issue](https://github.com/OOPS-ORG-PHP/mod_screwim/issues/3) 이슈를 참고 하십시오.
115 |
116 | 설정에 대한 자세한 사항은 아래의 ___실행___ 항목을 참고 하십시오.
117 |
118 |
119 | ### 5. APIs
120 |
121 | * ___(string) screwim_encrypt (string)___
122 | * PHP 실행 중에, data를 암호화 합니다.
123 | * ___tools/screwim___ 명령어 대신 사용할 수 있습니다.
124 | * 암호화된 설정 파일을 생성하는 데 이용할 수 있습니다.
125 | * ___screwim.enable___ 옵션 여부의 영향을 받지 않습니다.
126 |
127 | ```php
128 |
134 | EOF;
135 |
136 | $data = screwim_encrypt ($code);
137 | file_put_contents ('./config/config.php', $data);
138 | ?>
139 | ```
140 |
141 | * ___(string) screwim_decrypt (string, (optional) key, (optional) magickey_len)___
142 | * ___configure___ 시에 ___--enable-screwim-decrypt___ 옵션이 필요 합니다.
143 | * PHP 실행 중에, 암호화된 data를 복호화 합니다.
144 | * ___tools/screwim___ 명령어 대신 사용할 수 있습니다.
145 | * CLI 모드가 아니거나 root 권한이 아닐 경우, ___E_ERROR___ 처리 됩니다.
146 | * ___screwim.enable___ 옵션 여부의 영향을 받지 않습니다.
147 |
148 | ```php
149 |
153 | ```
154 |
155 | * ___(object) screwim_seed (void)___
156 | * ___configure___ 시에 ___--enable-screwim-decrypt___ 옵션이 필요 합니다.
157 | * 현재 모듈의 encrypt seed key를 반환 합니다.
158 | * ___tools/screwim___ 명령어 대신 사용할 수 있습니다.
159 | * CLI 모드가 아니거나 root 권한이 아닐 경우, ___E_ERROR___ 처리 됩니다.
160 | * ___screwim.enable___ 옵션 여부의 영향을 받지 않습니다.
161 |
162 | ```php
163 | 6b22886a0f4faa5f37783d36944d7823e707
168 | // [keystr] => 8811, 27272, 20239, 24490, 30775, 13885, 19860, 9080, 2023
169 | // [headerlen] => 14
170 | // )
171 | print_r (screwim_seed ());
172 | ?>
173 | ```
174 |
175 |
176 | ## 명령행 암호화 도구
177 |
178 | 암호화 도구는 소스코드의 ___tools___ 디렉토리에 있습니다.
179 |
180 | ### 1. 빌드
181 |
182 | ```bash
183 | [root@host mod_screwim]$ cd tools
184 | [root@host tools]$ ./autogen.sh
185 | [root@host tools]$ ./configure --prefix=/usr
186 | [root@host tools]$ make
187 | [root@host tools]$ make install # 또는 원하는 위치에 screwim 파일을 복사 하십시오.
188 | [root@host tools]$ /usr/bin/screwim -h
189 | screwim 1.0.6 : encode or decode php file
190 | Usage: screwim [OPTION] PHP_FILE
191 | -c VAL, --convert=VAL convert key byte to digits
192 | -d, --decode decrypt encrypted php script
193 | -h, --help this help messages
194 | -H VAL, --hlen=VAL length of magic key(SCREWIM_LEN or PM9SCREW_LEN). use with -d mode
195 | -k VAL, --key=VAL key bytes. use with -d mode
196 | -v, --view print head length and key byte of this file
197 | [root@host tools]$
198 | ```
199 |
200 | ### 2. 암호화
201 |
202 | 다음 명령으로 암호화된 스크립트를 생성할 수 있으며, 파일 이름은 ___파임이름.screw___ 로 생성이 됩니다.
203 | ```
204 | [root@host ~]$ /usr/bin/screwim test.php
205 | Success Crypting(test.php.screw)
206 | [root@host ~]$
207 | ```
208 |
209 | ### 3. 복호화
210 |
211 | 다음 명령으로 암호화된 스크립트를 복호화 할 수 있습니다. 파일 이름은 ___스크립트이름.discrew___ 로 생성이 됩니다.
212 | ```
213 | [root@host ~]$ /usr/bin/screwim -d test.php.screw
214 | Success Decrypting(test.php.screw.discrew)
215 | [root@host ~]$
216 | ```
217 |
218 | ## 실행
219 |
220 | PHP 설정 파일(php.ini등)에 다음 설정을 추가 하십시오. 이 설정은 PHP에 ___ScrewIm___ 의 복호화 기능을 사용가능 하게 합니다.
221 |
222 | ```ini
223 | extension=screwim.so
224 | ```
225 |
226 | 위의 모듈을 등록 하였다고 하여도, 기본적으로는 복호화 로직이 동작하지는 않습니다.
227 |
228 | 복호화 루틴은 다음의 과정으로 처리를 하게 됩니다.
229 |
230 | 1. 파일을 열어서 파일의 처음이 ___Magic key___ 로 시작하는지 확인 (ScrewIm 으로 암호화된 파일인지 체크)
231 | 2. 암호화 되지 않은 파일일 경우(Magic key가 없을 경우) 동작 하지 않고 ___zend compiler___ 로 복귀
232 | 3. ___Magic key___ 가 확인이 되면, 복호화 로직을 구동하여 복호화 후에 ___zend compile___ 로 복귀
233 |
234 | 분명히 암호화/복호화를 하는데는 성능을 떨어뜨리는 요소가 존재를 합니다. 그러므로 암호화 문서를 최대한 줄이는 것이 좋습니다. 하지만 암호화를 하지 않는다고 하여도 암호화가된 스크립트인지 확인을 하기 위하여 매번 file open을 해야 하는 것 또한 성능을 떨어뜨리는 요소임에 틀림이 없으며, 접속이 많은 경우에는 심각한 성능 저하를 유발할 수 있습니다.
235 |
236 | ___mod_screwim___ 은 이 문제를 해결하기 위하여, ___screwim.enable___ 옵션이 활성화가 되어 있지 않으면, 1번 사항 Magic key 체크를 하지 않고 바로 Zend compiler로 복귀를 하게 설계가 되어 있습니다.
237 |
238 | ___그러므로, 될 수 있는한 암호화는 최소화 하는 것이 좋으며, 특정 기능만 암호화 하여, php에서 include 하여 사용하는 것을 권장 합니다.___
239 |
240 | 다음은 ___screwim.enable___ 옵션을 사용하는 방법을 기술 합니다.:
241 |
242 | ### 1. PHP 설정 파일
243 |
244 | ```ini
245 | screwim.enable = 1
246 | ```
247 |
248 | PHP 설정 파일 (php.ini 등)에 위의 설정을 추가 합니다. 이 방법은 권장 하지 않습니다. 이 방법으로 설정을 했을 경우, 모든 PHP 스크립트에 대하여 암호화 파일 여부를 검사하게 되어 성능을 저하 시킬 수 있습니다. 접속이 그리 많지 않은 사이트이거나, 충분한 리소스가 보장이 되었다고 판단하는 경우에는 간단하게 이 방법으로 사용할 수 있습니다.
249 |
250 | CLI 환경에서 설정 파일을 따로 사용할 수 있다면, CLI 환경에서는 이 방법을 권장 합니다.
251 |
252 | ### 2. mod_php (Apache module) 환경
253 |
254 | ___Apache 모듈___ 로서 PHP를 구동하는 환경에서는 ___apache 설정 파일___ 에서 특정 경로에만 구동이 되도록 설정을 할 수 있습니다.
255 |
256 | ```apache
257 |
258 | php_falg screwim.enable on
259 |
260 | ```
261 |
262 | ### 3. PHP Cli 환경
263 |
264 | -d 명령행 옵션을 이용하여 구동할 수 있습니다.
265 |
266 | ```bash
267 | [root@host ~]$ php -d screwim.enable=1 encrypted.php
268 | ```
269 |
270 | CLI 환경의 경우에는 사용량 빈도가 시스템에 영향을 줄 정도가 아니기 때문에, apache 모듈 또는 FPM과 설정 파일을 따로 사용할 수 있다면 PHP 설정 파일에 이 옵션을 추가하여 사용하는 것을 권장 합니다.
271 |
272 | ### 4. PHP 코드에 포함 (권장)
273 |
274 | ```php
275 |
283 | ```
284 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PHP Screw Improved(ScrewIm) extension
2 | ==
3 | [](https://raw.githubusercontent.com/OOPS-ORG-PHP/mod_screwim/master/LICENSE)
4 | 
5 | [](https://github.com/OOPS-ORG-PHP/mod_screwim/releases)
6 | [](https://github.com/OOPS-ORG-PHP/mod_screwim/issues?q=is%3Aissue+is%3Aclosed)
7 | [](https://github.com/OOPS-ORG-PHP/mod_screwim/pulls?q=is%3Apr+is%3Aclosed)
8 |
9 | ## Information
10 |
11 | If you can read korean, see also [README.ko.md](README.ko.md)
12 |
13 | ## Abstract
14 |
15 | ___PHP Screw Imporved(ScrewIm)___ is a PHP script encryption tool. When you are developing a commercial package using PHP, the script can be distributed as encrypted up until just before execution. This preserves your intellectual property.
16 |
17 | This extension is based from [PHP screw](http://www.pm9.com/newpm9/itbiz/php/phpscrew/) who made by [___Kunimasa Noda___](mailto:kuni@pm9.com) in [PM9.com, Inc.](http://www.pm9.com)
18 |
19 | The differences from the original PHP-screw are as follows:
20 | 1. Improved performance by processing in memory rather than creating temporary files during decoding.
21 | 1. Applied [Sungwook-Shin's improved patch](https://github.com/edp1096)
22 | 2. Improved performance by fixing duplicated file open (issue #4)
23 | 3. Fixed memory leaks.
24 | 2. Improved performance by changing memory reallocation logic when encoding or decoding large files.
25 | 3. Only works if 'screwim.enable' option is on.
26 | * Improved performance by don't check magic key under normal environment(regular php script).
27 | * See also [#3 add screwim.enable ini option issue](https://github.com/OOPS-ORG-PHP/mod_screwim/issues/3)
28 | 4. Fixed memory leaks.
29 | 5. Remove global variable. Maybe thread safe.
30 | 6. Preventing problems that can be decompiled with [php_unscrew](https://github.com/dehydr8/php_unscrew)
31 | 7. support runtime encrypt function ```screwim_encrypt()```
32 | 8. support runtime decrypt function ```screwim_decrypt(), screwim_seed()```
33 | 9. And so on..
34 |
35 | ## Description
36 |
37 | ___ScrewIm___ is encipher a PHP script with the encryption tool.
38 |
39 | And, at the time of execution of a PHP script, the decryptor screwim.so is executed as PHP-Extension, just before the PHP script is handed to the Zend-Compiler.
40 |
41 | In fact what is necessary is just to add the description about php.screw to php.ini. A PHP script programmer does not need to be conscious of decrypting process. Moreover it is possible for you to intermingle an enciphered script file and an unenciphered one.
42 |
43 | The encryption logic in the encryption tool(screwim) and the decryption logic in the decryptor(screwim.so), can be customized easily.
44 |
45 | The normal purpose code and decryption logic included, can be customized by only changing the encryption SEED key. Although it is easy to cusomize the encryption, by the encryption SEED, it does NOT mean, that the PHP scripts can be decrypted by others easily.
46 |
47 | ## License
48 |
49 | Copyright 2022. JoungKyun.Kim All rights reserved.
50 |
51 | [BSD 2-clause](LICENSE)
52 |
53 | ## Requirement
54 |
55 | * ___PHP 5___ and after (Also support ___PHP 7___)
56 | * PHP ___zlib___ extension.
57 | Check that PHP has zlib compiled in it with the PHP script:
58 | ```php
59 |
60 | ```
61 | * Unix like OS.
62 |
63 | ## Installation
64 |
65 | ### 1. Customize encrytion / decryption
66 | * ~~change the encryption SEED key (___screwim_mcryptkey___) in ___my_screw.h___ into the values according to what you like.~~
67 | * ~~The encryption will be harder to break, if you add more values to the encryption SEED array.~~
68 | * ~~However, the size of the SEED is unrelated to the time of the decrypt processing.~~
69 | * The encryption SEED key is now automatically generated from 5 to 8 arrays at configure time. Don't use ___my_screw.h___ any more. (craeted with the ___SCREWIM_ENC_DATA___ constant in config.h)
70 | * Encrypted scripts get a stamp added to the beginning of the file. Before building, you must change this stamp defined by ___SCREWIM___ and ___SCREWIM_LEN___ in ___php_screwim.h___. ___SCREWIM_LEN___ must be less than or equal to the size of ___SCREWIM___.
71 | * In November 2017, [a php extension](https://github.com/jc-lab/php_screwhook) has been introduced that hooks up the ___zend_compile_file___ API before ___mod_screwim___ to take an encrypted file. To prevent this module, the values of ___SCREWIM___ and ___SCREWIM_LEN___ must be changed, and longer is better.
72 | * No matter how long you change to a string, you can not defend 100% in mod_screwim logic. It is not suitable for encrypted code distribution.
73 | * If you change the Magic key, it is not compatible with existing encrypted files. New encryption is required.
74 |
75 |
76 | ### 2. Build and install
77 | ```bash
78 | [root@host mod_screwim]$ phpize
79 | [root@host mod_screwim]$ ./configure
80 | [root@host mod_screwim]$ make install
81 | ```
82 | On configure, the ___--enable-screwim-decrypt___ option adds decrypt functions ( ___screwim_decrypt(), screwim_seed()___ ). This means that ___you can decrypt an encrypted PHP file___.
83 |
84 | If you are building ___for distribution___, never add the --enable-screwim-decrypt option!
85 |
86 | After the build, make sure to back up the values of the ```SCREWIM_ENC_DATA``` constant in the config.h file and the value the ```SCREWIM``` constant in the php_screwim.h file. If you forget the original source later, you can use this value to recover it.
87 |
88 | ```bash
89 | [root@an3 mod_screwim]$ grep SCREWIM_ENC_DATA < config.h
90 | #define SCREWIM_ENC_DATA 26501, 21882, 15211, 24181, 15060, 13145
91 | [root@an3 mod_screwim]$ grep "define SCREWIM " < php_screwim.h
92 | #define SCREWIM "\tSCREWIM DATA\t"
93 | ```
94 |
95 | ```SCREWIM_ENC_DATA``` values vary from time to time of build, so it is recommended to have a separate backup.
96 |
97 | ### 3. Test
98 |
99 | PHP can test to see if the built module works.
100 |
101 | ```bash
102 | [root@host mod_screwim]$ make test PHP_EXECUTABLE=/usr/bin/php
103 | ```
104 |
105 | Or, if you want to test the extension you built before installing, you can do the following:
106 |
107 | ```bash
108 | [root@host mod_screwim]$ php -d "extension_dir=./modules/" -d "extension=screwim.so" some.php
109 | ```
110 |
111 | ### 4. Configuration
112 | Add next line to php configuration file (php.ini and so on)
113 |
114 | ```ini
115 | extension=screwim.so
116 | screwim.enable = 1
117 | ```
118 |
119 | By default, decryption does not work, so the performance of regular PHP files is better than the original PHP Screw. The screwim.enable option must be turned on for decryption to work. See also https://github.com/OOPS-ORG-PHP/mod_screwim/issues/3
120 |
121 | For detail on the settings, refer to the ___Execution___ item below.
122 |
123 |
124 | ### 5. APIs
125 |
126 | * ___(string) screwim_encrypt (string)___
127 | * Support runtime encryption.
128 | * Can be used instead of ___tools/screwim___ command
129 | * This API is not affected by the ___screwim.enable___ option.
130 |
131 | ```php
132 |
138 | EOF;
139 |
140 | $data = screwim_encrypt ($code);
141 | file_put_contents ('./config/config.php', $data);
142 | ?>
143 | ```
144 |
145 | * ___(string) screwim_decrypt (string, (optional) key, (optional) magickey_len)___
146 | * The ___--enable-screwim-decrypt___ option must be given at build time.
147 | * Support runtime decryption.
148 | * Can be used instead of ___tools/screwim___ command
149 | * When call in an environment other than ___CLI mode___, ___E_ERROR___ occurs.
150 | * When not running as ___root privileges___, ___E_ERROR___ occurs.
151 | * This API is not affected by the ___screwim.enable___ option.
152 |
153 | ```php
154 |
158 | ```
159 |
160 | * ___(object) screwim_seed (void)___
161 | * The ___--enable-screwim-decrypt___ option must be given at build time.
162 | * Returns ___encrypt seed key___ of current ___mod_screwim.so___
163 | * Can be used instead of ___tools/screwim___ command
164 | * When call in an environment other than ___CLI mode___, ___E_ERROR___ occurs.
165 | * When not running as ___root privileges___, ___E_ERROR___ occurs.
166 | * This API is not affected by the ___screwim.enable___ option.
167 |
168 | ```php
169 | 6b22886a0f4faa5f37783d36944d7823e707
174 | // [keystr] => 8811, 27272, 20239, 24490, 30775, 13885, 19860, 9080, 2023
175 | // [headerlen] => 14
176 | // )
177 | print_r (screwim_seed ());
178 | ?>
179 | ```
180 |
181 |
182 | ## Command line Encryption Tool
183 |
184 | The encription tool is located in ___mod_screwim/tools/___ .
185 |
186 | ### 1. Build
187 |
188 | ```bash
189 | [root@host mod_screwim]$ cd tools
190 | [root@host tools]$ ./autogen.sh
191 | [root@host tools]$ ./configure --prefix=/usr
192 | [root@host tools]$ make
193 | [root@host tools]$ make install # Or copy the screwim file into an appropriate directory.
194 | [root@host tools]$ /usr/bin/screwim -h
195 | screwim 1.0.6 : encode or decode php file
196 | Usage: screwim [OPTION] PHP_FILE
197 | -c VAL, --convert=VAL convert key byte to digits
198 | -d, --decode decrypt encrypted php script
199 | -h, --help this help messages
200 | -H VAL, --hlen=VAL length of magic key(SCREWIM_LEN or PM9SCREW_LEN). use with -d mode
201 | -k VAL, --key=VAL key bytes. use with -d mode
202 | -v, --view print head length and key byte of this file
203 | [root@host tools]$
204 | ```
205 |
206 | ### 2. Encryptioin
207 |
208 | The follow command creates the script file enciphered by the name of ___script file name .screw___.
209 | ```
210 | [root@host ~]$ /usr/bin/screwim test.php
211 | Success Crypting(test.php.screw)
212 | [root@host ~]$
213 | ```
214 |
215 | ### 3. Decryption
216 |
217 | The follow command creates the script file enciphered by the name of ___script file name .discrew___.
218 | ```
219 | [root@host ~]$ /usr/bin/screwim -d test.php.screw
220 | Success Decrypting(test.php.screw.discrew)
221 | [root@host ~]$
222 | ```
223 |
224 | ## Execution
225 |
226 | Add next line to php configuration file (php.ini and so on)
227 |
228 | ```ini
229 | extension=screwim.so
230 | ```
231 |
232 | The decryption does not work by default, when loading module.
233 |
234 | The decryption process is as follows:
235 | 1. Open the file and verify that the beginning of the file starts with the Magic key. (Check if the file is encrypted with ScrewIm)
236 | 2. If the file is unencrypted(If the Magic key is missing or different), return to the zend compiler without working.
237 | 3. Once the Magic key is confirmed, return to zend compile after decoding.
238 |
239 | Obviously encryption and decryption will degrade performance. Therefore, it is recommended to reduce the number of encrypted documents as much as possible. However, even if you do not encrypt it, opening all files to check for encryption also causes performance degradation. In particular, a large number of connections can cause serious performance degradation.
240 |
241 | To solve this problem, ___mod_screwim___ will return to the Zend compiler without checking the Magic key if the screwim.enable option is not enabled.
242 |
243 | ___Therefore, it is best to minimize the encryption as much as possible, and it is recommended to include it in php after encrypting only certain functions___.
244 |
245 | Here is how to use the screwim.enable option:
246 |
247 | ### 1. PHP configuration file
248 |
249 | ```ini
250 | screwim.enable = 1
251 | ```
252 |
253 | Add the above settings to the PHP configuration file(___php.ini___ and so on). It is not recommended because it causes ___performance degradation___ when processing unencrypted php scripts.
254 |
255 | Use this setting if there are not many connections or if there is sufficient resources.
256 |
257 | In the CLI environment, if you can use the CLI configuration file separately from the apache module or FPM, it is recommended to add the above settings to php.ini.
258 |
259 | ### 2. mod_php (Apache module) envionment
260 |
261 | Use the block to make the decryptor work on the desired path.
262 |
263 | ```apache
264 |
265 | php_falg screwim.enable on
266 |
267 | ```
268 |
269 | ### 3. PHP Cli environments
270 |
271 | use -d option.
272 |
273 | ```bash
274 | [root@host ~]$ php -d screwim.enable=1 encrypted.php
275 | ```
276 |
277 | In the CLI environment, resource utilization is not high. If the configuration file is separate from the apache module or FPM, it is recommended that you add this option to your PHP configuration file.
278 |
279 | ### 4. embeded php code (Recommand)
280 |
281 | ```php
282 |
290 | ```
291 |
--------------------------------------------------------------------------------
/php_screwim.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022. JoungKyun.Kim All rights reserved.
3 | *
4 | * This file is part of mod_screwim
5 | *
6 | * This program is forked from PHP screw who made by Kunimasa Noda in
7 | * PM9.com, Inc. and, his information is follows:
8 | * http://www.pm9.com
9 | * kuni@pm9.com
10 | * https://sourceforge.net/projects/php-screw/
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice, this
16 | * list of conditions and the following disclaimer.
17 | *
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
19 | * this list of conditions and the following disclaimer in the documentation
20 | * and/or other materials provided with the distribution.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifdef HAVE_CONFIG_H
35 | #include "config.h"
36 | #endif
37 |
38 | #include "php.h"
39 | #include "php_ini.h"
40 | #include "ext/standard/file.h"
41 | #include "ext/standard/info.h"
42 | #include "SAPI.h"
43 |
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 |
51 | typedef unsigned long ULong; /* 32 bits or more */
52 |
53 | #include "php_screwim.h"
54 |
55 | ZEND_DECLARE_MODULE_GLOBALS(screwim)
56 |
57 | /* {{{ php function argument info
58 | * proto types
59 | * ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
60 | * ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)
61 | * ZEND_ARG_INFO(pass_by_ref, name)
62 | * ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
63 | * ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value)
64 | */
65 | #if PHP_VERSION_ID > 70199
66 | ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_screwim_encrypt, 0, 1, IS_STRING, 1)
67 | ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 1)
68 | ZEND_END_ARG_INFO()
69 | #ifdef SCREWIM_DECRYPT
70 | ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_screwim_decrypt, 0, 1, IS_STRING, 1)
71 | ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 1)
72 | #if PHP_VERSION_ID > 79999
73 | ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 1, "null")
74 | ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, header_len, IS_LONG, 0, "-1")
75 | #else
76 | ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 1)
77 | ZEND_ARG_TYPE_INFO(0, header_len, IS_LONG, 0)
78 | #endif
79 | ZEND_END_ARG_INFO()
80 | ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_screwim_seed, 0, 0, IS_OBJECT, 0)
81 | ZEND_END_ARG_INFO()
82 | #endif /* end of SCREWIM_DECRYPT */
83 | #else
84 | ZEND_BEGIN_ARG_INFO_EX(arginfo_screwim_encrypt, 0, 0, 1)
85 | ZEND_ARG_INFO(0, string)
86 | ZEND_END_ARG_INFO()
87 |
88 | #ifdef SCREWIM_DECRYPT
89 | ZEND_BEGIN_ARG_INFO_EX(arginfo_screwim_decrypt, 0, 0, 1)
90 | ZEND_ARG_INFO(0, string)
91 | ZEND_ARG_INFO(0, key)
92 | ZEND_ARG_INFO(0, header_len)
93 | ZEND_END_ARG_INFO()
94 | ZEND_BEGIN_ARG_INFO_EX(arginfo_screwim_seed, 0, 0, 0)
95 | ZEND_END_ARG_INFO()
96 | #endif /* end of SCREWIM_DECRYPT */
97 | #endif /* end of PHP_VERSION_ID > 79999 */
98 | /* }}} */
99 |
100 | /* {{{ +-- screwim_functions[]
101 | *
102 | * Every user visible function must have an entry in screwim_functions[].
103 | */
104 | const zend_function_entry screwim_functions[] = {
105 | PHP_FE(screwim_encrypt, arginfo_screwim_encrypt)
106 | #ifdef SCREWIM_DECRYPT
107 | PHP_FE(screwim_decrypt, arginfo_screwim_decrypt)
108 | PHP_FE(screwim_seed, arginfo_screwim_seed)
109 | #endif
110 | {NULL, NULL, NULL}
111 | };
112 | /* }}} */
113 |
114 | typedef struct screw_data {
115 | void * buf;
116 | size_t len;
117 | } SCREWData;
118 |
119 | /* {{{ +-- Internal APIs
120 | */
121 |
122 | /* {{{ +-- static void php_screwim_init_globals(zend_screwim_globals *screwim_globals)
123 | */
124 | static void php_screwim_init_globals(zend_screwim_globals *screwim_globals) {
125 | screwim_globals->enabled = 0;
126 | }
127 | /* }}} */
128 |
129 | /* {{{ +-- SCREWData screwdata_init (void)
130 | */
131 | SCREWData screwdata_init (void) {
132 | SCREWData data;
133 |
134 | data.buf = NULL;
135 | data.len = 0;
136 |
137 | return data;
138 | }
139 | /* }}} */
140 |
141 | /* {{{ +-- SCREWData mcryptkey (char * key)
142 | */
143 | SCREWData mcryptkey (char * key) {
144 | SCREWData sdata;
145 | short * buf;
146 | int i;
147 | short screwim_mycryptkey[] = {
148 | SCREWIM_ENC_DATA
149 | };
150 |
151 | if ( key != NULL && strlen (key) > 0 ) {
152 | sdata.len = strlen (key) / 4;
153 | if ( (strlen (key) % 4) != 0 )
154 | sdata.len++;
155 |
156 | buf = generate_key (key, sdata.len);
157 | } else {
158 | sdata.len = sizeof (screwim_mycryptkey) / sizeof (short);
159 | buf = (short *) emalloc (sizeof (screwim_mycryptkey));
160 |
161 | for ( i=0; ihandle.stream.mmap.buf + SCREWIM_LEN;
227 | datalen = file_handle->handle.stream.mmap.len - SCREWIM_LEN;
228 |
229 | datap = (char *) emalloc (datalen);
230 | memset (datap, 0, datalen);
231 | memcpy (datap, nbuf, datalen);
232 |
233 | sdata = screwim_ext_buf (datap, datalen, NULL);
234 | efree (datap);
235 |
236 | return sdata;
237 | }
238 | /* }}} */
239 | #endif
240 |
241 | ZEND_API zend_op_array *(*org_compile_file)(zend_file_handle * file_handle, int type TSRMLS_DC);
242 |
243 | // {{{ +-- ZEND_API zend_op_array * screwim_compile_file (zend_file_handle *, int TSRMLS_DC)
244 | ZEND_API zend_op_array * screwim_compile_file (zend_file_handle * file_handle, int type TSRMLS_DC)
245 | {
246 | FILE * fp;
247 | char buf[SCREWIM_LEN + 1] = { 0, };
248 | char fname[32] = { 0, };
249 | SCREWData sdata, tmp;
250 |
251 | if ( ! SCREWIM_G (enabled) )
252 | return org_compile_file (file_handle, type TSRMLS_CC);
253 |
254 | #if PHP_VERSION_ID < 70400
255 | // If file_handle->type is ZEND_HANDLE_MAPPED, handle.stream.mmap.buf has already
256 | // contents data. This case is include or require. when file is directly opened,
257 | // handle.stream.mmap.buf has NULL.
258 | if ( file_handle->type == ZEND_HANDLE_MAPPED ) {
259 | if ( file_handle->handle.stream.mmap.len > 0 ) {
260 | memcpy (buf, file_handle->handle.stream.mmap.buf, SCREWIM_LEN);
261 | if ( memcmp (buf, SCREWIM, SCREWIM_LEN) != 0 )
262 | return org_compile_file (file_handle, type TSRMLS_CC);
263 | } else
264 | return org_compile_file (file_handle, type TSRMLS_CC);
265 | }
266 | #endif
267 |
268 | if ( zend_is_executing (TSRMLS_C) ) {
269 | if ( get_active_function_name (TSRMLS_C) ) {
270 | strncpy (fname, get_active_function_name (TSRMLS_C), sizeof (fname - 2));
271 | }
272 | }
273 | if ( fname[0] ) {
274 | if ( strcasecmp (fname, "show_source") == 0 || strcasecmp (fname, "highlight_file") == 0) {
275 | return NULL;
276 | }
277 | }
278 |
279 | #if PHP_VERSION_ID < 70400
280 | if ( file_handle->type == ZEND_HANDLE_MAPPED ) {
281 | sdata = screwim_ext_mmap (file_handle);
282 | } else {
283 | #endif
284 | // When file is opened directly (type is ZEND_HANDLE_FP), check here.
285 |
286 | #if PHP_VERSION_ID >= 80100
287 | fp = fopen (ZSTR_VAL (file_handle->filename), "rb");
288 | #else
289 | fp = fopen (file_handle->filename, "rb");
290 | #endif
291 | if ( ! fp ) {
292 | return org_compile_file (file_handle, type TSRMLS_CC);
293 | }
294 |
295 | fread (buf, sizeof (char), SCREWIM_LEN, fp);
296 |
297 | if ( memcmp (buf, SCREWIM, SCREWIM_LEN) != 0 ) {
298 | fclose (fp);
299 | return org_compile_file (file_handle, type TSRMLS_CC);
300 | }
301 |
302 | sdata = screwim_ext_fopen (fp);
303 | #if PHP_VERSION_ID < 70400
304 | }
305 | #endif
306 |
307 | tmp = screwdata_init ();
308 |
309 | if ( sdata.buf == NULL )
310 | return NULL;
311 |
312 | if ( zend_stream_fixup (file_handle, (char **) &tmp.buf, &tmp.len TSRMLS_CC) == FAILURE )
313 | return NULL;
314 |
315 | #if PHP_VERSION_ID < 70400
316 | file_handle->handle.stream.mmap.buf = sdata.buf;
317 | file_handle->handle.stream.mmap.len = sdata.len;
318 | #else
319 | file_handle->buf = sdata.buf;
320 | file_handle->len = sdata.len;
321 | #endif
322 | file_handle->handle.stream.closer = NULL;
323 |
324 | return org_compile_file (file_handle, type TSRMLS_CC);
325 | }
326 | /* }}} */
327 |
328 | /* {{{ for PHP 5 APIs
329 | */
330 |
331 | #if PHP_VERSION_ID < 60000
332 | /* {{{ +-- zend_string * zend_string_alloc (size_t len, int persis)
333 | */
334 | zend_string * zend_string_alloc (size_t len, int persis) {
335 | zend_string * buf;
336 |
337 | buf = (zend_string *) emalloc (sizeof (zend_string));
338 | buf->val = (char *) emalloc (sizeof (char) * len + 1);
339 | memset (buf->val, 0, sizeof (char) * len + 1);
340 | buf->len = len;
341 |
342 | return buf;
343 | }
344 | /* }}} */
345 |
346 | /* {{{ +-- void zend_string_free (zend_string * buf)
347 | */
348 | void zend_string_free (zend_string * buf) {
349 | if ( buf == NULL )
350 | return;
351 |
352 | if ( buf->val != NULL ) {
353 | efree (buf->val);
354 | buf->val = NULL;
355 | }
356 |
357 | efree (buf);
358 | }
359 | /* }}} */
360 | #endif
361 |
362 | /* End of PHP 5 APIs }}} */
363 |
364 | /* end of internal APIs }}} */
365 |
366 | /* {{{ +-- PHP_FUNCTION (string) screwim_encrypt (string)
367 | */
368 | PHP_FUNCTION (screwim_encrypt) {
369 | zend_string * text;
370 | zend_string * ndata;
371 | char * datap;
372 | ULong datalen;
373 | int i;
374 |
375 | SCREWData key;
376 | short * keybuf;
377 |
378 | #if PHP_VERSION_ID < 60000
379 | text = (zend_string *) emalloc (sizeof (zend_string));
380 | ZSTR_VAL(text) = NULL;
381 | ZSTR_LEN(text) = 0;
382 | if ( zend_parse_parameters (ZEND_NUM_ARGS(), "s", &ZSTR_VAL(text), &ZSTR_LEN(text)) == FAILURE )
383 | #else
384 | if ( zend_parse_parameters (ZEND_NUM_ARGS(), "S", &text) == FAILURE )
385 | #endif
386 | {
387 | #if PHP_VERSION_ID < 60000
388 | zend_string_free (text);
389 | #endif
390 | return;
391 | }
392 |
393 | if ( ZSTR_LEN (text) == 0 ) {
394 | #if PHP_VERSION_ID < 60000
395 | zend_string_free (text);
396 | #endif
397 | RETURN_NULL ();
398 | }
399 |
400 | if ( memcmp (ZSTR_VAL (text), SCREWIM, SCREWIM_LEN) == 0 ) {
401 | php_error (E_WARNING, "given data already crypted");
402 | RETVAL_STR (text);
403 | #if PHP_VERSION_ID < 60000
404 | efree (text);
405 | #endif
406 | }
407 |
408 | datap = zencode (ZSTR_VAL (text), ZSTR_LEN (text), (ULong *) &datalen);
409 |
410 | #if PHP_VERSION_ID < 60000
411 | zend_string_free (text);
412 | #endif
413 |
414 | key = mcryptkey (NULL);
415 | keybuf = (short *) key.buf;
416 |
417 | for( i=0; i 0 ) {
544 | php_error (E_WARNING, "screwim_seed() expects exactly 0 parameter, %d given", ZEND_NUM_ARGS ());
545 | return;
546 | }
547 |
548 | key = mcryptkey (NULL);
549 | keybuf = (short *) key.buf;
550 | buflen = key.len * 4;
551 |
552 | keybyte = emalloc (buflen + 1);
553 | memset (keybyte, 0, buflen + 1);
554 |
555 | for ( i=0; i= 20010901
589 | STANDARD_MODULE_HEADER,
590 | #endif
591 | "screwim",
592 | screwim_functions,
593 | PHP_MINIT(screwim),
594 | PHP_MSHUTDOWN(screwim),
595 | NULL,
596 | NULL,
597 | PHP_MINFO(screwim),
598 | #if ZEND_MODULE_API_NO >= 20010901
599 | SCREWIM_VERSION, /* Replace with version number for your extension */
600 | #endif
601 | STANDARD_MODULE_PROPERTIES
602 | };
603 |
604 | #ifdef COMPILE_DL_SCREWIM
605 | ZEND_GET_MODULE (screwim);
606 | #endif
607 |
608 | PHP_INI_BEGIN()
609 | STD_PHP_INI_BOOLEAN("screwim.enable", "0", PHP_INI_ALL, OnUpdateBool, enabled, zend_screwim_globals, screwim_globals)
610 | PHP_INI_END()
611 |
612 | PHP_MINFO_FUNCTION (screwim)
613 | {
614 | php_info_print_table_start ();
615 | php_info_print_table_colspan_header (2, "PHP SCREW Imporved support");
616 | php_info_print_table_row (2, "Summary", "PHP script encryption tool");
617 | php_info_print_table_row (2, "URL", "http://github.com/OOPS-ORG-PHP/mod_screwim");
618 | php_info_print_table_row (2, "Build version", SCREWIM_VERSION);
619 | php_info_print_table_end ();
620 | }
621 |
622 | PHP_MINIT_FUNCTION (screwim)
623 | {
624 | CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
625 |
626 | ZEND_INIT_MODULE_GLOBALS(screwim, php_screwim_init_globals, NULL);
627 | REGISTER_INI_ENTRIES();
628 |
629 | org_compile_file = zend_compile_file;
630 | zend_compile_file = screwim_compile_file;
631 | return SUCCESS;
632 | }
633 |
634 | PHP_MSHUTDOWN_FUNCTION(screwim)
635 | {
636 | CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
637 |
638 | zend_compile_file = org_compile_file;
639 | return SUCCESS;
640 | }
641 |
642 | /* end of PHP Module registration }}} */
643 |
644 | /*
645 | * Local variables:
646 | * tab-width: 4
647 | * c-basic-offset: 4
648 | * End:
649 | * vim600: noet sw=4 ts=4 fdm=marker
650 | * vim<600: noet sw=4 ts=4
651 | */
652 |
--------------------------------------------------------------------------------
/tools/Makefile.in:
--------------------------------------------------------------------------------
1 | # Makefile.in generated by automake 1.16.1 from Makefile.am.
2 | # @configure_input@
3 |
4 | # Copyright (C) 1994-2018 Free Software Foundation, Inc.
5 |
6 | # This Makefile.in is free software; the Free Software Foundation
7 | # gives unlimited permission to copy and/or distribute it,
8 | # with or without modifications, as long as this notice is preserved.
9 |
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 | # PARTICULAR PURPOSE.
14 |
15 | @SET_MAKE@
16 |
17 | # Process this file with automake to produce Makefile.in
18 | # Copyright 2022. JoungKyun.Kim All rights reserved.
19 | #
20 | # This file is part of mod_screwim
21 | #
22 | # Redistribution and use in source and binary forms, with or without modification,
23 | # are permitted provided that the following conditions are met:
24 | #
25 | # 1. Redistributions of source code must retain the above copyright notice, this
26 | # list of conditions and the following disclaimer.
27 | #
28 | # 2. Redistributions in binary form must reproduce the above copyright notice,
29 | # this list of conditions and the following disclaimer in the documentation
30 | # and/or other materials provided with the distribution.
31 | #
32 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
36 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
39 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 | #
43 |
44 | VPATH = @srcdir@
45 | am__is_gnu_make = { \
46 | if test -z '$(MAKELEVEL)'; then \
47 | false; \
48 | elif test -n '$(MAKE_HOST)'; then \
49 | true; \
50 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
51 | true; \
52 | else \
53 | false; \
54 | fi; \
55 | }
56 | am__make_running_with_option = \
57 | case $${target_option-} in \
58 | ?) ;; \
59 | *) echo "am__make_running_with_option: internal error: invalid" \
60 | "target option '$${target_option-}' specified" >&2; \
61 | exit 1;; \
62 | esac; \
63 | has_opt=no; \
64 | sane_makeflags=$$MAKEFLAGS; \
65 | if $(am__is_gnu_make); then \
66 | sane_makeflags=$$MFLAGS; \
67 | else \
68 | case $$MAKEFLAGS in \
69 | *\\[\ \ ]*) \
70 | bs=\\; \
71 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
72 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
73 | esac; \
74 | fi; \
75 | skip_next=no; \
76 | strip_trailopt () \
77 | { \
78 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
79 | }; \
80 | for flg in $$sane_makeflags; do \
81 | test $$skip_next = yes && { skip_next=no; continue; }; \
82 | case $$flg in \
83 | *=*|--*) continue;; \
84 | -*I) strip_trailopt 'I'; skip_next=yes;; \
85 | -*I?*) strip_trailopt 'I';; \
86 | -*O) strip_trailopt 'O'; skip_next=yes;; \
87 | -*O?*) strip_trailopt 'O';; \
88 | -*l) strip_trailopt 'l'; skip_next=yes;; \
89 | -*l?*) strip_trailopt 'l';; \
90 | -[dEDm]) skip_next=yes;; \
91 | -[JT]) skip_next=yes;; \
92 | esac; \
93 | case $$flg in \
94 | *$$target_option*) has_opt=yes; break;; \
95 | esac; \
96 | done; \
97 | test $$has_opt = yes
98 | am__make_dryrun = (target_option=n; $(am__make_running_with_option))
99 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
100 | pkgdatadir = $(datadir)/@PACKAGE@
101 | pkgincludedir = $(includedir)/@PACKAGE@
102 | pkglibdir = $(libdir)/@PACKAGE@
103 | pkglibexecdir = $(libexecdir)/@PACKAGE@
104 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
105 | install_sh_DATA = $(install_sh) -c -m 644
106 | install_sh_PROGRAM = $(install_sh) -c
107 | install_sh_SCRIPT = $(install_sh) -c
108 | INSTALL_HEADER = $(INSTALL_DATA)
109 | transform = $(program_transform_name)
110 | NORMAL_INSTALL = :
111 | PRE_INSTALL = :
112 | POST_INSTALL = :
113 | NORMAL_UNINSTALL = :
114 | PRE_UNINSTALL = :
115 | POST_UNINSTALL = :
116 | bin_PROGRAMS = screwim$(EXEEXT)
117 | subdir = .
118 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
119 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac
120 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
121 | $(ACLOCAL_M4)
122 | DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
123 | $(am__configure_deps) $(am__DIST_COMMON)
124 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
125 | configure.lineno config.status.lineno
126 | mkinstalldirs = $(install_sh) -d
127 | CONFIG_HEADER = config.h
128 | CONFIG_CLEAN_FILES =
129 | CONFIG_CLEAN_VPATH_FILES =
130 | am__installdirs = "$(DESTDIR)$(bindir)"
131 | PROGRAMS = $(bin_PROGRAMS)
132 | am_screwim_OBJECTS = screw.$(OBJEXT) zencode.$(OBJEXT)
133 | screwim_OBJECTS = $(am_screwim_OBJECTS)
134 | screwim_LDADD = $(LDADD)
135 | AM_V_P = $(am__v_P_@AM_V@)
136 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
137 | am__v_P_0 = false
138 | am__v_P_1 = :
139 | AM_V_GEN = $(am__v_GEN_@AM_V@)
140 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
141 | am__v_GEN_0 = @echo " GEN " $@;
142 | am__v_GEN_1 =
143 | AM_V_at = $(am__v_at_@AM_V@)
144 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
145 | am__v_at_0 = @
146 | am__v_at_1 =
147 | DEFAULT_INCLUDES = -I.@am__isrc@
148 | depcomp =
149 | am__maybe_remake_depfiles =
150 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
151 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
152 | AM_V_CC = $(am__v_CC_@AM_V@)
153 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
154 | am__v_CC_0 = @echo " CC " $@;
155 | am__v_CC_1 =
156 | CCLD = $(CC)
157 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
158 | AM_V_CCLD = $(am__v_CCLD_@AM_V@)
159 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
160 | am__v_CCLD_0 = @echo " CCLD " $@;
161 | am__v_CCLD_1 =
162 | SOURCES = $(screwim_SOURCES)
163 | DIST_SOURCES = $(screwim_SOURCES)
164 | RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
165 | ctags-recursive dvi-recursive html-recursive info-recursive \
166 | install-data-recursive install-dvi-recursive \
167 | install-exec-recursive install-html-recursive \
168 | install-info-recursive install-pdf-recursive \
169 | install-ps-recursive install-recursive installcheck-recursive \
170 | installdirs-recursive pdf-recursive ps-recursive \
171 | tags-recursive uninstall-recursive
172 | am__can_run_installinfo = \
173 | case $$AM_UPDATE_INFO_DIR in \
174 | n|no|NO) false;; \
175 | *) (install-info --version) >/dev/null 2>&1;; \
176 | esac
177 | RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
178 | distclean-recursive maintainer-clean-recursive
179 | am__recursive_targets = \
180 | $(RECURSIVE_TARGETS) \
181 | $(RECURSIVE_CLEAN_TARGETS) \
182 | $(am__extra_recursive_targets)
183 | AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
184 | cscope distdir distdir-am dist dist-all distcheck
185 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
186 | $(LISP)config.h.in
187 | # Read a list of newline-separated strings from the standard input,
188 | # and print each of them once, without duplicates. Input order is
189 | # *not* preserved.
190 | am__uniquify_input = $(AWK) '\
191 | BEGIN { nonempty = 0; } \
192 | { items[$$0] = 1; nonempty = 1; } \
193 | END { if (nonempty) { for (i in items) print i; }; } \
194 | '
195 | # Make sure the list of sources is unique. This is necessary because,
196 | # e.g., the same source file might be shared among _SOURCES variables
197 | # for different programs/libraries.
198 | am__define_uniq_tagged_files = \
199 | list='$(am__tagged_files)'; \
200 | unique=`for i in $$list; do \
201 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
202 | done | $(am__uniquify_input)`
203 | ETAGS = etags
204 | CTAGS = ctags
205 | CSCOPE = cscope
206 | DIST_SUBDIRS = $(SUBDIRS)
207 | am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in compile \
208 | install-sh missing
209 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
210 | distdir = $(PACKAGE)-$(VERSION)
211 | top_distdir = $(distdir)
212 | am__remove_distdir = \
213 | if test -d "$(distdir)"; then \
214 | find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
215 | && rm -rf "$(distdir)" \
216 | || { sleep 5 && rm -rf "$(distdir)"; }; \
217 | else :; fi
218 | am__post_remove_distdir = $(am__remove_distdir)
219 | am__relativize = \
220 | dir0=`pwd`; \
221 | sed_first='s,^\([^/]*\)/.*$$,\1,'; \
222 | sed_rest='s,^[^/]*/*,,'; \
223 | sed_last='s,^.*/\([^/]*\)$$,\1,'; \
224 | sed_butlast='s,/*[^/]*$$,,'; \
225 | while test -n "$$dir1"; do \
226 | first=`echo "$$dir1" | sed -e "$$sed_first"`; \
227 | if test "$$first" != "."; then \
228 | if test "$$first" = ".."; then \
229 | dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
230 | dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
231 | else \
232 | first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
233 | if test "$$first2" = "$$first"; then \
234 | dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
235 | else \
236 | dir2="../$$dir2"; \
237 | fi; \
238 | dir0="$$dir0"/"$$first"; \
239 | fi; \
240 | fi; \
241 | dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
242 | done; \
243 | reldir="$$dir2"
244 | DIST_ARCHIVES = $(distdir).tar.gz
245 | GZIP_ENV = --best
246 | DIST_TARGETS = dist-gzip
247 | distuninstallcheck_listfiles = find . -type f -print
248 | am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
249 | | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
250 | distcleancheck_listfiles = find . -type f -print
251 | ACLOCAL = @ACLOCAL@
252 | AMTAR = @AMTAR@
253 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
254 | AUTOCONF = @AUTOCONF@
255 | AUTOHEADER = @AUTOHEADER@
256 | AUTOMAKE = @AUTOMAKE@
257 | AWK = @AWK@
258 | CC = @CC@
259 | CFLAGS = @CFLAGS@
260 | CPP = @CPP@
261 | CPPFLAGS = @CPPFLAGS@
262 | CYGPATH_W = @CYGPATH_W@
263 | DEFS = @DEFS@
264 | ECHO_C = @ECHO_C@
265 | ECHO_N = @ECHO_N@
266 | ECHO_T = @ECHO_T@
267 | EGREP = @EGREP@
268 | EXEEXT = @EXEEXT@
269 | GREP = @GREP@
270 | INSTALL = @INSTALL@
271 | INSTALL_DATA = @INSTALL_DATA@
272 | INSTALL_PROGRAM = @INSTALL_PROGRAM@
273 | INSTALL_SCRIPT = @INSTALL_SCRIPT@
274 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
275 | LDFLAGS = @LDFLAGS@
276 | LIBOBJS = @LIBOBJS@
277 | LIBS = @LIBS@
278 | LTLIBOBJS = @LTLIBOBJS@
279 | MAKEINFO = @MAKEINFO@
280 | MKDIR_P = @MKDIR_P@
281 | OBJEXT = @OBJEXT@
282 | PACKAGE = @PACKAGE@
283 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
284 | PACKAGE_NAME = @PACKAGE_NAME@
285 | PACKAGE_STRING = @PACKAGE_STRING@
286 | PACKAGE_TARNAME = @PACKAGE_TARNAME@
287 | PACKAGE_URL = @PACKAGE_URL@
288 | PACKAGE_VERSION = @PACKAGE_VERSION@
289 | PATH_SEPARATOR = @PATH_SEPARATOR@
290 | SET_MAKE = @SET_MAKE@
291 | SHELL = @SHELL@
292 | STRIP = @STRIP@
293 | VERSION = @VERSION@
294 | abs_builddir = @abs_builddir@
295 | abs_srcdir = @abs_srcdir@
296 | abs_top_builddir = @abs_top_builddir@
297 | abs_top_srcdir = @abs_top_srcdir@
298 | ac_ct_CC = @ac_ct_CC@
299 | am__leading_dot = @am__leading_dot@
300 | am__tar = @am__tar@
301 | am__untar = @am__untar@
302 | bindir = @bindir@
303 | build_alias = @build_alias@
304 | builddir = @builddir@
305 | datadir = @datadir@
306 | datarootdir = @datarootdir@
307 | docdir = @docdir@
308 | dvidir = @dvidir@
309 | exec_prefix = @exec_prefix@
310 | host_alias = @host_alias@
311 | htmldir = @htmldir@
312 | includedir = @includedir@
313 | infodir = @infodir@
314 | install_sh = @install_sh@
315 | libdir = @libdir@
316 | libexecdir = @libexecdir@
317 | localedir = @localedir@
318 | localstatedir = @localstatedir@
319 | mandir = @mandir@
320 | mkdir_p = @mkdir_p@
321 | oldincludedir = @oldincludedir@
322 | pdfdir = @pdfdir@
323 | prefix = @prefix@
324 | program_transform_name = @program_transform_name@
325 | psdir = @psdir@
326 | sbindir = @sbindir@
327 | sharedstatedir = @sharedstatedir@
328 | srcdir = @srcdir@
329 | sysconfdir = @sysconfdir@
330 | target_alias = @target_alias@
331 | top_build_prefix = @top_build_prefix@
332 | top_builddir = @top_builddir@
333 | top_srcdir = @top_srcdir@
334 | DISTCLEANFILES =
335 | #EXTRA_DIST = README.md LICENSE
336 | SUBDIRS = .
337 | AM_CFLAGS = -Wall
338 | screwim_SOURCES = screw.c zencode.c
339 | all: config.h
340 | $(MAKE) $(AM_MAKEFLAGS) all-recursive
341 |
342 | .SUFFIXES:
343 | .SUFFIXES: .c .o .obj
344 | am--refresh: Makefile
345 | @:
346 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
347 | @for dep in $?; do \
348 | case '$(am__configure_deps)' in \
349 | *$$dep*) \
350 | echo ' cd $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps'; \
351 | $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps \
352 | && exit 0; \
353 | exit 1;; \
354 | esac; \
355 | done; \
356 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps Makefile'; \
357 | $(am__cd) $(top_srcdir) && \
358 | $(AUTOMAKE) --foreign --ignore-deps Makefile
359 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
360 | @case '$?' in \
361 | *config.status*) \
362 | echo ' $(SHELL) ./config.status'; \
363 | $(SHELL) ./config.status;; \
364 | *) \
365 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
366 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
367 | esac;
368 |
369 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
370 | $(SHELL) ./config.status --recheck
371 |
372 | $(top_srcdir)/configure: $(am__configure_deps)
373 | $(am__cd) $(srcdir) && $(AUTOCONF)
374 | $(ACLOCAL_M4): $(am__aclocal_m4_deps)
375 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
376 | $(am__aclocal_m4_deps):
377 |
378 | config.h: stamp-h1
379 | @test -f $@ || rm -f stamp-h1
380 | @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
381 |
382 | stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
383 | @rm -f stamp-h1
384 | cd $(top_builddir) && $(SHELL) ./config.status config.h
385 | $(srcdir)/config.h.in: $(am__configure_deps)
386 | ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
387 | rm -f stamp-h1
388 | touch $@
389 |
390 | distclean-hdr:
391 | -rm -f config.h stamp-h1
392 | install-binPROGRAMS: $(bin_PROGRAMS)
393 | @$(NORMAL_INSTALL)
394 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
395 | if test -n "$$list"; then \
396 | echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
397 | $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
398 | fi; \
399 | for p in $$list; do echo "$$p $$p"; done | \
400 | sed 's/$(EXEEXT)$$//' | \
401 | while read p p1; do if test -f $$p \
402 | ; then echo "$$p"; echo "$$p"; else :; fi; \
403 | done | \
404 | sed -e 'p;s,.*/,,;n;h' \
405 | -e 's|.*|.|' \
406 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
407 | sed 'N;N;N;s,\n, ,g' | \
408 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
409 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
410 | if ($$2 == $$4) files[d] = files[d] " " $$1; \
411 | else { print "f", $$3 "/" $$4, $$1; } } \
412 | END { for (d in files) print "f", d, files[d] }' | \
413 | while read type dir files; do \
414 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
415 | test -z "$$files" || { \
416 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
417 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
418 | } \
419 | ; done
420 |
421 | uninstall-binPROGRAMS:
422 | @$(NORMAL_UNINSTALL)
423 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
424 | files=`for p in $$list; do echo "$$p"; done | \
425 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
426 | -e 's/$$/$(EXEEXT)/' \
427 | `; \
428 | test -n "$$list" || exit 0; \
429 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
430 | cd "$(DESTDIR)$(bindir)" && rm -f $$files
431 |
432 | clean-binPROGRAMS:
433 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
434 |
435 | screwim$(EXEEXT): $(screwim_OBJECTS) $(screwim_DEPENDENCIES) $(EXTRA_screwim_DEPENDENCIES)
436 | @rm -f screwim$(EXEEXT)
437 | $(AM_V_CCLD)$(LINK) $(screwim_OBJECTS) $(screwim_LDADD) $(LIBS)
438 |
439 | mostlyclean-compile:
440 | -rm -f *.$(OBJEXT)
441 |
442 | distclean-compile:
443 | -rm -f *.tab.c
444 |
445 | .c.o:
446 | $(AM_V_CC)$(COMPILE) -c -o $@ $<
447 |
448 | .c.obj:
449 | $(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
450 |
451 | # This directory's subdirectories are mostly independent; you can cd
452 | # into them and run 'make' without going through this Makefile.
453 | # To change the values of 'make' variables: instead of editing Makefiles,
454 | # (1) if the variable is set in 'config.status', edit 'config.status'
455 | # (which will cause the Makefiles to be regenerated when you run 'make');
456 | # (2) otherwise, pass the desired values on the 'make' command line.
457 | $(am__recursive_targets):
458 | @fail=; \
459 | if $(am__make_keepgoing); then \
460 | failcom='fail=yes'; \
461 | else \
462 | failcom='exit 1'; \
463 | fi; \
464 | dot_seen=no; \
465 | target=`echo $@ | sed s/-recursive//`; \
466 | case "$@" in \
467 | distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
468 | *) list='$(SUBDIRS)' ;; \
469 | esac; \
470 | for subdir in $$list; do \
471 | echo "Making $$target in $$subdir"; \
472 | if test "$$subdir" = "."; then \
473 | dot_seen=yes; \
474 | local_target="$$target-am"; \
475 | else \
476 | local_target="$$target"; \
477 | fi; \
478 | ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
479 | || eval $$failcom; \
480 | done; \
481 | if test "$$dot_seen" = "no"; then \
482 | $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
483 | fi; test -z "$$fail"
484 |
485 | ID: $(am__tagged_files)
486 | $(am__define_uniq_tagged_files); mkid -fID $$unique
487 | tags: tags-recursive
488 | TAGS: tags
489 |
490 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
491 | set x; \
492 | here=`pwd`; \
493 | if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
494 | include_option=--etags-include; \
495 | empty_fix=.; \
496 | else \
497 | include_option=--include; \
498 | empty_fix=; \
499 | fi; \
500 | list='$(SUBDIRS)'; for subdir in $$list; do \
501 | if test "$$subdir" = .; then :; else \
502 | test ! -f $$subdir/TAGS || \
503 | set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
504 | fi; \
505 | done; \
506 | $(am__define_uniq_tagged_files); \
507 | shift; \
508 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
509 | test -n "$$unique" || unique=$$empty_fix; \
510 | if test $$# -gt 0; then \
511 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
512 | "$$@" $$unique; \
513 | else \
514 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
515 | $$unique; \
516 | fi; \
517 | fi
518 | ctags: ctags-recursive
519 |
520 | CTAGS: ctags
521 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
522 | $(am__define_uniq_tagged_files); \
523 | test -z "$(CTAGS_ARGS)$$unique" \
524 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
525 | $$unique
526 |
527 | GTAGS:
528 | here=`$(am__cd) $(top_builddir) && pwd` \
529 | && $(am__cd) $(top_srcdir) \
530 | && gtags -i $(GTAGS_ARGS) "$$here"
531 | cscope: cscope.files
532 | test ! -s cscope.files \
533 | || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
534 | clean-cscope:
535 | -rm -f cscope.files
536 | cscope.files: clean-cscope cscopelist
537 | cscopelist: cscopelist-recursive
538 |
539 | cscopelist-am: $(am__tagged_files)
540 | list='$(am__tagged_files)'; \
541 | case "$(srcdir)" in \
542 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
543 | *) sdir=$(subdir)/$(srcdir) ;; \
544 | esac; \
545 | for i in $$list; do \
546 | if test -f "$$i"; then \
547 | echo "$(subdir)/$$i"; \
548 | else \
549 | echo "$$sdir/$$i"; \
550 | fi; \
551 | done >> $(top_builddir)/cscope.files
552 |
553 | distclean-tags:
554 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
555 | -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
556 |
557 | distdir: $(BUILT_SOURCES)
558 | $(MAKE) $(AM_MAKEFLAGS) distdir-am
559 |
560 | distdir-am: $(DISTFILES)
561 | $(am__remove_distdir)
562 | test -d "$(distdir)" || mkdir "$(distdir)"
563 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
564 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
565 | list='$(DISTFILES)'; \
566 | dist_files=`for file in $$list; do echo $$file; done | \
567 | sed -e "s|^$$srcdirstrip/||;t" \
568 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
569 | case $$dist_files in \
570 | */*) $(MKDIR_P) `echo "$$dist_files" | \
571 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
572 | sort -u` ;; \
573 | esac; \
574 | for file in $$dist_files; do \
575 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
576 | if test -d $$d/$$file; then \
577 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
578 | if test -d "$(distdir)/$$file"; then \
579 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
580 | fi; \
581 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
582 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
583 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
584 | fi; \
585 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
586 | else \
587 | test -f "$(distdir)/$$file" \
588 | || cp -p $$d/$$file "$(distdir)/$$file" \
589 | || exit 1; \
590 | fi; \
591 | done
592 | @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
593 | if test "$$subdir" = .; then :; else \
594 | $(am__make_dryrun) \
595 | || test -d "$(distdir)/$$subdir" \
596 | || $(MKDIR_P) "$(distdir)/$$subdir" \
597 | || exit 1; \
598 | dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
599 | $(am__relativize); \
600 | new_distdir=$$reldir; \
601 | dir1=$$subdir; dir2="$(top_distdir)"; \
602 | $(am__relativize); \
603 | new_top_distdir=$$reldir; \
604 | echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
605 | echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
606 | ($(am__cd) $$subdir && \
607 | $(MAKE) $(AM_MAKEFLAGS) \
608 | top_distdir="$$new_top_distdir" \
609 | distdir="$$new_distdir" \
610 | am__remove_distdir=: \
611 | am__skip_length_check=: \
612 | am__skip_mode_fix=: \
613 | distdir) \
614 | || exit 1; \
615 | fi; \
616 | done
617 | -test -n "$(am__skip_mode_fix)" \
618 | || find "$(distdir)" -type d ! -perm -755 \
619 | -exec chmod u+rwx,go+rx {} \; -o \
620 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
621 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
622 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
623 | || chmod -R a+r "$(distdir)"
624 | dist-gzip: distdir
625 | tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
626 | $(am__post_remove_distdir)
627 |
628 | dist-bzip2: distdir
629 | tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
630 | $(am__post_remove_distdir)
631 |
632 | dist-lzip: distdir
633 | tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
634 | $(am__post_remove_distdir)
635 |
636 | dist-xz: distdir
637 | tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
638 | $(am__post_remove_distdir)
639 |
640 | dist-tarZ: distdir
641 | @echo WARNING: "Support for distribution archives compressed with" \
642 | "legacy program 'compress' is deprecated." >&2
643 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
644 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
645 | $(am__post_remove_distdir)
646 |
647 | dist-shar: distdir
648 | @echo WARNING: "Support for shar distribution archives is" \
649 | "deprecated." >&2
650 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
651 | shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
652 | $(am__post_remove_distdir)
653 |
654 | dist-zip: distdir
655 | -rm -f $(distdir).zip
656 | zip -rq $(distdir).zip $(distdir)
657 | $(am__post_remove_distdir)
658 |
659 | dist dist-all:
660 | $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
661 | $(am__post_remove_distdir)
662 |
663 | # This target untars the dist file and tries a VPATH configuration. Then
664 | # it guarantees that the distribution is self-contained by making another
665 | # tarfile.
666 | distcheck: dist
667 | case '$(DIST_ARCHIVES)' in \
668 | *.tar.gz*) \
669 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
670 | *.tar.bz2*) \
671 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
672 | *.tar.lz*) \
673 | lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
674 | *.tar.xz*) \
675 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\
676 | *.tar.Z*) \
677 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
678 | *.shar.gz*) \
679 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
680 | *.zip*) \
681 | unzip $(distdir).zip ;;\
682 | esac
683 | chmod -R a-w $(distdir)
684 | chmod u+w $(distdir)
685 | mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
686 | chmod a-w $(distdir)
687 | test -d $(distdir)/_build || exit 0; \
688 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
689 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
690 | && am__cwd=`pwd` \
691 | && $(am__cd) $(distdir)/_build/sub \
692 | && ../../configure \
693 | $(AM_DISTCHECK_CONFIGURE_FLAGS) \
694 | $(DISTCHECK_CONFIGURE_FLAGS) \
695 | --srcdir=../.. --prefix="$$dc_install_base" \
696 | && $(MAKE) $(AM_MAKEFLAGS) \
697 | && $(MAKE) $(AM_MAKEFLAGS) dvi \
698 | && $(MAKE) $(AM_MAKEFLAGS) check \
699 | && $(MAKE) $(AM_MAKEFLAGS) install \
700 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \
701 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \
702 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
703 | distuninstallcheck \
704 | && chmod -R a-w "$$dc_install_base" \
705 | && ({ \
706 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
707 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
708 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
709 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
710 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
711 | } || { rm -rf "$$dc_destdir"; exit 1; }) \
712 | && rm -rf "$$dc_destdir" \
713 | && $(MAKE) $(AM_MAKEFLAGS) dist \
714 | && rm -rf $(DIST_ARCHIVES) \
715 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
716 | && cd "$$am__cwd" \
717 | || exit 1
718 | $(am__post_remove_distdir)
719 | @(echo "$(distdir) archives ready for distribution: "; \
720 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
721 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
722 | distuninstallcheck:
723 | @test -n '$(distuninstallcheck_dir)' || { \
724 | echo 'ERROR: trying to run $@ with an empty' \
725 | '$$(distuninstallcheck_dir)' >&2; \
726 | exit 1; \
727 | }; \
728 | $(am__cd) '$(distuninstallcheck_dir)' || { \
729 | echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
730 | exit 1; \
731 | }; \
732 | test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
733 | || { echo "ERROR: files left after uninstall:" ; \
734 | if test -n "$(DESTDIR)"; then \
735 | echo " (check DESTDIR support)"; \
736 | fi ; \
737 | $(distuninstallcheck_listfiles) ; \
738 | exit 1; } >&2
739 | distcleancheck: distclean
740 | @if test '$(srcdir)' = . ; then \
741 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \
742 | exit 1 ; \
743 | fi
744 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
745 | || { echo "ERROR: files left in build directory after distclean:" ; \
746 | $(distcleancheck_listfiles) ; \
747 | exit 1; } >&2
748 | check-am: all-am
749 | check: check-recursive
750 | all-am: Makefile $(PROGRAMS) config.h
751 | installdirs: installdirs-recursive
752 | installdirs-am:
753 | for dir in "$(DESTDIR)$(bindir)"; do \
754 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \
755 | done
756 | install: install-recursive
757 | install-exec: install-exec-recursive
758 | install-data: install-data-recursive
759 | uninstall: uninstall-recursive
760 |
761 | install-am: all-am
762 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
763 |
764 | installcheck: installcheck-recursive
765 | install-strip:
766 | if test -z '$(STRIP)'; then \
767 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
768 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
769 | install; \
770 | else \
771 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
772 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
773 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
774 | fi
775 | mostlyclean-generic:
776 |
777 | clean-generic:
778 |
779 | distclean-generic:
780 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
781 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
782 | -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
783 |
784 | maintainer-clean-generic:
785 | @echo "This command is intended for maintainers to use"
786 | @echo "it deletes files that may require special tools to rebuild."
787 | clean: clean-recursive
788 |
789 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
790 |
791 | distclean: distclean-recursive
792 | -rm -f $(am__CONFIG_DISTCLEAN_FILES)
793 | -rm -f Makefile
794 | distclean-am: clean-am distclean-compile distclean-generic \
795 | distclean-hdr distclean-local distclean-tags
796 |
797 | dvi: dvi-recursive
798 |
799 | dvi-am:
800 |
801 | html: html-recursive
802 |
803 | html-am:
804 |
805 | info: info-recursive
806 |
807 | info-am:
808 |
809 | install-data-am:
810 |
811 | install-dvi: install-dvi-recursive
812 |
813 | install-dvi-am:
814 |
815 | install-exec-am: install-binPROGRAMS
816 |
817 | install-html: install-html-recursive
818 |
819 | install-html-am:
820 |
821 | install-info: install-info-recursive
822 |
823 | install-info-am:
824 |
825 | install-man:
826 |
827 | install-pdf: install-pdf-recursive
828 |
829 | install-pdf-am:
830 |
831 | install-ps: install-ps-recursive
832 |
833 | install-ps-am:
834 |
835 | installcheck-am:
836 |
837 | maintainer-clean: maintainer-clean-recursive
838 | -rm -f $(am__CONFIG_DISTCLEAN_FILES)
839 | -rm -rf $(top_srcdir)/autom4te.cache
840 | -rm -f Makefile
841 | maintainer-clean-am: distclean-am maintainer-clean-generic
842 |
843 | mostlyclean: mostlyclean-recursive
844 |
845 | mostlyclean-am: mostlyclean-compile mostlyclean-generic
846 |
847 | pdf: pdf-recursive
848 |
849 | pdf-am:
850 |
851 | ps: ps-recursive
852 |
853 | ps-am:
854 |
855 | uninstall-am: uninstall-binPROGRAMS
856 |
857 | .MAKE: $(am__recursive_targets) all install-am install-strip
858 |
859 | .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
860 | am--refresh check check-am clean clean-binPROGRAMS \
861 | clean-cscope clean-generic cscope cscopelist-am ctags ctags-am \
862 | dist dist-all dist-bzip2 dist-gzip dist-lzip dist-shar \
863 | dist-tarZ dist-xz dist-zip distcheck distclean \
864 | distclean-compile distclean-generic distclean-hdr \
865 | distclean-local distclean-tags distcleancheck distdir \
866 | distuninstallcheck dvi dvi-am html html-am info info-am \
867 | install install-am install-binPROGRAMS install-data \
868 | install-data-am install-dvi install-dvi-am install-exec \
869 | install-exec-am install-html install-html-am install-info \
870 | install-info-am install-man install-pdf install-pdf-am \
871 | install-ps install-ps-am install-strip installcheck \
872 | installcheck-am installdirs installdirs-am maintainer-clean \
873 | maintainer-clean-generic mostlyclean mostlyclean-compile \
874 | mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
875 | uninstall-am uninstall-binPROGRAMS
876 |
877 | .PRECIOUS: Makefile
878 |
879 |
880 | distclean-local:
881 | -rm -rf autom4te.cache test-install z *.bz2 *.gz
882 | -rm -f tests/*.php.*
883 |
884 | test-install: all-recursive
885 | $(MAKE) DESTDIR=`pwd`/z install
886 |
887 | # Tell versions [3.59,3.63) of GNU make to not export all variables.
888 | # Otherwise a system limit (for SysV at least) may be exceeded.
889 | .NOEXPORT:
890 |
--------------------------------------------------------------------------------