Banner 1

Hacking de Redes UPnP - Parte II

0 comentarios

Una vista general sobre el protocolo UPnP

EL protocolo UPnP usa la dirección mulicast (multidifusión) 239.255.255.250 y el puerto TCP 1900. Los dispositivos que ofrecen servicios UPnP periódicamente enviarán mensajes SSDP NOTIFIY a 239:255:255:250:1900, anunciándose a cualquier cliente UPnP que en este en escucha. Si observas el tráfico en tu LAN que use un router con los servicios UPnP activos, notarás que éste envía una ráfaga de mensajes SSDP NOTIFY cada pocos segundos; esto ocurre porque la mayoría de los routers en realidad se anuncian como multiples dispositivos UPnP, y envían una notificación por cada tipo de dispositivo.

Asimismo, los clientes UPnP pueden enviar peticiones SSDP M-SEARCH a 239:255:255:250:1900 para ver si algún dispositivo UPnP responde. Los clientes pueden enviar una petición M-SEARCH buscando algún dispositivo UPnP, o pueden especificar que están buscando algún dispositivo en particular, o pueden consultar solo por algún dispositivo que soporte un servicio UPnP específico. Los hosts UPnP que concuerden con los dispositivos/servicios pedidos responderán con un mensaje SSDP RESPONSE, el cual contiene la misma información que la enviada en un mensaje SSDP NOTIFIY.

Un mensaje SSDP NOTIFY enviado por un host UPnP contiene una cabecera ‘Location’ la cual especifica la ubicación de un archivo XML. Este archivo XML contiene datos indicando, entre otras cosas, el tipo de dispositivo y los servicios soportados por el host, así como las rutas a otros documentos XML adicionales que describen los servicios detalladamente. Para descubrir las capacidades UPnP completas de un IGD, se debe analizar todos los archivos XML para extraer los tipos de dispositivos, servicios, y acciones ofrecidas por el IGD.

Los servicios UPnP soportan varios servicios que a su vez anuncian las acciones que soportan. Un cliente UPnP puede enviarle alguna petición al dispositivo UPnP en cualquier momento, esta podría ser una petición para abrir un puerto, cambiar el servidor DNS por defecto, o cualquier otra que el dispositivo soporte. Los datos enviados/devueltos en cualquier petición o respuesta son enviados usando SOAP, el cual usa XML para estructurar la información enviada entre las dos partes. Las peticiones SOAP son esencialmente peticiones HTTP POST con alguna cabecera SOAP adicional incluida en las cabeceras HTTP.

Auditando dispositivos UPnP manualmente

Para descubrir si algún router soporta UPnP, puedes ir a la interfaz administrativa de este y verificar si hay alguna opción para habilitar/deshabilitar UPnP, mientras que la mayoría de los routers tienen UPnP habilitado por defecto, algunos no.

Para realmente auditar la configuración de algún dispositivo UPnP, puedes encender Wireshark y buscar paquetes SSDP NOTIFIY siendo enviados a la dirección multicast 239.255.255.250 al puerto 1900; estas notificaciones serán dispositivos UPnP anunciándose a la red. Una vez los mensajes SSDP NOTIFIY son capturados, puedes examinar las cabeceras SSDP de los datos arrojados para obtener la ubicación del archivo XML raíz. Una vez tengas ese archivo (simplemente haciendo una petición HTTP GET), puedes examinarlo para ver que dispositivos y servicios soporta el host UPnP. Luego, puedes solicitar los archivos XML adicionales al host (uno por cada servicio) y analizar esos archivos XML para determinar que acciones soporta cada servicio, y luego correlacionar las posibles variables de estado (variables de entrada/salida) usada para cada acción, así como identificar cuales variables son usadas como “entrada”, y cuales como “salida” (una acción puede usar una variables como parametro de entrada, mientras que otras usan la misma variable como parametro de salida).

