Add imsnif and link it against uclibcxx (#2128)
authorFlorian Fainelli <florian@openwrt.org>
Sun, 9 Nov 2008 15:33:26 +0000 (15:33 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sun, 9 Nov 2008 15:33:26 +0000 (15:33 +0000)
SVN-Revision: 13145

net/imsnif/Makefile [new file with mode: 0644]
net/imsnif/files/imsnif [new file with mode: 0755]
net/imsnif/patches/001-openwrt_paths.patch [new file with mode: 0644]

diff --git a/net/imsnif/Makefile b/net/imsnif/Makefile
new file mode 100644 (file)
index 0000000..138d9a4
--- /dev/null
@@ -0,0 +1,58 @@
+# 
+# Copyright (C) 2008 OpenWrt.org
+#
+# $ Id:$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=imsnif
+PKG_VERSION:=0.04
+PKG_RELEASE:=2
+PKG_MD5SUM:=689c456f8edb77b9b4199a25514ac683
+
+PKG_SOURCE_URL:=http://kent.dl.sourceforge.net/sourceforge/im-snif
+PKG_SOURCE:=$(PKG_NAME)f_$(PKG_VERSION).tgz
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+PKG_UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR) -C $(PKG_BUILD_DIR) -xvf -
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/imsnif
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=+libpcap +uclibcxx
+  TITLE:=MSN Messenger sniffer
+  URL:=http://sourceforge.net/projects/im-snif
+endef
+
+define Package/imsnif/description
+  IMsnif is a simple program to log Instant Message activity
+  on the network. It uses libpcap to capture packets and
+  analyzes them, logging conversation, contact lists, etc.
+endef
+
+define Build/Compile
+       $(TARGET_CROSS)g++ $(TARGET_CPPFLAGS) -fno-builtin -fno-rtti -nostdinc++ \
+               -I$(STAGING_DIR)/usr/include/uClibc++ -I$(LINUX_DIR)/include \
+               -o $(PKG_BUILD_DIR)/src/imsnif \
+                       $(PKG_BUILD_DIR)/src/imsniff.cpp \
+                       $(PKG_BUILD_DIR)/src/util.cpp \
+                       $(PKG_BUILD_DIR)/src/msn_conntrack.cpp \
+                       $(PKG_BUILD_DIR)/src/msn_handlers.cpp \
+               -L$(STAGING_DIR)/usr/lib -nodefaultlibs -luClibc++ -lgcc_s -lpcap \
+                       $(PKG_BUILD_DIR)/src/pcap_stuff.cpp
+endef
+
+define Package/imsnif/install
+       $(INSTALL_DIR) $(1)/etc
+       $(INSTALL_CONF) $(PKG_BUILD_DIR)/docs/imsniff.conf.sample $(1)/etc/imsnif.conf
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/imsnif $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/imsnif $(1)/usr/bin
+endef
+
+$(eval $(call BuildPackage,imsnif))
diff --git a/net/imsnif/files/imsnif b/net/imsnif/files/imsnif
new file mode 100755 (executable)
index 0000000..12c2f28
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+#Copyright (C) 2007 RoadRunner.cx
+START=85
+
+start() {
+    [ -f /etc/imsnif.conf ] && /usr/bin/imsnif || {
+       cat <<EOF
+You have not created configuration file.
+Store your configuration as /etc/imsnif.conf
+EOF
+    }
+}
+
+stop() {
+    [ `ps ax|grep -v grep|grep -c imsnif` != "0" ] && killall imsnif
+}
\ No newline at end of file
diff --git a/net/imsnif/patches/001-openwrt_paths.patch b/net/imsnif/patches/001-openwrt_paths.patch
new file mode 100644 (file)
index 0000000..21d9a11
--- /dev/null
@@ -0,0 +1,62 @@
+diff -Naur imsniff.orig/docs/imsniff.conf.sample imsniff/docs/imsniff.conf.sample
+--- imsniff.orig/docs/imsniff.conf.sample      2005-05-23 21:14:06.000000000 +0300
++++ imsniff/docs/imsniff.conf.sample   2007-07-25 04:20:31.000000000 +0300
+@@ -1,7 +1,7 @@
+-daemonize = 0
++daemonize = 1
+ promisc = 0
+-verbose = 2
+-chatdir = /tmp/chats
+-debugdir = /tmp/debug
+-interface eth0
++verbose = 1
++chatdir = /var/log/imsnif
++debugdir = /var/log
++interface = eth0.1
+diff -Naur imsniff.orig/src/imsniff.cpp imsniff/src/imsniff.cpp
+--- imsniff.orig/src/imsniff.cpp       2005-09-02 15:52:28.000000000 +0300
++++ imsniff/src/imsniff.cpp    2007-07-25 03:14:00.000000000 +0300
+@@ -4,8 +4,8 @@
+ //char debuglogdir[1024]="/var/log";
+-char chatlogdir[MAX_DIR_LENGTH+1]="";
+-char debuglogdir[MAX_DIR_LENGTH+1]="";
++char chatlogdir[MAX_DIR_LENGTH+1]="/var/log/imsnif";
++char debuglogdir[MAX_DIR_LENGTH+1]="/var/log";
+ int daemonize=0;
+ char *currentversion = "0.04";
+ int data_offset = -1;
+@@ -652,7 +652,14 @@
+               c--;
+       c++; /* Start of real name */
+       if (strlen (c) == 0) /* Uh? */
++      { //Jake's hack to read default configuration file if it exists.
++              f = fopen("/etc/imsnif.conf", "r");
++              if (f!=NULL)
++              {
++                  read_file (f);
++              }
+               return 0;
++      }
+       if (strchr (c, '%')!=NULL) /* Prevent strange things */
+               return -1;
+       fn = (char *) malloc (strlen (c) + 11);
+diff -Naur imsniff.orig/src/util.cpp imsniff/src/util.cpp
+--- imsniff.orig/src/util.cpp  2005-09-02 15:27:58.000000000 +0300
++++ imsniff/src/util.cpp       2007-07-25 04:17:36.000000000 +0300
+@@ -254,11 +254,11 @@
+ #ifdef WIN32
+                       struct tm *stm;
+                       stm= localtime (&now);
+-                      sprintf (fn, "%s/imsniff_%04d-%02d-%02d.log", debuglogdir, stm->tm_year, stm->tm_mon, stm->tm_mday);
++                      sprintf (fn, "%s/imsnif_%04d-%02d-%02d.log", debuglogdir, stm->tm_year, stm->tm_mon, stm->tm_mday);
+ #else
+                       struct tm stm;
+                       localtime_r (&now, &stm);
+-                      sprintf (fn, "%s/imsniff_%04d-%02d-%02d.log", debuglogdir, stm.tm_year, stm.tm_mon, stm.tm_mday);
++                      sprintf (fn, "%s/imsnif_%04d-%02d-%02d.log", debuglogdir, stm.tm_year, stm.tm_mon, stm.tm_mday);
+ #endif
+                       FILE *o=fopen (fn, "a+t");
+                       if (o!=NULL)