Skip to content

Instantly share code, notes, and snippets.

View nielsvanderbeke's full-sized avatar

Niels Vanderbeke nielsvanderbeke

View GitHub Profile
@nielsvanderbeke
nielsvanderbeke / Apache_Hardening.md
Created February 26, 2014 08:15
Security by obscurity APACHE

Problem

HTML comments can expose information about the system where the webpages run.

Solution 1

ExtFilterDefine strip_comments remove_comments mode=output \
	intype=text/html cmd="/bin/sed s/\<\!--.*--\>//g"
<LocationMatch /cgi-bin/wm*>

SetOutputFilter remove_comments

@nielsvanderbeke
nielsvanderbeke / count_java_threads
Created March 17, 2014 06:54
count threads all java processes
ps -eLF | awk '{ { print $1,$13,$14 } }' | grep java | grep -v grep| sort | uniq -c
==== ps ====
-e Select all processes. Identical to
-F extra full format. See the -f option, which -F implies.
-L Show threads, possibly with LWP and NLWP columns
==== uniq ====
-c, --count prefix lines by the number of occurrences
@nielsvanderbeke
nielsvanderbeke / httpd_carto.sh
Created March 17, 2014 08:43
script to get carto of all httpd installs on machine
#!/bin/ksh
echo "hostname;location;process owner;server version;server build;server mulde magic number;server loaded;comiled using;architecture;server MPM;threaded;forked;verbose compile info;modules"
http_bins=`ps -eaf | grep -v grep | grep httpd | awk '{ print $8 }' | sort | uniq`
for http_version in $http_bins ; do
http_build=`${http_version} -V`
http_owner=`ps -eaf | grep -v grep | grep ${http_version} | awk '{ print $1 }' | sort | uniq`
http_serverVersion=`echo -e "${http_build}" | grep "Server version" | awk '{ {print $3,$4} }'`
pattern="smtp"
for jar in /usr/share/java/*.jar; do
for file in $(unzip -l $jar | perl -nle 'split /\s+/ and print $_[-1];'); do
unzip -c $jar $file | grep -qi "$pattern" && (
rpm -qf $jar 2>&1 >/dev/null && \
rpm -qf $jar || \
echo "orphan jar: $jar"
);
done
done | sort -u
@nielsvanderbeke
nielsvanderbeke / weblogic SSL problem
Created April 22, 2014 09:40
weblogic SSL problem
http://www.ateam-oracle.com/improve-ssl-support-for-your-weblogic-domains/
/**
* Access Flukso API server returning a JSON
*
*/
function getJSON(sensor, token, query) {
var sheetname = "test";
//var aUrl = "http://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?version=1.0&token=d8a8ab8893ea73f768b66b45234b5c3a&interval=month&unit=watt";
var api="1.0";
var aUrl = "http://api.flukso.net/sensor/"+sensor+"?version="+api+"&token="+token+query;
Kill all running containers
docker kill $(docker ps -q)
Delete all stopped containers (including data-only containers)
docker rm $(docker ps -a -q)
Delete all ‘untagged/dangling’ (<none>) images
@nielsvanderbeke
nielsvanderbeke / wtfpl
Created February 25, 2015 08:41
Do What The Fuck You Want To Public License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@nielsvanderbeke
nielsvanderbeke / duplicate files
Last active December 24, 2015 21:19
Find duplicate files
# print them
find . -regex '.*([0-9])\..*'
# count them
find . -regex '.*([0-9])\..*' | wc -l
# delete them
find . -regex '.*([0-9])\..*' -delete
@nielsvanderbeke
nielsvanderbeke / crontab syntax
Created October 7, 2013 09:40
crontab syntax
string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".