Created
January 27, 2019 05:39
-
-
Save si9ma/8c82cf4aae775e2b982f43f9a1150680 to your computer and use it in GitHub Desktop.
httpdump base on tcpdump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# string to hex | |
str2hex () { | |
echo -n "$@" | xxd -p | |
} | |
# httpdump | |
hdump() { | |
filter_cmd='s/^E.*?(GET|PUT|POST|HEAD|PATCH|CONNECT|DELETE|TRACE|OPTIONS|HTTP)/\1/' | |
if [ "$1" = "-m" ];then | |
method="0x`str2hex $2`" | |
params="" | |
for item in "${@:3}" | |
do | |
params="$params $item" | |
done | |
sudo tcpdump -A -l -nn -s0 `echo $params` "tcp[((tcp[12:1] & 0xf0) >> 2):4] = $method" | perl -pe "$filter_cmd" | |
else | |
sudo tcpdump -A -l -nn -s0 $@ "(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)" | perl -pe "$filter_cmd" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment