Curl Dump Response Headers to STDOUT and Ignore Response Body

Tags: May 7, 2018 6:48 AM
0 comments

Goals

Return only HTTP response header when opening a web page using curl. This is useful when we are interested in processing response headers only.

Command

We will utilize /dev/stdout and /dev/null to achieve what we want.

$ curl https://notes.rioastamal.net -D /dev/stdout -o /dev/null --silent
HTTP/2 200
date: Sun, 06 May 2018 23:42:37 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=d6347d57f364b276150034b241b19cdb01525650157; expires=Mon, 06-May-19 23:42:37 GMT; path=/; domain=.rioastamal.net; HttpOnly
expires: Sun, 06 May 2018 23:42:37 GMT
cache-control: private, max-age=0
last-modified: Sun, 06 May 2018 23:42:05 GMT
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 416f4deb6f51a320-HKG

Reference

Share on Facebook Twitter

Generate Random String in Shell Using /dev/urandom

Tags: May 3, 2018 8:18 AM
0 comments

Goals

Generate random string in Shell and using /dev/urandom as the source. This random string typically useful to be used as encryption key.

Implementation

We will use combination of tr and head to generate 32 random characters. Command below will only output alphanumeric and some characters symbol only.

$ </dev/urandom tr -dc 'A-Za-z0-9!"#$%&()*+,-./:;<=>[email protected][\]^_`{|}~' | head -c 32 && echo
}s9s2c8W7aZlI:yg<{bg&-<7YnyJEk.u

On Mac OS X system you may need to define LC_ALL=C environment variable as shown below.

$ LC_ALL=C </dev/urandom tr -dc 'A-Za-z0-9!"#$%&()*+,-./:;<=>[email protected][\]^_`{|}~' | head -c 32 && echo
f(s_TPj*.H3Z/s[*:zLe[=9&0$FF"*8[

References

Share on Facebook Twitter