Showing posts with label Network Forensics. Show all posts
Showing posts with label Network Forensics. Show all posts

2015-09-03

Wireshark 101

NOTE: This article is from another excellent resource called How-To Geek. Visit them at http://www.howtogeek.com/ and learn other cool geeky stuff.
How-To Geek

How to Use Wireshark to Capture, Filter and Inspect Packets


Wireshark, a network analysis tool formerly known as Ethereal, captures packets in real time and display them in human-readable format. Wireshark includes filters, color-coding and other features that let you dig deep into network traffic and inspect individual packets.
This tutorial will get you up to speed with the basics of capturing packets, filtering them, and inspecting them. You can use Wireshark to inspect a suspicious program’s network traffic, analyze the traffic flow on your network, or troubleshoot network problems.

Getting Wireshark

You can download Wireshark for Windows or Mac OS X from its official website. If you’re using Linux or another UNIX-like system, you’ll probably find Wireshark in its package repositories. For example, if you’re using Ubuntu, you’ll find Wireshark in the Ubuntu Software Center.
Just a quick warning: Many organizations don’t allow Wireshark and similar tools on their networks. Don’t use this tool at work unless you have permission.

Capturing Packets

After downloading and installing Wireshark, you can launch it and click the name of an interface under Interface List to start capturing packets on that interface. For example, if you want to capture traffic on the wireless network, click your wireless interface. You can configure advanced features by clicking Capture Options, but this isn’t necessary for now.

As soon as you click the interface’s name, you’ll see the packets start to appear in real time. Wireshark captures each packet sent to or from your system. If you’re capturing on a wireless interface and have promiscuous mode enabled in your capture options, you’ll also see other the other packets on the network.

Click the stop capture button near the top left corner of the window when you want to stop capturing traffic.

Color Coding

You’ll probably see packets highlighted in green, blue, and black. Wireshark uses colors to help you identify the types of traffic at a glance. By default, green is TCP traffic, dark blue is DNS traffic, light blue is UDP traffic, and black identifies TCP packets with problems — for example, they could have been delivered out-of-order.

Sample Captures

If there’s nothing interesting on your own network to inspect, Wireshark’s wiki has you covered. The wiki contains a page of sample capture files that you can load and inspect.
Opening a capture file is easy; just click Open on the main screen and browse for a file. You can also save your own captures in Wireshark and open them later.

Filtering Packets

If you’re trying to inspect something specific, such as the traffic a program sends when phoning home, it helps to close down all other applications using the network so you can narrow down the traffic. Still, you’ll likely have a large amount of packets to sift through. That’s where Wireshark’s filters come in.
The most basic way to apply a filter is by typing it into the filter box at the top of the window and clicking Apply (or pressing Enter). For example, type “dns” and you’ll see only DNS packets. When you start typing, Wireshark will help you autocomplete your filter.

You can also click the Analyze menu and select Display Filters to create a new filter.

Another interesting thing you can do is right-click a packet and select Follow TCP Stream.

You’ll see the full conversation between the client and the server.

Close the window and you’ll find a filter has been applied automatically — Wireshark is showing you the packets that make up the conversation.

Inspecting Packets

Click a packet to select it and you can dig down to view its details.

You can also create filters from here — just right-click one of the details and use the Apply as Filter submenu to create a filter based on it.


Wireshark is an extremely powerful tool, and this tutorial is just scratching the surface of what you can do with it. Professionals use it to debug network protocol implementations, examine security problems and inspect network protocol internals.

2014-08-15

DEFCON 22: Network Forensics Puzzle Contest

