adsr / injection-php

libinjection PHP wrapper
10 stars 3 forks source link

how can i build extension? #1

Open 5up3rc opened 7 years ago

5up3rc commented 7 years ago

configure: error: wrong libinjection version or lib not found

adsr commented 7 years ago

Hi, can you paste full build output?

5up3rc commented 7 years ago

thank you for your replay.

apples-MacBook-Air:injection-php apple$ sudo make -C libinjection && phpize && ./configure && make
(cd src; /Library/Developer/CommandLineTools/usr/bin/make all)
./make_parens.py < fingerprints.txt > fingerprints2.txt
mv fingerprints2.txt fingerprints.txt
./sqlparse_map.py > sqlparse_data.json
./sqlparse2c.py < sqlparse_data.json > libinjection_sqli_data.h
cc -Wall -Wextra -Werror -pedantic -ansi -g -O3 -fPIC -c -o libinjection_sqli.o libinjection_sqli.c
ld -shared -o libinjection.so libinjection_sqli.o libinjection_html5.o libinjection_xss.o -lc
ld: unknown option: -shared
make[1]: *** [libinjection.so] Error 1
make: *** [all] Error 2
5up3rc commented 7 years ago
apples-MacBook-Air:injection-php apple$ sudo phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
apples-MacBook-Air:injection-php apple$ sudo ./configure --with-php-config=/usr/local/php7/bin/php-config --with-injection=./libinjection/
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking target system type... x86_64-apple-darwin14.5.0
checking for PHP prefix... /usr/local/php7
checking for PHP includes... -I/usr/local/php7/include/php -I/usr/local/php7/include/php/main -I/usr/local/php7/include/php/TSRM -I/usr/local/php7/include/php/Zend -I/usr/local/php7/include/php/ext -I/usr/local/php7/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php7/lib/php/extensions/debug-zts-20160303
checking for PHP installed headers prefix... /usr/local/php7/include/php
checking if debug is enabled... yes
checking if zts is enabled... yes
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for libinjection support... yes, shared
checking for libinjection_is_sqli in -linjection... no
configure: error: wrong libinjection version or lib not found
adsr commented 7 years ago

It seems libinjection doesn't build properly on macOS. I don't have a mac laptop to test with but you can try applying this patch https://github.com/client9/libinjection/commit/b543fcc2795e8063af7f246c367babf8ca8fd200 from https://github.com/client9/libinjection/pull/112

adam@asx1c2:~/injection-php$ cd libinjection/
adam@asx1c2:~/injection-php/libinjection$ curl -s https://github.com/client9/libinjection/commit/b543fcc2795e8063af7f246c367babf8ca8fd200.patch | patch -p1

Then try building again.

5up3rc commented 7 years ago

build successful.but Running failed. php5:

apples-MacBook-Air:injection-php apple$ php -dextension=/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so example.php 
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so, 9): Library not loaded: libinjection.so
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so
  Reason: image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so, 9): Library not loaded: libinjection.so
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so
  Reason: image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/taint.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/taint.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/taint.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/taint.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so, 9): Library not loaded: libinjection.so
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so
  Reason: image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so, 9): Library not loaded: libinjection.so
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20121212/injection.so
  Reason: image not found in Unknown on line 0
PHP Fatal error:  Call to undefined function injection_is_sqli() in /Users/apple/Desktop/injection-php/example.php on line 8

Fatal error: Call to undefined function injection_is_sqli() in /Users/apple/Desktop/injection-php/example.php on line 8

php7:

apples-MacBook-Air:injection-php apple$ /usr/local/php7/bin/php -dextension=/usr/local/php7/lib/php/extensions/debug-zts-20160303/injection.so example.php 
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php7/lib/php/extensions/debug-zts-20160303/injection.so' - dlopen(/usr/local/php7/lib/php/extensions/debug-zts-20160303/injection.so, 9): Library not loaded: libinjection.so
  Referenced from: /usr/local/php7/lib/php/extensions/debug-zts-20160303/injection.so
  Reason: image not found in Unknown on line 0

Fatal error: Uncaught Error: Call to undefined function injection_is_sqli() in /Users/apple/Desktop/injection-php/example.php:8
Stack trace:
#0 {main}
  thrown in /Users/apple/Desktop/injection-php/example.php on line 8
adsr commented 7 years ago

@5up3rc libinjection.so needs to be in your library path. On Linux you can partially control this via the LD_LIBRARY_PATH env var. On macOS it sounds like DYLD_FALLBACK_LIBRARY_PATH does a similar thing? Try something like:

DYLD_FALLBACK_LIBRARY_PATH=/path/to/libinjection/src/ /usr/local/php7/bin/php -dextension=/usr/local/php7/lib/php/extensions/debug-zts-20160303/injection.so example.php

Or try moving libinjection.so to your system library path.

5up3rc commented 7 years ago

thank you! thank you! It run successfully:-)

5up3rc commented 7 years ago

It seems that in apache can not run successfully

adsr commented 7 years ago

Any error logs? Note Apache will need to be able to find libinjection as well.