This file contains 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
/* | |
simple usage of the tcpd/tcp wrapper API | |
a full-fledged program would probalby call hosts_access() upon accepting a new | |
connection and if denied it would close() | |
the established connection with FIN,ACK or most preferably RST | |
build with : | |
gcc -c tcpd_test.c |
This file contains 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
# capture SYN/ACK flagged packets | |
# tcp[13] is the byte location of TCP flags (URG,ACK,PSH,RST,SYN,FIN) | |
# | |
# mnemonic | |
# | |
# Unskilled 32 | |
# Attackers 16 | |
# Pester 8 | |
# Real 4 | |
# Security 2 |
This file contains 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
#!/bin/bash | |
# | |
# entry example | |
# | |
# (1579051) 10/16/2009 0:02:13 AM - (not logged in) (192.168.1.11)> USER chris | |
# | |
# sort -k1n fzs-2009-10-16.log | |
# does not work properly because when the session id and timestamp are the same | |
# it goes on and tries to sort based on the message |
This file contains 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
# multicast group 239.1.1.1 on port 4321 | |
# multicast listener/sink with read buffer of 512 bytes | |
iperf -s -u -B 239.1.1.1 -i 1 -l 512 -p 4321 | |
# multicast transmitter/source with write buffer of 512 bytes | |
# fill up bandwidth of 80Kb/s |
This file contains 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
# the argument must in a dot decimal ipv4 format | |
function is_valid_ipv4() { | |
if [ -z "$1" ]; then | |
return 0; | |
fi | |
IFS="." | |
local isvalid=1 | |
local bytectr=0 |
This file contains 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
# mycert.crt - certificate file | |
# mykey.key - private key file | |
openssl pkcs12 -export -in mycert.crt -inkey mykey.key -out env.p12 -password stdin |
This file contains 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
#!/bin/bash | |
# | |
# parses the time (in seconds) that elapsed between 2 consecutive entries | |
# each matching to pattern1 and pattern2. | |
# date format : [DDD] [MMM] [dd] [hh]:[mm]:[ss] [YYYY] | |
# example : Tue May 12 06:49:44 2009 | |
# | |
# substitute the patterns at will | |
# |
This file contains 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
# produces a patch between the files in the 2 dirs | |
# -c : special context for output | |
# -r : directory recursively | |
# -B : ignore blanks | |
diff -crB before_dir after_dir > foo.patch | |
# if you want to patch before_dir now |
This file contains 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
iptables -A INPUT -p icmp -m limit --limit 39.6/m --limit-burst 1 -j DROP | |
# it will cause 2 out of 3 icmp replies to fail when executing a ping like | |
# ping -c 3 -i 1 -w 3 10.10.10.10 | |
# | |
# we needed 1 out of 3 successful ping replies in, so that's 2/3 ~= 0.67 replies per second | |
# since we cannot use less than 0 values, we up the scale to the minute, so | |
# 0.67 * 60 = 39.6 replies in 1 minute :-) |
OlderNewer