Always grab a NFPC disc even if you don’t have time to play along at DEFCON so now you can check out the puzzle on your own.  The passwords to unlock the Truecrypt volumes for each round is listed below.  This contest is excellent for learning packet analysis as the puzzles will require you to dig through pcaps to find the answers.  This could be your first step in eventually crushing CTP in the future.
A full write-up of the contest is available on the forensicscontest.com website, but i'd advice against reading it until you've spent a good amount of time to solve this.  If you were not able to grab a CD, you can get the Truecrypt volumes here - DEFCON NFPC CDs (note: i'll upload the puzzle file as soon as i get better bandwidth sometime tomorrow.... 08/15/2014)

I will also post the previous DEFCON NFPC CD's shortly so stay tuned.
Please note that zeroes are often used instead of the letter ‘o.’
Round 1: izDEFCONf33ling22?#tSwift
Round 2: #pshth@twaSteh3@$y1#
Round 3: Ib3tuth0ughtQat@r&&
Round 4: h0wd1dug3tth@t1?%
Round 5: ur0nar0lln0w!@
Round 6: gud$luk^^0nth1s1
Round 7: !LA$$t0n3!!
Bonus round: Way-2_1337-4_u!

2012-08-05

The Wall of Sheep by Irongeek

I was searching a data dumb from this year's DC20 Wall of Sheep and came across Irongeek's script.  The date stamp on his post was 2006, kinda old but I just have the to find the time to test it out.  I've a also included the actual code at the bottom of this post.  There are links for an Slax iso at the bottom, but I'm not sure if it works, plus you might need a password by emailing Irongeek. 
 

Irongeek's Wall of Social Science Majors
(inspired by the Wall of Shame/Wall of Sheep)
        You all have seen the Wall of Shame/Wall of Sheep that they run at various hacker cons right? I know DefCON had one every year, and I saw something similar at PhreakNIC. Well, this is my version, the Wall of Social Science Majors. What the wall does is display the passwords of users at the con that are using insecure protocols. They set up a box on the gateway that sniffs for plaintext passwords (Telnet, HTTP Basic Authentication, FTP, POP3 etc. ) and displays them. Well, I could not find any code to do this on the web, so I made my own. You feed this PHP script with the output from Ettercap ("ettercap -Tq -d -m ettertest.log") and it seems to work pretty well, read the comments in the code for details on how to set it up. If you have any suggestions/changes/code fixes please email me. Feel free to use it on your co if you like.
Read the code and change the commenting to enable some of these features:
  • Display X characters of the password instead of the whole thing.
  • Change the automatic refresh rate.
  • Choose where the script finds the Ettercap log created with the -m option.

Download from:
Ver 1.2 (rename the txt file to shame.php)
Ver 1.0
Or you can get this 200MB+
Slax based live CD with Ver 1.2 of the Wall
(Having this up killed my bandwidth/connections limit with Dreamhost, email me for the password)
The CD has all of the basic tools needed to get the password wall up and running: Apache, Ettercap, PHP, Etc. However, you will have to edit the run scripts to fit your needs, your card may not be supported, and I'm not doing tech support if you have a problem with this Live CD. :)
Norad also set up a Rapidshare for the ISO:
http://rapidshare.com/files/25510785/igwall.0.1.part1.rar.html
http://rapidshare.com/files/25521883/igwall.0.1.part2.rar.html
http://rapidshare.com/files/25523205/igwall.0.1.part3.rar.html 
Here's the PHP script. (Rename it to shame.php)

<?
/*
 Irongeek's Wall Of Shame Code ver. 1.2
Irongeek -at- irongeek.com
http://www.irongeek.com
Contributors: 
 Julien Goodwin <jgoodwin#studio442.com.au>

Just a fugly script I wrote to take a logfile from Etthercap and display 
passwords to a webpage.

Ettercap supports:
TELNET, FTP,  POP,  RLOGIN,  SSH1,  ICQ,  SMB,
       MySQL,  HTTP,  NNTP, X11, NAPSTER, IRC, RIP, BGP, SOCKS 5, IMAP 4, VNC,
       LDAP, NFS, SNMP, HALF LIFE, QUAKE 3, MSN, YMSG (other protocols  coming
       soon...)
 Some help from:
 http://www.php.net/
 http://www.theukwebdesigncompany.com/articles/article.php?article=165

Consider this code GPLed, but it would be sweet of you to link back to 
Irongeek.com if you use it.
 */

//// Configuration settings
// Refresh time (in seconds), set to 0 to disable
$refresh = 30;

/*Point the line below to the log file you are creating with:
         "ettercap -Tq -D  -m ettertest.log".
 if you get an error like:
 BUG at [ec_ui.c:ui_register:339]
 ops->input == NULL
 then try just "ettercap -Tq  -m ettertest.log" without the daemon option..
 Also, you could ARP poison the gateway if you like with a command like:
 ettercap -Tq  -m /tmp/ettercap.log -M arp /gateway-IP/ //.
*/
// Logfile generated by ettercap
$logfile = '/tmp/ettercap.log';

// Show duplicate entries?
$showdupes = false;

/*Set the below to just show the first X characters of the password, "all" to
show all, or none to show all *'s */
//$showxchar = 3;
$showxchar = 'all';
//$showxchar = 'none';

// Show service names (instead of port numbers)
$showservnames = true;

// Do a reverse DNS query of target (WARNING! use only with a good local DNS cache)
$resolvetarget = false;

?>
<HTML>
<HEAD>
<?php if ($refresh > 0) { ?>
 <META HTTP-EQUIV="Refresh" Content = "<?= $refresh ?>; URL=shame.php">
<?php } ?>
 <TITLE>Irongeek's Wall Of Shame</TITLE>
<style type="text/css">
<!-- 
 BODY {
  background-color: #FFFFFF;
 }

 .SNMP {
  color: #009900;
 }

 .HTTP {
  color: #330099;
 }

 .TELNET {
  color: #CC33CC;
 }

 .POP {
  color: #8888FF;
 }

 .FTP {
  color: #004400;
 }

 .VNC {
  color: #007080;
 }

 .SMB {
  color: #F07080;
 }

 .IRC {
  color: #FF3333;
 }

 .YMSG {
  color: #BBBB00;
 }

-->
</style>
</HEAD>
<BODY>
<?

function between($somestring, $ss1, $ss2){
 if ($ss2 === false) { // That's what it does equate to in theory, just enforce it
  $ss2 = '';
 }

 preg_match('/' . $ss1 . '\s*(.*)\s*' . $ss2 . '/', $somestring, $matches);
 return $matches[1];
}

function showfirst($somestring, $chrnum) {
 global $showxchar;

 if ($showxchar == 'all') {
  return $somestring;
 } else if ($showxchar == 'none') {
  return str_pad(substr($somestring, 0, $showxchar), strlen($somestring), "*");
 } else {
  return str_pad(substr($somestring, 0, $showxchar), 10, '*');
 }
}

function padpw($string) {
 return showfirst($string, $showxchar);
}

function PrintCapItem($proto, $target, $user, $password, $info = false) {
 global $showservnames;
 global $resolvetarget;

// Generate full target data - NOTE, we assume TCP here
$server = explode(':', $target);
$host = $server[0];
$service = getservbyport($server[1],'tcp'); // Note this is a quick (and cached) operation so we do it anyway
if ((strlen($service) < 1) || ($showservnames === false)) {
 $service = $port;
} else {
 $service .= ' <small>(' . $server[1] . ')</small>';
}

if ($resolvetarget) {
 $host = gethostbyaddr($server[0]);
 if (strlen($host) < 1) {
  $host = $server[0];
 } else {
  $host .= ' <small>(' . $ip . ')</small>';
 }
}

?> <TR CLASS="<?= $proto ?>">
  <TD><B><?= $proto ?></TD>
  <TD><?= $host ?></TD>
  <TD><?= $service ?></TD>
  <TD><?= $user ?></TD>
  <TD><?= $password ?></TD>
 </TR>
<?php if ($info !== false) { ?>
 <TR CLASS="<?= $proto ?>">
  <TD></TD>
  <TD COLSPAN="4"><small><I>More Info:</I> <?= $info ?></small></TD>
 </TR>
<?php }
}

function linkify($text) {
 return preg_replace('/(https?:\/\/[a-zA-Z0-9\-\?\&\.\/\=\;]*)/','<a href="\1">\1</a>',$text);
}

$contents = file($logfile);
if ($contents === false) {
 echo 'Ettercap logfile could not be opened.';
 die();
}

$contents = array_reverse($contents);
// Note we want the latest entries first, by reversing first old values do show up, move the above line below the if to change this behaviour
if (!$showdupes) {
 $contents = array_unique($contents);
}

?>
<h1 align="center">Irongeek's<BR>
Wall Of Shame</h1>

<p>Using protocols that pass your credentials insecurely at a hacker con? Shame on you! Keep away from protocols like authenticated FTP, POP3, TELNET and Basic HTTP non-anonymous without SSL/TLS when you can. Try encrypted tunnels like SSH or a VPN to get through possibly hostile networks when you have to use such insecure protocols. Have a nice day.</p>
<P align="right">Your buddy,<BR>
Irongeek</P>
<hr>

<TABLE BORDER="1" ALIGN="CENTER">
<thead>
<TR>
 <TH>Protocol</TH>
 <TH colspan="2">Target</TH>
 <TH>User</TH>
 <TH>Password</TD>
</TR>
</thead>
<?
foreach ($contents as $line ) {
 $line   = htmlentities($line);
 $proto  = trim(substr($line, 0, strpos($line, ':')));
 $target = between($line, ' : ', ' -&gt;');
 switch ($proto) {
  case 'SNMP':
   $user     = 'N/A';
   $password = padpw(between($line, '-&gt; COMMUNITY:', 'INFO:'));
   $info     = between($line, 'INFO:', false);
   PrintCapItem($proto, $target,$user,$password, $info);
   break;

  case 'HTTP':
   $user     = between($line, 'USER:', 'PASS:');
   $password = padpw(between($line, 'PASS: ', '  INFO:'));
   $info     = linkify(between($line, 'INFO:', false));
   PrintCapItem($proto, $target,$user,$password, $info );
   break;

  case 'TELNET':
   $user     = between($line, 'USER:', 'PASS:');
   $password = padpw(between($line, 'PASS:', false));
   PrintCapItem($proto, $target, $user, $password);
   break;

  case 'POP':
   $user     = between($line, 'USER:', 'PASS:');
   $password = padpw(between($line, 'PASS:', false));
   PrintCapItem($proto, $target, $user, $password);
   break;  

  case 'FTP':
   $user     = between($line, 'USER:', 'PASS:');
   $password = padpw(between($line, 'PASS:', false));
   PrintCapItem($proto, $target, $user, $password);
   break; 

  case 'VNC':
   $user     = 'Challenge: ' . between($line, '-&gt; Challenge:', ' Response:');
   $password = 'Response: ' . between($line, ' Response:', false);
   PrintCapItem($proto, $target, $user, $password);
   break;

  case 'SMB':
   $user     = between($line, 'USER:', 'HASH:');
   $password = between($line, 'HASH:', false);
   PrintCapItem($proto, $target, $user, $password);
   break;

  case 'IRC':
   $user     = between($line, 'USER:', 'PASS:');
   $password = padpw(between($line, 'PASS:', 'INFO:'));
   $info     = between($line, 'INFO:', false);
   PrintCapItem($proto, $target,$user,$password, $info );
   break;

  case 'YMSG':
   $user     = between($line,'USER:', 'HASH:');
   $password = padpw(between($line, 'HASH: ', '  - '));
   $info     = between($line, '  - ', false);
   PrintCapItem($proto, $target, $user, $password, $info );
   break;

  case 'DHCP':
   break; // Just add any other protocols to hide to this list

  default:
   if (strpos($line, ' : ') != 0 && strpos($line, 'PASS') != 0){
    $target    = between($line, ' : ', ' -&gt; USER:'); 
    $user      = between($line, 'USER: ', '  PASS:');
    $password  = padpw(between($line, 'PASS:', false));
    PrintCapItem($proto, $target, $user, $password);
    break; 
   }else{
    $trash .= '<TR><TD>' . $proto . '</td><td colspan="3">' . $line . '</TD></TR>';
   }
 }
}
//Call the PHP script with a ?debug on the end to see the trash lines.
if (isset($_GET[debug])) {
?>
<tfoot>
 <tr><th colspan=4>Debug messages</th></tr>
<?= $trash ?>
</tfoot>
<?php
}
?>
</TABLE>
<HR>
<CENTER>Source code for this &quot;Wall of Shame&quot; script can be found at 
<A HREF="http://www.irongeek.com/">http://www.irongeek.com/</A></CENTER>
</BODY>
</HTML>



2012-07-31

DEFCON 20: Network Forensics Puzzle Contest

Decryption keys and answers for the DEFCON 20 Network Forensics Puzzle Contest are listed below.  The website indicated that they will provide a full write up of the solution.

If you're wondering where the questions are, they were on CDs handed out during the con when you registered to play.  You just have to go to the DC Contest Area and look for their desk.  The moderators will give you a piece of paper where you have to write your team name and a phone number where they can text you the decryption keys.  They will also provide you a cell number where you can text your answers.  For every correct answer you text them, they will text you back the decryption key for the next round and so on....etc. 

I guess if you can read packets, write code, analyze and listen to talks at the same time during the con, then you have a good chance of having a productive Defcon weekend. 



Decryption Keys
Contest Container: W3lc0m3toNFPC2012@defcon
Round2: Aw3s0m3s4uc3@
Round3: DFC=w00t!
Round4: 4r3g3ttingh4rd
Round5: tHiswi11b3fun#
Round6: Th3R4c3is0n$

Answers to DEFCON 2012 Contest Questions
Round 1 Answer: 99901
Round 2 Answer: Golden Alley
Round 3 Answer: ICdarkwater
Round 4 Answer: 15684-b5.12
Round 5 Answer: 2300
Round 6 Answer: Dogfort