offensive-security / exploitdb

The legacy Exploit Database repository - New repo located at https://gitlab.com/exploit-database/exploitdb
https://gitlab.com/exploit-database/exploitdb
GNU General Public License v2.0
7.73k stars 1.88k forks source link

searchsploit: JSON output produces extra double quotes #167

Closed kazkansouh closed 4 years ago

kazkansouh commented 4 years ago

I was just attempting to use jq to fine tune the results of a search and stumbled across a small issue. The output in the title and the author fields has double, double quotes. See output below (exploit was chosen at random, but issue appears to be present on all the ones I tried with):

$ searchsploit -j 55555 
{
        "SEARCH": "55555",
        "DB_PATH_EXPLOIT": "redacted",
        "RESULTS_EXPLOIT": [    ],
        "DB_PATH_SHELLCODE": "redacted",
        "RESULTS_SHELLCODE": [
                {"Title":"Linux/x86 - Reverse (127.1.1.1:55555/TCP) Shell + Null-Free Shellcode (72 bytes)"","EDB-ID":"43727","Date":"2013-01-01","Author":""Geyslan G. Bem"","Type":"shellcode","Platform":"linux_x86","Path":"redacted/shellcodes/linux_x86/43727.c"}
        ]
}

json_pp provides a clear error message when attempting to parse this:

$ searchsploit -j 55555 | json_pp 
, or } expected while parsing object/hash, at character offset 290 (before "","EDB-ID":"43727","...") at /usr/bin/json_pp line 45.

Issue was confirmed to be present in b1e1bfd7761c4e0682c743aa720d98d3c34f9ab8 (the current head).

g0tmi1k commented 4 years ago

I think this has been fixed in #166

srikwit commented 4 years ago

I think the bug is in the sed expression for SEARCH which gets passed into the later awk. The filter for removing quotes doesn't replace the quotes because of the double quotes get passed to the OUTPUT and ultimately to printresults

kazkansouh commented 4 years ago

Thanks. I've just given it a quick test and it appears fixed.

Checked at ccea007282bb78b727f593ce6b59c0e01075fdf2

g0tmi1k commented 4 years ago

V4.5.0 is out - should be fixed :)