slacktee icon indicating copy to clipboard operation
slacktee copied to clipboard

Color in ouput gives json error

Open marcelo321 opened this issue 3 years ago • 4 comments

When providing output from color to send to slack, slacktee gives a json error. I got this error when using a public tool called nuclei which gave a one line output of color, and when piping it to slacktee it gave this error:

slacktee.sh: {"ok":false,"error":"invalid_json"}

I guess this happens because of the color, since when removing it slacktee had no problems. Maybe add a condition to remove colorful output so it doesn't give this error? not sure

marcelo321 avatar Jun 25 '21 00:06 marcelo321

Thank you for the report, @marcelo321 ! If you don’t mind, could you share all of of the command line options you are using for sending the message? Also, if it’s possible, please share the sample of the input as well.

Chikashi-Kato avatar Jun 25 '21 05:06 Chikashi-Kato

Here an example:

~# echo "https://docs.zebra.com/" | nuclei -t /root/nuclei-templates/miscellaneous/dir-listing.yaml -tags misc -silent | slacktee.sh 
[2021-06-25 18:44:50] [dir-listing] [http] [info] https://docs.zebra.com/
slacktee.sh: {"ok":false,"error":"invalid_json"}

Editing it with vim:

[^[[36m2021-06-25 18:45:41^[[0m] [^[[92mdir-listing^[[0m] [^[[94mhttp^[[0m] [^[[34minfo^[[0m] https://docs.zebra.com/

marcelo321 avatar Jun 25 '21 18:06 marcelo321

Thank you so much for the detail! I see, it seems to be caused by escape sequences. Handling this case gracefully might not be easy but let me think about it.

Chikashi-Kato avatar Jul 01 '21 04:07 Chikashi-Kato

Any update regarding this..? some sed magic like this could do the work echo colorful | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g'

marcelo321 avatar Aug 19 '22 20:08 marcelo321