[Typo3] Highlighting currently displayed news in tt_news list view

In a current web design I encountered the problem, that the designer wanted a list of the current news to be displayed in a permanent visible box below some static information. By clicking on the news entry on the list it should be shown to the customer in the single view. Additionally to this the currently shown entry should be highlighted in the list of news in the permanent box.

The permanent box could easily be created by some Typoscript code. The code is shown for completeness below:

tempNews < plugin.tt_news
tempNews{
  templateFile = fileadmin/ext_template/tt_news_v3_template.html 
  displayList.subheader_stdWrap.crop = 40 | ... | 1
  displayList.subheader_stdWrap.append >
  pid_list = 3
  code >
  code = LIST
 #Seite auf der die Einzelnews angezeigt werden sollen
  singlePid = 23
  excludeAlreadyDisplayedNews = 0
}

The single view could be created as a standard plugin element on the page with id 23 in my example.

The challenge was to get the entry on the list view highlighted, when the single view of the current entry is displayed to the user, as tt_news does not provide any mechanism or hook for doing so.

Therefore the change required some coding in the template, where an additional Marker had to be added to the list item. A minimum example can be seen in the code below. The marker is later on used to determine, whether the class of the current element should contain the active-tag.

<div class="news-list-container">
	<!-- ###CONTENT### begin
		  This is the part of the template substituted with the list of news:
	-->
		<!-- ###NEWS### begin
			Template for a single item
		-->
			<div ###NEWS_CLASS###>
			  <h2><!--###LINK_ITEM###-->###NEWS_TITLE###<!--###LINK_ITEM###--></h2>
			  ###NEWS_SUBHEADER###
			
<hr class="clearer" /></div>
		<!-- ###NEWS### end-->
	<!-- ###CONTENT###  end -->
</div>

At last a little change to the tt_news source code was required. Namely some lines of code had to be added to the file typo3conf/ext/tt_news/pi/class.tx_ttnews.php to determine, if the selected news entry equals the one, which should be rendered for display in the list.

Therefore I added the following lines in the
function getListContent($itemparts, $selectConf, $prefix_display)
after line 1037:

// reset ATagParams
$this->tsfe->ATagParams = $pTmp;
$markerArray = $this->getItemMarkerArray($row, $lConf, $prefix_display);
                       
if($row['uid'] == $this->tt_news_uid){
$markerArray['###NEWS_CLASS###'] = 'class="news-list-item active"';
} else {
$markerArray['###NEWS_CLASS###'] = 'class="news-list-item"';
}

Keep in mind, that the modification in the source of tt_news will be lost after updating the extension to a newer version. Therefore you should keep the changes in your mind and apply them again after an update

The post above was tested with Typo3 4.5.32 and tt_news 3.5.1

Posted in Internet, Programming, Typo3 | Leave a comment

[Sleuthkit Development] Source Code structure

If you just want to start developing for TSK the organization of the source might be somehow confusing and it can be frustrating to crawl through all directories to get an overview.

Therefore I’ll here provide a short overview of the relevant directories for extension developers for TSK. The relevant directories in the source root are:

  • tools (this directory contains the C++ code files for the command-line tools of TSK. An overview of these tools can be found here. If you want to develop a new tool using the TSK framework or modify an existing one, this is the right position. If you want to write a FS extension or something similar, the files here are only partly interesting.)
  • tsk3 (This is the directory, which contains the code of the framework that is responsible for file system analysis and other cool things. These files are the heart of the sleuthkit and this directory will probably be the one you are mostly working in)
  • win32 (this directory contains the Visual Studio Project files, if you want to devlop using the Visual Studio on Windows)

Due to the fact, that the directory “tsk3″ is the most relevant one, the containing folders are explained now:

  • auto (this directory contains some source files for database access and automated file extraction)
  • base (this directory contains the source files, which provide the basic functionality of TSK, which for example are allocation of memory, error handling, printing of messages, various definitions of flags and some functions for changing and determining the endianess of data. You should definitely have a look at tsk_base.h and tsk_base_i.h)
  • docs (what can I say… documentation generation files and so on)
  • fs (this directory contains the file system related sources, for example ext2fs.c for EXT2, xfs.c for XFS support or other systems. If you want to extend TSK with a new  FS, this is the right point. The x_lib.c files also contain some specific code for the tools, which are named at “x”. The directory also contains some files with fs_xxx.c – these files contain file system independent functions for processing several things.)
  • hashdb (source code, which is responsible for hashing)
  • img (this directory contains the source files which contain the functions responsible for processing different image types. If you want to add support for some new image format, you are right here)
  • sorter (contains the config files for the sleuthkit sorter for various systems)
  • vs (this directory contains volume system ['vs'] specific source code)

I hope this helps some of you during the first steps!

Posted in IT Forensics, Sleuthkit | Leave a comment

[Sleuthkit Development] How to start developing

It has been a while since my last post, but in the next weeks there will be many new stuff to discover due to my latest work on a Sleuthkit extension.

