This was like 13 years ago, but it in essence rm -rvf / ... but it was a obfuscated one liner that some dick put out there as a joke. Result was having to restore a site and lose a few weeks of posts.
To run this with macOS, I had to use the GNU version of sed. I installed it with
$ brew install gnu-sed
And it is then called with 'gsed' instead of 'sed'.
As an avid Perl programmer, I had json_pp in my $PATH - for everyone else - it is here: https://metacpan.org/pod/JSON::PP You can install it with cpanm:
Improved version using jq.
This properly URL encodes the query parameter and uses a much simpler sed command.
Additionally the API returns UTF-8 encoded data when the user agent is specified.
Requires curl >= 7.18.0.
function c() {
url='https://www.google.com/complete/search?client=hp&hl=en&xhr=t'
# NB: user-agent must be specified to get back UTF-8 data!
curl -H 'user-agent: Mozilla/5.0' -sSG --data-urlencode "q=$*" "$url" |
jq -r .[1][][0] |
sed 's,,,g'
}
Example:
$ c ':)' ':('
) ( meaning
) ( emoticon
) ( ͡° ͜ʖ ͡°)
) ( emoticon meaning
Comments (85) 22 threads
Show all comments
Showing thread 2 of 22
There's a blog dedicated to shaming sites that do this: https://curlpipesh.tumblr.com/#_=_
Continue this thread — 8 replies
Continue this thread — 1 reply
To run this with macOS, I had to use the GNU version of sed. I installed it with
And it is then called with 'gsed' instead of 'sed'.As an avid Perl programmer, I had json_pp in my $PATH - for everyone else - it is here: https://metacpan.org/pod/JSON::PP
If you don't have cpanm, you can install it with The modified command line from above then becomes: Here is a little Bash function to encapsulate this: Which then allows you to use it like this: For spaces in your query, use a '+':You can install it with cpanm:
[0]: https://stedolan.github.io/jq/