Obviamente, auditar hosts UPnP manualmente puede consumir extremadamente mucho tiempo y nos forza a generar manualmente peticiones a los dispositivos UPnP para lanzar ataques contra ellos. Usar una herramienta para automatizar el proceso haría nuestra vida mucho más fácil… Esto será lo que trataremos en la parte III del artículo.

=======================
Hacking de Redes UPnP - Parte I
Hacking de Redes UPnP - Parte II
=======================

Segunda parte del articulo Plug-N-Play Network Hacking traducido por Cortex en nuestra seccion Traducción de Artículos de La Comunidad.


fuenTE:http://www.dragonjar.org/hacking-de-redes-upnp-parte-ii.xhtml

Windows Viewers & Information Extractors for Various File Types

0 comentarios

I’d been doing a bit of work with EnCase to optimize my configuration and minimize the amount of work required to view various file types or extract specific data from them. The results from this are a list of applications and a few associated options for use in employing them as viewer plugins for your forensic tool of choice.

1. Regripper

This tool, developed and maintained by Harlan Carvey, author of Windows Forensic Analysis, is a great all-purpose registry data extractor. It has many different plugins that handle extraction of different information, and I believe that Harlan updates it frequently. I sometimes browse its output by eye when digging for things that are frustratingly nonspecific.

It’s a command-line-only utility, but you can run it from within a GUI tool such as Encase by specifying CMD as the actual command, and then putting the meat into the options, such as “/c cd /d fullpathregripper&rip -r [file] -f sam&pause” this will dump the text output into the buffer of the CMD shell (which will, of course need its default size expanded), then pause until the user hits the spacebar. You can copy and paste items of note out of the buffer while it’s open if desired. I have 6 different lines of this nature in my Encase configuration to deal with the various different registry file types supported by regripper.

2. NavRoad Offline HTML Browser

Often, html files recovered from a subject’s browser cache won’t display properly in a browser because of missing content that’s expected to be downloaded directly. NavRoad gets around that, and will usually format all of an html document’s content for display.

3. 7zip

The 7zip archive browser, 7zFM, is a great way to deal with a large assortment of archive formats which may or may not be directly supported by your forensic tool of choice.

4. GlobFX Swiff Player

When examining downloaded multimedia web content, you often come across downloaded shockwave flash (.swf) movies. This application allows them to be played normally.

5. Wimpy FLV Player

FLV is a different flash video format. I’ve found it typically used for youtube content.

6. VideoLAN VLC

I’ve found this open source multimedia player application to be one of the most reliable ways to play almost any audio/video content. There’s no need to download any special codecs. The only things I’ve found so far that it won’t play are flash and some of the realmedia formats. It may also have issues with DRM protected files, but I haven’t run into any yet.

7. RealPlayer

As mentioned above, VLC has issues with some of real.com’s special formats, so I also include their player as a viewer.

8. SQLite Database browser

There are a number of applications that store cache or configuration data in the sqlite database format. I’ve mentioned a couple of them in previous blog postings. This application lets you examine the data contained in such a database directly.

9. Exiftool

I originally obtained this tool specifically for extracting embedded metadata from within .jpg files. I’ve since discovered that it also does a pretty good job on MS Office documents, and examination of the documentation shows that it supports a plethora of other file types.

10. AccessPDF pdftk

This tool is specifically designed to extract metadata from within PDF documents. Like regripper above, it’s a command-line-only tool, so executing it from within a GUI application takes some finagling. As with regripper, I use CMD as the application, and put the meat in the options, “/c fullpathpdftk-1.12pdftk.exe [file] dump_data output - & pause”.

11. Pinpoint Metaviewer

Another GUI application for extracting metadata from MS Office documents.

12. Codeplex JSON Viewer

I dug up this utility while working on analyzing the content of gmail datapack files. It’s able to take the text from one of those files and format it so that it’s easy to make visual sense of. I don’t use it a lot, but I think it’s handy.

13. Extract