The Sleuthkit (TSK) is an open source IT forensics toolkit (http://www.sleuthkit.org/). The sleuthkit homepage already provides a wiki and some articles about the development of the Sleuthkit itself, but as I had to experience first-hand these resources are only partly helpful when trying to develop an extension for TSK (in my case the extension with XFS support). Therefore I’ll try write down what I had to learn about the internals while developing.

So, if you want to develop for TSK you at first should go and clone the current source from the official GIT repository (URL and instructions can be found on the Sleuthkit homepage).

Directly after cloning the source my first challenge occurred (I have admit, that I’ve been not very experienced with Linux ;-) ): How can I compile the source for the first time?

In general this can be accomplished by the following 5 commands (I assume you are in the directory, which contains the source!):

  1. autoreconf -fiv
  2. ./configure –prefix=/usr
  3. make
  4. sudo make install
  5. sudo ldconfig

Please note, that the following packages have to be installed on your system first:

  • autoconf
  • automake
  • libtool
Posted in IT Forensics, Sleuthkit | Tagged , , , , | Leave a comment

Can trains be hacked?

Hey guys,

for those of you, which are curious about safety in railroad systems and IT systems, which interact in the area of railway systems, I’ve some interesting link.

The following talk was held by Prof. Dr. Stefan Katzenbeisser during the 28C3, the 28th Chaos Communication Congress, in late December 2011. The first part gives an introduction to the switchboxes, which have been used in railroad systems since 1900 and also provides some basics. The second part discusses the ETCS standard and several weaknesses in it.

Enjoy the talk “Can trains be hacked?” (unfortunately the language is german) on YouTube:
Link to the Video

Posted in Railroad, Security, Signalboxes | Leave a comment

Transport Layer Security (SSL/TLS) – In Short

Anothe article, which I wrote some weeks ago for university. This time the Transport Layer Security is covered.

Abstract

This article deals with security in network communication and in this area especially with the protocol family of SSLv3 and TLS.
Therefore in the first section the general motivation for security in network communication will be given. Thereafter an overview of SSL/TLS will be given and afterwards an in-detail explanation of the establishment of a secure connection will be shown. At last some applications and protocols, which make use of SSL/TLS are shown and a final conclusion is given. Continue reading

Posted in Internet, Networking, Security | Leave a comment

Upcoming Article Series on Tracking and Anonymity

In the following weeks I am going to provide a series of articles, which elaborate on the topic of tracking the user behavior and browsing-habits in the Internet and the loss of anonymity, which comes along with this. Continue reading

Posted in Uncategorized | Leave a comment

Nimbus Look and Feel with Java SE 6 Update 26

Hey guys,
if you are interested in UI design for JAVA the “new” Nimbus L&F may be interesting. Below is the official graphic from oracle, which gives a brief look at the new style for Java UIs. It is included into the JRE since version 6.10 and maybe will be the standard L&F in Java 7.

Nimbus L&F (Source: ORACLE)

Oracle provides an article, which explains, how to use the new L&F in a Java application. For usage the following code should be included:

import javax.swing.UIManager.*;

try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
}

So far the way in which the things should normally work, but if it would be this easy I would not write this article ;-)
After trying the above mentioned code fragment, in my case, only the standard “Metal” L&F appeared, which was rather disappointing. The problem was that the Nimbus L&F is not found by the getInstalledLookAndFeels() method.

Therefore for using the L&F has to be set by hand with the following command:

UIManager.setLookAndFeel(“com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel”);

After this you will find your UI in a nice modern look.

Posted in Java, Programming | Leave a comment

Addressing and Subnetting in IPv4 Networks

As a first post in my blog I will present you some work on IPv4 Adressing and Subnetting, which I originally made during a lecture in university.

Abstract

This article deals with the adressing scheme of IPv4 and the ability of separating a given network into smaller subnets. Therefore at first a short primer on the IPv4 addressing scheme will be given and it will be described why it is desirable to build many subnets instead of one large network.
Furthermore the function of subnet mask and IP adress will be shown. After this the building of a subnet with static and variable subnet mask will be shown. An at last it will be demonstrated, how IP address and subnet mask can be altered.

Introduction

Let us consider, a scenario in which we want to connect three or more end devices over an intermediate device. In this case it is not possible any longer to establish a direct cable connection between the end devices and we need to determine for every packet which end device is the destination. At this point the IPv4 address is used. The IP address is 32 bit long and every end device which wants to communicate over an IP network has to occupy one.
The IP address may be enough for serving source and destination for a communication, but if we consider that only one really large network exists, there would also be only one broadcast domain, which leads us to the problem, that a broadcast message, like it is produced by an ARP request, produces a number of responses, which cannot be handled any more. Also it is impossible to represent geographic or hierarchical structures. At this point the subnet mask, which also has a length of 32 bits, is called into action. Due to the subnet mask it becomes possible to divide a network into smaller subnets.

Networking Primer

In an IPv4 network the address consists of 32 bit, which for a better presentation to the user is normally displayed in form of four integer values ranging from 0 to 255. Some of these 32 bits are used to determine in which network the host is located (the so called ‘Network Portion’) and some of these bits are used to identify the host itself inside of this subnetwork (the ‘Host Portion’). To determine, which of these bits are used for which purpose, the subnet mask is used. Besides this every network has two reserved addresses, which cannot be used by an host system. These two addresses are the network address, which determines the beginning of the network, and the broadcast address, which is the last address in every network and is used to send messages to every device in this network.

