<?xml version="1.0" encoding="ISO-8859-1"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xml:lang="en-US">
	<title>Jack Hacks</title>
	<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php" />
	<modified>2008-08-20T16:51:53Z</modified>
	<author>
		<name>Jack</name>
	</author>
	<copyright>Copyright 2008, Jack</copyright>
	<generator url="http://www.sourceforge.net/projects/sphpblog" version="0.4.8">SPHPBLOG</generator>
	<entry>
		<title>List user open sockets on cPanel server</title>
		<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php?entry=entry070317-004147" />
		<content type="text/html" mode="escaped"><![CDATA[As simple as this:<br /><b><br /><code><br />lsof -n -u^65534,^`cat /etc/passwd | awk -F&#039;:&#039; &#039;{if($3 &lt; 32000) print $3}&#039; | xargs | sed -e &#039;s/ /,\^/g&#039;` -i | awk &#039;{if ($2 ~ /[0-9]*/) print $3, $1}&#039; | sort | uniq -c | sort -n<br /></code><br /></b><br />The awk part is for excluding the system users ids &lt; 32000.]]></content>
		<id>http://notany.net/blog/index.php?entry=entry070317-004147</id>
		<issued>2007-03-16T00:00:00Z</issued>
		<modified>2007-03-16T00:00:00Z</modified>
	</entry>
	<entry>
		<title>How to extract SYN packets with tcpdump</title>
		<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php?entry=entry070221-233617" />
		<content type="text/html" mode="escaped"><![CDATA[<b>tcpdump</b><br /><b><code><br /># tcpdump -ne dst port 80 and &#039;tcp[13] &amp; 2 == 2&#039;<br /></code></b><br />This way effectively filtering only SYN packets on port 80.<br /><br /><b><code><br /># tcpdump -c 30000 -ne dst port 80 and &#039;tcp[13] &amp; 2 == 2&#039; | awk &#039;{print $11}&#039; | cut -d. -f1|sort | uniq -c | sort -n<br /></code></b><br />Dumping 30K packets,cutting the first octet from the IPs and sorting by number of packets originating from this A class net.<br /><br />A bit more complicated:<br /><b><code><br /># for i in `tcpdump -c 30000 -ne dst port 80 and &#039;tcp[13] &amp; 2 == 2&#039; | awk &#039;{print $11} | cut -d. -f1|sort | uniq -c | awk &#039;{if ($1 &gt; 4000) print $2}&#039;`; do \<br />      iptables -I INPUT -s $i.0.0.0/8 -j DROP; \<br />done<br /></code></b><br />Dumping 30K packets and if more than 4000 packets originate from the same A class net - block the net via iptables.]]></content>
		<id>http://notany.net/blog/index.php?entry=entry070221-233617</id>
		<issued>2007-02-21T00:00:00Z</issued>
		<modified>2007-02-21T00:00:00Z</modified>
	</entry>
	<entry>
		<title>WPA for Ubuntu</title>
		<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php?entry=entry070218-005903" />
		<content type="text/html" mode="escaped"><![CDATA[It is a bit tricky (took me almost two days :), but basically this is the procedure:<br /><br /><b>- configure your wireless card</b><br />(using ndiswrapper is described in another article)<br />in case your wifi card is identified as wlan0 add the following to <i>/etc/network/interfaces</i><br /><code><br />auto wlan0<br />iface wlan0 inet dhcp<br />pre-up wpa_supplicant -Bw -Dwext -iwlan0 -c/etc/wpa_supplicant.conf<br />post-down killall -q wpa_supplicant<br /></code><br /><br /><b>- install and configure <i>wpasupplicant</i></b><br /><code># apt-get install wpasupplicant</code><br /><br />create <i>/etc/wpa_supplicant.conf</i> with simular content <br /><code><br />network={<br />  ssid=&quot;testwlan&quot;<br />  psk=&quot;7cHBV294H_something_long_and complicate&quot;<br />  scan_ssid=1<br />  key_mgmt=WPA-PSK<br />  proto=WPA<br />  pairwise=CCMP TKIP<br />  group=CCMP TKIP<br />}<br /></code><br /><br />This would automatically engage/shutdown wpasupplicant on up/down of the wlan0 interface.<br />Works nice for me :)]]></content>
		<id>http://notany.net/blog/index.php?entry=entry070218-005903</id>
		<issued>2007-02-17T00:00:00Z</issued>
		<modified>2007-02-17T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Make BASH update your terminal window title after logon</title>
		<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php?entry=entry070218-004821" />
		<content type="text/html" mode="escaped"><![CDATA[<b>~/.bash_profile</b><br /><br />This code would do the trick:<br /><br /><pre><br />if [ &quot;$TERM&quot; = &quot;xterm&quot; ] ; then<br />    export PROMPT_COMMAND=&#039;echo -ne &quot;\033]0;${USER}@${HOSTNAME}\007&quot;&#039;<br />else<br />    unset PROMPT_COMMAND<br />fi<br /></pre><br /><br />After logon the terminal title would be updated in the form &#039;jack@server&#039; and after logout the old value will be restored.]]></content>
		<id>http://notany.net/blog/index.php?entry=entry070218-004821</id>
		<issued>2007-02-17T00:00:00Z</issued>
		<modified>2007-02-17T00:00:00Z</modified>
	</entry>
	<entry>
		<title>FreeBSD rc.firewall fix for blacklisted ip support</title>
		<link rel="alternate" type="text/html" href="http://notany.net/blog/index.php?entry=entry070218-002731" />
		<content type="text/html" mode="escaped"><![CDATA[<b>/etc/rc.firewall</b><br /><br />Add this code at the end of the set_loopback function:<br /><br /><pre><br />        if [ -f &quot;${banned_ips}&quot; ]; then<br />                for i in `cat ${banned_ips} | grep -vE &quot;^#&quot;`; do<br />                        echo ${fwcmd} add deny ip from ${i} to me<br />                done<br />        fi<br /></pre><br /><br />This expects a variable banned_ips to be defined in rc.conf and to point to a file containing list (one per line) of blacklisted IPs/NETs in the form:<br /><br /><pre><br />192.168.1.0/24<br />10.2.2.2<br /># This is a comment<br /></pre><br /><br />Firewall rules would be up on the next reboot or after running /etc/netstart. <br /><br />This is more a way to preserve blocked IPs/NETs across the reboots.]]></content>
		<id>http://notany.net/blog/index.php?entry=entry070218-002731</id>
		<issued>2007-02-17T00:00:00Z</issued>
		<modified>2007-02-17T00:00:00Z</modified>
	</entry>
</feed>