Extract is a command line utility that’s provided as part of the open-source libextractor library for linux. It’s what metagoofil uses to extract metadata, and was the first metadata viewer that I attempted to install. By dint of much persistence, I was able to compile it under Windows using the current version of cygwin. I also had to download and install the following packages (most of them were just trying to get PDF extraction to work, and not all of them may have actually been necessary): freetype-2.3.1, lesstif-0.95.0, libgsf-1.14.10, libmpeg2-0.5.1, t1lib-5.1.0, xpdf-3.02. This may or may not actually be worth the work, as I’m not sure that it extracts any data that the other metadata viewers I’ve found since (see above) do not.

14. Please add comments with file types you can’t browse, or file browsers that you think are useful

I’ll start the ball rolling. I’m looking for something I can use to play .qtch Quicktime cache files. Alternatively, I’d like to at least be able to determine what the URL download was that caused the creation of the cache file. Does anybody know anything that can be done with these files?

As always, you’re also welcome to leave commentary if you liked this article or want to call me on the carpet for some inaccuracy.

John McCash, GCFA Silver #2816, is currently a Forensic Investigator employed by a fortune 500 telecommunications equipment provider.


fuente:http://sansforensics.wordpress.com/2008/12/17/windows-viewers-information-extractors-for-various-file-types/

Forensic Gmail Artifact Analysis

0 comentarios

Forensic Gmail Artifact Analysis

I don’t know if you’ve had the pleasure of trying to extract GMail message content from a drive image, but there aren’t a lot of references out there. Those that I found helpful, I’ve listed below.

Gmail uses JavaScript to manage the user experience on the front end, and passes content back and forth between the client and server using ‘datapack’ files, which are formatted using JavaScript Object Notation (JSON). See Google for details on JSON, but basically a complete datapack file looks something like the following (indentation & newlines added):

while(1);
[
[
["tag1","string1.1","string1.2","string1.3","string1.4","string1.5"]
,["tag2","data2.1"]
,["tag3"
,[]
,[]
]
,["tag4",number4.1]
,["tag5",number5.1]
,["tag6","string6.1","string6.2","string6.3","string6.4",number6.5,
number6.6,number6.7,"string6.8","string6.9"]
.
.
.
.
]
]

Each pair of brackets is a data structure. Given a complete datapack file and a complete description of each tag, including its name and the ordering and individual descriptions of each of its various subordinate data fields, one could format the contents for display as the GMail application did originally.

Here’s what I’ve got so far (no subfield descriptions, sorry):