For resolving the network address the networking equipment is able to compute the network address from the full ip adress by simply AND-ing the ip address and the subnet mask. The process is shown in the figure below. Often in networking-related literature it is the case, that the subnet mask is directly appended to the network address, like 192.168.1.0/24. In this case the number on the right side of the slash tells the reader how much bits are used for the network portion.

Calculation Formulas

Building the subnet

When divinding a larger network the administrator has two possible options for building the subnets. He either can use classful subnetting (Fixed Length) or classless subnetting (Variable Length).
Classful subnetting is the easier method, because the subnet mask only has to be computed once and is used for all subnets. Due to this fact all subnets are of the same size, which however is a wasteful variant, because you are not able to build special purpose mini subnets (like for router connections).
With classless subnetting this problem is solved, because subnets can be tailored to the number of users in the group, for which the subnet is set. Therefore different subnet masks are used.

Fixed Length Subnet Mask

A Fixed Length Subnet Mask is used in classful subnetting. Due to the fixed subnet mask all networks are of the same size. The process of classful subnetting is now described in detail.

Let us consider a network as shown in figure EX1. On the left we need enough addresses for 256 host. On the right we have a single host directly connected to Router1 and an additional network consisting of 20 hosts. Furthermore we have to bear in mind that we also have a network between the Router0 and Router1, which use a DCE serial connection. Our available network is 220.128.64.0/21 (subnet mask: 255.255.248.0). As we can see 11 bits are currently left for host adresses.

This leads us to the following requirements:
Net1 = 256 hosts
Net2 = 20 hosts
Net3 = 2 hosts (Router1 ↔ Router 0)
Net4 = 2 hosts (Router1 ↔ PC1)

For building the subnet mask we have to take a look at the biggest subnet, which in this case has 256 hosts. After adding the broadcast and network adress we eventually need 258 adresses. Therefore we need 9 bit for assigning an address to every host in this network. This finally leads us to the following:

So our resulting network has the following configuration:

Overall subnet mask: 255.255.254.0
Net1: 220.128.64.0 (BC: 220.128.65.255)
Net2: 220.128.66.0 (BC: 220.128.67.255)
Net3: 220.128.68.0 (BC: 220.128.69.255)
Net4: 220.128.70.0 (BC: 220.128.71.255)

As it becomes obvious we are possible to solve the above described problem, but due to the enormous difference of the net sizes we waste many addresses (e.g. In Net3 for example 508 addresses are wasted).

Variable Length Subnet Mask

A better aproach for building a subnet is the classless subnetting, because the subnet masks in this aproach have a variable length, which means, that you can combine very large networks and very small networks without a enormous waste of address space. For using VLSM the network should at least support RIP v2, OSPF, EIGRP, Dual IS-IS or BGP.

Now we will again build a subnet for our demo configuration (details on this configuration can be found above), but this time we will utilize VLSM.
In a first step we have to find out how much bits each of our networks will need for addressing all hosts inside:

Req. Hosts Req. Hosts + Structure Bits needed Max. Hosts
Net1 256 258 9 512
Net2 20 22 5 32
Net3 2 4 2 4
Net4 2 4 2 4

After having found out, how much bits we need for the representation of the host portion and fitting the individual subnets to the smallest possible size, it should be obvious, that this principle will save us a lot of address space. In the next step we have to calculate the network address, the subnet mask and the broadcast addresses for each of the subnets.
This leads us to the following result:

Network Address Subnet Mask Broadcast Address
Net1 220.128.64.0/23 255.255.254.0 220.128.65.255
Net2 220.128.66.0/27 255.255.255.224 220.128.66.31
Net3 220.128.66.32/30 255.255.255.252 220.128.66.35
Net4 220.128.66.36/30 255.255.255.252 220.128.66.39

Viewing and changing IP Address and Subnet mask

In the following section the methods for setting and viewing the ip address and the subnet mask are shown.

Windows

On a windows machine the user has several possibilities to change the ip address. The first way is to go to locate the symbols for the active network interfaces and then modifying their configuration by selecting the properties of the IPv4 protocol for this device. The configuration window of Windows 7 is shown beneath.

A faster accessible way is using the command-line of the windows system. Then the user is able to manipulate and view the settings with either the tool ipconfig or netsh, which also allows to import and export the interface settings.
For further information on netsh please refer to: netsh explanation
The typical output of ipconfig is shown below.

Linux

Every linux-based machine comes with the ifconfig tool, which allows it to either simply show the configuration of the network interfaces or manipulate the settings for each interface by using the command-line.
For further information please refer to: ifconfig explanation

Resources

  • Network Fundamentals, V4.0, Cisco Networking Academy
  • IP Adressing and Subnetting Workbook, V1.5, Cisco Networking Academy
  • VLSM – Variable-Length Subnet Mask Workbook, V1.1, Cisco Networking Academy
Posted in Networking | Leave a comment