LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Wapiti install script issue (http://www.linuxquestions.org/questions/linux-software-2/wapiti-install-script-issue-934393/)

shayno90 03-14-2012 08:04 AM

Wapiti install script issue
 
I have setup Wapiti in /usr/local/wapiti but get the following error message upon during the install:

http://www.hacktoolrepository.com/tool/125/Wapiti

user@localhost:~$ sudo -s
root@localhost:~# sh /usr/local/src/Wapiti/Wapiti.sh
usage /usr/local/src/Wapiti/Wapiti.sh username
username is the person you normally log on with that will configure and make the program
root@localhost:~# sh /usr/local/src/Wapiti/Wapiti.sh user
/usr/local/sbin/setpath.sh: You must be root to run /usr/local/sbin/setpath.sh
bash: líne 7: cd: /usr/local/src/Wapiti/setpath: No such file or directory
cd: 122: can't cd to /usr/local/src/Wapiti/setpath
.....................................................
/usr/local/src/Wapiti/Wapiti.sh: 141: /usr/local/sbin/setpath: not found
root@localhost:~# sh /usr/local/src/Wapiti/Wapiti.sh root
grep: option requires an argument -- 'd'
Usage: grep [CHOICE]... [DIRECTORY]...


In the wapiti.sh

#The directory where the source can be downloaded and build
SRCDIR='/usr/local/src/Wapiti'
#The directory where the software should be installed
TRGDIR='/usr/local'

PATH185="http://www.hacktoolrepository.com/files/Miscellaneous/setpath/setpath.sh"
FILE185="setpath.sh"
DIR185="setpath"
PROG185="setpath"

PATH125="http://www.hacktoolrepository.com/files/Web%20applications/Wapiti/wapiti-2.2.1.tar.bz2"
FILE125="wapiti-2.2.1.tar.bz2"
DIR125="wapiti-2.2.1"
PROG125="wapiti"

line 122 cd "${SRCDIR}/${DIR185}"
line 141 ${TRGDIR}/sbin/setpath ${TRGDIR}/wapiti/

Directory setup:
root@localhost:~# ls -ld /usr/local/src/Wapiti/*
-rw-r--r-- 1 user user 545 2011-05-20 09:26 /usr/local/src/Wapiti/setpath.sh
drwxr-xr-x 4 user users 4096 2009-12-29 18:11 /usr/local/src/Wapiti/wapiti-2.2.1
-rw-r--r-- 1 user user 405418 2010-01-06 06:27 /usr/local/src/Wapiti/wapiti-2.2.1.tar.bz2
-rw-r--r-- 1 user user 4094 2012-03-14 10:35 /usr/local/src/Wapiti/Wapiti.sh

root@user:~# ls -ld /usr/local/sbin/*
-rwxr-xr-x 1 root root 545 2012-03-14 11:43 /usr/local/sbin/setpath.sh

How can I get the setpath.sh to run properly as part of wapiti.sh?

weibullguy 03-14-2012 10:48 AM

You would need to hack the Wapiti.sh script so it works. From a quick look at Wapiti.sh, you should be able to comment out line 122 and then add a .sh to setpath in line 141. Of course, you could not use Wapiti.sh at all. I don't know what the setpath.sh script does, but Wapiti.sh just moves the wapiti-2.2.1 directory to /usr/local/wapiti. You could do that yourself if you wanted. You could also just keep wapiti-2.2.1 somewhere in your $HOME and execute it according to the INSTALL document that comes with wapiti.

shayno90 03-14-2012 12:47 PM

Quote:

Originally Posted by weibullguy (Post 4626618)
You would need to hack the Wapiti.sh script so it works. From a quick look at Wapiti.sh, you should be able to comment out line 122 and then add a .sh to setpath in line 141. Of course, you could not use Wapiti.sh at all. I don't know what the setpath.sh script does, but Wapiti.sh just moves the wapiti-2.2.1 directory to /usr/local/wapiti. You could do that yourself if you wanted. You could also just keep wapiti-2.2.1 somewhere in your $HOME and execute it according to the INSTALL document that comes with wapiti.

I edited the wapiti.sh script to:
line 122 #cd "${SRCDIR}/${DIR185}"
line 144 ${TRGDIR}/sbin/setpath.sh ${TRGDIR}/wapiti/

but it still complains:
root@localhost:~# sh /usr/local/src/Wapiti/Wapiti.sh root
grep: option requires an argument -- 'd'
Use: grep [CHOICE]... [DIRECTORY]...
Run as `grep --help' to get more help.
grep: option requires an argument -- 'd'
Use: grep [CHOICE]... [DIRECTORY]...
Run as `grep --help' to get more help.
bash: line 7: cd: /usr/local/src/Wapiti/setpath: No such file or directory

Line 7 in wapiti.sh is
# (c) http://www.hacktoolrepostory.com

Line 7 in setpath.sh is
#!/bin/bash

if [ -z $1 ] ; then
echo "Need a directory as argument to add to the path"
exit 1
else
PREFIX="$1" (Line 7)
fi

I assume setpath.sh is to check the path variable and user running the script is correct?

I would like to compile it this way in order to confirm I can run it via this method.

shayno90 03-15-2012 06:21 AM

I am using Openvas and in the report it says about Wapiti:

"wapiti could not be found in your system path.
OpenVAS was unable to execute wapiti and to perform the scan you
requested.
Please make sure that wapiti is installed and that wapiti is
available in the PATH variable defined for your environment."

This is why I want to correct the setpath.sh script to work with the wapiti.sh script.
The setpath.sh script is a "bash script to set the path for all users including root".

I want to install it in /usr/local/bin or symlink it to there from /usr/local.

Any thoughts on this?

shayno90 03-15-2012 01:16 PM

Ok I solved one error by doing the following:

Remove existing wapiti package installations:

root@user:~# rm -r /usr/local/wapiti/
root@user:~# rm -r /usr/local/src/Wapiti/

Note**
/usr/local/sbin/setpath.sh: You must be root to run /usr/local/sbin/setpath.sh

Edit the Wapiti.sh script on line 144

root@localhost:~# nano Wapiti.sh
replace
${TRGDIR}/sbin/setpath ${TRGDIR}/wapiti/
change to
${TRGDIR}/sbin/setpath.sh ${TRGDIR}/wapiti/
root@shayno90:~# sh Wapiti.sh user

Running as root removes these warnings:
bash: line 6: setpath.sh: cannot find command

However this error still remains as it looks for a directory that was not created by the Wapiti.sh script:
bash: line 7: cd: /usr/local/src/Wapiti/setpath: No such file or directory

In the directory /usr/local/src/Wapiti/ it only contains:
root@localhost:~# ls -l /usr/local/src/Wapiti/
total 404
-rw-r--r-- 1 user user 545 2011-05-20 09:26 setpath.sh
drwxr-xr-x 4 user user 4096 2009-12-29 18:11 wapiti-2.2.1
-rw-r--r-- 1 user user 405418 2010-01-06 06:27 wapiti-2.2.1.tar.bz2

What else should be changed in the Wapiti.sh script to correct this? (The problem areas of the script are below)

PATH185="http://www.hacktoolrepository.com/files/Miscellaneous/setpath/setpath.sh"
FILE185="setpath.sh"
DIR185="setpath"
PROG185="setpath"

cd "${SRCDIR}/${DIR185}"
cp setpath.sh ${TRGDIR}/sbin/
chmod +x ${TRGDIR}/sbin/setpath.sh

cd "${SRCDIR}/${DIR125}"
mkdir -p ${TRGDIR}/wapiti/ && cp -R ${SRCDIR}/${DIR125}/* ${TRGDIR}/wapiti/
${TRGDIR}/sbin/setpath.sh ${TRGDIR}/wapiti/

weibullguy 03-15-2012 10:36 PM

Commenting this line
Code:

cd "${SRCDIR}/${DIR185}"
doesn't resolve the error? Also, can you wrap the code in code tags? It's a lot easier to read.

shayno90 03-16-2012 06:46 AM

No commenting that did not work in Wapiti.sh:

#!/bin/bash
#cd "${SRCDIR}/${DIR185}"

Error message:
/usr/local/sbin/setpath.sh: You must be root to run /usr/local/sbin/setpath.sh
bash: líne 7: cd: /usr/local/src/Wapiti/setpath: No such file or directory


From setpath.sh:

#!/bin/bash

if [ -z $1 ] ; then
echo "Need a directory as argument to add to the path"
exit 1
else
PREFIX="$1"
fi

weibullguy 03-16-2012 10:31 AM

I guess wrapping the code in code tags didn't work? Try removing this code in Wapiti.sh that starts around line 117
Code:

"${FILE185}" -d "${DIR185}"
cd "${SRCDIR}/${DIR185}"


shayno90 03-17-2012 06:23 PM

Yes that worked thanks.

Comment out line 117/118
"${FILE185}" -d "${DIR185}"
cd "${SRCDIR}/${DIR185}"
to
# "${FILE185}" -d "${DIR185}"
# cd "${SRCDIR}/${DIR185}"

Comment out line 122
change
cd "${SRCDIR}/${DIR185}"
to
#cd "${SRCDIR}/${DIR185}"

edit and line 141
change
${TRGDIR}/sbin/setpath ${TRGDIR}/wapiti/
to
${TRGDIR}/sbin/setpath.sh ${TRGDIR}/wapiti/


Run the script as:

user@localhost:~$ sudo sh Wapiti.sh user

You should get no errors related to directories or user privileges.

However I am not sure why script wanted to create a setpath directory?

Next I want to run Wapiti with Openvas but have previously got this error:

"wapiti report filename is empty. that could mean that
wrong version of wapiti is used or tmp dir is not accessible.
Make sure to have wapiti 2.x as wapiti 1.x is not supported.
In short: check installation of wapiti and OpenVAS"

I tried symlinking wapiti.py to the following directories but this did not work:
/usr/local/bin
/usr/bin

Then I tried creating a small shellscript to run in $PATH:
Code:

#!/bin/sh
cd //usr/local/src/Wapiti/wapiti-2.2.1/src/
./wapiti.py $*

and adding this line to the end of ~/.profile
#run wapiti script
:/user/scripts/wapiti.sh

No luck with this unfortunately, any suggestions?

shayno90 03-19-2012 09:00 AM

According to this guide:
http://www.ict-romulus.eu/web/wapiti.../Users%20Guide

Examples

python wapiti.py http://server.com/base/url/ -o my_report_folder -f html
python wapiti.py http://server.com/base/url/ -v 2

This examples works if python executable is in the PATH environment variable and you are in the root directory of Wapiti. In other case you cannot execute the application like in the examples and you have to put all the path to Python executable.
For example:
Windows:

C:\Python25\python C:\Wapiti\wapiti.py http://server.com/base/url/ -o my_report_folder -f html

Linux:

/usr/bin/python /home/user/wapiti.py http://server.com/base/url/ -o my_report_folder -f html
---------------------------------------------------------------------------------------------------------------------
I will change the wapiti script to this:

Code:

#!/bin/sh
cd //usr/local/src/Wapiti/wapiti-2.2.1/src/
python wapiti.py $*

instead of
./wapiti.py

as when run in the command line it gave an error such as command not found.

I will launch a scan on Openvas to see if it can run the Wapiti scan.

shayno90 03-19-2012 11:43 AM

The Openvas scan still does not run script giving the same error:
"wapiti report filename is empty. that could mean that
wrong version of wapiti is used or tmp dir is not accessible.
Make sure to have wapiti 2.x as wapiti 1.x is not supported.
In short: check installation of wapiti and OpenVAS"

I testing the script command in the terminal and it runs.

I also increased the timeout for the Wapiti plugin to run to 900 seconds from the default and still no change.

I am running Wapiti 2.2.1 so need so more insight into resolving this.


All times are GMT -5. The time now is 03:33 PM.