Keyword/Tagname Description
["gn", Account Name
["st", Server name
["qu", Account Quota
["ds", Folders
["t", Message List (Thread)
["cs", Conversation Summary
["mi", Message Information/Index
["mb", Message Body (This is where the meat is)
["ma", Message Attachments (Number & Filenames)
while(1); GMail Data Packet header (beginning of file)
["i", Invitation
["ft", Fast Tip (no I don't know what that means)
["ct", Categories/Labels/Contacts
["ts", Thread Summary (Similar to Conversation Summary)
["te", End of Thread List
["v", GMail Version

"So where do I find the files that contain this content?", you ask. Sad to say, sometimes you don't. The reason that this data is sometimes lying around to benefit a forensic analyst is largely because of browser bugs or lack of proper support for the no-cache HTML meta tag. This data isn't supposed to be written to disk in the first place, but due to a number of issues outside the scope of this article, it often is. I understand that support is improving for this in newer browser versions, so most GMail forensics may soon be a thing of the past. Then again, some people are still running Windows 95 (shudder) so this will probably be useful for a while at least.

When the files are cached, you will find them named "mail[somenumber]“, and located either in Temporary Internet Files, or wherever your tool of choice puts files it can’t identify the previous location of. You’ll also quite often be able to find these files in unallocated space by searching for the various keywords I’ve specified. Additionally, you will find other files in the same places named “mail[somenumber].htm”. While these contain other ‘stuff’, there’s often some JSON as described above buried inside them.

Finally, the most useful part of this is the “mb” datapacks, which contain the formatted body of a message. All message body elements found in a given file belong to the same message, and can simply be concatenated to produce a mostly readable body. The following UNIX/cygwin shell script can be applied to a datapack file to render any message body it might contain back into more-or-less displayable HTML:

for I in $*
do
cat $I | grep \"mb\" |while L=`line`
do
echo $L| \
sed -e s/\\\(\\\\n\ \\?\\\)\\+/\/g \
-e s/\\\\u003e/\>/g \
-e s/\\\\u003d/=/g \
-e s/\\\\u0026/\\\&/g \
-e s/\\\\u003c/\ -e s/^,\\\[\"mb\",\"// \
-e s/\",1\\\]$// -e s/\\\\\"/\"/g \
>> $I.html
done


fuente:http://sansforensics.wordpress.com/2008/09/19/forensic-gmail-artifact-analysis/
done

If you liked this article, want to add something to it, or simply want to call me on the carpet for some inaccuracy, please feel free to leave a comment.

References: (Some may not be available to those without Guidance Software portal access, sorry)

Slides from CEIC 2008 Presentation on Gmail Forensics

Codeproject page for GMail Agent API / Mail Notifier & Address Importer

Locating GMail Traces Article at ForensicFocus.com

A perl interface to Google’s webmail service

GMail Agent API/Mail Notifier & Address Importer

GMail Evidence - EnCase User’s Group Posting

Web Mail Question - EnCase User’s Group Posting

JSON (Google)

So, You Don’t Want To Cache, Huh?

John McCash, GCFA Silver #2816, is currently a Forensic Investigator employed by a fortune 500 telecommunications equipment provider.

A Metadata Format For CSV Files

0 comentarios

Using CSV files in batch processing applications has many advantages, most prominently interoperability between programming languages and tools. One of its weaker points is data integrity though. The format has no way to declare data types or additional metadata other than assigning names to data fields using a header.

The simple metadata format proposed in this article can help to mitigate this disadvantage.

A Case for CSV

First of all, why would anyone use such a simple plain text format? After all it’s just a semi-structured collection of data sets.

Sure, CSV isn’t exactly the most sophisticated data format available, but it has many advantages that make up for this flaw:

  • CSV is simple and well-understood.
  • There are libraries available for many programming languages or they can easily be written.
  • It can be analysed in a text editor.
  • Samples of a file can be loaded into a spread sheet application.
  • Files can be processed using standard Unix utilities.
  • It is easy to split CSV files into individual, self-contained chunks.

See The Pragmatic Programmer, "The Power of Plain Text" (chapter 3) for a more detailed discussion.

Unfortunately, there are disadvantages, too. Parsing the file format is usually a bit more expensive than for carefully designed binary formats (though it’s much cheaper than parsing XML). And since the ASCII representation of numbers can easily be three times as big as the usual binary representation, CSV files tend to be rather large.

Fortunately, streaming compressors like GZIP typically reduces files to about 20% of their original sizes even on the lowest compression ratio. Compression saves disk space and network bandwidth but it comes at a slightly increased processing cost. In many scenarios, however, the added overhead is negligible compared to the cost of the actual processing.

Using a Simple Metadata Format

There are basically three places where metadata can reside:

  • Inside the data file.
  • As a file next to the actual data files.
  • In a remote metadata repository.

If the data file format is extended to include metadata, we’d have to abandon the CSV format together with its advantages listed above. A remote metadata repository may be useful, but testing is a lot easier if you aren’t coupled to network resources, so a file next to the data seems to be the way to go.

The metadata format proposed here uses XML because it is human readable, well-understood and has excellent tool support (that should sound familiar). The format serves several purposes:

  • It declares the overall representation of CSV files (field separator, whether compression is used etc.).
  • It lists the set of files that make up the entire collection of data sets.
  • It defines the data fields and their respective types.

Here’s an example of how it looks (see the Relax NG Schema for the semi-formal definition):






















fuente:http://unmaintainable.wordpress.com/2008/04/26/metadata-for-csv/

This format is pretty much self-explanatory, except for the data field declarations which use data mining terminology. The continuous type is for floating point numeric values, while the categorical field can be compared to enums in programming languages like C. The optional missing attribute defines how an unknown (aka NULL) value is represented. Of course, different and/or more data types with arbitrary
restrictions could be defined.

The data fields have to be listed in the order they appear in the CSV files. Reading applications may choose to accept any order though. Field names have to be unique and may not contain the field separator for obvious reasons.

Depending on policy, applications can either ignore unknown elements (or attributes) or flag an error. There’s also the option of declaring optional parts of the format in a different XML namespace. Some applications can use those elements while others may ignore them safely.

There are several ways of extending XML schemas, either by explicitly allowing unvalidated content (usually in a different namespace) or by including the basic schema from another, more specialized schema that extends definitions as necessary. Updating the base schema can be done via namespace and/or schema versioning, but since this isn’t entirely trivial I’ll leave it for a future article.

A Note on Container Formats

When you split your files into multiple chunks for parallel processing, you end up with lots of files. To avoid confusion and to simplify transfer between systems you might be tempted to use a container format that packages all your data into a single file (using tar, for example). This may work in some cases, but if your data files are large and created in parallel, the creation of the container is a long and I/O-intensive operation. In batch operations this causes a significant overhead that you have to subtract from your time window.

A compromise is to use a natural but cheap container format: A file system directory. It may only be a "virtual" container, but combined with a proper delivery protocol, it’s still useful.

The Delivery Protocol

If you’re handing collections of CSV files from one system to another make sure you follow a simple protocol: Copy the data files first and the metadata file last. The delivery isn’t complete until the metadata file is there. The best approach is to take advantage of the atomic renaming feature many file systems provide (see the rename(2) syscall on Unix). Copy the metadata to a temporary file and then rename it. That way the receiver will never try to read an incomplete file.

The Verification Process

With the information contained in the metadata file, it is easy to verify the CSV files as much as required. The most basic check would only make sure that all of the listed files are there and have the declared file sizes. A simple consistency check would parse the headers to see if all data fields are there. This would also detect if the field separator is correct.

The most thorough check would then go through all of the files and make sure the data fields match their declarations. Since this is extremely expensive, it should usually be a side effect of regular processing rather than an up-front operation.

Recovering Open But Unlinked File Data

0 comentarios

Recovering Open But Unlinked File Data

By Hal Pomeranz, Deer Run Associates

If you’ve ever been a Unix system administrator, you may have encountered “open but unlinked” files in the course of your normal duties. The typical scenario is a user who’s launched a process that creates an unexpectedly large output file which consumes all of the free space in the partition. In a panic, the user deletes the output file but leaves the process running. Unfortunately, the operating system is not allowed to reclaim the space until the last process that has the output file open actually exits. So until the user kills their process, the space is still in use and the file system is full. But when you as the system administrator logs in to free some space in the partition, you’re unable to find the massive file that’s consuming all of the space with your normal file system tools because the file has been unlinked (deleted) from the file system. Finding the process that’s holding the file open and killing it would free the space, but that requires some specialized knowledge and trickery which we’ll see a little later.

In an incident, attackers have been known to use open but unlinked files to hide their data. For example, suppose the attacker were running a packet sniffer that was capturing usernames and passwords off your network and storing it in a file. Perhaps they have another process that’s reading the data as it’s placed in the file and using some covert channel to move it off system. At this point the attacker could delete the data file: the packet sniffer would continue writing data to the file and their reader process could continue reading the data because they opened the file before it was removed from the file system, but the system administrator would have trouble locating the file because it’s now unlinked from the file system. In fact, the attacker can even delete the executables for the packet sniffer and the reader process from the file system and the current processes will continue to run.

This kind of open but unlinked file data can be difficult to recover from a “cold” system image, because the minute the system is shut down and the attacker’s processes are terminated, the data in these files just becomes part of the free block collection and must be recovered like any other deleted file data. However, if you have the luxury of analyzing the running system, it is extremely easy to spot and recover this kind of file data.

Creating Our Test Case

As a stand-in for our attacker’s hypothetical packet sniffer, I’m going to start a tcpdump process and have it dump its packet captures into a file. Since I plan on removing the tcpdump binary as part of my demonstration, I’m first going to make a copy of the binary in /tmp:

# cp /usr/sbin/tcpdump /tmp/tcpdump
# /tmp/tcpdump -w /tmp/capture &
[1] 12437
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
# ls -l /tmp/tcpdump /tmp/capture
-rw-r--r-- 1 root root 4096 2009-01-21 18:08 /tmp/capture
-rwxr-xr-x 1 root root 639416 2009-01-21 18:07 /tmp/tcpdump

So far, so good. Our tcpdump process is running and has captured a little bit of data. Now I’m going to remove the binary and the output file and verify that the process is still running:

# rm /tmp/tcpdump /tmp/capture
# ls -l /tmp/tcpdump /tmp/capture
ls: cannot access /tmp/tcpdump: No such file or directory
ls: cannot access /tmp/capture: No such file or directory
# ps -ef | grep tcpdump
root 12437 12289 0 18:08 pts/1 00:00:00 /tmp/tcpdump -w /tmp/capture

Great! The process is still active, but neither the binary nor its output file are visible to standard Unix tools like ls. Now let’s have some fun.

The Power of lsof

It turns out that the highly indispensible lsof utility has an option for detecting exactly these open but unlinked files:

# lsof +L1
COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
init 1 root 0u CHR 5,1 0 623 /dev/console (deleted)
init 1 root 1u CHR 5,1 0 623 /dev/console (deleted)
init 1 root 2u CHR 5,1 0 623 /dev/console (deleted)
wineserve 10510 hal 31u REG 254,1 16777216 0 42233 /tmp/.wine-1000/server-fe05-4ee00e/anonmap.WKvI4J (deleted)
firefox 10826 hal 60u REG 254,4 8200 0 139466 /var/tmp/etilqs_wkK3U9h1sAcQpD3 (deleted)
tcpdump 12437 root txt REG 254,1 639416 0 25463 /tmp/tcpdump (deleted)
tcpdump 12437 root 4w REG 254,1 65536 0 25500 /tmp/capture (deleted)

The “+L1″ option is translated as “show me all files with link count less than one”– in other words, “show me all files with link count zero” which is just another way of saying “files which have been unlinked from the file system”. It’s almost anti-climactic how easy it is to spot these files with lsof.

However, the above output also demonstrates another important aspect of this discussion: not all open but unlinked files are necessarily cause for concern. There are a few processes that are common to the Unix/Linux platform that sometimes make use of open but unlinked files as part of their normal operations. This is clearly a situation where one must “know thy systems”– be familiar with how the operating systems you’ll be investigating appear during normal operations– so that you can spot discrepancies. That being said, programs that I’ve seen regularly using open but unlinked files include the Linux init process, Firefox, the Wine Windows emulator (all of which you can see in the output above), and VMware Server.

OK, at this point we’ve spotted the open but unlinked files, but how can we recover the data that’s in them? The lsof output above gives us the inode numbers for the files if you look in the “NODE” column (25463 for our deleted tcpdump binary and 25500 for the output file). This means we could use a tool like icat from the Sleuthkit to dump the contents of these files. But it turns out that there’s another approach that doesn’t require any tools that aren’t already present in most Unix-like operating systems.

/proc to the Rescue!

The lsof output also gives us the process ID of the processes with open but unlinked files. In this case, our tcpdump process is PID 12437. Let’s head over to the /proc/12437 directory and see what we can see:

# cd /proc/12437
# ls
attr cpuset io mountinfo oom_score smaps
auxv cwd latency mounts pagemap stat
cgroup environ limits mountstats root statm
clear_refs exe loginuid net sched status
cmdline fd maps numa_maps schedstat task
coredump_filter fdinfo mem oom_adj sessionid wchan

There’s a lot of interesting data in /proc, but for our purposes the “exe” object is the first interesting thing: “exe” is always a copy of the binary image of the running process. So all we have to do to recover the deleted executable is make a copy of this “file” under /proc. Obviously in a real incident you wouldn’t want to copy the file back into the file system of the compromised machine because you’d potentially be overwriting important evidence. You’d either want to copy it to a portable drive you’ve connected to the system, or move the executable off the machine via the network with a command line like:

# cat /proc/12437/exe | nc 192.168.1.1 9999

This assumes you’ve got a machine acting as a “collector” at 192.168.1.1 with another netcat process listening on port 9999/tcp and writing the incoming data into a file.

Just to prove to you that this works, however, let me just copy the binary into my local file system and demonstrate that the result is a working executable:

# cp /proc/12437/exe /tmp/testing
# /tmp/testing --version
testing version 3.9.8
libpcap version 0.9.8
Usage: testing [-aAdDeflLnNOpqRStuUvxX] [-c count] [ -C file_size ]
[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -Z user ]
[ expression ]

Again, in a real incident you wouldn’t just blindly execute a suspicious program you’d recovered in this manner. You’d only want to experiment with a copy of the executable in an isolated “sandbox” type system.

OK, so what about recovering the data file that the tcpdump process is writing? If you look at the directory listing of /proc/12437, you’ll notice that there’s an object called /proc/12437/fd. “fd” here stands for “file descriptor” and /proc/12437/fd is actually a directory that contains links to all files this process currently has open. Let’s take a look at this directory in more detail:

# ls -l /proc/12437/fd
total 0
lrwx------ 1 root root 64 2009-01-21 18:14 0 -> /dev/pts/1
lrwx------ 1 root root 64 2009-01-21 18:14 1 -> /dev/pts/1
lrwx------ 1 root root 64 2009-01-21 18:12 2 -> /dev/pts/1
lrwx------ 1 root root 64 2009-01-21 18:14 3 -> socket:[4197672]

Fuente:http://sansforensics.wordpress.com/2009/01/27/recovering-open-but-unlinked-file-data/
l-wx------ 1 root root 64 2009-01-21 18:14 4 -> /tmp/capture (deleted)

Notice that the link names are named for the internal file descriptor number used by the process, but the names of the files associated with these file descriptors can be clearly seen, along with the fact that the /tmp/capture file has been deleted.

The cool thing is that you can use these links as arguments to normal Unix file system commands. For example, if you wanted to copy the data in the deleted file over the network to your capture workstation:

# cat < /proc/12437/fd/4 | nc 192.168.1.1 9999

There’s a little bit of subtlety to the command above. Notice that I’m not just doing “cat /proc/12437/fd/4″, because that would only give me a snapshot of the contents of the file at a particular instant in time. Instead I’m using input redirection (”<”) to dump the current state of the file and then continue reading data and dumping it into netcat as it’s being written into the file. Our cat process will only terminate when the tcpdump file closes its output file. This is one of the things that makes this approach superior to just using a tool like icat to dump the current state of the file.

Some Final Thoughts

It’s fairly uncommon to find attackers making use of open but unlinked files in this manner. But if you’re accessing the compromised system anyway– for example to capture a memory dump before you shut the machine down– it doesn’t hurt to run a quick lsof command to check for any instances of these files. In the cases where they do exist, the techniques described above can allow you to quickly recover some information that is typically critical to analyzing what the attacker is doing to your system.

Also, don’t forget about the /proc//cwd link, which is a link to the current working directory of the process. If the attacker was foolish enough to start the suspicious process from their rootkit installation directory, you may be able to zero-in on the compromise in record time!

Hal Pomeranz is an independent Computer Security/IT consultant and SANS Institute Faculty Fellow. He wants to name his first child “Elesso’ef Slashproc”, which probably means it’s a good thing he’s not planning on having kids.

Powered by Bad Robot
Helped by Blackubay