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

Created on 3 Apr 2015  Â·  27Comments  Â·  Source: wpscanteam/wpscan

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

Most helpful comment

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

All 27 comments

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

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

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.

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

that's basically what I ended up doing.

will fix this now, should be easy

@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 :(

@eheydrick now it's fully working :)

@FireFart exit code is working great. :+1: Thanks!

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?

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?

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

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

@jopfre anything above 0

@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

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

0 is only returned when nothing was found

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

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

@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.

Pull requests welcome!

On 26 Jan 2017 4:48 p.m., "Brandon Sturgeon" notifications@github.com
wrote:

@FireFart https://github.com/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
terms of automation.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/wpscanteam/wpscan/issues/796#issuecomment-275423356,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATuKZ2lpI0QZ3I2nRGLpTzhJvkPmlSSks5rWMBggaJpZM4D5glg
.

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

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.

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.

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" ?

I think that looks like what was suggested more or less. Shall we just make
v3 public and start getting feedback from users?

On 26 Jan 2017 6:47 p.m., "erwanlr" notifications@github.com wrote:

Exit codes in v3 can be found there: https://github.com/wpscanteam/
CMSScanner/blob/master/lib/cms_scanner/exit_code.rb

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/wpscanteam/wpscan/issues/796#issuecomment-275458329,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATuKYwruPXNFlLpxK1NpErId62-7yERks5rWNw4gaJpZM4D5glg
.

@ethicalhack3r ship it

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digininja picture digininja  Â·  10Comments

erwanlr picture erwanlr  Â·  6Comments

jamezlee picture jamezlee  Â·  11Comments

sayjeyhi picture sayjeyhi  Â·  6Comments

thEpisode picture thEpisode  Â·  11Comments