<?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>El-Shihabi Daily Blog</title>
	<atom:link href="http://el-shihabi.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://el-shihabi.com</link>
	<description>El-Shihabi</description>
	<lastBuildDate>Wed, 20 Mar 2013 11:39:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>10 Windows 7 commands every administrator should know</title>
		<link>http://el-shihabi.com/?p=722</link>
		<comments>http://el-shihabi.com/?p=722#comments</comments>
		<pubDate>Wed, 20 Mar 2013 11:39:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=722</guid>
		<description><![CDATA[1: System File Checker Malicious software will often attempt to replace core system files with modified versions in an effort to take control of the system. The System File Checker can be used to verify the integrity of the Windows system files. If any of the files are found to be missing or corrupt, they &#8230;<br/><a href="http://el-shihabi.com/?p=722">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>1: System File Checker</p>
<p>Malicious software will often attempt to replace core system files with modified versions in an effort to take control of the system. The System File Checker can be used to verify the integrity of the Windows system files. If any of the files are found to be missing or corrupt, they will be replaced. You can run the System File Checker by using this command:<br />
<span id="more-722"></span><br />
sfc /scannow<br />
2: File Signature Verification</p>
<p>One way to verify the integrity of a system is to make sure that all the system files are digitally signed. You can accomplish this with the File Signature Verification tool. This tool is launched from the command line but uses a GUI interface. It will tell you which system files are signed and which aren’t. As a rule, all the system files should be digitally signed, although some hardware vendors don’t sign driver files. The command used to launch the File Signature Verification tool is:</p>
<p>sigverif<br />
3: Driverquery</p>
<p>Incorrect device drivers can lead to any number of system problems. If you want to see which drivers are installed on a Windows 7 system, you can do so by running the driverquery tool. This simple command-line tool provides information about each driver that is being used. The command is:</p>
<p>driverquery<br />
If you need a bit more information, you can append the -v switch. Another option is to append the -si switch, which causes the tool to display signature information for the drivers. Here’s how they look:</p>
<p>driverquery -v<br />
driverquery -si<br />
4: Nslookup</p>
<p>The nslookup tool can help you to verify that DNS name resolution is working correctly. When you run nslookup against a host name, the tool will show you how the name was resolved, as well as which DNS server was used during the lookup. This tool can be extremely helpful when troubleshooting problems related to legacy DNS records that still exist but that are no longer correct.</p>
<p>To use this tool, just enter the nslookup command, followed by the name of the host you want to resolve. For example:</p>
<p>nslookup dc1.contoso.com<br />
5: Ping</p>
<p>Ping is probably the simplest of all diagnostic commands. It’s used to verify basic TCP/IP connectivity to a network host. To use it, simply enter the command, followed by the name or IP address of the host you want to test. For example:</p>
<p>ping 192.168.1.1<br />
Keep in mind that this command will work only if Internet Control Message Protocol (ICMP) traffic is allowed to pass between the two machines. If at any point a firewall is blocking ICMP traffic, the ping will fail.</p>
<p>6: Pathping</p>
<p>Ping does a good job of telling you whether two machines can communicate with one another over TCP/IP, but if a ping does fail, you won’t receive any information regarding the nature of the failure. This is where the pathping utility comes in.</p>
<p>Pathping is designed for environments in which one or more routers exist between hosts. It sends a series of packets to each router that’s in the path to the destination host in an effort to determine whether the router is performing slowly or dropping packets. At its simplest, the syntax for pathping is identical to that of the ping command (although there are some optional switches you can use). The command looks like this:</p>
<p>pathping 192.168.1.1<br />
7: Ipconfig</p>
<p>The ipconfig command is used to view or modify a computer’s IP addresses. For example, if you wanted to view a Windows 7 system’s full IP configuration, you could use the following command:</p>
<p>ipconfig /all<br />
Assuming that the system has acquired its IP address from a DHCP server, you can use the ipconfig command to release and then renew the IP address. Doing so involves using the following commands:</p>
<p>ipconfig /release<br />
ipconfig /renew<br />
Another handy thing you can do with ipconfig is flush the DNS resolver cache. This can be helpful when a system is resolving DNS addresses incorrectly. You can flush the DNS cache by using this command:</p>
<p>ipconfig /flushdns<br />
8: Repair-bde</p>
<p>If a drive that is encrypted with BitLocker has problems, you can sometimes recover the data using a utility called repair-bde. To use this command, you will need a destination drive to which the recovered data can be written, as well as your BitLocker recovery key or recovery password. The basic syntax for this command is:</p>
<p>repair-bde -rk | rp<br />
You must specify the source drive, the destination drive, and either the rk (recovery key) or the rp (recovery password) switch, along with the path to the recovery key or the recovery password. Here are two examples of how to use this utility:</p>
<p>repair-bde c: d: -rk e:\recovery.bek<br />
repair-bde c: d: -rp 111111-111111-111111-111111-111111-111111<br />
9: Tasklist</p>
<p>The tasklist command is designed to provide information about the tasks that are running on a Windows 7 system. At its most basic, you can enter the following command:</p>
<p>tasklist<br />
The tasklist command has numerous optional switches, but there are a couple I want to mention. One is the -m switch, which causes tasklist to display all the DLL modules associated with a task. The other is the -svc switch, which lists the services that support each task. Here’s how they look:</p>
<p>tasklist -m<br />
tasklist -svc<br />
10: Taskkill</p>
<p>The taskkill command terminates a task, either by name (which is referred to as the image name) or by process ID. The syntax for this command is simple. You must follow the taskkill command with -pid (process ID) or -im (image name) and the name or process ID of the task that you want to terminate. Here are two examples of how this command works:</p>
<p>taskkill -pid 4104<br />
taskkill -im iexplore.exe</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=722</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql Repair Corrupted</title>
		<link>http://el-shihabi.com/?p=713</link>
		<comments>http://el-shihabi.com/?p=713#comments</comments>
		<pubDate>Mon, 18 Mar 2013 12:11:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=713</guid>
		<description><![CDATA[mysqlcheck --check-upgrade --all-databases --auto-repair -u root -p mysql_upgrade --force -u root -p check table TABLE_NAME; Repair table TABLE_NAME; &#160;]]></description>
				<content:encoded><![CDATA[<p><code><br />
mysqlcheck --check-upgrade --all-databases --auto-repair -u root -p<br />
mysql_upgrade --force -u root -p<br />
</code></p>
<p><code><br />
check table TABLE_NAME;<br />
Repair table TABLE_NAME;<br />
</code></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=713</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSIPS Test Tools</title>
		<link>http://el-shihabi.com/?p=707</link>
		<comments>http://el-shihabi.com/?p=707#comments</comments>
		<pubDate>Mon, 11 Mar 2013 09:23:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=707</guid>
		<description><![CDATA[This list contains a few tools which can be used in setting up or testing your OpenSIPS installation. 1. m4 Included on most Linuxes. This is a simple way to set up and use separate parameter files or even a good way of accomplishing INCLUDE&#8217;s in your configs. Example of usage is provided by Iñaki &#8230;<br/><a href="http://el-shihabi.com/?p=707">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This list contains a few tools which can be used in setting up or testing your OpenSIPS installation.<br />
1.  m4</p>
<p>Included on most Linuxes. This is a simple way to set up and use separate parameter files or even a good way of accomplishing INCLUDE&#8217;s in your configs. Example of usage is provided by Iñaki Baz Castillo;<br />
<more><br />
I strongly recommend you to use M4 to compile your opensips.cfg file:</p>
<p>file /etc/opensips/opensips.cfg.m4:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
debug=3<br />
log_stderror=no<br />
log_facility=LOG_LOCAL7<br />
fork=yes<br />
&#8230;<br />
listen=MY_IP:MY_PORT<br />
&#8230;<br />
    rewritehost(&#8220;MEDIA_SERVER_IP:MEDIA_SERVER_PORT&#8221;);<br />
&#8230;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>file /etc/opensips/defines.m4 (at your home):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
divert(-1)<br />
define(`MY_IP&#8217;,		`192.168.10.23&#8242;)<br />
define(`MY_PORT&#8217;,		`5060&#8242;)<br />
define(`MEDIA_SERVER_IP&#8217;,   `192.168.10.23&#8242;)<br />
define(`MEDIA_SERVER_PORT&#8217;, `5065&#8242;)<br />
divert(0)dnl<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>file /etc/opensips/defines.m4 (at your office):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
divert(-1)<br />
define(`MY_IP&#8217;,		`123.123.123.123&#8242;)<br />
define(`MY_PORT&#8217;,		`5060&#8242;)<br />
define(`MEDIA_SERVER_IP&#8217;,	`22.22.22.22&#8242;)<br />
define(`MEDIA_SERVER_PORT&#8217;,	`5065&#8242;)<br />
divert(0)dnl<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Create a bash script:<br />
/usr/local/bin/op-restart.sh:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
#!/bin/bash<br />
DIR=&#8221;/etc/opensips&#8221;<br />
m4 $DIR/defines.m4 $DIR/opensips.cfg.m4 > $DIR/opensips.cfg<br />
/etc/init.d/opensips restart<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>So you just must change the /etc/opensips/opensips.cfg.m4 file and the<br />
defines.m4 (this last file will be different depending on your location).</p>
<p>2.  ngrep</p>
<p>### capture all SIP packages on 5060 on all interfaces<br />
ngrep -W byline -td any . port 5060</p>
<p>### capture all SIP packages containing &#8216;username&#8217; on port 5060 on all interfaces<br />
ngrep -W byline -tqd any username port 5060</p>
<p>3.  SIPp<br />
4.  tshark</p>
<p>### Filter on RTCP packets reporting any packet loss or jitter over 30ms:<br />
tshark -i eth0 -o &#8220;rtcp.heuristic_rtcp: TRUE&#8221; -R &#8216;rtcp.ssrc.fraction >= 1 or rtcp.ssrc.jitter >= 30&#8242; -V</p>
<p>### View a remote realtime capture with a local wireshark:<br />
wireshark -k -i <(ssh -l root 192.168.10.98 tshark -w &#8211; not tcp port 22)</p>
<p>5.  sipviewer<br />
6.  sipana<br />
7.  pcapsipdump</p>
<p>pcapsipdump is libpcap-based SIP sniffer with per-call sorting capabilities. It writes SIP/RTP sessions to disk in a same format, as &#8220;tcpdump -w&#8221;, but one file per SIP session (even if there is thousands of concurrent SIP sessions).</p>
<p>WEB page http://pcapsipdump.sourceforge.net/<br />
8.  sipscenario<br />
9.  the &#8220;siptrace&#8221; table</p>
<p>Don&#8217;t forget the sip_trace() command (in module http://www.opensips.org/html/docs/modules/1.4.x/siptrace.html )</p>
<p>(Maybe some clever usage for something other than just plain searching it (like an integration with sipscenario))<br />
10.  sipinspector</p>
<p>http://sites.google.com/site/sipinspectorsite/</p>
<p>11.  Resync/reboot Linksys phones</p>
<p>PhPSIP UA for sending a NOTIFY to resync/reboot Linksys phone. The tool can authenticate (SIP digest) against the Linksys phone.</p>
<p>http://code.google.com/p/php-sip/</p>
<p>12.  Nagios memory check plugin</p>
<p>http://level7systems.co.uk/en/blog/OpenSIPs+memory+check+in+Nagios</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=707</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling ARCHIVELOG Mode</title>
		<link>http://el-shihabi.com/?p=699</link>
		<comments>http://el-shihabi.com/?p=699#comments</comments>
		<pubDate>Wed, 06 Mar 2013 07:55:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBA]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=699</guid>
		<description><![CDATA[Most of the High Availability features of Oracle require you to enable ARCHIVELOG mode for your database. When you enable this mode redo logs will be archived instead of overwritten. The archivelogs are stored in a seperate place usually can backed up regularly by your standard filesystem backup system (NetBackup or whatever). Archive logs are &#8230;<br/><a href="http://el-shihabi.com/?p=699">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img title="  " alt="  " src="http://upload.wikimedia.org/wikipedia/commons/7/79/Oracle_Challenger-II.jpg" width="424" height="268" /></p>
<p>Most of the High Availability features of Oracle require you to enable ARCHIVELOG mode for your database. When you enable this mode redo logs will be archived instead of overwritten. The archivelogs are stored in a seperate place usually can backed up regularly by your standard filesystem backup system (NetBackup or whatever). Archive logs are utilized by RMAN, Data Guard, Flashback and many others.</p>
<p>If your going to enable archivelog mode on a real database thats important to you, I would recommend shutting down the database and doing a cold backup just in case. Keeping a &#8220;final noarchivelog mode backup&#8221; seems to be a good and excepted practice.</p>
<p>Enabling archive mode is simple, just connect to your database in mounted but closed mode (startup mount) and alter the database. But if you don&#8217;t tune alittle you&#8217;ll run into problems down the road, so lets specify some parameters too. Namely, consider LOG_ARCHIVE_DEST.</p>
<p>Lets start by checking the current archive mode.</p>
<p>SQL&gt; SELECT LOG_MODE FROM SYS.V$DATABASE;</p>
<p>LOG_MODE<br />
&#8212;&#8212;&#8212;&#8212;<br />
NOARCHIVELOG<br />
<span id="more-699"></span><br />
So we&#8217;re in NOARCHIVELOG mode and we need to change. We can use a database alter statement, but that won&#8217;t be perminant, so lets just update the pfile directly. The pfile should be in either $ORACLE_BASE/admin/SID/pfile or $ORACLE_HOME/admin/SID/pfile. I&#8217;ll add the following lines to the end of the file:</p>
<p>############################<br />
# Archive Log Destinations -benr(10/15/04)<br />
############################<br />
log_archive_dest_1=&#8217;location=/u02/oradata/cuddle/archive&#8217;<br />
log_archive_start=TRUE</p>
<p>Note that we&#8217;re not actually required to specify the location of the log destination, but if you don&#8217;t it&#8217;ll end up in strange places (in my test it went to $ORACLE_HOME/dbs making a mess). You can specify as many as 10 diffrent archive log destinations by using the paramters log_archive_dest_1 through log_archive_dest_10. Remember, if you run out of space in your archive log destination the database will shut down!</p>
<p>Now we can startup the database in mount mode and put it in archivelog mode.</p>
<p>[oracle@vixen pfile]$sqlplus sys/passwd as sysdba;<br />
SQL*Plus: Release 10.1.0.2.0 &#8211; Production on Fri Oct 15 16:00:58 2004<br />
Copyright (c) 1982, 2004, Oracle. All rights reserved.<br />
Connected to an idle instance.</p>
<p>SQL&gt; startup mount<br />
ORACLE instance started.</p>
<p>Total System Global Area 184549376 bytes<br />
Fixed Size 1300928 bytes<br />
Variable Size 157820480 bytes<br />
Database Buffers 25165824 bytes<br />
Redo Buffers 262144 bytes<br />
Database mounted.</p>
<p>SQL&gt; alter database archivelog;<br />
Database altered.</p>
<p>SQL&gt; alter database open;<br />
Database altered.</p>
<p>You can see here that we put the database in ARCHIVELOG mode by using the SQL statement &#8220;alter database archivelog&#8221;, but Oracle won&#8217;t let us do this unless the instance is mounted but not open. To make the change we shutdown the instance, and then startup the instance again but this time with the &#8220;mount&#8221; option which will mount the instance but not open it. Then we can enable ARCHIVELOG mode and open the database fully with the &#8220;alter database open&#8221; statement.</p>
<p>There are several system views that can provide us with information reguarding archives, such as:</p>
<p>V$DATABASE<br />
Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.<br />
V$ARCHIVED_LOG<br />
Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.<br />
V$ARCHIVE_DEST<br />
Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.<br />
V$ARCHIVE_PROCESSES<br />
Displays information about the state of the various archive processes for an instance.<br />
V$BACKUP_REDOLOG<br />
Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information.<br />
V$LOG<br />
Displays all redo log groups for the database and indicates which need to be archived.<br />
V$LOG_HISTORY<br />
Contains log history information such as which logs have been archived and the SCN range for each archived log.</p>
<p>Using these tables we can verify that we are infact in ARCHIVELOG mode:</p>
<p>SQL&gt; select log_mode from v$database;</p>
<p>LOG_MODE<br />
&#8212;&#8212;&#8212;&#8212;<br />
ARCHIVELOG</p>
<p>SQL&gt; select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=699</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle 11gR2 issue &#8220;SHARED MEMORY&#8221;</title>
		<link>http://el-shihabi.com/?p=682</link>
		<comments>http://el-shihabi.com/?p=682#comments</comments>
		<pubDate>Fri, 08 Feb 2013 08:04:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=682</guid>
		<description><![CDATA[I have faced &#8220;SHARED_MEMORY&#8221; issue with oracle, I flushed memory, and after one hour it came back again and again but i was not able to login as sysdba, even system. I found below steps which helped to up the system in 10 min. 1- use oracle $ORACLE_HOME/bin tools to flush the mem Error Message &#8230;<br/><a href="http://el-shihabi.com/?p=682">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have faced &#8220;SHARED_MEMORY&#8221; issue with oracle, I flushed memory, and after one hour it came back again and again but i was not able to login as sysdba, even system.</p>
<p>I found below steps which helped to up the system in 10 min.<br />
<span id="more-682"></span><br />
1- use oracle $ORACLE_HOME/bin tools to flush the mem</p>
<p><code><br />
Error Message :  ORA-01075: you are currently logged on<br />
Solution :  Clean up the shared memory occupied by ora by executing below commands.<br />
ipcs -s | grep ora<br />
This will list the semaphores occupied by orasid, use the semaphore id to clear up the memory.<br />
ipcrm -s<br />
ipcrm -m<br />
</code></p>
<p><code><br />
oracle@db# export ORACLE_SID=oradb<br />
oracle@<code>db#</code> cd /u01/app/oracle/product/10.2.0/bin/<br />
oracle@<code>db#</code> /u01/app/oracle/product/10.2.0/bin&gt; sysresv </p>
<p>IPC Resources for ORACLE_SID "oradb" :<br />
Shared Memory:<br />
ID KEY<br />
805306484 0xe9389910<br />
Semaphores:<br />
ID KEY<br />
167772287 0xf09f4914<br />
Oracle Instance alive for sid "oradb"<br />
oracle@sb /u01/app/oracle/product/10.2.0/bin&gt; ipcrm -m 805306484<br />
oracle@db /u01/app/oracle/product/10.2.0/bin&gt; ipcrm -s 167772287<br />
oracle@db /u01/app/oracle/product/10.2.0/bin&gt; sysresv</p>
<p>IPC Resources for ORACLE_SID "oradb" :<br />
Shared Memory<br />
ID KEY<br />
No shared memory segments used<br />
Semaphores:<br />
ID KEY<br />
No semaphore resources used<br />
Oracle Instance not alive for sid "oradb"<br />
oracle@server /u01/app/oracle/product/10.2.0/bin&gt; cd<br />
oracle@server ~&gt; ps -ef | grep oradb<br />
oracle 3326 23776 0 14:12:05 pts/1 0:00 grep oradb<br />
</code></p>
<p>Instated of </p>
<p><code>alter system flush shared_pool;</code> </p>
<p>because you can not log to sqlplus / as sysdba </p>
<p><code>ORA-01075: you are currently logged on</code></p>
<p>2- When you going to startup it will show you that </p>
<p><code>ORA-00845: MEMORY_TARGET not supported on this system </code></p>
<p>his error comes up because you tried to use the Automatic Memory Management (AMM) feature of Oracle 11g R2. Well done, but it seems that your shared memory filesystem (shmfs) is not big enough. So let’s look at the steps necessary to enlarge your shared memory filesystem to avoid the error above.</p>
<p>First of all, login as root and have a look at the filesystem:</p>
<p><code>[root@db]# df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/mapper/vg_oracleem-lv_root<br />
                       93G   19G   69G  22% /<br />
tmpfs                 5.9G  112K  5.9G   1% /dev/shm<br />
/dev/sda1             485M   99M  362M  22% /boot</code></p>
<p>So we can see that tmpfs has a size of 6GB. We can change the size of that filesystem by issuing the following command:</p>
<p>[root@db oracle]# mount -t tmpfs shmfs -o size=8g /dev/shm</p>
<p>This command (re)mounts the shmfs filesystem (check this post for more information about shmfs) with the option “size=8g“.</p>
<p>3- SQL> startup </p>
<p>4- try to upgrade and raise </p>
<p>check the shared pool size<br />
<code>select name,value  from   v$parameter where  name='shared_pool_size'</code></p>
<p>Change it<br />
<code> ALTER SYSTEM SET shared_pool_size=8G scope=both </code></p>
<p>but you need to restart db<br />
shutdown immediate<br />
startup </p>
<p>[ GOOD LUCK <img src='http://el-shihabi.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ]</p>
<p>[ References ]</p>
<p>http://www.dba-oracle.com/t_ora_04031_unable_to_allocate_shared_memory.htm</p>
<p>http://www.artun.eu/blog/?p=31</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=682</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle 11gR2 on RHEL6</title>
		<link>http://el-shihabi.com/?p=679</link>
		<comments>http://el-shihabi.com/?p=679#comments</comments>
		<pubDate>Tue, 29 Jan 2013 12:38:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=679</guid>
		<description><![CDATA[This is a step by step guide, which will walk you through the installation of Oracle 11g Release 2 on RHEL 6 The requirement packages for  installation: Base System &#62; Base Base System &#62; Client management tools Base System &#62; Compatibility libraries Base System &#62; Hardware monitoring utilities Base System &#62; Large Systems Performance Base &#8230;<br/><a href="http://el-shihabi.com/?p=679">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is a step by step guide, which will walk you through the installation of Oracle 11g Release 2 on RHEL 6</p>
<p>The requirement packages for  installation:</p>
<ul>
<li>Base System &gt; Base</li>
<li>Base System &gt; Client management tools</li>
<li>Base System &gt; Compatibility libraries</li>
<li>Base System &gt; Hardware monitoring utilities</li>
<li>Base System &gt; Large Systems Performance</li>
<li>Base System &gt; Network file system client</li>
<li>Base System &gt; Performance Tools</li>
<li>Base System &gt; Perl Support</li>
<li>Servers &gt; Server Platform</li>
<li>Servers &gt; System administration tools</li>
<li>Desktops &gt; Desktop</li>
<li>Desktops &gt; Desktop Platform</li>
<li>Desktops &gt; Fonts</li>
<li>Desktops &gt; General Purpose Desktop</li>
<li>Desktops &gt; Graphical Administration Tools</li>
<li>Desktops &gt; Input Methods</li>
<li>Desktops &gt; X Window System</li>
<li>Development &gt; Additional Development</li>
<li>Development &gt; Development Tools</li>
<li>Applications &gt; Internet Browser<span id="more-679"></span></li>
</ul>
<p>Download the Oracle software from OTN or MOS depending on your support status.</p>
<ul>
<li><a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html">OTN: Oracle Database 11g Release 2 (11.2.0.1) Software (64-bit) &#8211; For unsupported installation.</a></li>
<li><a href="http://support.oracle.com">MOS: Oracle Database 11g Release 2 (11.2.0.3) Software (64-bit) &#8211; For supported installation.</a></li>
</ul>
<p>Unzip the files.</p>
<blockquote>
<pre># 11.2.0.1
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip</pre>
</blockquote>
<p><strong>Hosts File</strong></p>
<p>The &#8220;/etc/hosts&#8221; file must contain a fully qualified name for the server.<br />
<code> </code></p>
<p><strong>Automatic Setup</strong><br />
If you plan to use the &#8220;oracle-rdbms-server-11gR2-preinstall&#8221; package to perform all your prerequisite setup, follow the instructions at http://public-yum.oracle.com to setup the yum repository for OL, then perform the following command.</p>
<p><code> # yum install oracle-rdbms-server-11gR2-preinstall</code></p>
<h2>Manual Setup</h2>
<p>Oracle recommend the following minimum parameter settings.</p>
<blockquote>
<pre>fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586</pre>
</blockquote>
<p>The current values can be tested using the following command.</p>
<blockquote>
<pre>/sbin/sysctl -a | grep &lt;param-name&gt;</pre>
</blockquote>
<p>Add or amend the following lines in the &#8220;/etc/sysctl.conf&#8221; file.</p>
<blockquote>
<pre>fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586</pre>
</blockquote>
<p>Run the following command to change the current kernel parameters.</p>
<blockquote>
<pre>/sbin/sysctl -p</pre>
</blockquote>
<p>Add the following lines to the &#8220;/etc/security/limits.conf&#8221; file.</p>
<blockquote>
<pre>oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  4096
oracle              hard    nofile  65536
oracle              soft    stack   10240</pre>
</blockquote>
<p>Install the following packages if they are not already present.</p>
<blockquote>
<pre># From Oracle Linux 6 DVD
cd /media/cdrom/Server/Packages
rpm -Uvh binutils-2*x86_64*
rpm -Uvh glibc-2*x86_64* nss-softokn-freebl-3*x86_64*
rpm -Uvh glibc-2*i686* nss-softokn-freebl-3*i686*
rpm -Uvh compat-libstdc++-33*x86_64*
rpm -Uvh glibc-common-2*x86_64*
rpm -Uvh glibc-devel-2*x86_64*
rpm -Uvh glibc-devel-2*i686*
rpm -Uvh glibc-headers-2*x86_64*
rpm -Uvh elfutils-libelf-0*x86_64*
rpm -Uvh elfutils-libelf-devel-0*x86_64*
rpm -Uvh gcc-4*x86_64*
rpm -Uvh gcc-c++-4*x86_64*
rpm -Uvh ksh-*x86_64*
rpm -Uvh libaio-0*x86_64*
rpm -Uvh libaio-devel-0*x86_64*
rpm -Uvh libaio-0*i686*
rpm -Uvh libaio-devel-0*i686*
rpm -Uvh libgcc-4*x86_64*
rpm -Uvh libgcc-4*i686*
rpm -Uvh libstdc++-4*x86_64*
rpm -Uvh libstdc++-4*i686*
rpm -Uvh libstdc++-devel-4*x86_64*
rpm -Uvh make-3.81*x86_64*
rpm -Uvh numactl-devel-2*x86_64*
rpm -Uvh sysstat-9*x86_64*
rpm -Uvh compat-libstdc++-33*i686*
rpm -Uvh compat-libcap*
cd /
eject</pre>
</blockquote>
<p>Note. This will install all the necessary 32-bit packages for 11.2.0.1. From 11.2.0.2 onwards many of these are unnecessary, but having them present does not cause a problem.</p>
<p>Create the new groups and users.</p>
<blockquote>
<pre>groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
groupadd -g 504 asmadmin
groupadd -g 506 asmdba
groupadd -g 505 asmoper

useradd -u 502 -g oinstall -G dba,asmdba,oper oracle
passwd oracle</pre>
</blockquote>
<p>Note. We are not going to use the &#8220;asm&#8221; groups, since this installation will not use ASM.</p>
<h2>Additional Setup</h2>
<p>Disable secure linux by editing the &#8220;/etc/selinux/config&#8221; file, making sure the SELINUX flag is set as follows.</p>
<blockquote>
<pre>SELINUX=disabled</pre>
</blockquote>
<p>Once the change is complete, restart the server.</p>
<p>If you have the Linux firewall enabled, you will need to disable or configure it, as shown <a href="http://www.oracle-base.com/articles/linux/oracle-linux-6-installation.php#firewall">here</a> or <a href="http://www.oracle-base.com/articles/linux/linux-firewall.php#installation">here</a>.</p>
<p>Create the directories in which the Oracle software will be installed.</p>
<blockquote>
<pre>mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01</pre>
</blockquote>
<p>Login as root and issue the following command.</p>
<blockquote>
<pre>xhost +&lt;machine-name&gt;</pre>
</blockquote>
<p>Login as the oracle user and add the following lines at the end of the &#8220;.bash_profile&#8221; file.</p>
<blockquote>
<pre># Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=ol6-112.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID

PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH</pre>
</blockquote>
<h2>Installation</h2>
<p>Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable.</p>
<blockquote>
<pre>DISPLAY=&lt;machine-name&gt;:0.0; export DISPLAY</pre>
</blockquote>
<p>Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.</p>
<blockquote>
<pre>./runInstaller</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=679</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial tcpdump</title>
		<link>http://el-shihabi.com/?p=670</link>
		<comments>http://el-shihabi.com/?p=670#comments</comments>
		<pubDate>Mon, 14 Jan 2013 07:12:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=670</guid>
		<description><![CDATA[Options Basic Usage Common Syntax Writing to a File Getting Creative Advanced tcpdump is the premier network analysis tool for information security professionals. Having a solid grasp of this über-powerful application is mandatory for anyone desiring a thorough understanding of TCP/IP. Many prefer to use higher level analysis tools such as Ethereal Wireshark, but I &#8230;<br/><a href="http://el-shihabi.com/?p=670">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="attachment_671" class="wp-caption aligncenter" style="width: 510px"><a href="http://el-shihabi.com/?attachment_id=671" rel="attachment wp-att-671"><img class="size-full wp-image-671" alt="http://danielmiessler.com/study/tcpdump/" src="http://el-shihabi.com/wp-content/uploads/2013/01/tcp_header.gif" width="500" height="206" /></a><p class="wp-caption-text">http://danielmiessler.com/study/tcpdump/</p></div>
<ul class="toc">
<li><a href="#options">Options</a></li>
<li><a href="#basics">Basic Usage</a></li>
<li><a href="#common">Common Syntax</a></li>
<li><a href="#writing">Writing to a File</a></li>
<li><a href="#creative">Getting Creative</a></li>
<li><a href="#advanced">Advanced</a></li>
</ul>
<p><a href="http://en.wikipedia.org/wiki/Tcpdump"><code>tcpdump</code></a> is the premier network analysis tool for <a href="http://en.wikipedia.org/wiki/Information_security">information security</a> professionals. Having a solid grasp of this über-powerful application is mandatory for anyone desiring a thorough understanding of <a href="http://en.wikipedia.org/wiki/TCPIP">TCP/IP</a>. Many prefer to use higher level analysis tools such as <a href="http://www.ethereal.com/"><span style="text-decoration: line-through;">Ethereal</span></a> <a href="http://www.wireshark.org/">Wireshark</a>, but I believe this to usually be a mistake.</p>
<p>In a discipline so dependent on a true understanding of concepts vs. <a href="http://en.wikipedia.org/wiki/Rote_learning">rote learning</a>, it&#8217;s important to stay fluent in the underlying mechanics of the TCP/IP suite. A thorough grasp of these protocols allows one to troubleshoot at a level far beyond the average analyst, but mastery of the protocols is only possible through continued exposure to them.</p>
<p>When using a tool that displays network traffic a more natural (raw) way the burden of analysis is placed directly on the human rather than the application. This approach cultivates continued and elevated understanding of the TCP/IP suite, and for this reason I <em>strongly</em> advocate using <code>tcpdump</code> instead of other tools whenever possible.<span id="more-670"></span></p>
<pre><strong>15:31:34.079416</strong> <span style="color: orange;">IP</span> (tos 0x0, ttl  <span style="color: blue;">64</span>, id 20244, offset 0, flags <span style="color: red;">[DF]</span>, 
proto: TCP (6), length: <span style="color: green;">60</span>) source.35970 &gt; dest.80: S, cksum 0x0ac1 
(correct), 2647022145:2647022145(0) win 5840<span style="color: green;"> 0x0000:  4500 003c 4f14 4000 
4006 7417 0afb 0257  E..  0x0010:  4815 222a 8c82 0050 9dc6 5a41 0000 
0000  H."*...P..ZA....  0x0020:  a002 16d0 0ac1 0000 0204 05b4 
0402 080a  ................  0x0030:  14b4 1555 0000 0000 0103 0302</span></pre>
<p>&nbsp;</p>
<h2><a name="options"></a>Options</h2>
<p>Below are a few options (with examples) that will help you greatly when working with the tool. They&#8217;re easy to forget and/or confuse with other types of filters, i.e. ethereal, so hopefully this page can serve as a reference for you, as it does me.</p>
<p>First off, I like to add a few options to the <code>tcpdump</code> command itself, depending on what I&#8217;m looking at. The first of these is <strong>-n</strong>, which requests that names are not resolved, resulting in the IPs themselves always being displayed. The second is <strong>-X</strong>, which displays both hex and ascii content within the packet. The final one is <strong>-S</strong>, which changes the display of sequence numbers to absolute rather than relative. The idea there is that you can&#8217;t see weirdness in the sequence numbers if they&#8217;re being hidden from you. Remember, the advantage of using <code>tcpdump</code> vs. another tool is getting manual interaction with the packets.</p>
<p>It&#8217;s also important to note that <code>tcpdump</code> only takes the first <span style="text-decoration: line-through;">68</span> 96 bytes of data from a packet by default. If you would like to look at more, add the <strong>-s <em>number</em></strong> option to the mix, where <em>number</em> is the number of bytes you want to capture. I recommend using 0 (zero) for a snaplength, which gets everything. Here&#8217;s a short list of the options I use most:</p>
<ul class="nobullet">
<li><strong><code><span style="color: blue;">-i any</span></code></strong> : Listen on all interfaces just to see if you&#8217;re seeing any traffic.</li>
<li><strong><code><span style="color: blue;">-n</span></code></strong> : Don&#8217;t resolve hostnames.</li>
<li><strong><code><span style="color: blue;">-nn</span></code></strong> : Don&#8217;t resolve hostnames <em>or</em> port names.</li>
<li><strong><code><span style="color: blue;">-X</span></code></strong> : Show the packet&#8217;s <em>contents</em> in both <a href="http://en.wikipedia.org/wiki/Hexidecimal">hex</a> and <a href="http://en.wikipedia.org/wiki/Ascii">ASCII</a>.</li>
<li><strong><code>-XX</code></strong> : Same as <strong><code><span style="color: blue;">-X</span></code></strong>, but also shows the ethernet header.</li>
<li><strong><code><span style="color: blue;">-v, -vv, -vvv</span></code></strong> : Increase the amount of packet information you get back.</li>
<li><strong><code><span style="color: blue;">-c</span></code></strong> : Only get <em>x</em> number of packets and then stop.</li>
<li><strong><code><span style="color: blue;">-s</span></code></strong> : Define the <em>snaplength</em> (size) of the capture in bytes. Use <code>-s0</code> to get everything, unless you are intentionally capturing less.</li>
<li><strong><code><span style="color: blue;">-S</span></code></strong> : Print absolute sequence numbers.</li>
<li><strong><code><span style="color: blue;">-e</span></code></strong> : Get the ethernet header as well.</li>
<li><strong><code><span style="color: blue;">-q</span></code></strong> : Show less protocol information.</li>
<li><strong><code><span style="color: blue;">-E</span></code></strong> : Decrypt IPSEC traffic by providing an encryption key.</li>
</ul>
<p class="post_note">[ The default snaplength as of <code>tcpdump</code> 4.0 has changed from 68 bytes to 96 bytes. While this will give you more of a packet to see, it still won't get everything. Use <code>-s 1514</code> to get full coverage ]</p>
<h2><a name="basics"></a>Basic Usage</h2>
<p>So, based on the kind of traffic I&#8217;m looking for, I use a different combination of options to <code>tcpdump</code>, as can be seen below:</p>
<ol>
<ol>
<li><strong>Basic communication</strong> <small>// see the basics without many options</small>
<p class="command"># <span class="first">tcpdump</span> <span class="third">-nS</span></p>
</li>
</ol>
</ol>
<p>&nbsp;</p>
<ol>
<ol>
<li><strong>Basic communication (very verbose)</strong> <small>// see a good amount of traffic, with verbosity and no name help</small>
<p class="command"># <span class="first">tcpdump</span> <span class="third">-nnvvS</span></p>
</li>
</ol>
</ol>
<p>&nbsp;</p>
<ol>
<ol>
<li><strong>A deeper look at the traffic</strong> <small>// adds -X for payload but doesn&#8217;t grab any more of the packet</small>
<p class="command"># <span class="first">tcpdump</span> <span class="third">-nnvvXS</span></p>
</li>
</ol>
</ol>
<p>&nbsp;</p>
<ol>
<li><strong>Heavy packet viewing</strong> <small>// the final &#8220;s&#8221; increases the snaplength, grabbing the whole packet</small>
<p class="command"># <span class="first">tcpdump</span> <span class="third">-nnvvXSs</span> <span class="fifth">1514</span></p>
</li>
</ol>
<p>Here&#8217;s a capture of exactly two (<code>-c2</code>) <a href="http://en.wikipedia.org/wiki/Icmp">ICMP</a> packets (a <a href="http://www.networksorcery.com/enp/protocol/icmp/msg8.htm">ping</a> and <a href="http://www.networksorcery.com/enp/protocol/icmp/msg0.htm">pong</a>) using some of the options described above. Notice how much we see about each packet.</p>
<pre><span style="color: red;">linux</span> <span style="color: blue;">root</span> # tcpdump -nnvXSs 0 -c2 icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), 23:11:10.370321 IP 
(tos 0x20, ttl  48, id 34859, offset 0, flags [none], length: 84) 
69.254.213.43 &gt; 72.21.34.42: icmp 64: echo request seq 0
<span style="color: green;">
        0x0000:  4520 0054 882b 0000 3001 7cf5 45fe d52b  E..T.+..0.|.E..+
        0x0010:  4815 222a 0800 3530 272a 0000 25ff d744  H."*..50'*..%..D
        0x0020:  ae5e 0500 0809 0a0b 0c0d 0e0f 1011 1213  .^..............
        0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
        0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&amp;'()*+,-./0123
        0x0050:  3435 3637                                4567</span>
23:11:10.370344 IP (tos 0x20, ttl  64, id 35612, offset 0, flags [none], 
length: 84) 72.21.34.42 &gt; 69.254.213.43: icmp 64: echo reply seq 0<span style="color: green;">
        0x0000:  4520 0054 8b1c 0000 4001 6a04 4815 222a  E..T....@.j.H."*
        0x0010:  45fe d52b 0000 3d30 272a 0000 25ff d744  E..+..=0'*..%..D
        0x0020:  ae5e 0500 0809 0a0b 0c0d 0e0f 1011 1213  .^..............
        0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#
        0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&amp;'()*+,-./0123
        0x0050:  3435 3637                                4567</span>
2 packets captured
2 packets received by filter
0 packets dropped by kernel
<span style="color: red;">linux</span> <span style="color: blue;">root</span> #</pre>
<p>&nbsp;</p>
<pre class="codeblock"> #</pre>
<h2><a name="common"></a>Common Syntax</h2>
<p>Expressions allow you to trim out various types of traffic and find exactly what you&#8217;re looking for. Mastering the expressions and learning to combine them creatively is what makes one truly powerful with <code>tcpdump</code>. There are three main types of expression: <code>type</code>, <code>dir</code>, and <code>proto</code>.</p>
<p>Type options are <code>host</code>, <code>net</code>, and <code>port</code>. Direction is indicated by <code>dir</code>, and there you can have <code>src</code>, <code>dst</code>, <code>src or dst</code>, and <code>src and dst</code>. Here are a few that you should definitely be comfortable with:</p>
<ul>
<ul>
<li><strong><code>host</code></strong> <small>// look for traffic based on IP address (also works with hostname if you&#8217;re not using <strong>-n</strong>)</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">host</span> <span class="third">1.2.3.4</span></p>
</li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong><code>src</code></strong>, <strong><code>dst</code></strong> <small>// find traffic from only a source or destination (eliminates one side of a <strong>host</strong> conversation)</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">src</span> <span class="third">2.3.4.5</span></p>
<p># <span class="first">tcpdump</span> <span class="second">dst</span> <span class="third">3.4.5.6</span></li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong><code>net</code></strong> <small>// capture an entire network using <a href="http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">CIDR</a> notation</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">net</span> <span class="third">1.2.3.0/24</span></p>
</li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong><code>proto</code></strong> <small>// works for tcp, udp, and icmp. Note that you don&#8217;t have to type <code>proto</code></small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">icmp</span></p>
</li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong><code>port</code></strong> <small>// see only traffic to or from a certain port</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">port</span> <span class="third">3389</span></p>
</li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong><code>src, dst port</code></strong> <small>// filter based on the source or destination port</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">src</span> <span class="second">port</span> <span class="third">1025</span></p>
<p># <span class="first">tcpdump</span> <span class="second">dst</span> <span class="second">port</span> <span class="third">389</span></li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<li><strong><code>src/dst, port, protocol</code></strong> <small>// combine all three</small>
<p class="command"># <span class="first">tcpdump</span> <span class="second">src</span> <span class="second">port</span> <span class="third">1025</span> and <span class="fourth">tcp</span></p>
<p># <span class="first">tcpdump</span> <span class="second">udp</span> and <span class="third">src</span> <span class="third">port</span> <span class="fourth">53</span></li>
</ul>
<p>You also have the option to filter by a <em>range</em> of ports instead of declaring them individually, and to only see packets that are above or below a certain size.</p>
<ul>
<ul>
<li><strong>Port Ranges</strong> <small>// see traffic to any port in a range</small><code>tcpdump <span style="color: blue;">portrange</span> <span style="color: red;">21-23</span></code></li>
</ul>
</ul>
<p>&nbsp;</p>
<ul>
<ul>
<li><strong>Packet Size Filter</strong> <small>// only see packets below or above a certain size (in bytes)</small><code>tcpdump <span style="color: blue;">less</span> <span style="color: red;">32</span></code>
<p><code>tcpdump <span style="color: blue;">greater</span> <span style="color: red;">128</span></code></li>
</ul>
</ul>
<p class="post_note">[ You can use the symbols for <em>less than</em>, <em>greater than</em>, and <em>less than or equal</em> / <em>greater than or equal signs</em> as well. ]</p>
<p><small>// filtering for size using symbols</small></p>
<p><code>tcpdump <span style="color: blue;">&gt;</span> <span style="color: red;">32</span></code></p>
<p><code>tcpdump <span style="color: blue;">&lt;=</span> <span style="color: red;">128</span></code></p>
<h2><a name="writing"></a>Writing to a File</h2>
<p><code>tcpdump</code> allows you to send what you&#8217;re capturing to a file for later use using the <strong><code>-w</code></strong> option, and then to read it back using the <strong><code>-r</code></strong> option. This is an excellent way to capture raw traffic and then run it through various tools later.</p>
<p>The traffic captured in this way is stored in <code>tcpdump</code> format, which is pretty much universal in the network analysis space. This means it can be read in by all sorts of tools, including <a title="Wireshark · Go deep." href="http://www.wireshark.org/">Wireshark</a>, <a title="Snort :: Home Page" href="http://www.snort.org/">Snort</a>, etc.</p>
<p>&nbsp;</p>
<h4>Capture all Port 80 Traffic to a File</h4>
<p class="command"># <span class="first">tcpdump -s 1514</span> <span class="second">port</span> <span class="second">80</span> <span class="third">-w</span> <span class="fourth">capture_file</span></p>
<p>Then, at some point in the future, you can then read the traffic back in like so:</p>
<p>&nbsp;</p>
<h4>Read Captured Traffic back into <code>tcpdump</code></h4>
<p class="command"># <span class="first">tcpdump -r</span> <span class="second">capture_file</span></p>
<h2><a name="creative"></a>Getting Creative</h2>
<p>Expressions are nice, but the real magic of <code>tcpdump</code> comes from the ability to <em>combine</em> them in creative ways in order to isolate exactly what you&#8217;re looking for. There are three ways to do combinations, and if you&#8217;ve studied computers at all they&#8217;ll be pretty familar to you:</p>
<ol>
<li><strong>AND</strong><em><code><span style="color: green;">and</span></code></em> or <code><span style="color: green;">&amp;&amp;</span></code></li>
<li><strong>OR</strong><em><code><span style="color: blue;">or</span></code></em> or <code><span style="color: blue;">||</span></code></li>
<li><strong>EXCEPT</strong><em><code><span style="color: red;">not</span></code></em> or <code><span style="color: red;">!</span></code></li>
</ol>
<h3>More Examples</h3>
<div id="commandentry">
<p class="commandcomment"># TCP traffic from 10.5.2.3 destined for port 3389</p>
<p class="command"><span class="first">tcpdump -nnvvS</span> <span class="second">and</span> <span class="third">src 10.5.2.3</span> <span class="fourth">and</span> <span class="fifth">dst port 3389</span></p>
</div>
<div id="commandentry">
<p class="commandcomment"># Traffic originating from the 192.168 network headed for the 10 or 172.16 networks</p>
<p class="command"><span class="first">tcpdump -nvX src net 192.168.0.0/16</span> <span class="second">and</span> <span class="third">dst net 10.0.0.0/8</span> <span class="fourth">or</span> <span class="fifth">172.16.0.0/16</span></p>
</div>
<div id="commandentry">
<p class="commandcomment"># Non-ICMP traffic destined for 192.168.0.2 from the 172.16 network</p>
<p class="command"><span class="first">tcpdump -nvvXSs 1514 dst 192.168.0.2</span> <span class="second">and</span> <span class="third">src net</span> <span class="fourth">and</span> <span class="fifth">not icmp</span></p>
</div>
<div id="commandentry">
<p class="commandcomment"># Traffic originating from Mars or Pluto that isn&#8217;t to the SSH port</p>
<p class="command"><span class="first">tcpdump -vv src mars</span> <span class="second">and</span> <span class="third">not</span> <span class="fourth">dst port 22</span></p>
</div>
<p>As you can see, you can build queries to find just about anything you need. The key is to first figure out <em>precisely</em> what you&#8217;re looking for and then to build the syntax to isolate that specific type of traffic.</p>
<h3>Grouping</h3>
<p>Also keep in mind that when you&#8217;re building complex queries you might have to group your options using single quotes. Single quotes are used in order to tell <code>tcpdump</code> to ignore certain special characters &#8212; in this case the &#8220;( )&#8221; brackets. This same technique can be used to group using other expressions such as <code>host</code>, <code>port</code>, <code>net</code>, etc. Take a look at the command below:</p>
<div id="commandentry">
<p class="commandcomment"># Traffic that&#8217;s from 10.0.2.4 AND destined for ports 3389 or 22 <strong>(incorrect)</strong></p>
<p class="command"><span class="first">tcpdump src 10.0.2.4 and</span> <span class="second">(dst port 3389 or 22)</span></p>
</div>
<p>If you tried to run this otherwise very useful command, you&#8217;d get an error because of the parenthesis. You can either fix this by escaping the parenthesis (putting a \ before each one), or by putting the entire command within single quotes:</p>
<div id="commandentry">
<p class="commandcomment"># Traffic that&#8217;s from 10.0.2.4 AND destined for ports 3389 or 22 <strong>(correct)</strong></p>
<p class="command"><span class="first">tcpdump &#8216;src 10.0.2.4 and</span> <span class="second">(dst port 3389 or 22)&#8217;</span></p>
</div>
<h2><a name="advanced"></a>Advanced</h2>
<p>You can also filter based on specific portions of a packet, as well as combine multiple conditions into groups. The former is useful when looking for only SYNs or RSTs, for example, and the latter for even more advanced traffic isolation.</p>
<p class="post_note">[ Hint: An anagram for the TCP flags: <a href="http://danielmiessler.com/study/tcpflags/"> <b>U</b>nskilled <b>A</b>ttackers <b>P</b>ester <b>R</b>eal <b>S</b>ecurity <b>F</b>olk</a> ]</p>
<div id="commandentry">
<p>Show me all URGENT <strong>(URG)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">32</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all ACKNOWLEDGE <strong>(ACK)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">16</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all PUSH <strong>(PSH)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">8</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all RESET <strong>(RST)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">4</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all SYNCHRONIZE <strong>(SYN)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">2</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all FINISH <strong>(FIN)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span> &amp;</span> <span class="third">1</span>!=<span class="fifth">0</span>&#8216;</p>
</div>
<div id="commandentry">
<p>Show me all SYNCHRONIZE/ACKNOWLEDGE <strong>(SYNACK)</strong> packets&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[13]</span><span class="third">=18</span>&#8216;</span></p>
</div>
<p class="post_note">[ Note: Only the PSH, RST, SYN, and FIN flags are displayed in <code>tcpdump</code>'s flag field output. URGs and ACKs are displayed, but they are shown elsewhere in the output rather than in the flags field ]</p>
<p>Keep in mind the reasons these filters work. The filters above find these various packets because <code>tcp[13]</code> looks at offset 13 in the <a href="http://www.networksorcery.com/enp/protocol/tcp.htm">TCP header</a>, the number represents the location within the byte, and the !=0 means that the flag in question is set to 1, i.e. it&#8217;s on.</p>
<p>As with most powerful tools, however, there are multiple ways to do things. The example below shows another way to capture packets with specific TCP flags set.</p>
<div id="commandentry">
<p class="strong">Capture TCP Flags Using the <code>tcpflags</code> Option&#8230;</p>
<p class="command"><span class="first"># tcpdump <span class="fourth">&#8216;tcp[tcpflags]</span> &amp;</span> <span class="third">&amp; tcp-syn != 0</span>&#8216;</p>
</div>
<h3>Specialized Traffic</h3>
<p>Finally, there are a few quick recipes you&#8217;ll want to remember for catching specific and specialized traffic, such as IPv6 and malformed/likely-malicious packets.</p>
<div id="commandentry">
<p class="strong">IPv6 traffic</p>
<p class="command"><span class="first"># tcpdump <span class="fifth">ip6</span></span></p>
</div>
<div id="commandentry">
<p class="strong">Packets with both the RST and SYN flags set (why?)</p>
<p class="command"><span class="first"># tcpdump <span class="fifth">&#8216;tcp[13] = 6&#8242;</span></span></p>
</div>
<div id="commandentry">
<p class="strong">Traffic with the &#8216;Evil Bit&#8217; Set</p>
<p class="command"><span class="first"># tcpdump <span class="fifth">&#8216;ip[6]</span> &amp; <span class="second">128 != 0</span>&#8216;</span></p>
</div>
<h2>Conclusion</h2>
<p>Well, this primer should get you going strong, but <a href="http://www.tcpdump.org/tcpdump_man.html">the man page</a> should always be handy for the most advanced and one-off usage scenarios.</p>
<p>Source: http://danielmiessler.com/study/tcpdump/</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=670</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Archiving and Extracting files</title>
		<link>http://el-shihabi.com/?p=632</link>
		<comments>http://el-shihabi.com/?p=632#comments</comments>
		<pubDate>Sun, 30 Dec 2012 11:34:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=632</guid>
		<description><![CDATA[Create a .tar.gz file from a folder: tar czf /path/to/output/folder/filename.tar.gz /path/to/folder Extract a .tar.gz file: gunzip -c /path/to/folder/filename.tar.gz View a list of all files in a .tar.gz archive: gunzip -c /path/to/folder/filename.tar.gz &#124; tar -tvf - Extract a single file from a .tar.gz file: gunzip -c /path/to/folder/filename.tar.gz &#124; tar -xvf - path/within/archive/filename.php]]></description>
				<content:encoded><![CDATA[<p>Create a .tar.gz file from a folder:<br />
<code>tar czf /path/to/output/folder/filename.tar.gz /path/to/folder<br />
</code><br />
Extract a .tar.gz file:<br />
<code>gunzip -c /path/to/folder/filename.tar.gz<br />
</code><br />
View a list of all files in a .tar.gz archive:<br />
<code>gunzip -c /path/to/folder/filename.tar.gz | tar -tvf -<br />
</code><br />
Extract a single file from a .tar.gz file:<br />
<code>gunzip -c /path/to/folder/filename.tar.gz | tar -xvf - path/within/archive/filename.php<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=632</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running UNIX shell commands from &#8220;vi&#8221;</title>
		<link>http://el-shihabi.com/?p=626</link>
		<comments>http://el-shihabi.com/?p=626#comments</comments>
		<pubDate>Thu, 27 Dec 2012 07:00:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=626</guid>
		<description><![CDATA[You can run UNIX commands and see their output without leaving vi. You can also insert the output of a UNIX command into the file you that are editing. To run a single UNIX command use the command: :!UNIX_command You can start a shell from within vi and use it as you would your usual &#8230;<br/><a href="http://el-shihabi.com/?p=626">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://el-shihabi.com/?attachment_id=629" rel="attachment wp-att-629"><img class="alignright size-thumbnail wp-image-629" alt="vim-start" src="http://el-shihabi.com/wp-content/uploads/2012/12/vim-start-150x150.png" width="150" height="150" /></a>You can run UNIX commands and see their output without leaving vi. You can also insert the output of a UNIX command into the file you that are editing.</p>
<p>To run a single UNIX command use the command:</p>
<p><strong>:!UNIX_command</strong></p>
<p>You can start a shell from within vi and use it as you would your usual UNIX environment, then exit the shell and return to vi</p>
<p>To start up a shell enter the command:</p>
<p><strong>:sh</strong></p>
<p>The type of shell that is started is determined by the $SHELL variable. You can specify that some other shell is to be started by setting the vi shell option</p>
<p>Return to using vi by entering the command exit or Ctrl-D</p>
<p>To insert the output from a UNIX command into a file, immediately after the cursor:</p>
<p><strong>:r!command</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=626</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips on using lsof</title>
		<link>http://el-shihabi.com/?p=620</link>
		<comments>http://el-shihabi.com/?p=620#comments</comments>
		<pubDate>Mon, 24 Dec 2012 10:26:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://el-shihabi.com/?p=620</guid>
		<description><![CDATA[lsof -n -i The -n option prevents lsof from being slowed down by a large number of DNS lookups, and the -i option returns all TCP/IP connections (with process numbers, user ids, file descriptor ids, and so on). To narrow it down, utilize options like the following – to list all SMTP connections, for example: &#8230;<br/><a href="http://el-shihabi.com/?p=620">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>lsof -n -i</p>
<p>The -n option prevents lsof from being slowed down by a large number of DNS lookups, and the -i option returns all TCP/IP connections (with process numbers, user ids, file descriptor ids, and so on). To narrow it down, utilize options like the following – to list all SMTP connections, for example:</p>
<p>lsof -n -i :25</p>
<p>It is also possible to list only certain processes (such as process 25 and process 45):</p>
<p>lsof -n -p 25 -p 45</p>
<p>Alternately, the process can be selected by name:</p>
<p>lsof -n -c perl</p>
<p>However, suppose one wants to list all TCP/IP sockets held open by perl processes. The obvious choice does not work! This is because the options are combined together as an OR function; to combine them as an AND function (that is, all options must be satisfied) use the -a option – such as this:</p>
<p>lsof -a -n -c perl -i</p>
<p>This lists, as desired, all TCP/IP sockets held open by perl processes.</p>
<p>Another that might be useful in a security context is listing all files that are open but have no links to them: that is, they’ve been deleted, but one or more processes are keeping the file open, which means the file itself (and its blocks) are being preserved even though it appears to be deleted from the filesystem. To see these files, use this option:</p>
<p>lsof +L1</p>
<p>The utility lsof is indeed very useful, and reading the man page for lsof is recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://el-shihabi.com/?feed=rss2&#038;p=620</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
