Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: exit with non-zero code when problems are found #796

Closed
eheydrick opened this issue Apr 2, 2015 · 27 comments
Closed

Feature request: exit with non-zero code when problems are found #796

eheydrick opened this issue Apr 2, 2015 · 27 comments

Comments

@eheydrick
Copy link

Exiting with a non-zero code when problems are found would enable using wpscan to automate monitoring of wordpress security.

@erwanlr
Copy link
Member

erwanlr commented Apr 3, 2015

What's the command you were running and error output ?

It should exit with code 1 when an error occurs, 0 otherwise

@eheydrick
Copy link
Author

Just running wpscan --url whatever. I'd like a mode where it exits non-0 when a vulnerability is found and 0 when all is good.

@pvdl
Copy link
Contributor

pvdl commented Apr 13, 2015

@eheydrick
This is a work-around: wpscan.rb --url www.yourtarget.com --no-color | grep "[!]"

@eheydrick
Copy link
Author

that's basically what I ended up doing.

@firefart
Copy link
Contributor

will fix this now, should be easy

@firefart
Copy link
Contributor

@eheydrick can you please try the new implementation?

1 is returned on error
0 when no warning or critical message is printed
> 0 (=count of warning and critical messages) if smth was found

PS: currently investigating why 0 is always returned :(

firefart added a commit that referenced this issue May 12, 2015
@firefart
Copy link
Contributor

@eheydrick now it's fully working :)

@eheydrick
Copy link
Author

@firefart exit code is working great. 👍 Thanks!

@brandonsturgeon
Copy link

Curious then, how do you test if the code actually fails? Like errors out? How do you distinguish between a REAL error, and just there being a vulnerability?

@jopfre
Copy link

jopfre commented Jan 25, 2017

What code is returned if one warning/crit is found? The same as the code for an error? Also sometimes null is returned, does that mean anything?

@firefart
Copy link
Contributor

@jopfre for every critical or warning output the return code is increased by 1. So everything above 0 means something was found.

@jopfre
Copy link

jopfre commented Jan 26, 2017

@firefart Ok so what is the code for an error? null?

@firefart
Copy link
Contributor

@jopfre anything above 0

@jopfre
Copy link

jopfre commented Jan 26, 2017

@firefart but do you see what I mean.
0 is nothing found OR error.
1+ is the number of warnings.

Seems like it would be good to differentiate between nothing found and errors

Above you said:

1 is returned on error
0 when no warning or critical message is printed
0 (=count of warning and critical messages) if smth was found

@firefart
Copy link
Contributor

No. Everything warning+critical is > 0. So every error counts too.

0 is only returned when nothing was found

@brandonsturgeon
Copy link

@firefart I would like to know what happens when the application itself runs into an unrecoverable error. What is the return code then?

@firefart
Copy link
Contributor

@brandonsturgeon as said before: something greater than zero. There is no specific app error return code

@brandonsturgeon
Copy link

brandonsturgeon commented Jan 26, 2017

@firefart We were just talking about how these codes help with automation, but any good automation tool will have to check for failures in its tools. This seems to be a pretty big flaw in this regard.

@ethicalhack3r
Copy link
Contributor

ethicalhack3r commented Jan 26, 2017 via email

@brandonsturgeon
Copy link

brandonsturgeon commented Jan 26, 2017

I see the benefit to having a return code that is relevant to the results, but looking at return code conventions, this is a bit of an antipattern. The general rule is: 0 for success, 1 for error (and then >1 for specific error codes).

Here's a compromise, let me know what you think;

  • 0 for a successful run with no wpscan warnings/ wpscan errors (meaning vulnerabilities)
  • 1 for an application error
  • 2 for a successful run with wpscan warnings / wpscan errors found

And then we can even go a bit further and maybe say 2 is just for warnings found, 3 is when wpscan errors are found

@jopfre
Copy link

jopfre commented Jan 26, 2017

Yeah exactly what @brandonsturgeon is saying. When I was saying errors before I meant application errors. For example sometimes the scan is interrupted ([!] The target seems to be down) or I get ECONNRESET so I think these should return a different code to a successful run with or without discovered vulnerabilities.

0 for a successful run with no wpscan warnings/ wpscan errors (meaning vulnerabilities)
1 for an application error
2 for a successful run with wpscan warnings / wpscan errors found
And then we can even go a bit further and maybe say 2 is just for warnings found, 3 is when wpscan errors are found

Looks good to me.

@ethicalhack3r
Copy link
Contributor

ethicalhack3r commented Jan 26, 2017

I think the proposed exit codes make sense. This change may break backwards compatibility for users who have implemented the current logic. This would require a major version bump to warn users of the breaking change.

@erwanlr do you know if the above exit codes are the same as what is currently supported by wpsan v3? or does it do something else?

It may be worth leaving this as-is, and releasing the re-written v3 with the suggested exist codes.

@brandonsturgeon
Copy link

I agree, this would definitely be a breaking change (Some of my code included!). Is there somewhere we can write this down to make sure it "stays on the radar" ?

@erwanlr
Copy link
Member

erwanlr commented Jan 26, 2017

@ethicalhack3r
Copy link
Contributor

ethicalhack3r commented Jan 26, 2017 via email

@jopfre
Copy link

jopfre commented Jan 26, 2017

@ethicalhack3r ship it

@ethicalhack3r
Copy link
Contributor

Here you go chaps https://github.com/wpscanteam/wpscan-v3 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants