<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>AlbanianWizard</title> <atom:link href="http://albanianwizard.org/feed" rel="self" type="application/rss+xml" /><link>http://albanianwizard.org</link> <description>What you don&#039;t know, can&#039;t hurt you… it just leaves you stupid</description> <lastBuildDate>Sat, 28 Aug 2010 22:38:28 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>VLAN tutorial &#124; How VLAN Works &#8211; VLAN Configuration Linux</title><link>http://albanianwizard.org/vlan-tutorial-how-vlan-works-vlan-configuration-linux.albanianwizard</link> <comments>http://albanianwizard.org/vlan-tutorial-how-vlan-works-vlan-configuration-linux.albanianwizard#comments</comments> <pubDate>Sat, 28 Aug 2010 22:33:01 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[round robin NAT]]></category> <category><![CDATA[VLAN Configuration Linux]]></category> <category><![CDATA[VLAN How To]]></category> <category><![CDATA[VLAN Tutorial]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=92</guid> <description><![CDATA[VLAN Theory Before we understand what VLAN (Virtual Local Area Network) is we should understand what an LAN (Local Area Network) is. Here we have an LAN In this case, we have a router 192.168.0.1/24 and 3 switches that are physically separating our network, but at network configuration level they have all 192.168.0.x IP-s. A]]></description> <content:encoded><![CDATA[<h2>VLAN Theory</h2><p>Before we understand what <a title="what Virtual Local Area Network is">VLAN (Virtual Local Area Network) is</a> we should understand what an LAN (Local Area Network) is. Here we have an LAN</p><div><div><div><div id="attachment_99" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-99" title="Lan Diagram" src="http://albanianwizard.org/wp-content/uploads/2010/08/lan_diagram.png" alt="Lan Diagram" width="600" height="424" /><p class="wp-caption-text">Lan Diagram</p></div></div></div></div><p>In this case, we have a router 192.168.0.1/24 and 3 switches that are  physically separating our network, but at network configuration level  they have all 192.168.0.x IP-s. A <a title="Local Area Network">LAN</a> includes all systems in the broadcast domain. All of the network  components on a single LAN receive a broadcast sent by any member of  that LAN. By this definition, a LAN is bordered by routers or other  devices that operate at OSI Layer 3.  Any component of the LAN can communicate with any other component if the  machines personal firewalls allow to do so, but this is fine when we  are talking about small home networks, but when we are talking about big  networks many problems raise. For example, I have different employees and my enterprise network is  divided in different sectors:</p><p>a)Administration</p><p>b)Development</p><p>c)Marketing/Sales</p><p>d)Help Desk</p><p>e)Hotspot &#8211; Free Access<br /> and I don&#8217;t want that the Hotspot part of my network communicate with  Administration, or Development or any other portion of my network cause  of security. So the first <a title="LAN problem is security">problem is security.</a><br /> Another problem is maintenance of all of this switches , and the network  configuration and administration is difficult, lets think about an big  LAN /16 with many switches. You have to configure any hardware device,  when physically moving server computer to another location. Let&#8217;s say I want to move my radius server from the Help desk to  Administration, then I should physically move this server to the  administration RAK and re-configure with the administration network  settings. Performance as well raise as a problem.</p><p><strong>All of this problems are solved with VLAN</strong></p><p><a title="VLAN Tutorial">VLAN (Virtual Local Area Network) is</a> a group of hosts that  communicate as if they were attached to the same <a title="broadcast domain">broadcast domain</a>,  regardless of their physical location. VLAN offer the combination of different LAN&#8217;s network in to a single  physical device.<br /> You have to buy an switch with VLAN capabilities. A single <a title="VLAN Paper">VLAN-capable</a> switch is able to participate in multiple LANs at  once.</p><p>This functionality alone has a variety of uses, but VLANs become  far more interesting when combined with trunking. A trunk is a single  physical connection that can carry multiple VLANs. Each frame that  crosses the trunk has a VLAN identifier attached to it, so it can be  identified and kept within the correct VLAN.</p><p>Trunks can be used between two switches, between a switch and a  router or between a switch and a computer that supports trunking. When  connecting to a router or computer, each <a title="VLAN Configuration 3Com switch">VLAN</a> appears as a separate  virtual interface.</p><p>Cool ha? So this means, 1 switch (save allot of money) and different networks, the networks are:</p><ul><li>Physically connected but in the same time isolated from each other</li><li>They have different subnets and different locations</li><li>Administration is easy and centralized , if you have to move  now your radius server you have only to unplug the cable from VLAN 5 to  VLAN lets say 3</li><li>The networks share the same physical link without leakage of information between networks</li></ul><p><a title="How VLAN Works | VLAN How TO" name="How_VLAN_Works"></a></p><h2><a title="How VLAN Works">How VLAN Works</a></h2><p>VLAN uses IEEE 802.1Q IEEE standard a.k.a VLAN Tagging that in  reality doesn&#8217;t encapsulate or change the normal packet but it just add a  32-bit field between the source <a title="MAC Address">MAC address</a> and the EtherType/Length  fields of the original frame, this for including specific VLAN data as  the <a>VLAN ID</a>, TPID (Tag Protocol Identifier) etc.</p><p>So this is how the switch knows where to redirect the traffic, if  the traffic comes with VLAN ID x he will redirect this packets to the  virtual LAN X.</p><p>In order to correctly communicate the firewall /router must  &#8220;understand&#8221; the packets received from the switch and also send packets  that the switch &#8220;understands&#8221;. For this, our firewall supports VLAN and have vlan  software installed in order to generate VLAN traffic. The switch from his side is just recognising the traffic and redirecting  it but indeed this packets are generated by an interface like:</p><p>eth1.2 (eth1 vlan id 2)</p><p>or eth1.4 (eth1 vlan id 4&#8230; etc..</p><p><a name="VLAN_Configuration"></a></p><h2>VLAN Configuration</h2><ul><li>Switch Configuration</li></ul><p>so I have an <a title="3COM VLAN Configuration">3Com switch with VLAN support</a>, now I want to create 3  different VLAN-s with 3 different firewalls. I create a new VLAN and change the id to 5 (or whatever except 1 &#8211; is  reserved/default) now there are 3 type of switch port modality:</p><p>a) Tagged =&gt; Green</p><p>b) Untagged =&gt; Blue</p><p>c) Not a Member =&gt; White</p><p>Tagged means for the switch that hi will expect tagged packets on  that ports, so if the id is 5 the switch will expect packets with VLAN  ID 5 on the tagged port, and this is the port when we should attach the  firewall because the VLAN traffic is generated and handled by the  firewall.</p><p>Untagged means that from that port the firewall should expect  normal packets without VLAN ID, but if I set any port to Untaged this  port automatically becomes a member of VLAN 5, and when I connect the PC  the dhcp request is redirected to the first DHCP server available on  his LAN (in reality VLAN) and this is our firewall.</p><p>Not a Member means that this port is not a member of this VLAN  and the packet that pass through this port are not handled by VLAN 5.</p><ul><li> <a title="VLAN Linux / Firewall Configuration"> Firewall / Linux configuration</a></li></ul><p>Configuring VLANs under Linux is a process similar to configuring regular Ethernet interfaces. The main difference is you first must  attach each VLAN to a physical device. This is accomplished with the vconfig utility. If the trunk device itself is configured, it is treated as native. For example, these commands define VLANs 2-4 on device eth0:</p><pre>vconfig add eth0 2
vconfig add eth0 3 where 3 is vlan ID
</pre><p>So we use 1 switch instead of 3 <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br /> here a pic:</p><div id="attachment_101" class="wp-caption alignnone" style="width: 385px"><img class="size-full wp-image-101" title="VLAN_Configuration" src="http://albanianwizard.org/wp-content/uploads/2010/08/VLAN_Configuration.jpg" alt="VLAN_Configuration" width="375" height="263" /><p class="wp-caption-text">VLAN_Configuration</p></div> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/vlan-tutorial-how-vlan-works-vlan-configuration-linux.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>&#8220;Anti-Security&#8221; &#124; Save a Bug, Save a Life :)</title><link>http://albanianwizard.org/anti-security-save-a-bug-save-a-life.albanianwizard</link> <comments>http://albanianwizard.org/anti-security-save-a-bug-save-a-life.albanianwizard#comments</comments> <pubDate>Sun, 22 Aug 2010 11:52:53 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[antiSecurity]]></category> <category><![CDATA[antisecurity]]></category> <category><![CDATA[antisecurity movement]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=66</guid> <description><![CDATA[I could not start this category except with the old and wise anti.security.is home page statement and some Q&#38;A. This is what it was writ-ed once upon a time&#8230;. The purpose of this movement is to encourage a new policy of anti-disclosure among the computer and network security communities. The goal is not to ultimately]]></description> <content:encoded><![CDATA[<p>I could not start this category except with the old and wise anti.security.is home page statement and some Q&amp;A.</p><p>This is what it was writ-ed once upon a time&#8230;.</p><p>The purpose of this movement is to encourage a new policy of anti-disclosure among the computer and network security communities. The goal is not to ultimately discourage the publication of all security-related news and developments, but rather, to stop the disclosure of all unknown or non-public exploits and vulnerabilities. In essence, this would put a stop to the publication of all private materials that could allow script kiddies from compromising systems via unknown methods.</p><p>The open-source movement has been an invaluable tool in the computer world, and we are all indebted to it. Open-source is a wonderful concept which should and will exist forever, as educational, scientific, and end-user software should be free and available to everybody.</p><p>Exploits, on the other hand, do not fall into this broad category. Just like munitions, which span from cryptographic algorithms to hand guns to missiles, and may not be spread without the control of export restrictions, exploits should not be released to a mass public of millions of Internet users. A digital holocaust occurs each time an exploit appears on Bugtraq, and kids across the world download it and target unprepared system administrators. Quite frankly, the integrity of systems world wide will be ensured to a much greater extent when exploits are kept private, and not published.</p><p>A common misconception is that if groups or individuals keep exploits and security secrets to themselves, they will become the dominators of the &#8220;illegal scene&#8221;, as countless insecure systems will be solely at their mercy. This is far from the truth. Forums for information trade, such as Bugtraq, Packetstorm, www.hack.co.za, and vuln-dev have done much more to harm the underground and net than they have done to help them.</p><p>What casual browsers of these sites and mailing lists fail to realize is that some of the more prominent groups do not publish their findings immediately, but only as a last resort in the case that their code is leaked or has become obsolete. This is why production dates in header files often precede release dates by a matter of months or even years.</p><p>Another false conclusion by the same manner is that if these groups haven&#8217;t released anything in a matter of months, it must be because they haven&#8217;t found anything new. The regular reader must be made aware of these things.</p><p>We are not trying to discourage exploit development or source auditing. We are merely trying to stop the results of these efforts from seeing the light. Please join us if you would like to see a stop to the commercialization, media, and general abuse of infosec.</p><p>Thank you.</p><p><strong>Quoting from some Q&amp;A :</strong></p><table border="0" align="center"><tbody><tr><th align="left" valign="top"><span style="color: #bfbfbf;"><br /> <span> </span></span></th><th align="left" valign="top"> <em>(this is free-speach copyright, mean like i told that to you freely in personal/public talk, so you can do anything to it)</em><br /> <span style="color: red;">Q: </span>Why security is bad thing?<br /> <span style="color: red;">A: </span>In short &#8211; <em>hell is totally secure</em>. Do we want live in hell?.. If people follow security at first everywhere &#8211; probably we will still live in den.</p><p><span style="color: red;">Q: </span>What is nature of security?<br /> <span style="color: red;">A: </span>Nature of security is restriction,  destruction and antagonism to freedom. That thing is balance freedom.  Wrong is &#8211; in current situation &#8211; process of security &#8211; grow much faster  then freedom.  And that speed is not accident &#8211; that is artifically  stimulated by <em>technology of war</em>.  We are now stand on fork and choosing between totalitarism or freedom. And governemt always glad to help us choose first.</p><p><span style="color: red;">Q: </span>Technology of war in security? What do you mean?<br /> <span style="color: red;">A: </span>When <em>people</em> improve weapon to beat other <em>people</em>. Other people, of course, improving own weapon too. Keyword is &#8220;people vs. people&#8221;.</p><p><span style="color: red;">Q: </span>Who profits from the infosec war?<br /> <span style="color: red;">A: </span>Security companies do (this is their line of  employment). They need to use scare tactics to motivate more people and  companies into thinking their services are not only desirable, but  necessary. It&#8217;s simple Capitalism. These corporations make security  popular and fashionable, and turn it into a consumer pastime. Why can&#8217;t  they carry out their jobs with less glamour?</p><p><span style="color: red;">Q: </span>How do scriptkiddies help security?<br /> <span style="color: red;">A: </span>This is an easy answer. The term was coined  as a whip fashioned by various &#8220;security experts&#8221; with which to flog the  public. They show us depictions of these lawless, rabid, savage kids  who are out of control, so they can impress upon us the demographic from  which they defend us.</p><p><span style="color: red;">Q: </span>Can I sleep safely at night while Bugtraq is around?<br /> <span style="color: red;">A: </span>Absolutely not.</p><p><span style="color: red;">Q: </span>How does Bugtraq help security?<br /> <span style="color: red;">A: </span>Bugtraq serves as a front for an underground  cabal through which electronic weapons of mass destruction disseminate  amongst scriptkiddies. It is also an addictive substance which has  hooked admins trying to preserve their systems&#8217; security without getting  owned by the &#8220;early bird&#8221; defacer who grabs the exploit before their  local ISP has been notified of the vulnerability. However, even Bugtraq  publicizes a false concept of &#8220;full disclosure,&#8221; since information about  competitors or friends (like @stake) is tossed in the trash. Full  disclosure simply serves to sate the scriptkid&#8217;s addiction to power, and  this addiction is very hard to break. antiSecurity aims to help stop  that addiction.</p><p><span style="color: red;">Q: </span>What&#8217;s wrong with full disclosure?<br /> <span style="color: red;">A: </span>Full disclosure attempts to contradict the  saying &#8220;two wrongs don&#8217;t make a right&#8221; in the sense that it stimulates  criminal activities in order to catalyze security awareness. Take the  following example:<br /> An unrestricted maniac runs around the streets,  shooting people in the name of improving security because he aims to  increase the public use of bullet-proof vests. And who makes these  vests? After everybody is protected by vest v1, the public is  complacent, and sales of vest v2 must be stimulated by inventing a  shotgun which penetrates the first vest. There is competition in the  vest manufacturing business, so they all profit from the development of  higher powered munitions. Manufacturers get money, and also lobby for  pro-homicidal laws in other countries to spread the market, while  innocent people suffer at their expense. The cycle still doesn&#8217;t end  with vest v666, because a newer armor-piercing bullet is in the works.  How do you end the rat race? Stop full disclosure!</p><p><span style="color: red;">Q: </span>We should fix all bugs! How could it be otherwise?<br /> <span style="color: red;">A: </span>Imagine terrorist control nuclear bomb from  box on internet, and nobody can terminate bomb controlling process to  stop countdown. Or your house is absolutely secure but you lost key by  accident &#8211; how you will return in your own home? In real world security  is always limited &#8211; nobody make safe doors everywhere and lock them. In  case of emergency you will need access w/o keys. Absolute security is  nonsense. People forgot about that for computers and trying to reach  it..</p><p><span style="color: red;">Q: </span>Isn&#8217;t all hackers is a bad people?<br /> <span style="color: red;">A: </span>No! People are different, but probabilty of  bad person in 10 or in 1000000 is different&#8230; (hint about script-kids).  And i tell you if compare hard working person who know cost of own work  and idling kid or newbie &#8211; who will do shit very likely?</p><p><span style="color: red;">Q: </span>All admins are good/bad people?<br /> <span style="color: red;">A: </span>No! Think! So don&#8217;t attack EVERYBODY, and  don&#8217;t protect EVERYBODY! If you pretect bastards you are on bastard&#8217;s  side. Do you know BOFH admins are exists?</p><p><span style="color: red;">Q: </span>Why worry about security? Vulnerabilities will always exist and there is no absolute protection against them.<br /> <span style="color: red;">A: </span>Exactly correct. But if problem can&#8217;t  besolved in dumb way, this is don&#8217;t mean it is can&#8217;t be solved indirect.  This is why many of us have safeguarded ourselves with security  measures such as encrypted or steganographized filesystems in the case  that our sensitive information is accessed in an unauthorized manner.  Security will never be absolute, but technological developments will  continue to be made to push possible system security as close to  absolute system security as possible.</p><p>I can&#8217;t disallow people come to my computer, but I can make another  restriction so even if them come they can&#8217;t access data. I put encrypted  disk. Side efect is i need always enter password myself and id slower  disk operation.<br /> We can fight spam. But we can disable relaying email thru our system for unknown.<br /> Can&#8217;t stop DDOS attack but can make global tracking system over internet.<br /> We can&#8217;t restrict access for one, so we restrict for everybody. This is  cost of security. More and more progressive restrictions.<br /> <span style="color: red;">Q: </span>I just love finding bugs, though. What&#8217;s wrong with that?<br /> <span style="color: red;">A: </span>Air Force pilots loving flying planes, too. Sometimes they even find themselves flying missions over Hiroshima and Nagasaki.</p><p><span style="color: red;">Q: </span>What are &#8220;grayhats&#8221; and how are they different from whitehats and blackhats?<br /> <span style="color: red;">A: </span>Grayhats are indecisive people who consider  themselves to be neither blackhats nor whitehats, or both blackhat and  whitehat. However, being a grayhat, is not synonymous to existing in a  &#8220;healthy medium.&#8221; Rather, these individuals do not pledge allegiance to  either side of the controversy, and in not doing so, commit blunders  that hurt supporters of both viewpoints.</p><p><span style="color: red;">Q: </span>Is antiSecurity motivated in any part by personal profit?<br /> <span style="color: red;">A: </span>Can true freedom be reduced to the sole  notion of economy? What seems odd in all of this is that many of Bugtraq  and Packetstorm&#8217;s followers are aficionados of free, open-sourced  operating systems which have been provided as efficient and stable  alternatives to highly commercialized and unduly popular OS&#8217;es such as  Windows. But when it comes to security, they can&#8217;t understand that  measures they take towards &#8220;freeing information&#8221;, such as full  disclosure actually serves to fuel commercialism in the security market.  How can we bring this to popular attention?</p><p><span style="color: red;">Q: </span>Is antiSecurity trying to change the world? Isn&#8217;t that a bit radical?<br /> <span style="color: red;">A: </span>Everything is going to sound a bit ambitious  at first. But it&#8217;s got to start somewhere. So far, we have had  manifestos published on the net concerning the ethics of hacking,  defacement, and the definition of a &#8220;hacker&#8221;, but we have yet to see a  comprehensive document or set of documents that defines the parameters  of anti-disclosure policies. The discussion has, up until this point,  been an imbalanced one. Generally, disclosure is discussed on forums  such as Bugtraq, which obviously have a predominant pro-disclosure  following. Supporters of non-disclosure very rarely make similar  postings for obvious reasons: they avoid the glare of the public  limelight. The antiSecurity site is the perfect non-threatening  environment in which open intellectual discussion relevant to this topic  can take place. (So in answering the question, yes, we are <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><span style="color: red;">Q: </span>What does antiSecurity suggest we do about  people who siphon their reputations off the hard work and creativity of  others (ie Aleph1, route) ?<br /> <span style="color: red;">A: </span>This is probably the simplest answer of them  all: don&#8217;t support them. Don&#8217;t subscribe to their mailing lists, don&#8217;t  read their &#8216;zines, don&#8217;t use their software. Who said boycotts won&#8217;t  work on the Internet?</p><p><span style="color: red;">Q: </span>Is there anything I can do to help?<br /> <span style="color: red;">A: </span>Yes! We would greatly appreciate any  assistance. Please email any proposals or suggestions you might have,  including essays or rants to (mail-down).  Whatever happens, don&#8217;t post to Bugtraq! If you still can&#8217;t stop  yourself from doing this, try posting fake exploits and advisories, or  trojaned code <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Remember that anybody who consciously decides to fire a  loaded gun at somebody has already decided to accept the consequences.</p><p><span style="color: red;">Q: </span>Give me your root password, or i don&#8217;t believe you!<br /> <span style="color: red;">A: </span>Obviously, you have failed to either read or  comprehend any of the contents of this document. You might want to read  this FAQ again, but there&#8217;s a chance that won&#8217;t do you much good.</th></tr></tbody></table><p>End,</p><p>now the main concept of this movement, as you (I hope) understand is stop publishing exploit, this could be mis-understead as &#8220;don&#8217;t find exploits&#8221; but this is not the message.<br /> In deed finding exploits, help security, helps quality code writing and improve the technology.<br /> The problem is that with publishing this exploits and make them available online for all with an mini how-to DESTROY attached to the exploit we are just selling weapons of mass-destruction at the corner.</p><p>WHY? , lol I&#8217;m just asking my self when milw0rm whent down how many web-sites and servers where saved from the rutine defacement, and how many admins was saved?</p><p>Until the programmer are humans, in the code will be always a bug, trying to find them improve security and improve technology, publishing them helps destruction and help the Security Industry make his money.</p><p>PS, I&#8217;m not a hacker, I&#8217;m only interested in publishing this information so many people should understand what&#8217;s right and what&#8217;s wrong.<br /> What is in reality security and what is understood this days with &#8220;security&#8221;.</p> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/anti-security-save-a-bug-save-a-life.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to read Tcpdump Output &#124; Tcpdump Advanced Use</title><link>http://albanianwizard.org/how-to-read-tcpdump-output-tcpdump-advanced-use.albanianwizard</link> <comments>http://albanianwizard.org/how-to-read-tcpdump-output-tcpdump-advanced-use.albanianwizard#comments</comments> <pubDate>Fri, 20 Aug 2010 16:04:16 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[read tcpdump output]]></category> <category><![CDATA[tcpdump advanced]]></category> <category><![CDATA[tcpdump paper]]></category> <category><![CDATA[tcpdump reference]]></category> <category><![CDATA[Tcpdump tutorial]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=52</guid> <description><![CDATA[How to read Tcpdump Output Continuing our tcpdump series (read this if you are new here) we will present an easy to understand how to about reading tcpdump output and running advanced commands for and advanced tcpdump use. First we need a packet, I used from the command line hping, for sending just a SYN]]></description> <content:encoded><![CDATA[<p>How to read Tcpdump Output</p><p>Continuing our tcpdump series (read <a title="Tcpdump HOW-TO, the Linux Troubleshooter" href="http://albanianwizard.org/tcpdump-how-to-the-linux-troubleshooter.albanianwizard">this</a> if you are new here) we will present an easy to understand how to about reading tcpdump output and running advanced commands for and advanced tcpdump use.</p><p>First we need a packet, I used from the command line hping, for sending just a SYN packet to my web server, and here is the first packet hitting tcpdump.</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0000;">19</span><span style="color: #000066;">:</span><span style="color: #ff0000;">57</span><span style="color: #000066;">:</span><span style="color: #ff0000;">06.748557</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">33646</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">60</span><span style="color: #000066;">&#41;</span><br /> 192.168.1.4.33922 &amp;gt<span style="color: #000066;">;</span> 68.178.254.190.80<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>S<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0x83ae</span> &nbsp;<span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">4011514848</span>, win <span style="color: #ff0000;">5840</span>, options <span style="color: #000066;">&#91;</span>mss <span style="color: #ff0000;">1460</span>,sackOK,TS val &nbsp;<span style="color: #ff0000;">612494</span> ecr <span style="color: #ff0000;">0</span>,nop,wscale <span style="color: #ff0000;">6</span><span style="color: #000066;">&#93;</span>, length <span style="color: #ff0000;">0</span></div></td></tr></tbody></table></div><p><strong>19:57:06.748557</strong> this is the timestamp of the request, I made it on h 19, min 57, sec  06</p><p><strong>IP</strong> &#8211; this are all IP (protocol) related settings</p><p><strong>tos 0&#215;0</strong> =&gt; type of service field</p><p><strong>ttl 64 </strong>stands  for time to live and is =&gt; number of hops that the packet has to  reach its destination i.e throw how many routers the packets should  pass, this is for not living the packets travel the net for ever. After  64 hops the packet will &#8220;die&#8221;.</p><p><strong>id 33646</strong> this is the packet  ID, so in this case this is a SYN request, the reply will be an ACK if  the host is online and the packet ID will be the same.<br /> In a case of  hijacking , the attacker should be able to hack the packet ID and  present as a response a packet with the same ID but with malicious data.</p><p><strong>[DF]</strong> means don&#8217;t fragment, so the packet is entire and not fragmented [F]</p><p><strong>proto TCP</strong> is the protocol type it will be some times UDP and some times ICMP.</p><p><strong>length 60 </strong>length of the packet</p><p><em><strong>The mos important part of the packet:</strong></em></p><p><strong>192.168.1.4.33922 </strong>192.168.1.4 is the original IP and 33922 is the port used by the client</p><p><strong>&gt;</strong> (destination)</p><p><strong>68.178.254.190.80 </strong>the  destination is 68.178.254.190 (my poor shared server IP address) and  .80 is the port used to contact the web-server (apache).</p><p><strong>Flags [S] </strong>this is not anymore the IP flag, but is the TCP flag SYN , it could be <strong>[S.] </strong>in this case is an ack reply from the server, or it could be <strong>[R] </strong>wich means RESET, and in this case the connection is reset-ed, or could be <strong>[F]</strong> FIN for finalising a transfer etc, or <strong>[P] </strong>PUSH which means that the data should be transferred immediately,or URG.</p><p><strong>cksum 0x83ae (correct) </strong>this is the TCP-header check-sum of the packet (for checking packets integrity)</p><p><strong>seq 4011514848</strong> this is the TCP sequence number</p><p><strong>win 5840 </strong>the amount that I will send before requiring an ACK packet back from the server</p><p><strong>options [mss 1460,sackOK,TS val 612494 ecr 0,nop,wscale 6] </strong>just TCP options, don&#8217;t bother your self finding out the meaning</p><p><strong>length 0 </strong>this  is the length of the packet (hey wait a min, I&#8217;m seeing another length  just above) yes it&#8217;s true but it is the IP packet length and this is the  TCP (IP &#8211; encapsulated) length , so why is 0 ? Because we sent just a  SYN packet, and a SYN packet contain only the header of a TCP packet and  doesn&#8217;t contain any data.</p><p>Ok, the second packet received is an ACK reply from the web server:</p><p>20:04:53.213020 IP (tos 0&#215;0, ttl 26, id 48589, offset 0, flags [none], proto TCP (6), length 44)<br /> 68.178.254.190.80 &gt; 192.168.1.4.1158: Flags [S.], cksum 0xaaab (correct), seq 2217564751, ack 882823260, win 0, options [mss 1460], length 0</p><p>In this case it&#8217;s almost the same except the flag [S.] which means SYN . response =&gt; ack  and the generating IP this time is the server and the response is send to my local nat-ed IP.</p><h1>Tcpdump Advanced Use</h1><p><strong>First let&#8217;s rock with some protocols</strong></p><p><em>tcpdump protocol</em></p><p>protocol can be:<strong> <em>icmp, icmp6, igmp, igrp, pim, ah, esp, vrrp, udp, tcp, ip6, arp, rarp</em></strong><em><strong> </strong></em><br /> <strong>Note: </strong>filters can be applied only to protocols that support them, i.e we ca not use host filter when using arp as protocol because this filter need and IP to track (layer 3), and arp is an layer 2 protocol, so for arp there is no IP address, there is only MAC address.<br /> Check wikipedia if you don&#8217;t understand any of this protocols (you should understand at least tcp,udp,icmp,ipv6, arp if you are reading this how-to).<br /> We can also just:</p><pre>tcpdump -i br0 ip proto \\udp</pre><p>if we want to specify the protocol, so udp is part of IP like icmp and tcp so we can use proto \\ for specifying the protocol.</p><p>Another interesting use of tcpdump is monitoring vlan traffic, we can select packets by their VLAN ID i.e:</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump -i eth1 -vv vlan <span style="color: #ff0000;">3</span> -X<br /> tcpdump<span style="color: #000066;">:</span> <span style="color: #000080; font-weight: bold;">WARNING</span><span style="color: #000066;">:</span> eth1<span style="color: #000066;">:</span> no IPv4 address assigned<br /> tcpdump<span style="color: #000066;">:</span> listening <span style="color: #000080; font-weight: bold;">on</span> eth1, link-<span style="color: #000080; font-weight: bold;">type</span> EN10MB <span style="color: #000066;">&#40;</span>Ethernet<span style="color: #000066;">&#41;</span>, capture size <span style="color: #ff0000;">96</span> bytes<br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">44.698741</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">255</span>, id <span style="color: #ff0000;">7394</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">17</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">60</span><span style="color: #000066;">&#41;</span> 192.168.1.253.52811 &amp;gt<span style="color: #000066;">;</span> 192.168.1.15.domain<span style="color: #000066;">:</span> <span style="color: #000066;">&#91;</span>udp sum ok<span style="color: #000066;">&#93;</span> &nbsp;<span style="color: #ff0000;">3366</span>+ A? www.google.com. <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">32</span><span style="color: #000066;">&#41;</span><br /> <span style="color: #ff0000;">0x0000</span><span style="color: #000066;">:</span> &nbsp;0003 0800 <span style="color: #ff0000;">4500</span> 003c 1ce2 0000 ff11 1a72 &nbsp;....E..&amp;lt<span style="color: #000066;">;</span>.......r &nbsp; <span style="color: #ff0000;">0x0010</span><span style="color: #000066;">:</span> &nbsp;c0a8 01fd c0a8 010f ce4b 0035 0028 10f3 &nbsp;.........K.5.<span style="color: #000066;">&#40;</span>.. &nbsp;<span style="color: #ff0000;">0x0020</span><span style="color: #000066;">:</span> &nbsp;0d26 0100 0001 0000 0000 0000 0377 <span style="color: #ff0000;">7777</span> &nbsp;.&amp;amp<span style="color: #000066;">;</span>...........www &nbsp;<span style="color: #ff0000;">0x0030</span><span style="color: #000066;">:</span> &nbsp;0667 6f6f 676c <span style="color: #ff0000;">6503</span> 636f 6d00 0001 0001 &nbsp;.google.com..... <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">44.718772</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">0</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">17</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">232</span><span style="color: #000066;">&#41;</span> 192.168.1.15.domain &amp;gt<span style="color: #000066;">;</span> 192.168.1.253.52811<span style="color: #000066;">:</span> &nbsp;<span style="color: #ff0000;">3366</span> q<span style="color: #000066;">:</span> A? www.google.com. <span style="color: #ff0000;">2</span>/<span style="color: #ff0000;">4</span>/<span style="color: #ff0000;">4</span> www.google.com. CNAME<span style="color: #000066;">&#91;</span>|domain<span style="color: #000066;">&#93;</span><br /> <span style="color: #ff0000;">0x0000</span><span style="color: #000066;">:</span> &nbsp;0003 0800 <span style="color: #ff0000;">4500</span> 00e8 0000 <span style="color: #ff0000;">4000</span> <span style="color: #ff0000;">4011</span> b5a8 &nbsp;....E.....@.@...<br /> <span style="color: #ff0000;">0x0010</span><span style="color: #000066;">:</span> &nbsp;c0a8 010f c0a8 01fd 0035 ce4b 00d4 <span style="color: #ff0000;">4319</span> &nbsp;.........5.K..C.<br /> <span style="color: #ff0000;">0x0020</span><span style="color: #000066;">:</span> &nbsp;0d26 <span style="color: #ff0000;">8180</span> 0001 0002 0004 0004 0377 <span style="color: #ff0000;">7777</span> &nbsp;.&amp;amp<span style="color: #000066;">;</span>...........www<br /> <span style="color: #ff0000;">0x0030</span><span style="color: #000066;">:</span> &nbsp;0667 6f6f 676c <span style="color: #ff0000;">6503</span> 636f 6d00 0001 0001 &nbsp;.google.com.....<br /> <span style="color: #ff0000;">0x0040</span><span style="color: #000066;">:</span> &nbsp;c00c 0005 0001 0000 0000 0008 0377 <span style="color: #ff0000;">7777</span> &nbsp;.............www<br /> <span style="color: #ff0000;">0x0050</span><span style="color: #000066;">:</span> &nbsp;016c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .l<br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">44.719394</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">12187</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">1</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">84</span><span style="color: #000066;">&#41;</span> 192.168.1.253 &amp;gt<span style="color: #000066;">;</span> mil01s07-in-f104.1e100.net<span style="color: #000066;">:</span> icmp <span style="color: #ff0000;">64</span><span style="color: #000066;">:</span> echo request seq <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">0x0000</span><span style="color: #000066;">:</span> &nbsp;0003 0800 <span style="color: #ff0000;">4500</span> 0054 2f9b 0000 <span style="color: #ff0000;">4001</span> 55f2 &nbsp;....E..T/...@.U.<br /> <span style="color: #ff0000;">0x0010</span><span style="color: #000066;">:</span> &nbsp;c0a8 01fd 480e ea68 0800 cfcd 5e02 0000 &nbsp;....H..h....^...<br /> <span style="color: #ff0000;">0x0020</span><span style="color: #000066;">:</span> &nbsp;4c6e 9c98 000a f61b 0809 0a0b 0c0d 0e0f &nbsp;Ln..............<br /> <span style="color: #ff0000;">0x0030</span><span style="color: #000066;">:</span> &nbsp;<span style="color: #ff0000;">1011</span> <span style="color: #ff0000;">1213</span> <span style="color: #ff0000;">1415</span> <span style="color: #ff0000;">1617</span> <span style="color: #ff0000;">1819</span> 1a1b 1c1d 1e1f &nbsp;................<br /> <span style="color: #ff0000;">0x0040</span><span style="color: #000066;">:</span> &nbsp;<span style="color: #ff0000;">2021</span> <span style="color: #ff0000;">2223</span> <span style="color: #ff0000;">2425</span> <span style="color: #ff0000;">2627</span> <span style="color: #ff0000;">2829</span> 2a2b 2c2d 2e2f &nbsp;.!<span style="color: #7f007f;">&quot;#$%&amp;amp;'()*+,-./<br /> 0x0050: &nbsp;3031 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 01<br /> 17:17:44.721422 IP (tos 0x0, ttl &nbsp;54, id 15156, offset 0, flags [none], proto 1, length: 84) mil01s07-in-f104.1e100.net &amp;gt; 192.168.1.253: icmp 64: echo reply seq 0<br /> 0x0000: &nbsp;0003 0800 4500 0054 3b34 0000 3601 5459 &nbsp;....E..T;4..6.TY<br /> 0x0010: &nbsp;480e ea68 c0a8 01fd 0000 d7cd 5e02 0000 &nbsp;H..h........^...<br /> 0x0020: &nbsp;4c6e 9c98 000a f61b 0809 0a0b 0c0d 0e0f &nbsp;Ln..............<br /> 0x0030: &nbsp;1011 1213 1415 1617 1819 1a1b 1c1d 1e1f &nbsp;................<br /> 0x0040: &nbsp;2021 2223 2425 2627 2829 2a2b 2c2d 2e2f &nbsp;.!&quot;</span>#$<span style="color: #008000; font-style: italic;">%&amp;amp;'()*+,-./<br /> 0x0050: &nbsp;3031 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 01<br /> <br /> 4 packets captured<br /> 4 packets received by filter<br /> 0 packets dropped by kernel</span></div></td></tr></tbody></table></div><p>In this case, my firewall monitored an icmp request in hexadecimal from an host in VLAN.</p><p>We can monitor broadcast traffic as well <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><pre>tcpdump -i eth3 broadcast</pre><p>And we are able to see all packets broadcast to our network, or <strong>multicast</strong> if we want multicast.</p><p>Ok, now we want some TCP, on other tuts you will find unreadable 0þ@#þßøðj→ß  commands, here we are more human <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , this is easy to remember when you are in a real life situation:</p><pre>tcpdump -nnvv -i eth3 'tcp[tcp-syn] &amp; (tcp-syn)' != 0 and not port 22</pre><p>So what is this?<br /> I&#8217;m saying to tcpdump to monitor using tcp protocol only tcp-syn packets that are not 0 and I don&#8217;t want port 22 crap (I&#8217;m currently connected with ssh).</p><p>Lets detect a SYN scan now <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><pre>tcpdump -nnvv -i br0 'tcp[tcp-syn]  &amp; (tcp-syn)' != 0 and not port 22 and host 192.168.0.4</pre><p>Ok, I&#8217;m at 192.168.0.4 scanning with nmap, and here is the output on the scanned machine.</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.369468</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">0</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.1.80 &amp;gt<span style="color: #000066;">;</span> 192.168.0.4.39578<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">481284648</span><span style="color: #000066;">:</span><span style="color: #ff0000;">481284648</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> ack <span style="color: #ff0000;">749969547</span> win <span style="color: #ff0000;">5840</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.369790</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">38</span>, id <span style="color: #ff0000;">29797</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.4.39578 &amp;gt<span style="color: #000066;">;</span> 192.168.0.1.5900<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">749969546</span><span style="color: #000066;">:</span><span style="color: #ff0000;">749969546</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> win <span style="color: #ff0000;">3072</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.369910</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">39</span>, id <span style="color: #ff0000;">31675</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.4.39578 &amp;gt<span style="color: #000066;">;</span> 192.168.0.1.554<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">749969546</span><span style="color: #000066;">:</span><span style="color: #ff0000;">749969546</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> win <span style="color: #ff0000;">4096</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.372776</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">47</span>, id <span style="color: #ff0000;">29521</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.4.39578 &amp;gt<span style="color: #000066;">;</span> 192.168.0.1.993<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">749969546</span><span style="color: #000066;">:</span><span style="color: #ff0000;">749969546</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> win <span style="color: #ff0000;">4096</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.373049</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">50</span>, id <span style="color: #ff0000;">12150</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.4.39578 &amp;gt<span style="color: #000066;">;</span> 192.168.0.1.8080<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">749969546</span><span style="color: #000066;">:</span><span style="color: #ff0000;">749969546</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> win <span style="color: #ff0000;">3072</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.373245</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">0</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">40</span><span style="color: #000066;">&#41;</span> 192.168.0.1.8080 &amp;gt<span style="color: #000066;">;</span> 192.168.0.4.39578<span style="color: #000066;">:</span> R <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">0</span><span style="color: #000066;">:</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> ack <span style="color: #ff0000;">749969547</span> win <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">17</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">40.376608</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl &nbsp;<span style="color: #ff0000;">52</span>, id <span style="color: #ff0000;">8971</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto <span style="color: #ff0000;">6</span>, length<span style="color: #000066;">:</span> <span style="color: #ff0000;">44</span><span style="color: #000066;">&#41;</span> 192.168.0.4.39578 &amp;gt<span style="color: #000066;">;</span> 192.168.0.1.587<span style="color: #000066;">:</span> S <span style="color: #000066;">&#91;</span>tcp sum ok<span style="color: #000066;">&#93;</span> <span style="color: #ff0000;">749969546</span><span style="color: #000066;">:</span><span style="color: #ff0000;">749969546</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #000066;">&#41;</span> win <span style="color: #ff0000;">1024</span></div></td></tr></tbody></table></div><p>The &#8220;easy&#8221; way to detect port-scans is the src port, it is always the same as you can see in this situation nmap is using 3957.</p><h2>Monitoring ICMP-Traffic with tcpdump</h2><p><em>Ok, now I want to monitor ICMP traffic but I don&#8217;t want random icmp echo and I want to save this capture to a file. </em></p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump -vvi wlan0 -w icmp.cap <span style="color: #ff0000;">'icmp</span><span style="color: #000066;">&#91;</span>icmptype<span style="color: #000066;">&#93;</span> !<span style="color: #000066;">=</span> icmp-echo <span style="color: #000080; font-weight: bold;">and</span> icmp<span style="color: #000066;">&#91;</span>icmptype<span style="color: #000066;">&#93;</span> !<span style="color: #000066;">=</span> icmp-echoreply'<br /> tcpdump<span style="color: #000066;">:</span> listening <span style="color: #000080; font-weight: bold;">on</span> wlan0, link-<span style="color: #000080; font-weight: bold;">type</span> EN10MB <span style="color: #000066;">&#40;</span>Ethernet<span style="color: #000066;">&#41;</span>, capture size <span style="color: #ff0000;">65535</span> bytes<br /> Got <span style="color: #ff0000;">0</span></div></td></tr></tbody></table></div><p>So this is how we sniff icmp traffic, of course not just echo reply/requests.</p><p>Ok, but <strong>how to monitor only icmp echo traffic with tcpump</strong> ?</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump -vvi wlan0 -w icmp.cap icmp <span style="color: #000080; font-weight: bold;">and</span> &nbsp;<span style="color: #ff0000;">'icmp</span><span style="color: #000066;">&#91;</span>icmptype<span style="color: #000066;">&#93;</span> <span style="color: #000066;">==</span> icmp-echo || icmp<span style="color: #000066;">&#91;</span>icmptype<span style="color: #000066;">&#93;</span> <span style="color: #000066;">==</span> icmp-echoreply'</div></td></tr></tbody></table></div><p>Ok, in this case we have specified to capture only icmp-echo || (OR) icmp-echoreply packets. How about and?<br /> Is impossible that an icmp packet could be echo and echoreply at the same time, don&#8217;t you think <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ?</p><p>You should use the above examples with the following ICMP packet types.</p><p>Other ICMP types could be:</p><blockquote><p>icmp-echoreply, icmp-unreach,<br /> icmp-sourcequench, icmp-redirect, icmp-echo,<br /> icmp-routeradvert, icmp-routersolicit, icmp-<br /> timxceed, icmp-paramprob, icmp-tstamp, icmp-<br /> tstampreply, icmp-ireq, icmp-ireqreply,<br /> icmp-maskreq, icmp-maskreply.</p></blockquote><p>Ok, now I want to read what I captured before:</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump -vvAr icmp.cap<br /> reading from <span style="color: #000080; font-weight: bold;">file</span> icmp.cap, link-<span style="color: #000080; font-weight: bold;">type</span> EN10MB <span style="color: #000066;">&#40;</span>Ethernet<span style="color: #000066;">&#41;</span><br /> <span style="color: #ff0000;">11</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">47.244942</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">0</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto ICMP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">84</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.82 &amp;gt<span style="color: #000066;">;</span> p3slh045.shr.phx3.secureserver.net<span style="color: #000066;">:</span> ICMP echo request, id <span style="color: #ff0000;">15513</span>, seq <span style="color: #ff0000;">1</span>, length <span style="color: #ff0000;">64</span><br /> E..T..@.@.fl.z.RD......d&amp;lt<span style="color: #000066;">;</span>.....pL.....&nbsp; &nbsp; &nbsp;.................. !<span style="color: #7f007f;">&quot;#$%&amp;amp;'()*+,-./01234567 11:58:47.423368 IP (tos 0x0, ttl 44, id 42889, offset 0, flags [none], proto ICMP (1), length 84) &nbsp; &nbsp; p3slh045.shr.phx3.secureserver.net &amp;gt; 1.122.143.82: ICMP echo reply, id 15513, seq 1, length 64<br /> E..T....,...D....z.R...d&amp;lt;.....pL.....&nbsp; &nbsp; &nbsp;.................. !&quot;</span>#$<span style="color: #008000; font-style: italic;">%&amp;amp;'()*+,-./01234567 11:58:48.246803 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) &nbsp; &nbsp; 1.122.143.82 &amp;gt; p3slh045.shr.phx3.secureserver.net: ICMP echo request, id 15513, seq 2, length 64<br /> E..T..@.@.fl.z.RD......\&amp;lt;.....pL.....&nbsp; &nbsp; &nbsp;.................. !&quot;#$%</span>&amp;amp<span style="color: #000066;">;</span>'<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>*+,-./01234567 <span style="color: #ff0000;">11</span><span style="color: #000066;">:</span><span style="color: #ff0000;">58</span><span style="color: #000066;">:</span><span style="color: #ff0000;">48.426344</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">44</span>, id <span style="color: #ff0000;">42890</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto ICMP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">84</span><span style="color: #000066;">&#41;</span> &nbsp; &nbsp; p3slh045.shr.phx3.secureserver.net &amp;gt<span style="color: #000066;">;</span> 1.122.143.82<span style="color: #000066;">:</span> ICMP echo reply, id <span style="color: #ff0000;">15513</span>, seq <span style="color: #ff0000;">2</span>, length <span style="color: #ff0000;">64</span><br /> E..T....,...D....z.R...\&amp;lt<span style="color: #000066;">;</span>.....pL.....&nbsp; &nbsp; &nbsp;.................. !<span style="color: #7f007f;">&quot;#$%&amp;amp;'()*+,-./01234567 11:58:53.436798 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) &nbsp; &nbsp; 1.122.143.82 &amp;gt; p3slh045.shr.phx3.secureserver.net: ICMP echo request, id 15513, seq 3, length 64</span></div></td></tr></tbody></table></div><p>This is some nice output <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><em><strong>In this example you have learned also how to read and write with tcpdump.</strong></em></p><h2>Monitoring TCP-Traffic with Tcpdump</h2><pre>tcpdump -vv tcp and 'tcp[tcpflags] &amp; tcp-syn == tcp-syn' and 'tcp[tcpflags] &amp; tcp-ack == tcp-ack'
</pre><p>For monitoring TCP syn/ack packets only.<br /> So this is if we want to monitor only replies received from the Internet, it&#8217;s a good command to execute when we want to know with ho our host is communicating in that precise moment.</p><p><strong>What about monitoring only specific packet types with tcpdump?</strong></p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump -vv tcp <span style="color: #000080; font-weight: bold;">and</span> <span style="color: #ff0000;">'tcp</span><span style="color: #000066;">&#91;</span>tcpflags<span style="color: #000066;">&#93;</span> &amp;amp<span style="color: #000066;">;</span> tcp-fin <span style="color: #000066;">==</span> tcp-fin'<br /> <br /> tcpdump<span style="color: #000066;">:</span> listening <span style="color: #000080; font-weight: bold;">on</span> wlan0, link-<span style="color: #000080; font-weight: bold;">type</span> EN10MB <span style="color: #000066;">&#40;</span>Ethernet<span style="color: #000066;">&#41;</span>, capture size <span style="color: #ff0000;">65535</span> bytes<br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">31</span><span style="color: #000066;">:</span><span style="color: #ff0000;">53.682928</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">5985</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">52</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.82.54140 &amp;gt<span style="color: #000066;">;</span> mil01s07-in-f104.1e100.net.www<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>F.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0x5c10</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">4026359992</span>, ack <span style="color: #ff0000;">2774872111</span>, win <span style="color: #ff0000;">111</span>, options <span style="color: #000066;">&#91;</span>nop,nop,TS val <span style="color: #ff0000;">44332924</span> ecr <span style="color: #ff0000;">3098814989</span><span style="color: #000066;">&#93;</span>, length <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">31</span><span style="color: #000066;">:</span><span style="color: #ff0000;">53.689434</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">55</span>, id <span style="color: #ff0000;">61029</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">52</span><span style="color: #000066;">&#41;</span><br /> mil01s07-in-f104.1e100.net.www &amp;gt<span style="color: #000066;">;</span> 1.122.143.82.54140<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>F.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0x5c0e</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">1</span>, ack <span style="color: #ff0000;">1</span>, win <span style="color: #ff0000;">106</span>, options <span style="color: #000066;">&#91;</span>nop,nop,TS val <span style="color: #ff0000;">3098814995</span> ecr <span style="color: #ff0000;">44332924</span><span style="color: #000066;">&#93;</span>, length <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">31</span><span style="color: #000066;">:</span><span style="color: #ff0000;">57.184582</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">64</span>, id <span style="color: #ff0000;">8132</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>DF<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">52</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.82.54141 &amp;gt<span style="color: #000066;">;</span> mil01s07-in-f104.1e100.net.www<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>F.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0xd8af</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">4067714265</span>, ack <span style="color: #ff0000;">2940968668</span>, win <span style="color: #ff0000;">111</span>, options <span style="color: #000066;">&#91;</span>nop,nop,TS val <span style="color: #ff0000;">44333975</span> ecr <span style="color: #ff0000;">3100781064</span><span style="color: #000066;">&#93;</span>, length <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">31</span><span style="color: #000066;">:</span><span style="color: #ff0000;">57.194547</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">55</span>, id <span style="color: #ff0000;">37010</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">52</span><span style="color: #000066;">&#41;</span><br /> mil01s07-in-f104.1e100.net.www &amp;gt<span style="color: #000066;">;</span> 1.122.143.82.54141<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>F.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0xd8a4</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">1</span>, ack <span style="color: #ff0000;">1</span>, win <span style="color: #ff0000;">106</span>, options <span style="color: #000066;">&#91;</span>nop,nop,TS val <span style="color: #ff0000;">3100781079</span> ecr <span style="color: #ff0000;">44333975</span><span style="color: #000066;">&#93;</span>, length <span style="color: #ff0000;">0</span></div></td></tr></tbody></table></div><p>If you see, there are only FIN packets, and the following examples should be valid with this packet types also:<br /> <em>tcp-rst,<br /> tcp-push,<br /> tcp-urg<br /> </em></p><p><strong>Ok, how to detect an XMAS scan?</strong></p><p>An XMAS scan, is a port scan typo with flags set to Fin, Push &amp; Urg at the same packet.<br /> At least, this is what tcpdump says:</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcpdump<span style="color: #000066;">:</span> listening <span style="color: #000080; font-weight: bold;">on</span> wlan0, link-<span style="color: #000080; font-weight: bold;">type</span> EN10MB <span style="color: #000066;">&#40;</span>Ethernet<span style="color: #000066;">&#41;</span>, capture size <span style="color: #ff0000;">65535</span> bytes<br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">47</span><span style="color: #000066;">:</span><span style="color: #ff0000;">30.778407</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">47</span>, id <span style="color: #ff0000;">41535</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">40</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.82.53136 &amp;gt<span style="color: #000066;">;</span> 1.122.143.1.22<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>FPU<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0x77eb</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">2476122955</span>, win <span style="color: #ff0000;">4096</span>, urg <span style="color: #ff0000;">0</span>, length <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">12</span><span style="color: #000066;">:</span><span style="color: #ff0000;">47</span><span style="color: #000066;">:</span><span style="color: #ff0000;">30.789526</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">128</span>, id <span style="color: #ff0000;">60248</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">40</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.1.22 &amp;gt<span style="color: #000066;">;</span> 1.122.143.82.53136<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>R.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0x87ff</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">0</span>, ack <span style="color: #ff0000;">2476122956</span>, win <span style="color: #ff0000;">0</span>, length <span style="color: #ff0000;">0</span></div></td></tr></tbody></table></div><p>So the working tcpdump command should be:</p><pre>tcpdump -nnvvi wlan0 'tcp[tcpflags] &amp; (tcp-push &amp; tcp-fin &amp; tcp-urg) == (tcp-push &amp; tcp-fin &amp; tcp-urg)'</pre><p>And this is what tcpdump captured while I was XMAS-ing my router:</p><div class="codecolorer-container vhdl mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="vhdl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0000;">13</span><span style="color: #000066;">:</span><span style="color: #ff0000;">10</span><span style="color: #000066;">:</span><span style="color: #ff0000;">21.847432</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">39</span>, id <span style="color: #ff0000;">50647</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">40</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.82.52216 &amp;gt<span style="color: #000066;">;</span> 1.122.143.1.22<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>FPU<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0xce5b</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">2453623242</span>, win <span style="color: #ff0000;">4096</span>, urg <span style="color: #ff0000;">0</span>, length <span style="color: #ff0000;">0</span><br /> <span style="color: #ff0000;">13</span><span style="color: #000066;">:</span><span style="color: #ff0000;">10</span><span style="color: #000066;">:</span><span style="color: #ff0000;">21.850590</span> IP <span style="color: #000066;">&#40;</span>tos <span style="color: #ff0000;">0x0</span>, ttl <span style="color: #ff0000;">128</span>, id <span style="color: #ff0000;">60248</span>, offset <span style="color: #ff0000;">0</span>, flags <span style="color: #000066;">&#91;</span>none<span style="color: #000066;">&#93;</span>, proto TCP <span style="color: #000066;">&#40;</span><span style="color: #ff0000;">6</span><span style="color: #000066;">&#41;</span>, length <span style="color: #ff0000;">40</span><span style="color: #000066;">&#41;</span><br /> 1.122.143.1.22 &amp;gt<span style="color: #000066;">;</span> 1.122.143.82.52216<span style="color: #000066;">:</span> Flags <span style="color: #000066;">&#91;</span>R.<span style="color: #000066;">&#93;</span>, cksum <span style="color: #ff0000;">0xde6f</span> <span style="color: #000066;">&#40;</span>correct<span style="color: #000066;">&#41;</span>, seq <span style="color: #ff0000;">0</span>, ack <span style="color: #ff0000;">2453623243</span>, win <span style="color: #ff0000;">0</span>, length <span style="color: #ff0000;">0</span></div></td></tr></tbody></table></div><p>Ok, thank you for watching <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/how-to-read-tcpdump-output-tcpdump-advanced-use.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Open-Source HotSpot Anatomy &#8211; ChilliSpot, Radius and Postgres</title><link>http://albanianwizard.org/open-source-hotspot-anatomy-chillispot-radius-and-postgres.albanianwizard</link> <comments>http://albanianwizard.org/open-source-hotspot-anatomy-chillispot-radius-and-postgres.albanianwizard#comments</comments> <pubDate>Sat, 14 Aug 2010 09:14:34 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[AAA and NAS]]></category> <category><![CDATA[Chillispot and Freeradius]]></category> <category><![CDATA[Hotspot Diagram workflow]]></category> <category><![CDATA[How hotspots works]]></category> <category><![CDATA[Network Access Server]]></category> <category><![CDATA[Postgresql Freeradius]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=36</guid> <description><![CDATA[Preface This is the most comprehensive material that you fill find in the &#8220;!wild net!&#8221; , it will explain in theory how stuff works and how components fit with each-other. For a techical aproach and &#8220;how to make an hostpost&#8221; you must wait. HotSpot So what is an hotspot first? Most people know what this]]></description> <content:encoded><![CDATA[<h2>Preface</h2><p>This is the most comprehensive material that you fill find in the &#8220;!wild  net!&#8221; , it will explain in theory how stuff works and how components  fit with each-other.<br /> For a techical aproach and &#8220;how to make an hostpost&#8221; you must wait.</p><h2>HotSpot</h2><p>So what is an hotspot first?<br /> Most people know what this is , but for the people that don&#8217;t know I will give a simple answer.<br /> If you go to an airport or an hotel you find the &#8220;free access point&#8221;, you connect to it and you think that now you gona surf the web free of charge.<br /> Well, then you open your browser and an redirect gives you an login/password page with option to buy traffic and access.</p><p>This is a hotspot <img src='http://albanianwizard.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    [ :/ ]</p><p>A normal open-source Hotspot is made of 3 components:</p><ul><li>ChilliSpot (acting as NAS) [Network Access Server]</li><li>FreeRadius (acting as AAA) [An AAA Server is a server or  servers that provide authentication, authorization and accounting  services.]</li><li>Postgressql (responsible for the Accounts data)</li></ul><h2>NAS / ChilliSpot</h2><p>NAS stands for Network Access Server. The term network access server refer to a server devoted entirely to  managing network access, ChilliSpot is meant to act as a gateway to  guard access to a protected network. So, ChilliSpot is the initial entry point to the network, it is the  first &#8220;device&#8221; in the network to provide services to an end user. After the client is connected ChilliSpot redirect the user on the  authentication page requesting Username &amp; Password credentials, and  acts as a gateway for all further services. Typical Chillispot Operation Sequence:</p><ul><li> Call arrival on tcp        0      0 192.168.10.15:3990          0.0.0.0:*                   LISTEN</li><li> Prompt for username and password</li><li> Request authentication from AAA server</li><li> Confirm authentication information with AAA server</li><li> If the authentication is OK, proceed to service.</li></ul><p>AAA is responsible for handling :</p><ul><li> User authentication (first A)</li><li> User authorization (second A)</li><li> Accounting (last A)</li></ul><p>What AAA do?</p><p>Freeradius provides:</p><ul><li>authentication services; checks passwords  (static or dynamic)</li><li>provides authorization information to Chillispot</li></ul><p>The process of providing a service leads to requests for additional  information like date based, time based, variable cost debits ,etc and  this requires real-time enforcement session accounting information is  tallied by the Chillispot and reported to Freeradius.</p><p>All communications regarding RADIUS accounting are done with an  Accounting-Request packet.  Chillispot that is participating in the RADIUS accounting process will  generate an Accounting Start packet, which is a specific kind of  Accounting-Request packet. This packet includes information on which service has been provisioned  and on the user for which these services are provided. The packet is sent to the RADIUS accounting server, which will then  acknowledge receipt of the data. When the client is finished with the  network services, it will send to the accounting server an Accounting  Stop packet (again, a specialized Accounting-Request packet), which will  include the service delivered; usage statistics such as time elapsed,  amount transferred, average speed; and other details. The accounting  server acknowledges receipt of the stop packet, and all is well.</p><ul><li><strong>Packet Types</strong></li></ul><p><strong>Access-Request</strong></p><p>The Access-Request packet is used by the service consumer when it is  requesting a particular service from a network. The client sends a  Request packet to the RADIUS server with a list of the requested  services</p><p><strong>Access-Accept</strong></p><p>Packets sent by the RADIUS server to the client to acknowledge that the client&#8217;s request is granted. <strong></strong></p><p><strong>Access-Reject</strong></p><p>The RADIUS server is required to send an Access-Reject packet back to  the client if it must deny any of the services requested in the  Access-Request packet.</p><p><strong>Access-Challenge</strong></p><p>If a server receives conflicting information from a user, requires more  information, or simply wishes to decrease the risk of a fraudulent  authentication, it can issue an Access-Challenge packet to the client.  The client, upon receipt of the Access-Challenge packet, must then issue  a new Access-Request with the appropriate information included.</p><p><strong>Accounting-Request</strong></p><p>Accounting-Request packets are sent from the client to the server.  When the server receives this request packet, it is required to transmit  an acknowledgment to the client unless it cannot handle or process the  packet.</p><p><strong>Accounting-Response</strong></p><p>The Accounting-Response packets are primarily designed as acknowledgment  packets to be sent from the accounting server to the client, indicating  that the request from the client has been received and logged.</p><ul><li><strong>Packet Attributes</strong></li></ul><p>This 2 general packets, have many attributes (currently RADIUS can  specify 92 different attributes) , able to control the connections made  by the clients, here we can find some of them:</p><ul><li>User-Name</li></ul><p>This attribute carries the distinguished name of the client requesting access to services on the network</p><ul><li>User-Password</li></ul><p>This attribute is designed to carry authentication information that a  user provides in order to gain access to network services. Primarily,  the content of this value will be an encrypted password, but sometimes  it can be the response from an Access-Challenge packet sent to the  client from the RADIUS server.</p><ul><li>Chap password</li></ul><p>CHAP-Password indicates to the RADIUS client gear that CHAP, instead of PAP, is going to be used for the transaction.</p><ul><li>Session-Timeout</li></ul><p>It indicates the maximum length of time in seconds that a user may  remain connected to the network before the RADIUS client will kick him  off.</p><ul><li>Acct-Status-Type</li></ul><p>This attribute indicates whether the Accounting-Request packet is  being sent upon the user first authenticating and connecting to the  network or upon the user finishing use of the services and  disconnecting.</p><ul><li>Idle-Timeout</li></ul><p>The user is logged out after this amount of time of inactivity (no traffic).</p><ul><li>NAS-IP-Address</li></ul><p>This attribute specifies the IP address of the NAS gear that requests service on behalf of the client computer.</p><ul><li>Terminate-Action</li></ul><p>This is the SIG-Term of Radius, it means that the client should be disconnected.</p><ul><li>Acct-Session-ID</li></ul><p>This attribute is used to uniquely identify a session so that  accounting stop and start records can be collated and recorded  accurately.</p><ul><li>Acct-Authentic</li></ul><p>This optional attribute indicates the method with which the user&#8217;s declared identity was verified.</p><ul><li>Acct-Session-Time</li></ul><p>This attribute, found in Accounting-Request packets and interim  records, indicates the time in seconds that a user has been connected.</p><ul><li>Acct-Terminate-Cause indicates the reason, if possible and applicable, that a user&#8217;s session was ended</li></ul><h2>PostgreSql</h2><p>Responsible for data management.<br /> Here is the place where data is stored end this is the end point of the data.</p><p>Here we go , let&#8217;s see our database.</p><pre>su - postgres
</pre><pre> psql radius
</pre><pre>radius=# \l
       List of databases
  Name    |  Owner   | Encoding
-----------+----------+----------
postgres  | postgres | UTF8
radius    | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
</pre><pre>                      List of relations
Schema |               Name               |   Type   | Owner
--------+----------------------------------+----------+--------
public | hotspot_account                  | table    | radius
public | hotspot_account_generator        | table    | radius
public | hotspot_account_generator_id_seq | sequence | radius
public | hotspot_account_id_seq           | sequence | radius
public | hotspot_db_version               | table    | radius
public | hotspot_db_version_id_seq        | sequence | radius
public | hotspot_rate                     | table    | radius
public | hotspot_rate_id_seq              | sequence | radius
public | hotspot_setting                  | table    | radius
public | hotspot_setting_id_seq           | sequence | radius
public | hotspot_ticket                   | table    | radius
public | hotspot_ticket_accounting        | table    | radius
public | hotspot_ticket_accounting_id_seq | sequence | radius
public | hotspot_ticket_id_seq            | sequence | radius
public | nas                              | table    | radius
public | radacct                          | table    | radius
public | radacct_radacctid_seq            | sequence | radius
public | radcheck                         | table    | radius
public | radcheck_id_seq                  | sequence | radius
public | radgroupcheck                    | table    | radius
public | radgroupcheck_id_seq             | sequence | radius
public | radgroupreply                    | table    | radius
public | radgroupreply_id_seq             | sequence | radius
public | radpostauth                      | table    | radius
public | radpostauth_id_seq               | sequence | radius
public | radreply                         | table    | radius
public | radreply_id_seq                  | sequence | radius
public | realmgroup                       | table    | radius
public | realmgroup_id_seq                | sequence | radius
public | realms                           | table    | radius
public | realms_id_seq                    | sequence | radius
public | usergroup                        | table    | radius
public | usergroup_id_seq                 | sequence | radius
(33 rows)
</pre><pre>radius-# \c postgres
You are now connected to database "postgres".
postgres-# \d
No relations found.
</pre><h2>Work Flow Diagram</h2><p><a title="Hotspot Diagram - Chillispot Freeradius and postgresql" rel="parent" href="http://albanianwizard.org/wp-content/uploads/2010/08/Hotspot1.jpg"></a><a href="http://albanianwizard.org/wp-content/uploads/2010/08/Hotspot2.jpg"><img class="alignnone size-full wp-image-42" title="Hotspot Workflow Diagram" src="http://albanianwizard.org/wp-content/uploads/2010/08/Hotspot2.jpg" alt="Right click - View Image for full view" width="1399" height="724" /></a></p> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/open-source-hotspot-anatomy-chillispot-radius-and-postgres.albanianwizard/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Ubuntu 10.04 Lucid Lynx ldap configuration &#8211; the working how-to</title><link>http://albanianwizard.org/ubuntu-10-0-4-lucid-lynx-ldap-configuration-the-working-how-to.albanianwizard</link> <comments>http://albanianwizard.org/ubuntu-10-0-4-lucid-lynx-ldap-configuration-the-working-how-to.albanianwizard#comments</comments> <pubDate>Wed, 11 Aug 2010 12:04:47 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[10.04 ubuntu ldap working how-to]]></category> <category><![CDATA[ldap configuration linux]]></category> <category><![CDATA[openldap ubuntu 10.04 configuration]]></category> <category><![CDATA[the working how to openldap configuration]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=30</guid> <description><![CDATA[Hi there, Here at work I use Ubuntu 10.04 lts, and I was trying to configure openldap. Yes, on the internet are many how-to&#8217;s but half write-d and not really tested, but the most important is that none of them seems to really work. I have reed about the argument online (ubuntu doc&#8217;s to &#8211;]]></description> <content:encoded><![CDATA[<p>Hi there,</p><p>Here at work I use Ubuntu 10.04 lts, and I was trying to configure openldap.<br /> Yes, on the internet are many how-to&#8217;s but half write-d and not really tested, but the most important is that none of them seems to really work.<br /> I have reed about the argument online (ubuntu doc&#8217;s to &#8211; not working), and from many how to&#8217;s and now here is the final script for the ldap Ubuntu configuration:</p><p>First install with :<br /> <em>#apt-get install slapd ldap-utils</em><br /> Then create a script ie (touch script.sh) and put the following in.</p><div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br /> <span style="color: #007800;">passwd</span>=pleaseeditme<br /> <span style="color: #007800;">dc1</span>=pleaseeditme<br /> <span style="color: #007800;">dc2</span>=pleaseeditme<br /> <span style="color: #007800;">hash_pw</span>=<span style="color: #000000; font-weight: bold;">`</span>slappasswd <span style="color: #660033;">-s</span> <span style="color: #007800;">$passwd</span><span style="color: #000000; font-weight: bold;">`</span><br /> <span style="color: #007800;">tmpdir</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<br /> <span style="color: #666666; font-style: italic;">#--------------------------------------------------------------#</span><br /> ldapadd <span style="color: #660033;">-Y</span> EXTERNAL <span style="color: #660033;">-H</span> ldapi:<span style="color: #000000; font-weight: bold;">///</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ldap<span style="color: #000000; font-weight: bold;">/</span>schema<span style="color: #000000; font-weight: bold;">/</span>cosine.ldif<br /> ldapadd <span style="color: #660033;">-Y</span> EXTERNAL <span style="color: #660033;">-H</span> ldapi:<span style="color: #000000; font-weight: bold;">///</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ldap<span style="color: #000000; font-weight: bold;">/</span>schema<span style="color: #000000; font-weight: bold;">/</span>inetorgperson.ldif<br /> ldapadd <span style="color: #660033;">-Y</span> EXTERNAL <span style="color: #660033;">-H</span> ldapi:<span style="color: #000000; font-weight: bold;">///</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ldap<span style="color: #000000; font-weight: bold;">/</span>schema<span style="color: #000000; font-weight: bold;">/</span>nis.ldif<br /> ldapadd <span style="color: #660033;">-Y</span> EXTERNAL <span style="color: #660033;">-H</span> ldapi:<span style="color: #000000; font-weight: bold;">///</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ldap<span style="color: #000000; font-weight: bold;">/</span>schema<span style="color: #000000; font-weight: bold;">/</span>misc.ldif<br /> <span style="color: #666666; font-style: italic;">#——————————————————————-#</span><br /> <span style="color: #666666; font-style: italic;"># database.ldif</span><br /> <span style="color: #666666; font-style: italic;">#——————————————————————-#</span><br /> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>EOF <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>database.ldif<br /> <span style="color: #666666; font-style: italic;"># Load dynamic backend modules</span><br /> dn: <span style="color: #007800;">cn</span>=module<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>,<span style="color: #007800;">cn</span>=config<br /> objectClass: olcModuleList<br /> cn: module<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><br /> olcModulePath: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ldap<br /> olcModuleLoad: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>back_hdb<br /> <br /> <span style="color: #666666; font-style: italic;"># Create directory database</span><br /> dn: <span style="color: #007800;">olcDatabase</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>hdb,<span style="color: #007800;">cn</span>=config<br /> objectClass: olcDatabaseConfig<br /> objectClass: olcHdbConfig<br /> olcDatabase: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>hdb<br /> olcDbDirectory: <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ldap<br /> olcSuffix: <span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> olcRootDN: <span style="color: #007800;">cn</span>=admin,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> olcRootPW: <span style="color: #007800;">$hash_pw</span><br /> olcAccess: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>to <span style="color: #007800;">attrs</span>=userPassword,shadowLastChange by <span style="color: #007800;">dn</span>=<span style="color: #ff0000;">&quot;cn=admin,dc=<span style="color: #007800;">$dc1</span>,dc=<span style="color: #007800;">$dc2</span>&quot;</span> <span style="color: #c20cb9; font-weight: bold;">write</span> by anonymous auth by self <span style="color: #c20cb9; font-weight: bold;">write</span> by <span style="color: #000000; font-weight: bold;">*</span> none<br /> olcAccess: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>to dn.base=<span style="color: #ff0000;">&quot;&quot;</span> by <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #c20cb9; font-weight: bold;">read</span><br /> olcAccess: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>to <span style="color: #000000; font-weight: bold;">*</span> by <span style="color: #007800;">dn</span>=<span style="color: #ff0000;">&quot;cn=admin,dc=<span style="color: #007800;">$dc1</span>,dc=<span style="color: #007800;">$dc2</span>&quot;</span> <span style="color: #c20cb9; font-weight: bold;">write</span> by <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #c20cb9; font-weight: bold;">read</span><br /> olcLastMod: TRUE<br /> olcDbCheckpoint: <span style="color: #000000;">512</span> <span style="color: #000000;">30</span><br /> olcDbConfig: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>set_cachesize <span style="color: #000000;">0</span> <span style="color: #000000;">2097152</span> <span style="color: #000000;">0</span><br /> olcDbConfig: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>set_lk_max_objects <span style="color: #000000;">1500</span><br /> olcDbConfig: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>set_lk_max_locks <span style="color: #000000;">1500</span><br /> olcDbConfig: <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>set_lk_max_lockers <span style="color: #000000;">1500</span><br /> olcDbIndex: uid pres,eq<br /> olcDbIndex: cn,sn,mail pres,eq,approx,sub<br /> olcDbIndex: objectClass eq<br /> <span style="color: #666666; font-style: italic;">################################</span><br /> <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;Modifications</span><br /> <span style="color: #666666; font-style: italic;">################################</span><br /> <br /> dn: <span style="color: #007800;">cn</span>=config<br /> changetype: modify<br /> <br /> dn: <span style="color: #007800;">olcDatabase</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span>-<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>frontend,<span style="color: #007800;">cn</span>=config<br /> changetype: modify<br /> delete: olcAccess<br /> <br /> dn: <span style="color: #007800;">olcDatabase</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>config,<span style="color: #007800;">cn</span>=config<br /> changetype: modify<br /> add: olcRootDN<br /> olcRootDN: <span style="color: #007800;">cn</span>=admin,<span style="color: #007800;">cn</span>=config<br /> <br /> dn: <span style="color: #007800;">olcDatabase</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>config,<span style="color: #007800;">cn</span>=config<br /> changetype: modify<br /> add: olcRootPW<br /> olcRootPW: <span style="color: #007800;">$hash_pw</span><br /> <br /> dn: <span style="color: #007800;">olcDatabase</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>config,<span style="color: #007800;">cn</span>=config<br /> changetype: modify<br /> delete: olcAccess<br /> EOF<br /> <span style="color: #c20cb9; font-weight: bold;">sudo</span> ldapadd <span style="color: #660033;">-Y</span> EXTERNAL <span style="color: #660033;">-H</span> ldapi:<span style="color: #000000; font-weight: bold;">///</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>database.ldif<br /> <span style="color: #666666; font-style: italic;">####################################</span><br /> <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; Mini DIT</span><br /> <span style="color: #666666; font-style: italic;">####################################</span><br /> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>EOF<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>dit.ldif<br /> <span style="color: #666666; font-style: italic;"># Tree root</span><br /> <br /> dn: <span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> objectClass: dcObject<br /> objectclass: organization<br /> o: <span style="color: #007800;">$dc1</span>.<span style="color: #007800;">$dc2</span><br /> <span style="color: #c20cb9; font-weight: bold;">dc</span>: <span style="color: #007800;">$dc1</span><br /> description: Tree root<br /> <br /> <span style="color: #666666; font-style: italic;"># Populating</span><br /> dn: <span style="color: #007800;">cn</span>=admin,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> objectClass: simpleSecurityObject<br /> objectClass: organizationalRole<br /> cn: admin<br /> userPassword: <span style="color: #007800;">$hash_pw</span><br /> description: LDAP administrator<br /> <br /> dn: <span style="color: #007800;">cn</span>=aw,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> objectClass: simpleSecurityObject<br /> objectClass: organizationalRole<br /> cn: aw<br /> userPassword: <span style="color: #007800;">$hash_pw</span><br /> description: LDAP aw<br /> <br /> dn: <span style="color: #007800;">ou</span>=people,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> ou: people<br /> objectClass: organizationalUnit<br /> objectClass: top<br /> <br /> dn: <span style="color: #007800;">ou</span>=<span style="color: #c20cb9; font-weight: bold;">groups</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> ou: <span style="color: #c20cb9; font-weight: bold;">groups</span><br /> objectClass: organizationalUnit<br /> objectClass: top<br /> <br /> dn: <span style="color: #007800;">ou</span>=addressbook,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> ou: addressbook<br /> objectClass: top<br /> objectClass: organizationalUnit<br /> <br /> <span style="color: #666666; font-style: italic;">#Adding user</span><br /> dn: <span style="color: #007800;">uid</span>=ldap1,<span style="color: #007800;">ou</span>=people,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span><br /> objectClass: inetOrgPerson<br /> objectClass: posixAccount<br /> objectClass: shadowAccount<br /> uid: ldap1<br /> sn: Asdasd<br /> givenName: ldap1<br /> cn: ldap1 Asdasd<br /> displayName: ldap1 asdasd<br /> uidNumber: <span style="color: #000000;">1002</span><br /> gidNumber: <span style="color: #000000;">1000</span><br /> userPassword: <span style="color: #007800;">$hash_pw</span><br /> gecos: ldap1 asdasd<br /> loginShell: <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span><br /> homeDirectory: <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>ldap1<br /> shadowExpire: <span style="color: #660033;">-1</span><br /> shadowFlag: <span style="color: #000000;">0</span><br /> shadowWarning: <span style="color: #000000;">7</span><br /> shadowMin: <span style="color: #000000;">8</span><br /> shadowMax: <span style="color: #000000;">999999</span><br /> shadowLastChange: <span style="color: #000000;">10877</span><br /> mail: aw<span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$dc1</span>.<span style="color: #007800;">$dc2</span><br /> postalCode: <span style="color: #000000;">31000</span><br /> l: Mysity<br /> o: <span style="color: #007800;">$dc1</span><br /> mobile: +<span style="color: #000000;">33</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000;">6</span> <span style="color: #000000;">22</span> <span style="color: #000000;">22</span> <span style="color: #000000;">22</span> <span style="color: #000000;">22</span> <span style="color: #000000;">22</span><br /> homePhone: +<span style="color: #000000;">33</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000;">5</span> <span style="color: #000000;">33</span> <span style="color: #000000;">22</span> <span style="color: #000000;">33</span> <span style="color: #000000;">22</span><br /> title: System Administrator<br /> postalAddress:<br /> initials: LP<br /> EOF<br /> <br /> <span style="color: #c20cb9; font-weight: bold;">sudo</span> ldapadd <span style="color: #660033;">-x</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">cn</span>=admin,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc1</span>,<span style="color: #007800;">dc</span>=<span style="color: #007800;">$dc2</span> <span style="color: #660033;">-W</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>dit.ldif</div></td></tr></tbody></table></div><p>Execute the script with $sh script.sh<br /> If you have problems, want to edit etc, use the following script, it will fully remove and reinstall ldap.</p><div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br /> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> purge slapd ldap-utils<br /> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>debug<br /> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ldap<span style="color: #000000; font-weight: bold;">/*</span><br /> <span style="color: #c20cb9; font-weight: bold;">rm</span> &nbsp;<span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ldap<br /> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> slapd ldap-utils</div></td></tr></tbody></table></div><p>For testing if all is working fine you should try :</p><pre>
ldapsearch -D cn=admin,dc=yourhost,dc=yourdomain -W -x -b dc=yourhost,dc=yourdomain
</pre><p>Last words, for managing you can use phpldapadmin (it is in the repository).<br /> Then visit your localhost :<br /> http://localhost/phpldapadmin and log-in,<br /> Enjoy.</p> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/ubuntu-10-0-4-lucid-lynx-ldap-configuration-the-working-how-to.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Tcpdump how to &#8211; the linux network troubleshooter</title><link>http://albanianwizard.org/tcpdump-how-to-the-linux-troubleshooter.albanianwizard</link> <comments>http://albanianwizard.org/tcpdump-how-to-the-linux-troubleshooter.albanianwizard#comments</comments> <pubDate>Mon, 09 Aug 2010 22:50:11 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[how to read tcpdump output]]></category> <category><![CDATA[linux network troubleshooting]]></category> <category><![CDATA[read tcpdump output]]></category> <category><![CDATA[tcpdump commands]]></category> <category><![CDATA[tcpdump how-to]]></category> <category><![CDATA[Tcpdump tutorial]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=24</guid> <description><![CDATA[Cool Intro Some people say that &#8220;wireshark&#8221; is good, and bla bla bla , &#38; bla bla bla&#8230; Yes , wireshark is a great project but when it comes to firewalls, or to real work stuff nothing is like tcpdump. When you log in to a remote firewall, and want to check out what the]]></description> <content:encoded><![CDATA[<h1>Cool Intro</h1><p>Some people say that &#8220;wireshark&#8221; is good, and bla bla bla , &amp; bla bla bla&#8230;<br /> Yes , wireshark is a great project but when it comes to firewalls, or to real work stuff nothing is like tcpdump.</p><p>When you log in to a remote firewall, and want to check out what the hack is going on, tcpdump is your buddy.<br /> It is old and wise, it is the Adam of sniffers, so lets see what we can do with it.</p><h1>Worming Up</h1><p>In this example we use eth0 as the interface of our interest</p><p>First, we wan to see what interfaces can use for capturing packets,</p><pre>tcpdump -D</pre><p>This will print something like:</p><pre>1.wlan0
2.any (Pseudo-device that captures on all interfaces)
3.lo
</pre><p>Hey, wait a min, you don&#8217;t have an ethernet card?<br /> Yes, I have it but we need to set it up:</p><pre>ip link set eth0 up</pre><p>Now see the following output</p><pre>tcpdump -D
1.eth0
2.wlan0
3.any (Pseudo-device that captures on all interfaces)
4.lo
</pre><p>Ok, lets continue our tcpdump trip ,</p><p>More info about your card, and what it supports:</p><pre>tcpdump -L -i wlan0
Data link types for wlan0 when not in monitor mode (use option -y to set):
DOCSIS (DOCSIS) (printing not supported)
EN10MB (Ethernet)
</pre><p>Ok, lets begin:</p><pre>tcpdump -nvi eth0</pre><p>In this case, -n tells to not convert the port numbers in names, and host addresses to names, but treat the output numerically. -v is for &#8220;verbose&#8221; output, so it prints more stuff out.</p><p>And -i is for specifying the desired interface.<br /> Lets make a difficult example,</p><p>We have 1 firewall with 4 physical interfaces, eth0, eth1, eth2, eth3 and bridged interfaces, like br0, br1 etc.</p><p>If we want to monitor the traffic between DMZ and Blue zone we should monitor eth1 as DMZ and eth2 as Wireless /hotspot, /blue &#8211; zone interface, so we need to specify the interface for monitoring.</p><p>A common good command to use is:</p><pre>tcpdump -nnvvi eth0
</pre><h1>Protocol Specification</h1><p>I want only ICMP traffic</p><pre>tcpdump -nvi eth0 icmp
</pre><p>I want only tcp traffic:</p><pre>tcpdump -nnvvi eth0 tcp
</pre><p>and the same is for udp, we need only to specify.</p><p>What about monitoring only ping requests?</p><pre>tcpdump -nnvvi br0 icmp[0] = 8 or icmp[0] = 30</pre><h1>Tcpdump Recipes</h1><p><strong>host, src, dst, net, proto, port</strong></p><p>This are the mos common used tcpdump recipes</p><p><strong>host &#8211; </strong>specify the host address like host www.google.com will monitor only packets coming from or to www.google.com</p><p><strong>src &#8211; </strong>specify the source ip that you are monitoring i.e tcpdump -nnvvi eth0 tcp src 192.168.0.15 (local green IP)</p><p><strong>dst &#8211; </strong>specify the destination ip address that you want to monitor</p><p><strong>net &#8211; </strong>capture the entire traffic of a network using CIDR like tcpdump -nnvvi eth0 net 192.168.0.1/24 will capture any packet send from or to IP-s in the /24 range, in this case from 192.168.0.1 min to 192.168.0.254 max.</p><p><strong>proto &#8211; </strong>is the example above for specifying the protocol (icmp, tcp or udp) but don&#8217;t type it you just have to type tcpdump -nnvvi eth0 udp</p><p><strong>port &#8211; </strong>with this we can specify the port we want to monitor and the <strong>port </strong>option have 2 more sub-options , src and dst.</p><p>if we use:</p><pre>tcpdump -nvi eth0 tcp port 80 [this will monitor for one or another destination\source port 80]
</pre><p>So this will capture packets to or from port 80.</p><p>Destination port 80</p><pre>tcpdump -nvi eth0 tcp dst port 80
</pre><p>This will capture only packets that have us destination port 80, this is handy when we want to see what web sites are visiting our clients.</p><p>Source port 80</p><pre>tcpdump -nvi eth0 tcp src port 80
</pre><p>In this case, i have said to tcpdump that I want to monitor traffic passing through eth0 using tcp protocol with source port 80.</p><h1>Using tcpdump</h1><p>I want to specify the IP, the port and in the same time I want to see the packets in ASCII</p><pre>tcpdump -nvi lo host www.host.com and port 9999 -A
</pre><p>Wait buddy, we are going to fare, what is that &#8220;and&#8221;?</p><p>Tcpdump, supports Boolean operations like:</p><p><strong>and</strong></p><p><strong>or</strong></p><p><strong>not</strong></p><p>So it&#8217;s cool to use them, especially when we are interested only in some portion of the traffic.<br /> Lets see how we can combine this options:</p><pre>tcpdump -nnvvi wlan0 udp src port 50 and host www.google.com -X
</pre><p>-X prints the output in hexadecimals + ASCII like -A / I prefer -A</p><pre>tcpdump -nnvvi wlan0 src net 1.127.64.0/24 and dst host www.google.com or dst host www.yahoo.com -A
</pre><p>this is a curious packet capture dooring this command:</p><blockquote><p>00:24:29.842726 IP (tos 0&#215;0, ttl 64, id 8851, offset 0, flags [DF], proto TCP (6), length 1053)<br /> 1.127.64.205.57482 &gt; 72.14.234.104.80: Flags [P.], cksum 0xe693 (correct), seq 0:1001, ack 1, win 92, options [nop,nop,TS val 39390568 ecr 2016401695], length 1001<br /> E&#8230;&#8221;.@.@&#8230;..@.H..h&#8230;P../../#B&#8230;\&#8230;&#8230;.<br /> hx/..GET /csi?v=3&amp;s=webhp&amp;action=&amp;e=23051,25657&amp;ei=dYBgTOjtO8qv_QbC0MD4AQ&amp;expi=23051,25657&amp;imc=1&amp;imn=1&amp;imp=0&amp;rt= HTTP/1.1<br /> Host: www.google.com<br /> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100724 Firefox/3.6.8<br /> Accept: image/png,image/*;q=0.8,*/*;q=0.5<br /> Accept-Language: en-us,en;q=0.5<br /> Accept-Encoding: gzip,deflate<br /> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br /> Keep-Alive: 115<br /> Connection: keep-alive<br /> Referer: http://www.google.com/<br /> Cookie: PREF=ID=840ee66f4930292e:U=4b582d1d35710b91:LD=en:CR=2:TM=12802341176:LM=12803427747:GM=1:S=zj2wIxxG3Lg_Y8gw; NID=37=WjwrG6yFHasdpeOQMhPD40IOhJlVny7KUqlmoHyVx3R54B-Gv50bzklMcAeTmrq-67U-I5xtmjpJCQWcVNfxJ5aHJTnmf3M-a9haKuS8HdEclDqAe0cKhehME6vlZqChf; rememberme=false; TZ=-120; SID=DQAAAIIAAAA8-XYkoxlfhdksFPtnDHB6XymasdBnl2dDDfJeHx8pC0uup-AbijDoYU2WzrJJVDiFJ2bg6te6EKyOj-g5eAwUYpomEq1hmE-1BgjjbAkISr2vt4f5eKcR2asdJp8-kLfct8Qh58T_f1csmPeW02DEN5bHCHzXhGFxqTC-d9OWl7099WrvUmzgUUtFyiWE3fHHu0; HSID=A-IoVh0m5t-Ijrt-8</p></blockquote><p>Let&#8217;s go further..</p><p><strong>Show all URG packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 32 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all ACK packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 16 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all PSH packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 8 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all RST packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 4 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all SYN packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 2 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all FIN packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] &amp; 1 != 0'</div></td></tr></tbody></table></div>
</pre><p><strong>Show all SYN-ACK packets:</strong></p><pre>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># tcpdump 'tcp[13] = 18'</div></td></tr></tbody></table></div>
</pre><p>So in this case, if we want only a SYN-ACK view of a connection we can just type:</p><pre>tcpdump -nnvvi wlan0 'tcp[13] = 18' and host www.google.com</pre><p>For more advanced use, we should grep &amp; write data, and we can use | (pipes) &gt; &lt; redirects, or build in commands of tcpdump.</p><p>If we have some worse with the output from 1 or more ports, i.e ssh, or http, or any other port we can easily clear the output with:</p><p>tcpdump -nnvvi wlan0 not port 22 and not port  80</p> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/tcpdump-how-to-the-linux-troubleshooter.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Linux Network Configuration for home Users</title><link>http://albanianwizard.org/linux-network-configuration-for-home-users.albanianwizard</link> <comments>http://albanianwizard.org/linux-network-configuration-for-home-users.albanianwizard#comments</comments> <pubDate>Sun, 08 Aug 2010 20:59:22 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[how to add default gateway linux]]></category> <category><![CDATA[how to ethernet linux]]></category> <category><![CDATA[how to set up wireless under linux]]></category> <category><![CDATA[linux networking how to]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=13</guid> <description><![CDATA[The Tools – net-tools VS iproute2 There are 2 generic packages that do all-most the same thing’s. net-tools which include: ifconfig, nameif plipconfig rarp route slattach ipmaddr iptunnel mii-tool netstat hostname It is older compared to iproute2 packages but it is still used. iproute2 includes: rtmon ip netbug rtacct ss lnstat nstat cbq tc arpd]]></description> <content:encoded><![CDATA[<div><div><h2>The Tools – net-tools VS iproute2</h2><p>There are 2 generic packages that do all-most the same thing’s.</p><ul><li><strong>net-tools</strong> which include:</li><li> ifconfig,</li><li> nameif</li><li> plipconfig</li><li> rarp</li><li> route</li><li> slattach</li><li> ipmaddr</li><li> iptunnel</li><li> mii-tool</li><li> netstat</li><li> hostname</li></ul><p>It is older compared to iproute2 packages but it is still used.</p><ul><li><strong>iproute2</strong> includes:</li><li> rtmon</li><li> ip</li><li> netbug</li><li> rtacct</li><li> ss</li><li> lnstat</li><li> nstat</li><li> cbq</li><li> tc</li><li> arpd</li></ul><p>Net-tools have been great till 2.4/2.4/2.6 kernel shows up with    completely new network design. They work just fine but, for some tasks,   they show some strange behavior  and are very outdated for complicated   tasks / advanced routing. Sow, we are going to use generally iproute2.</p><p><a id="Settings_things_UP_.7Beth0.7Cwlan0.7D" name="Settings_things_UP_.7Beth0.7Cwlan0.7D"></a></p><h2>Settings things UP {eth0|wlan0}</h2><p>We just started the PC, and want to be online, we have a router in my    case just a linksys-cisco, and we are going to use /24 CIDR with the    router at 192.168.1.1 (default).</p><ul><li><strong>Dealing with our “links” – interfaces bringing them up and down</strong></li></ul><p>This is the easy way, for home networks with 1-2 box’s connected and   this is the “plug’n play” way. First we bring the interfaces up :</p><pre>#ip link set eth0 down   ==&gt; Same as ifconfig eth0 down
#ip link set wlan0 down  ==&gt; Same as ifconfig wlan0 down
</pre><p>Now, the 2 interfaces are down, and we can check this with</p><pre>#ip link show
</pre><pre>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
   link/ether 00:11:60:0a:ed:c6 brd ff:ff:ff:ff:ff:ff
3: wlan0: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc mq state DOWN qlen 1000
   link/ether 00:11:de:bc:ad:e2 brd ff:ff:ff:ff:ff:ff
</pre><p>We can notice that the lo interface (LoopBack is UP) instead of eth0   and wlan0 , there is no UP at &lt;BROADCAST,MULTICAST&gt;  the “state   DOWN” tells the state of the connection and not the state of the our   wireless card or ethernet card.</p><p>Now we want them up, because we want to connect to our router.</p><pre>#ip link set eth0 up; ip link set wlan0 up
OR
#ifconfig eth0 up; ifconfig wlan0 up
</pre><p>We want to see if the interfaces are up and we check with</p><pre>#ip link show
</pre><pre>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
   link/ether 00:1d:60:0f:eb:c6 brd ff:ff:ff:ff:ff:ff
3: wlan0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc mq state DOWN qlen 1000
   link/ether 00:18:de:c7:a0:6b brd ff:ff:ff:ff:ff:ff
</pre><ul><li><strong> Static DHCP or Dynamic DHCP?</strong></li></ul><p>Now that they are up, we have 2 ways of doing things with this interfaces,</p><ul><li> Static DHCP   — we have to specify the IP, the Netmask, the Default Gateway</li><li> Dynamic DHCP  — we dont have to specify nothing</li></ul><p>Sow, why Static DHCP? – In large network’s it’s all most a default   type of configuration,  because lets say we have a postgres sql server   at 192.168.1.201 and 3 servers A,B,C with different ip address   connecting to him for  getting reading\writing data. Some – day, we have   a problem with him, or just want to restart and we  restart him, but   now we have a big problem because the DHCP gives him 192.168.1.13 as ip   address and the things goes mad. The same happens if we apply for   different service that need other  service etc. Why Dynamic DHCP ? If we   are at home, and friends come to my house, i don’t want to set  they  ip  manually so just plug &amp; play.</p><p><a id="Configuring_eth0_with_Automatic__DHCP" name="Configuring_eth0_with_Automatic__DHCP"></a></p><h2>Configuring eth0 with Automatic IP (DHCP)</h2><p>We just connect the cable and we are just fine :) NOTE: If you have   no dhcp client running you must run the client for  getting your   connection setting from the DHCP server running on the  server. In my   case, befor connecting the cable:</p><ul><li>No – ip  |  No connection UP</li></ul><p>WARNING: NO-CARRIER,BROADCAST,MULTICAST,UP ==&gt;&gt; Hardware Interface UP state DOWN ==&gt;&gt; Connection is Down</p><pre>#ip addr show eth0
</pre><pre>2: eth0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
   link/ether 00:1d:60:0f:eb:c6 brd ff:ff:ff:ff:ff:ff
   inet6 fe80::21d:60ff:fe0f:ebc6/64 scope link
</pre><ul><li>Routing table clear, no router:</li></ul><pre>#ip route show
[root@darkinet arditi]#
</pre><p><strong>Routing table is empty</strong></p><p>Or we can use:</p><pre>#route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
</pre><p>Now i connect the ethernet cable on my laptop and on the router, the    result is the same. Nothing happens, and this is because I’m on arch   linux and all is manual  , so I have to contact the dhcp server for   getting the data and in my case:</p><pre># dhcpcd eth0
dhcpcd: version 5.2.2 starting
dhcpcd: eth0: rebinding lease of 192.168.1.100
dhcpcd: eth0: acknowledged 192.168.1.100 from 192.168.1.1
dhcpcd: eth0: checking for 192.168.1.100
dhcpcd: eth0: leased 192.168.1.100 for 86400 seconds
dhcpcd: forking to background
</pre><p>Now for being shore we want to check if we are connected and we ping the router.</p><pre># ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=3.95 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.492 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.486 ms
^C
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
</pre><p>rtt min/avg/max/mdev = 0.486/1.645/3.957/1.634 ms</p><p>Ctrl+C for stopping.</p><p>OK, lets see what happens to our interface and rooting table:</p><pre>2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:1d:60:0f:eb:c6 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
   inet6 fe80::21d:60ff:fe0f:ebc6/64 scope link
   valid_lft forever preferred_lft forever
</pre><p>Now we have an ip addres at 129.168.1.100 , this because it is the first free ip on the router. Lets see our rooting table:</p><pre># ip route show
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.100  metric 202
default via 192.168.1.1 dev eth0  metric 202
</pre><p>Ok, this is nice now lets deal with wireless.</p><p><a id="Configuring_wlan0_with_Automatic_DHCP" name="Configuring_wlan0_with_Automatic_DHCP"></a></p><h2>Configuring wlan0 with Automatic IP (DHCP)</h2><p><strong>Read eth0 with DHCP for more detailed information</strong></p><p>Now, it’s the same story, if you expect finding here WPA2, WEP,    WPA2-Enterprise how to, it’s not the section, here we are going to use    an OPN (Open) Access Point with essid “linksys”. Now the wlan0  interface  is up, if not #ip link set wlan0 up Than we connect our  wireless card  with the Access Point</p><pre>#iwconfig wlan0 essid "linksys"
</pre><ul><li>Case 1</li></ul><p>We have automatic dhcp client running and this is all and we are connected</p><ul><li>Case 2</li></ul><p>We don’t have dhcp client running so we need to run it on the interface: In this case:</p><pre>dhcpcd wlan0
dhcpcd: version 5.2.2 starting
dhcpcd: wlan0: rebinding lease of 192.168.1.100
dhcpcd: wlan0: NAK: from 192.168.1.1
dhcpcd: wlan0: broadcasting for a lease
dhcpcd: wlan0: offered 192.168.1.102 from 192.168.1.1
dhcpcd: wlan0: acknowledged 192.168.1.102 from 192.168.1.1
dhcpcd: wlan0: checking for 192.168.1.102
dhcpcd: wlan0: leased 192.168.1.102 for 86400 seconds
dhcpcd: forking to background
</pre><p>We ping for being shore that we are connected:</p><pre>ping -c 2 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=4.96 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.770 ms
</pre><pre>--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.770/2.869/4.969/2.100 ms
</pre><p><a id="Configuring_eth0_with_Static_DHCP" name="Configuring_eth0_with_Static_DHCP"></a></p><h2>Configuring eth0 with Static IP</h2><p>Indeed here we must Stop the DHCP server on our Router, so we point our browser to <a title="http://192.168.1.1" rel="nofollow" href="http://192.168.1.1/">http://192.168.1.1</a> , log – in and see around about dhcp settings, than stop the dhcp   server. Now, we suppose that your computer have never been connected   with that router so, I’m going to clear my connection info with:</p><pre>ip link set wlan0 down
</pre><p>Setting the interface down, automatically clears out connection info.   Now, in the Dynamic DHCP we get the IP and Default Gateway from the   DHCP  server running on the router, but now that it is not running any   more on the server how we’r going to get this data?</p><ul><li><strong> We are going to supply this data to our interface eth0 </strong></li></ul><p>Now, we can get any ip that we like, and we now that the router is on    192.168.1.1 But if we don’t know this info? -Check your router quick   start guide, or google it. Ok, now we connect the ethernet cable with   our ethernet port on laptop  and the ethernet port on the router. Ok,   here we go, if we run dhcpcd eth0 nothing happens because there is  not   anymore the dhcp server running to give us the date so now:</p><p>For connecting in the correct way with the router we need 3 important   data: Ip address Subnet Mask Default Gateway  Broadcast Address The   only 2 wee need to specify for make this connection work are IP address ,   and the Default Gateway. The range of the Ip address must be of course   192.168.0.* The ip address lets say we want 192.168.0.200 How to find   the subnet mask? (yes I know is 255.255.255.0 but lets suppose that you   don’t) We use a tool called ipcalc which is not currently installed on   my machine so: $ipcalc 192.168.1.200 And from the output we get  netmask  255.255.255.0  Broadcast is : 192.168.1.255 We use ipcalc, very  nice  tool helping with info about 1 ip. But normally the ip are :</p><pre>   /8
   /16
   /24
</pre><p>Or, their dotted-quad equivalents:</p><pre>   255.0.0.0
   255.255.0.0
   255.255.255.0
</pre><p><strong>Adding IP, subnet and broadcast address</strong> Sow, we find   that our selected ip 192.168.1.200 have a netmask  255.255.255.0 and  we  all ready know our router ip 192.168.1.1 The broadcast from ipcalc  was  192.168.0.255. PS:Anyway we need to now only the router gateway ip   (because the IP is  of our selection) and we must select an ip in the   right range. In this case 192.168.1.* from 2-254</p><pre>ip addr add 192.168.1.200/24 eth0
or the other way
ifconfig eth0 192.168.1.200 netmask 255.255.255.0
</pre><p><strong>If you are not shore about your subnet mask you just add your   ip  and than the ip program will calculate automatically your Subnet   Mask</strong><br /> Here our nice output:</p><pre>#ip addr show eth0
</pre><pre>2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:1d:60:0f:eb:c6 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.200/24 brd 192.168.0.255 scope global eth0
   inet6 fe80::21d:60ff:fe0f:ebc6/64 scope link
      valid_lft forever preferred_lft forever
</pre><p>After this we add the route</p><pre>ip route add 192.168.1.1 dev eth0
(this will work btw but if we want to add a default gateway than we just)
ip route add default 192.168.1.1 dev eth0
</pre><p>Now:</p><pre>#ip addr show eth0
2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:1d:60:0f:eb:c6 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.200/24 scope global eth0
   inet6 fe80::21d:60ff:fe0f:ebc6/64 scope link
      valid_lft forever preferred_lft forever
</pre><p>and</p><pre># ping -c 3 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.490 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.443 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.492 ms
</pre><pre>--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.443/0.475/0.492/0.022 ms
</pre><p>Now we see that we are connected. Lets deal with the wireless connection.</p><p><a id="Configuring_wlan0_with_Static_DHCP" name="Configuring_wlan0_with_Static_DHCP"></a></p><h2>Configuring wlan0 with Static IP</h2><ul><li>Set all interfaces down and than again up.</li></ul><p>Than:</p><pre>ip link set wlan0 up
ip addr add 192.168.1.200/24 dev wlan0
ip route add 192.168.1.1 dev wlan0

 #ip addr show wlan0
</pre><pre>3: wlan0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP qlen 1000
   link/ether 00:18:de:c7:a0:6b brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.200/24 scope global wlan0
   inet6 fe80::218:deff:fec7:a06b/64 scope link
      valid_lft forever preferred_lft forever
</pre><pre># ping -c 3 192.168.1.1
</pre><pre>PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.826 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.715 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.752 ms
</pre><pre>--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.715/0.764/0.826/0.051 ms
</pre><p><a id="Troubleshooting" name="Troubleshooting"></a></p><h2>Troubleshooting</h2><ul><li>Checking for duplicate ip address on your network:</li></ul><pre>arping  -c5 -D 192.168.1.1 -I wlan0
</pre><pre>ARPING 192.168.1.1 from 0.0.0.0 wlan0
Unicast reply from 192.168.1.1 [00:1D:7E:B2:B7:90] for 192.168.1.1 [00:1D:7E:B2:B7:90] 1.752ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)
</pre></div></div> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/linux-network-configuration-for-home-users.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Minicom How To &#124; How to use minicom when installing firewalls</title><link>http://albanianwizard.org/minicom-how-to-how-to-use-minicom-when-installing-firewalls.albanianwizard</link> <comments>http://albanianwizard.org/minicom-how-to-how-to-use-minicom-when-installing-firewalls.albanianwizard#comments</comments> <pubDate>Sun, 08 Aug 2010 20:55:55 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[how to use minicom]]></category> <category><![CDATA[minicom how to]]></category> <category><![CDATA[minicom paper]]></category> <category><![CDATA[minicom tutorial]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=11</guid> <description><![CDATA[The Problem So we say that we get a brand new hardware with 4-8-16 ethernet cards, 600mhz cpu, a nice RAM and hdd. Now we want to install on it some firewall based distribution and manage the installation process. Installing the software on our firewall HDD The best way is to attach the firewall hdd,]]></description> <content:encoded><![CDATA[<div><h2>The Problem</h2><p>So we say that we get a brand new hardware with 4-8-16 ethernet  cards, 600mhz cpu, a nice RAM and hdd. Now we want to install on it some  firewall based distribution and manage the installation process.</p><h2>Installing the software on our firewall HDD</h2><p>The best way is to attach the firewall hdd, on our pc – free hdd slot  and linux will automatically recognise the hard-disk, or wee can use a  CF writer (Compact Flash) First we download the image (.img) with wget,  or curl , or your browser. Normally we will find a .img.tar.gz file ,  first we tar -xzvf the file and than we copy our image to  the firewall  hdd. We assume that the hard-disk is located at /dev/sdb (/dev/sdb1)  Than:</p><pre>dd if=/home/user/downoads/our_img_distro.img of=/dev/sdb
</pre><p>if stands for input file, and of stands for output file.</p><p>Or we directly:</p><pre> tar -xzvf /location/our_img_firewall_distro.img.tar.gz | of=/dev/sdb
</pre><p>This requires a boot-able operating system image. You cant just copy   files to the Flash card because it needs a boot sector. dd does a   byte-by-byte copy, including the boot sector, which most other copy   commands cannot do.</p><p><a id="Minicom_at_work" name="Minicom_at_work"></a></p><h2>Minicom at work</h2><p>Now we re-attached the hard-disk on our hardware firewall, and want to check the installation. We need:</p><ul><li> Minicom (software) installed on our Linux-box</li><li> A null-modem serial cable(if you don’t know what I mean, search google images with “null-modem serial cable”</li></ul><p>Than we fix the serial cable and start minicom with:</p><pre>[root@mybox]# minicom -s  [s stands for setup]
------[configuration]-------
| Filenames and paths
| File transfer protocols
| Serial port setup
| Modem and dialing
| Screen and keyboard
| Save setup as dfl
| Save setup as..
| Exit
| Exit from Minicom
----------------------------
</pre><p>Than we go to serial-port-setup and hit [enter]</p><pre>-------------------------------------------
| A -     Serial Device     : /dev/tty8
| B - Lockfile Location     : /var/lock
| C -    Callin Program     :
| D - Callout Program       :
| E -     Bps/Par/Bits      : 19200 8N1
| F - Hardware Flow Control : No
| G - Software Flow Control : No
|
|     Change which setting?
-------------------------------------------
</pre><p>Now , if the A -option (serial device) is not /dev/ttyS0 (which is   normally our normal working port) we hit Shift+A and change it to  /dev/ttyS0 Than we change the E /Bps/Par/Bits in the same way. What’s  the right setting? This have to do with what are you using as hardware,  but normally <em>you  get this information form the website of the firewall company</em>.<br /> Now we have attached our minicom and we’r reddy for a fresh new   installation. Start up the firewall and if it’s all right we will see  the booting  information on our terminal. (just like we have a monitor  and are booting our software) If we have different firewall box’s and  don’t want to repeate  configurations we just “Save setup as…” and than  chose a name for  our configuration like efw, ipcop, etc and than for  connecting directly  with that we just:</p><pre>minicom ipcop
</pre><p>On the old times this cable was the “T1″ of today lol.</p></div> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/minicom-how-to-how-to-use-minicom-when-installing-firewalls.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>dnsmasq round-robin how to</title><link>http://albanianwizard.org/dnsmasq-round-robin-how-to.albanianwizard</link> <comments>http://albanianwizard.org/dnsmasq-round-robin-how-to.albanianwizard#comments</comments> <pubDate>Sun, 08 Aug 2010 20:52:42 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[dnsmasq configuration round robin]]></category> <category><![CDATA[dnsmasq round-robin]]></category> <category><![CDATA[round-robin algorithm]]></category> <category><![CDATA[roundrobin how to]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=9</guid> <description><![CDATA[Dnsmasq is currently compiled with round – robin algorithm (or a simple implementation of this algorithm). We make use of this capability for an very simple load balancing technique. What dnsmasq &#38; round robin do? Basically , we configure 1 host and give for him N° IP addresses , dnsmasq changes the IP order of]]></description> <content:encoded><![CDATA[<div><p>Dnsmasq is currently compiled with round – robin algorithm (or a  simple implementation of this algorithm). We make use of this  capability for an very simple load balancing technique.<br /> What dnsmasq &amp; round robin do? Basically , we configure 1 host and  give for him N° IP addresses ,  dnsmasq changes the IP order of this IP  corresponding to one host after  any single DNS request.<br /> Whats the point?<br /> <em>After each new connection the IP responding will be the next in the list</em> , doing so the requests will be balanced on 3 different servers managing 1 domain.<br /> Let’s say we have a very big host called blackbox and for not bombing  our host and the load we just add 3-5 or N servers for balancing the  load of the server.</p><blockquote><p>We give to our linux router/firewall an configuration like:<br /> cat /etc/hosts<br /> #<br /> # /etc/hosts: static lookup table for host names<br /> #</p><p>#&lt;ip-address&gt;    &lt;hostname.domain.org&gt;    &lt;hostname&gt;<br /> 127.0.0.1        localhost.localdomain    localhost darkinet<br /> 192.168.0.150       blackbox<br /> 192.168.0.151       blackbox<br /> 192.168.0.152       blackbox<br /> #NOTE: In real life this should be something like blackbox.com with an public IP address.<br /> #192.168.1.200           www.google.com   #I added google before lol <img src="http://shqip.albanianwizard.org/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" /><br /> # End of file</p></blockquote><p>Ok, this is good, now lets see our simple configuration at work:<br /> <strong>If we just $dig blackbox</strong></p><p><strong> </strong></p><pre>;; ANSWER SECTION:
blackbox.		0	IN	A	192.168.0.150
blackbox.		0	IN	A	192.168.0.151
blackbox.		0	IN	A	192.168.0.152
</pre><p><em>The seccond response</em></p><pre>;; ANSWER SECTION:
blackbox.		0	IN	A	192.168.0.151
blackbox.		0	IN	A	192.168.0.152
blackbox.		0	IN	A	192.168.0.150
</pre><p><em>The third response</em></p><pre>;; ANSWER SECTION:
blackbox.		0	IN	A	192.168.0.152
blackbox.		0	IN	A	192.168.0.150
blackbox.		0	IN	A	192.168.0.151
</pre><p>So, we see that the order of the IP changes after each DNS request cyclically.<br /> Then we restart dnsmasq<br /> # /etc/init.d/dnsmasq restart</p><p>This is not for serious load balancing (yep it costs up to 4000 bucks or even more)<br /> So in conclusion, if you are not</p><pre>;; ADDITIONAL SECTION:
ns1.google.com.        329163    IN    A    216.239.32.10
ns2.google.com.        327587    IN    A    216.239.34.10
ns3.google.com.        331744    IN    A    216.239.36.10
ns4.google.com.        331744    IN    A    216.239.38.10</pre><p>And you don’t have the need to use 4 server farms for a domain, than this may be your case.<br /> Bye.</p></div> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/dnsmasq-round-robin-how-to.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>AW iptables firewall bash script 1.0 personal edition</title><link>http://albanianwizard.org/aw-iptables-firewall-bash-script-1-0-personal-edition.albanianwizard</link> <comments>http://albanianwizard.org/aw-iptables-firewall-bash-script-1-0-personal-edition.albanianwizard#comments</comments> <pubDate>Sun, 08 Aug 2010 20:14:37 +0000</pubDate> <dc:creator>arditi</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[firewall script]]></category> <category><![CDATA[iptables blocking ipv6 traffic]]></category> <category><![CDATA[iptables firewall script]]></category> <category><![CDATA[iptables script]]></category> <category><![CDATA[iptables VS nmap]]></category><guid isPermaLink="false">http://albanianwizard.org/?p=6</guid> <description><![CDATA[Hi there, Update, now bug fix release 1.1, the firewall was to restrictive and doesn’t allow fast internet browsint, fixed First of all , from now on this website will be in english language, if some one from the staff wold like to translate, i can add a subdomain with a new installation of wordpress.]]></description> <content:encoded><![CDATA[<div><p>Hi there,</p><p>Update, now bug fix release 1.1, the firewall was to restrictive and doesn’t allow fast internet browsint, fixed <img src="http://shqip.albanianwizard.org/wp-includes/images/smilies/icon_smile.gif" alt=":)" /></p><p>First of all , from now on this website will be in english language,  if some one from the staff wold like to translate, i can add a subdomain  with a new installation of wordpress.<br /> So, this is a simple bash script which creates  an stateful iptables  firewall designed for blocking most common attacks at layer 3 &amp; for  on personal box’s.[not for gateways]<br /> Implemented:<br /> # a) Static rule based policies (not to be confused with a “static firewall”)<br /> # b) Connection based stateful policies<br /> # c) Sanity based policies<br /> I have tested it and it blocks most nmap port-scans, syn floods,  spoofing attacks and filter all ports , even open ones if the nmap sends  more than 1 packet /s (very normal). I wanted to block also IPV6  traffic.<br /> Here is the link ,<br /> Enjoy:</p><div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#AlbanianWizard Iptables Firewall Script v 1.1 [connection bug fix]</span><br /> <span style="color: #666666; font-style: italic;">#Tested against most nmap personalised scans,</span><br /> <span style="color: #666666; font-style: italic;">#To Do : portbunny/unicornscan/ping3 scanning [next versions]</span><br /> <span style="color: #666666; font-style: italic;">#Author : Arditi</span><br /> <span style="color: #666666; font-style: italic;">#License : GPLv3</span><br /> <span style="color: #666666; font-style: italic;">#Contact : arditi[nospam]hush.ai</span><br /> <span style="color: #666666; font-style: italic;">#WARNINGS: You must be root to run this,</span><br /> <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp;This script is designed only for personal pclaptopbox's it is not for Gatewaysrouters</span><br /> <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dont change the chain/rule-set order</span><br /> <span style="color: #666666; font-style: italic;">#Technologies for building this mini-firewall:</span><br /> <span style="color: #666666; font-style: italic;"># a) Static rule based policies (not to be confused with a &quot;static firewall&quot;)</span><br /> <span style="color: #666666; font-style: italic;"># b) Connection based stateful policies</span><br /> <span style="color: #666666; font-style: italic;"># c) Sanity based policies</span><br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#Variables, please check the correct location of iptables</span><br /> <span style="color: #666666; font-style: italic;">#whereis iptables ; whereis ip6tables</span><br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #007800;">IPT</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables<br /> <span style="color: #007800;">IPT6</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ip6tables<br /> <span style="color: #007800;">MP</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe<br /> <span style="color: #007800;">INET</span>=192.168.1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span><br /> <span style="color: #007800;">IF</span>=eth0<br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$USER</span> is setting up AW iptables firewall on <span style="color: #007800;">$HOSTNAME</span><br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#Setting up Connection Tracking Modules</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up Connection Tracking Modules<br /> <span style="color: #007800;">$MP</span> ip_conntrack<br /> <span style="color: #007800;">$MP</span> iptable_nat<br /> <span style="color: #007800;">$MP</span> ip_conntrack_ftp<br /> <span style="color: #007800;">$MP</span> ip_nat_ftp<br /> <span style="color: #007800;">$MP</span> nfnetlink_log<br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#Initial Setup</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up Chains<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-F</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-X</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> INPUT DROP<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> FORWARD DROP<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> OUTPUT ACCEPT <span style="color: #666666; font-style: italic;">#Or change to DROP and allow what you want if is not your personal box</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-N</span> FLOOD_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-N</span> BAD_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-N</span> TCP_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-N</span> ICMP_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-N</span> UDP_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> FLOOD_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> BAD_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> TCP_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> ICMP_CHAIN<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> UDP_CHAIN<br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#Blocking IPV6 traffic</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Blocking all IPV6 Traffic<br /> <span style="color: #007800;">$IPT6</span> <span style="color: #660033;">-P</span> INPUT DROP<br /> <span style="color: #007800;">$IPT6</span> <span style="color: #660033;">-P</span> FORWARD DROP<br /> <span style="color: #007800;">$IPT6</span> <span style="color: #660033;">-P</span> OUTPUT DROP<br /> <span style="color: #666666; font-style: italic;">#*****************************************************************</span><br /> <span style="color: #666666; font-style: italic;">#Setting up the Rules</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the rules<br /> <span style="color: #666666; font-style: italic;">#Good things :)</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> conntrack <span style="color: #660033;">--ctstate</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT <span style="color: #666666; font-style: italic;">#Accept loopback traffic</span><br /> <span style="color: #666666; font-style: italic;">#Bad things are normal :)</span><br /> <span style="color: #666666; font-style: italic;">#against -sO IP Protocol Scan (for supported protocols)</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> sctp <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> gre <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the FLOOD_CHAIN<br /> <span style="color: #666666; font-style: italic;">#This will only get better the situation, in real life you should use Reactive Address Blocking (RAB)</span><br /> <span style="color: #666666; font-style: italic;">#This will work for UDPTCPICMP floods sending more than 1 packet/s and also try to block nmap -sS scan.</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> FLOOD_CHAIN <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>s <span style="color: #660033;">--limit-burst</span> <span style="color: #000000;">6</span> <span style="color: #660033;">-j</span> RETURN <span style="color: #666666; font-style: italic;">#Accept only 6 packet/sec and we match only the first 6 packet.</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> FLOOD_CHAIN <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #000000;">7</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;# Syn Flood #&quot;</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> FLOOD_CHAIN <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #666666; font-style: italic;">#***********THE BAD CHAINS *****************************************</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the BAD_CHAIN<br /> <span style="color: #666666; font-style: italic;">#$IPT -A BAD_CHAIN -p tcp ! --syn -m state --state NEW -j DROP #Force --syn packet check for NEW connections, if not DROP IT!</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> BAD_CHAIN <span style="color: #660033;">-m</span> conntrack <span style="color: #660033;">--ctstate</span> INVALID <span style="color: #660033;">-j</span> DROP <span style="color: #666666; font-style: italic;">#Enforcing, dropping invalid connections beginning with FIN,PSH,ACK,RST etc..</span><br /> <span style="color: #666666; font-style: italic;">#Throw away fragmentation attacks</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> BAD_CHAIN <span style="color: #660033;">-f</span> <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #666666; font-style: italic;">#nmap scans not blocked by &quot;INVALID&quot; state</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> BAD_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--tcp-flags</span> ALL SYN,PSH <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> BAD_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--tcp-flags</span> ALL SYN,URG <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> BAD_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--tcp-flags</span> ALL NONE <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #666666; font-style: italic;">#Anti-spoofing</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>ipv4<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>all<span style="color: #000000; font-weight: bold;">/</span>rp_filter <span style="color: #666666; font-style: italic;">#setting to 0 disable spoofing protection</span><br /> <span style="color: #666666; font-style: italic;">#******************************************************************</span><br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the TCP_CHAIN<br /> <span style="color: #666666; font-style: italic;">#WEB-SERVER</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> TCP_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> NEW <span style="color: #660033;">-j</span> ACCEPT<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> TCP_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">443</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> NEW <span style="color: #660033;">-j</span> ACCEPT <span style="color: #666666; font-style: italic;">#ssl</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> TCP_CHAIN <span style="color: #660033;">-m</span> conntrack <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">--ctstate</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT <span style="color: #666666; font-style: italic;">#enforcing</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> TCP_CHAIN <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the UDP_CHAIN<br /> <span style="color: #666666; font-style: italic;">#UDP_CHAIN</span><br /> <span style="color: #666666; font-style: italic;">#$IPT -A UDP_CHAIN -p udp --dport 53 -j ACCEPT &nbsp;if you want some DNS server</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> UDP_CHAIN <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #7a0874; font-weight: bold;">&#93;</span> Setting up the ICMP_CHAIN<br /> <span style="color: #666666; font-style: italic;">#ICMP_CHAIN</span><br /> <span style="color: #666666; font-style: italic;">#allow ping | Currently you can ping others but others can't ping you :D [uncomment below if you want to be pinged]</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> ICMP_CHAIN <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-m</span> hashlimit <span style="color: #660033;">--hashlimit</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #660033;">--hashlimit-mode</span> srcip,dstip <span style="color: #660033;">--hashlimit-name</span> xticmp <span style="color: #660033;">-m</span> icmp <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> ACCEPT<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> ICMP_CHAIN <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-m</span> hashlimit <span style="color: #660033;">--hashlimit</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #660033;">--hashlimit-mode</span> srcip,dstip <span style="color: #660033;">--hashlimit-name</span> xticmp <span style="color: #660033;">-m</span> icmp <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">30</span> <span style="color: #660033;">-j</span> ACCEPT<br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> ICMP_CHAIN <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-i</span> <span style="color: #007800;">$IF</span> <span style="color: #660033;">-j</span> DROP<br /> <span style="color: #666666; font-style: italic;">#Logging dropping things</span><br /> <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>min <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;DROP: &quot;</span> <span style="color: #660033;">--log-level</span> <span style="color: #000000;">7</span><br /> <br /> <span style="color: #666666; font-style: italic;">#°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°#</span><br /> <span style="color: #666666; font-style: italic;">#Note, this are all some of the common layer-3 attacks, but the real firewall attacks today are with</span><br /> <span style="color: #666666; font-style: italic;">#Protocol Tunneling /or firewall piercing so for this you need to use Snort l7-firewall or some other</span><br /> <span style="color: #666666; font-style: italic;">#application designed for performing layer 7 application checks.</span><br /> <span style="color: #666666; font-style: italic;">#Yes, iptalbes can do this stuff but it is to mutch resource consuming</span><br /> <span style="color: #666666; font-style: italic;">#°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°#</span><br /> <span style="color: #666666; font-style: italic;">#print the configuration</span><br /> <span style="color: #666666; font-style: italic;">#$IPT -nvL</span></div></td></tr></tbody></table></div><p>Save it as firewall.sh than execute it as root with sh firewall.sh and it will print the rules <img src="http://shqip.albanianwizard.org/wp-includes/images/smilies/icon_smile.gif" alt=":)" /><br /> GPLv3.</p></div> ]]></content:encoded> <wfw:commentRss>http://albanianwizard.org/aw-iptables-firewall-bash-script-1-0-personal-edition.albanianwizard/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 1632/1694 objects using disk

Served from: albanianwizard.org @ 2010-09-03 11:51:40 -->