Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Sunday, February 14, 2010

Hidding messages in icmp packets

Hello everybody. A new month, a new article (I wish I could do this so periodically).

Today I'm going to show you something that I've been playing with. As you probably know (if you don't, I'm just telling you now :-)), the ICMP packets provides an arbitrary data space right after the ICMP header. Normally, no one use it, since ICMP is a control protocol that has all its usage right inside of it, leaving this data space useless.

A few days ago, I saw someone connected on Cinetix (http://nomius.ath.cx) and he was just connected, but not on the IRC server and I didn't know who he or she was. So an idea started to flow around my head "What about if I could send messages with ICMP packets".

So actually this is what I did... I wrote a tool to put a message in the data space and send it using the ICMP type 7 which is unassigned (for example, ping is the type 8). The problem is that the kernel just drop type 7 (as we all assume) and the data space is also dropped in any icmp packet. So I wrote a kernel patch that print the message in the output of dmesg or /var/log/message if you have set KERN_NOTICE to be displayed (I think klogd -c 6 does).

With this, you can send to a friend a message of the kind "Hey. This is David, I'm online on irc (jabber or whatever), jump in!" and it will be displayed in the system logs as a kernel notice.

Please, take note that this is not a chat system, but an "emergency system", so don't start using it as an everyday conversation protocol. This also isn't a patch that should be in the kernel mainstream, since ICMP packets of type 7 is unassigned, and NOT a communication protocol.

What about security?
Well, you might start asking yourself this "What if someone from the outside starts flooding my logs with dumb messages?". Right, well, the answer to this is netfilter; use iptables to drop these kind of package. Something like this:
iptables -A INPUT -p icmp --icmp-type 7 -j DROP

As you might know or guess, you can also block only one IP address or accept from a certain network like this:
iptables -A INPUT -p icmp --icmp-type 7 \! -s 10.0.0.1/24 -j DROP

Use more complex rules creating policies like "if someone exceed the number of 5 ICMP type 7 packets in a minute, drop any packet from the IP address".

Enough with the talking... How do I use it?
Great, right to the point. So the steps:

1) First of all, patch and compile your kernel.
cd linux-2.6.31 && patch -p1 < patch_icmp_type_7_messages.diff

And compile and install your new kernel using the way you normally do (make config/menuconfig, etc...)

2) Then compile the icmp_send.c program:
gcc icmp_send.c -o icmp_send

3) Send a test message:
./icmp_send 127.0.0.1 "Hello world"

3) Check out the dmesg output:
./dmesg | grep "ICMP 7 Message"

Get it!
Anyways, this is a really nice thing to play with and I hope people find it useful. You can get the kernel patch and the ICMP message program from the links below.

patch_icmp_type_7_messages.diff
icmp_send.c

Have fun.

Friday, January 08, 2010

Using the ZTE MF 110 with 3g Movistar (Argentina) on Linux

Hello all,
Today I'm going to explain how to do something really simple. As some of you might already know, I got this year a EEE PC netbook (1000HA). I have to admit that this baby is going great, I'm running the latest Kwort on it and it's really resource saving if you know how to set it up correctly.
If I add this netbook a 3g connection, I can say that I'm online everywhere almost all of the time. Well, this is what happened... As most of you already know, I've been working for Accenture for over a year now and they provided me (and some of my co-workers) a 3g modem with internet connection, which is pretty nice.
So, on january 1st after all the people who came my home to celebrate the new year left I sitted on the computer to figure out how to make it work.
This is a ZTE MF 110, and I found some people who made it work (kinda) or those who plugged it in at ubuntu and said that it works OoTB. Well, this is true kind of, but I hate when you don't really know how things works. Also, I found some people who made it parcially work with wvdial, which is a nice tool also.
So, my quest was to make it work with plain pppd. And this isn't really hard to do if you know a little how to play with the AT commands.

Ok, let's put the hands in the mud, first of all, I'm one of those people who likes to have a latest kernel tuned for my device, so this implies that yeah, I compile my own kernel with almost every release... In this case we are compiling 2.6.32.2.
So, for this you'll need the usb mass storage system in order to be able to switch from it to the modem mode.
Device Drivers -> USB Support -> (Select your usb version, ehci, uhci or ohci) USB Mass Storage support

Now, this GSM modem (as several others) needs the serial support... Well, actually, this is a serial GSM modem that you want to jack into the USB bus. So you need:
Device Drivers -> USB Support -> USB Serial Converter support

This will create the usbserial module. And now, you need the GSM modem support. So for this, you have to select:
Device Drivers -> USB Support -> USB Serial Converter support -> USB driver for GSM and CDMA modems

I would recommend you to compile them as modules (M) instead of built in, as this isn't a feature that you will be running all the time, so you can unload modules and free some memory (not too much, but everything counts nowadays).

I'm assumming that you already have the PPP support, if not, it's in the device drivers and Network Devices. But if you're reading this, you might already know.

Now, everything is ready for us to set it up.

We need usb_modeswitch, this tool will allow us to switch from the "ZeroCD" mode to the modem mode in order to allow us to call our provider. Basically we need this config (/etc/usb_modeswitch.conf):
DefaultVendor=0x19d2
DefaultProduct=0x2000

TargetVendor=0x19d2
TargetProduct=0x0031

MessageEndpoint=0x1
MessageContent="55534243b8fe6681000000000000061b000000020000000000000000000000"

This config file will make the usb_modeswtich to swtich the device 0x2000, of the vendor 0x19d2, to 0x0031 sending the message pointed by MessageContent. If the usb_storage module is loaded and you run:
usb_modeswtich -c /etc/usb_modeswitch.conf

And then you run lsusb you'll see the product id changed from 2000 to 0031.

If you got here, now it comes to nice part.
In order for us to not use wvdial, we need a call script (also called chat script). I'm going to show you you the script I wrote (/etc/ppp/peers/chats/movistar):
ABORT BUSY ABORT 'NO CARRIER'
ABORT VOICE ABORT 'NO DIALTONE'
ABORT 'NO DIAL TONE' ABORT 'NO ANSWER'
ABORT DELAYED
'' ATZ
OK ATQ0\sV1\sE1\sS0=0\s&C1\s&D2\s+FCLASS=0
OK AT+CGDCONT=1,"IP","internet"
OK-AT-OK ATX3DT*99#
CONNECT \d\c

This basically it reads like this: abort in any of the conditions above (no carrier, no dialtone, etc...), then reset the modem waiting for nothing, initialize the modem, find out the CID for an APN GPRS, dial and connect. There's information about Hayes AT commands all over the web, so if you're interested you can google it yourself. :-)

Well, now we have to set up our user and password:
echo -e "internet\t*\tinternet" >> /etc/ppp/chap-secrets

And finally, the ppp configuration itself (/etc/ppp/peers/movistar):
lock
hide-password
noauth
connect "/usr/sbin/chat -v -f /etc/ppp/peers/chats/movistar"
/dev/ttyUSB2
460800
defaultroute
noipdefault
user "internet"
mtu 1492
ipparam movistar

Most of this options are self explanatory, but the importants one are the connect line and the "/dev/ttyUSB2" one. The first one tells pppd to use the chat program to connect the other point and the chat script that will be used (/etc/ppp/peers/chats/movistar, that we created before), if, for example, you set up a pptp connection you'll see this line pointing to the pptp client program. The second one tells pppd the modem device, maybe you have to play a little bit with this one trying /dev/ttyUSB2 or /dev/ttyUSB3 (if you don't wan't to try you can use minicom to find out, good luck with that :-P).

Well, now everything is ready to connect, you just need to run:
pppd call movistar

From now one, if you restart your laptop/netbook or normal PC, all you have to do is:
usb_modeswitch
sleep 1 # Let the device sync with the switch
pppd call movistar

Monday, December 14, 2009

New Kpkg hosting

Well, the C version of kpkg is now hosted at: http://code.google.com/p/kpkg. It would be cool if people start checking it out.

Upgrade support is working partially, as only one package at the time can be upgrated, I will try to finish the whole upgrade support soon.

If any people want to use kpkg in their personal distributions (I don't think ubuntu/suse/etc... users will want to run kpkg on their systems, but who knows), it would be nice to know.

Also patches to add more functionality, fixes or any kind of power, are always welcome.

Oh, and btw, the sqlite databases structures (for mirrors and personal systems) are included in datastructs.h. If you have any questions, please ask here or mail me. :-)

Cheers!

Wednesday, December 09, 2009

The kpkg issues

Hello everybody... Today I'm going to speak about kpkg.
Well, I wrote 4 package managers before I started kpkg, there was kwt-get, kum, kget and another one I can't remember.
With every package manager I wrote things where from a very simple start, allowing to install, search and remove packages to a more complex usage allowing several mirrors, dependencies resolution out of the box, and finally the idea of third party packages (this last idea appeared in kpkg), package series, etc.
Let's analyze those 4 functionalities:
1.- More than one mirror was something asked, but once I implemented, there wasn't more than 3 or 4 mirrors out there.
2.- Dependencies resolution is a huge deal, the real thing is that under the hood it sucks, and I see why big distributions with lots of developers has package managers supporting this feature, as they have several developers who everyone takes 10 or 20 packages, build them and fill the databases with the dependency tree. The fact is that this feature is bad implemented in any distribution, it shouldn't be something that the developer has to fill (the database with its dependencies), it should be something auto generated at build time, I don't know, a file listing its dependencies generated by configure (when using autotools) or something similar. I could spend like an hour talking about this feature since I made 3 different implementations of its resolution algorithm.
3.- Well, third party packages (also known as tpp). This actually wasn't a feature it was a way to deal with an inconsistency in kpkg, the fact that packages were registered in mirror databases, if one was repeated, it has to be a "third party package", so kpkg (without any environment variable altering its normal course) treated it as a non identified package (or a package provided by a third party developer not included in any mirror). Of course someone could deal with this using environment variables (MIRROR, STANDALONE and SERIE). So installing a package from the console without having it in a mirror and keeping the database clean without tpp was a huge deal. With tpp, kpkg tried to do, with the same tool, what debian does with a separated tool (dpkg).
4.- Series was kinda one of those features that supposed to help but didn't, in fact, it complicated things. If you start looking at a package system you think "Great, series, this is a way to pre-hash every package", well, it kinda did that job, but complicated all other things, actually this feature was one of those that pushed the "third party packages" "feature".

Despite with dependency resolution (now, a few years back it was supported), kpkg support all this features. By this time you might be asking "Why god why this package manager is so complex and twisted"... Well, the fact is that even I hate kpkg nowadays.
Also, as most of you might know, kpkg is written in bash, with leave us a lot of issue. Why? Well, kpkg makes use of several console tools included in packages like coreutils (ls, rm, mktemp, md5sum, etc), findutils (find), sed, awk, grep, wget, tar, lzma, etc... Can you imagine what could happen if you try to update for example the coreutils? Well, to understand this question and being able to answer it, you need to know some of the kpkg internals, but summarizing what kpkg does is "Download the new package, remove the old package, install the new package", and almost every package managers do this (there's also some other algorithms to deal with this but you need to save more data of every file included in the package). Now, if you upgrade to a new version of, for example, the coreutils, what kpkg do is: "Download the new coreutils, remove the old coreutils, install the new coreutils", if you remove coreutils kpkg starts failing pathetically leaving your system out of use (sorry, toilet cleaning :-P) and we all have to pull the shades down and go home.
In fact this happened some weeks ago and a user came to me with insults, ranting and all the bad things you can imagine. Well, he was right about my mistake, but I'm human and I can make tons of those (and thank god we all still making mistakes, it's a proof that we still humans) and the fact is that no one is paying me for developing Kwort and all its tools, so take it easy.
Anyways, this leave us to the fact that we can't upgrade some (several) packages and with them, of course, the libc.


So, I'm dealing with all this problems re-writing kpkg in what we can call "kpkg new generation" (LOL, it even sounds cool eh? :-P). How I dealed with all this problems? Well, some of those original "features" were dropped, "dependencies resolution" was out of the table way before starting, "series" support was removed as with the new database it isn't needed anymore, and third party packages was also dropped since the new approach is more consistent. What about the fact that you can't upgrade several packages? Well, kpkg is now written in C and static compiled (so everything can be upgraded :-)).

The new kpkg use sqlite3 as database backend, libarchive for package decompressing (giving us support for tgz, tbz2, tar, lzma, xz, zip, etc) and libcurl for package retrieving which leave us support for tons of protocols. And every piece of the code is very well documented with doxygen which will help everyone who wants to read the source code.

So far, the new implementation of kpkg (in C) has support for almost the same options (search, install, remove, provides, update and download) the actual kpkg has, and only the upgrade support is the only one missing (I hope I have time to code it this week). So I will try to upload the source to github as soon as I can, so everyone can start to find bugs in it and improve it.

See you soon guys, and if I don't before Christmas, Merry Christmas :-)

Cheers!

Monday, October 12, 2009

Vim bug using tags

Well, lot of people know that I'm a vim fan and that I use it everyday, to me is like the killer app that everyone should know how to use in Unix.
Even at work, I'm a programmer (doing C on Unix now), and some of my fellows were using Eclipse and after I show them Vim, they was like "woooo, I can use this editor as an IDE and still can use my machine for do something else while programming" (I was like, blame the one who introduced you to Eclipse :-P).

Anyways, I like using tags, allows me to browse the code really fast (for those using Eclipse, I think is like if you press F3 over a function name). But I found this weird behavior using ctags+vim. See the above code:
  1 #include <stdio.h>
2
3 int asd(int s,
4 char a);
5
6 int main(int argc, char *argv[])
7 {
8 asd(1, 's');
9 return 0;
10 }
11
12 int asd(int s,
13 char a)
14 {
15 return s;
16 }

When I press ctrl+] over asd in line 8, it takes you to the 3rd line instead to the 12th...
There's a "workaround" to this behavior, using --excmd=number while running ctags put the line numbers in the tags file (without this option ctags puts just an 'f' identifier to tell the editor that it is on that file). But it is just a visualization workaround, because you can't put any new line (or remove) in those files or your tags file will screw the tags file.

Does anyone knows a solution to this issue?

Thanks.

Tuesday, September 29, 2009

Kwort 3... The big change

Hello everybody. This is just a flashlight of what Kwort 3 will be.
Kwort 3 brings a whole new era of Kwort Linux, Kwort public might change now, I'm not focusing anymore in inexperienced users, but on intermediate-advanced users and up.
Why is that?
Well, kinda I'm forced to that. Kwort's most important problem was always the kernel, not because Linux is bad, but because some drivers are.
For example, wireless drivers tend to suck... I mean, WTH is that closed source microcode needed for most drivers? That's just plain wrong. I'm not talking here about making it free software, but open source would help everybody to make better drivers. Also there are tons of wireless cards out there unsupported (or half supported) because companies not releasing specifications, we are not even talking about open source anything here. COME ON!
I'm not going to take this to the free software vs. open source vs. closed software, people who know me, knows that I hate those topics and I leave those to politicians and software philosophers.

Despite of that, some other things are not easy (as it should be) to support, and inexperienced users tend to not know what they want (first they want a desktop, then they want to be able to configure a web server with a GUI (that I'm not going to write) for some php scripting , then they want to create a RAID or LVM). Kwort was always meant to be for the desktop, and the desktop only, not a web server not a redundant file server, etc.
And the funny part is: If you don't provide packages for what they want, they get pissed off and I've also got insults because of this. People, what is going on here? It's not like you're paying me (and if you would, that doesn't even give you the right to insult me), you can ask for something. I develop Kwort in my free time.
So, advanced users tend to know a lot more, from the work that takes to do something like Kwort, to how to check logs and write or hack some script to do what they want (for example a network configuration script).

So... Kwort 3 is now based on CRUX which will make it more advanced. I'm not changing it to CRUX because I want it to be hard and for truly advanced users, but because Slackware has become a really multi-purpose distribution, and strip out all the "unneeded" stuff for Kwort would take me a lot of time.
Also the init system has changed and the way it is configured too. Don't worry about all this, it is already well documented in the new website (this new one is really cool, with tons of information as it always should be but never was). There's no more wizards tools like knm (Kwort network manager) and kum (Kwort user manager), but a console and the chosen editor. Despite of that kum and knm will still be maintained and developed.

Anyways, Kwort 3 is almost ready be released. There's a beta release already that everyone can test (there are some testers already doing a great job that helped me a lot).

Sorry for not having you all up to date related to Kwort, but I've been working a lot and in my free time I try to develop Kwort. For example, now, I'm in my lunch time, and I passed out lunch in order to write something for you about the new direction of this project.

Cheers.

Sunday, July 12, 2009

Thunar and hard drive partitions

Hello everybody, It's been so long since my last post here.
There's so much to talk about, but today I'm going to talk about Thunar. As some of you might know, thunar is the file manager used in Xfce, written by Benedikt Meurer, and nowadays maintained by Jannis Pohlmann.
I really like thunar, but the fact that hard drive partitions are left to the distribution itself when hal can manage them and because of that the file manager also can, isn't really nice, as you can browse your partitions in newer versions of GTK's (with Gvfs) GtkFileChooser.
An ugly workaround would be to mount them and add some gtk bookmarks, but you would like to set an emblem to differentiate them from normal bookmarks, and emblems are not part of the gtk library, so you wouldn't see emblems in a GtkFileChooser. Another issue would be that isn't dynamic, so if someone change partitions that would be a total mess.
So IMHO the best solution to this is: Hard Drive partitions managed by hal (DeviceKit in the future) and let Thunar show them in the left pane. And this is what I actually did.

So, as everybody loves screenshots and you probably want to see how this looks:



And finally, the patch: http://dcortarello.googlepages.com/Thunar-1.0.0-hd-partitions.diff

Enjoy!

Thursday, April 09, 2009

Kwort Linux 2.4.1 released

I’m happy to announce that Kwort 2.4.1 final is here!


This version took a year to develop and provides a lot of changes from 2.4 release, including a new, more cleaned up than usual, base system, whole new tool chain, new configuration tools and lots of new things.


Good things in this new version:



  • Kwort’s init system: From 2.4, the init system has evolved keeping its simplicity but providing some new features.

  • Linux 2.6.28.7: A lot of hardware support was included since the kernel included in Kwort 2.4.

  • Kpkg: The new version of kpkg include several new features as the adoption of multi-mirror support.


  • Kwort User Manager: Re-written from scratch it Provides a simple way to create and remove users with a new interface.

  • Kwort Network Manager: Also re-written from scratch, allows you to configure your network (wired and wireless), as manage your dns and hostname system. It also allows you to switch wireless drivers.

  • Xfce: This new version brings a lot of changes under the hood making the desktop more extensible.

  • Audacious: This is the default music player since Kwort 2.4.1 allowing you to play your music in a very simple way.

  • Our new Google group (http://groups.google.com/group/kwort-linux): Ok, this has nothing to do with something included in the release, but it allows the developers behind Kwort to communicate between them and also with the users (who are what Kwort is all about).


As in every old version now comes the things that I look forward to improving:




  • Thunderbird: It’s kind of sad, but thunderbird isn’t yet full “xulrunnized”, so starting firefox+thundebird brings two copies of xulrunner up to memory, which as we all know, is kinda in the chubby side.

  • Audacious: Although audacious is pretty good doing its job, I think a jukebox is more needed these days, as people needs more information while playing their music. It is known that using gstreamer would take out some of the features audacious brings, but we have a full-featured media-handling components and using those frameworks would allow the Linux desktop to improve, communicate between applications and to remain simple.


People who I would like to thank:

Andreas Schipplock as always for making and maintaining the website, mirroring the Kwort iso image, and kind of playing a role of resources manager that allows me to develop easily Kwort.

Sebastian Reisse for writing the kpkg manpage, and for taking a lot of his time testing every release candidate, if it wasn’t for him, this release would come with several bugs.

The Aircable people for their donations as they helped me to buy some hardware I was needing for develop Kwort.

The mirror providers as usual, the people from PGHosting and Ricardo Brisighelli for the package mirror in the UNR.


Finally, but not less important a very big THANKS to Patrick Volkerding for Slackware Linux, the system Kwort is based on.

The Xfce developers (core and goodies) who made 4.6 a lot more simple to configure for distributions and provided help when needed.

The people who develop every project Kwort includes. I hope I didn’t forget anyone.


As usual, if you need support, help, or you just feel like talking about Kwort (or anything else), or you just want to meet the people who is behind Kwort, you can join us on IRC or our Google group:



  • IRC: irc://irc.oftc.net/Kwort

  • Google Group: http://groups.google.com/group/kwort-linux


–

David B. Cortarello

Monday, February 09, 2009

Lots of stuff going on

Well, it's been 3 months since my last post, and I've been doing a lot...

Let's start with Kwort. Well we're just there from the release, lots of new improvements are being done around it, and something really interesting is the new network manager and the new user manager I wrote from scratch with a completely new design using gtkdialog.

The new network manager allows you to configure your ethernet and wireless network, supporting static and dhcp, for wireless network, support for several encryption mode are available, from wep to wpa2:



The user manager stills very simple but with a very simple and smooth interface:



So, as you can see we have almost everything, since looking at the screenshot the Xfce settings manager is in it, so Xfce is kinda there, so you might be questioning "What are you waiting for a release?" Well, Xfce 4.6 is in release candidate time, so when they release it final we'll see how's the Mozilla people going with Firefox 3.1, since it would be really cool to ship it with Kwort 2.4.1. I wouldn't matter to ship a beta 3 with 2.4.1, but we'll see, since beta 3 should be released already according to Mozilla's Firefox schedule, and their delivery meeting is schedule to the end of the month (February 25th), which is just around the corner.

Resuming, lots of improvements are going on and I'm trying to make it pretty cool and easy for the end user.

That's just for Kwort, now... Some friends saw I was migrating to git, and yeah, I did, since in the past I used git with gitorious.org which didn't convinced me, I came back to darcs. But now, I discovered GitHub which is really cool, fast and easy to use and with lots of guides around, so you can see and follow my work at: http://github.com/nomius.
I have to admit here that I was influenced at work by warlock, which is the author of the wbar, to move from darcs to git, so I found a darcs2git python script and it was like charm.

Also, I implemented lots of cool new features for kpkg, and I merged kpkg with the kwort network manager and user manager making a "big" project called kwtools. Looking right now at the master tree page, you'll see this: "Implemented kpkg search /all with csv support" and you might be asking "What the hell is this guy making with kpkg implementing stuff like this?", well, I hope this feature is just enough, but basically, it is because a friend, x-ip, and I we are writing a graphical interface for kpkg, at the moment the interface is pretty rough but does show the idea, of course, icons and all that stuff is going to be implemented with also a more eye-candy interface, so you can see a preview of the application here:



As I said before and as you can see, the interface looks pretty rough, but give us some time and you'll see how cool it looks. I doubt we get in time to include this new tool in Kwort 2.4.1, we'll try, but I really doubt it since I'm just learning python, which is the language we use to write this, and x-ip is just learning wxPython with me, which is the framework we use for this.

Please, if you have any ideas for Kwort or any of the tools/applications I write, please write me, it would be nice to hear (read) about you and your ideas, and also, I don't know... help maybe? :-)

We'll, this post is already becoming large so I'm off to bed now. Have a nice week and see you around guys.

Saturday, November 01, 2008

Updates!

Well, it's been a long time in the road since my last post here. This weblog isn't over, but I been doing a lot of things and didn't got the time to write something.

Ok, things I've been doing:
* I wrote a new network manager for Kwort 2.4.2 (I'm already working on a new Kwort version), screenshots are coming
* I also wrote a new user manager for next Kwort also. Screenshots are ON the way. :-D
* A friend of mine (Jp) is working on a new init system which is very cool, so Kwort will use it.
* Bought a pretty cool (4 cores) new computer (Desktop). I would like to thank to the aircable.net people who helped me to buy my new computer with a donation. (A BIG THANKS TO YOU GUYS)
* Working... :-)

Anyways, I want here to point to two links, the first one if from my good old friend Andreas Schipplock, he made a small list of interesting links to read and/or hear. The second one is to the "Open Unix Society" which is a cool place full of documents and books for learning.

Online video lectures
Open Unix Society



Btw, I took a position at iProgrammers and I'm working at Accenture now as a Senior Programmer.

Monday, August 11, 2008

NQqueue 0.3b

I'm just releasing NQqueue 0.3 beta.
This is just a bug fix release and it is beta because of the new spamassassin plugin; I wrote this one on sunday, but since I don't use spamassassin (I have servers running dspam), I can't test it.

This is just a release asking for people to flood my inbox with feedback on the spamassassin plugin, the configuration parameters are the same used with the dspam plugin, so only "pass" parameter is allowed, or empty.

In case you have doubts on how to configure NQqueue, you can read this:
NQqueue 0.2 + Configuring NQqueue + Configuration schemes


So, get latest NQqueue release here: http://europa.fapyd.unr.edu.ar/releases/NQqueue-0.3b.tar.gz

Enjoy!

Thursday, July 17, 2008

NQqueue 0.2

Well, I just tagged NQqueue as 0.2. Several changes has been done from 0.1. For those who doesn't know, NQqueue is a threaded queue for qmail with support for plugins. Full details of what nqqueue is can be found here: http://nomius.blogspot.com/2008/06/nqqueue-what-is-that.html

Download the latest release version here: http://europa.fapyd.unr.edu.ar/releases/NQqueue-0.2.tar.gz

Changelog can be found here: http://europa.fapyd.unr.edu.ar/darcs/NQqueue/Changelog
If you want to get nightly builds packages. Use this link: http://europa.fapyd.unr.edu.ar/darcs/NQqueue/NQqueue.tar.gz
Darcs repository: http://europa.fapyd.unr.edu.ar/darcs/NQqueue

NQqueue stills in development, it is stable enough, but there are some things that must be fixed before the next release.

Plugins included:

  1. General plugins:

    • black - Parameters:
      • user@domain - email address to put in the blacklist.

    • clamav - Parameters:
      • "pass" - will make the email pass even if it contains a virus (used to send it to a quarantine).
      • None parameter given will block a containing virus mail.

  2. User plugins:

    • dspam - Parameters:
      • "pass" - will make the email pass even if it considered spam (used to send it to a quarantine).
      • None parameter given will block a spam considered email.

    • quarantine - Parameters:
      • "all" - will send to quarantine any email that was considered spam or that contains a virus.
      • "dspam" will send to quarantine any email that was considered spam.
      • "clamav" - will send to quarantine any email that contains a virus.
      • "q=" - allow the administrator to set the quarantine type. Allowed types of quarantines are:
        • general - will put the email in /var/qmail/nqqueue/quarantine.
        • vquad(VHOME) - will put the email in your vpopmail home (ex: vquad(.Spam), will put your email in Maildir/.Spam/cur). [vpopmail support must be given in configure script]

Example of common usage:
This example shown here will block an incoming email from billgates@microsoft.com, put emails containing virus to general quarantine (in /var/qmail/nqqueue/quarantine/domain/user), and deliver spam considered emails in Maildir/.Spam/new (which is the personal user spam directory in his vpopmail home).
  • /var/qmail/control/general.cfb
:clamav=pass;black=billgates@microsoft.com
  • /var/qmail/control/mydomain.com.cfb
dspam=pass;quarantine=clamav,q=general;quarantine=dspam,q=vquad(.Spam)

I hope people start using nqqueue, since it is fast, secure, flexible and very easy to use.

Wednesday, July 02, 2008

ktsuss 1.4 released

Well, the people of wicd asked me for some modifications in ktsuss so they could support it as they do with gksu.
These modifications were made in the weekend; also bug fixes has been done, and as it looks very stable I'm writing a post release announce here. :-)

Changelog can be found here
Also, you can follow ktsuss development in my darcs server here
Latest ktsuss download link here

Bugs and feature requests are always welcome :-)

Cheers!

Tuesday, June 24, 2008

NQqueue? What is that?

As some people asked me the last few weeks what I've been doing I've decided to take some time to write this and explain what NQqueue (aka nqq) is all about.
Well, some of you maybe listened (or read) me telling that queues for qmail are bloated. We don't have several choices, there is just plain qmail-queue which is unfeatured, qmail-scanner (aka give me my CPU back) which is the bloatest one, and simscan which is kind of featured, fast, but not extensible at all, both of the last ones are buggy when getting an email with several Rcpts (they only analyze one. Which is a big bug).
So, because of all this, I've been using simscan, I actually extended it from those 2000 lines to 4000 adding features. But it became so big, that it is hard to maintain and to trace errors in it.
This situation drove me nuts the last year so I decided "Why I don't just write my own qmail queue?". Well, NQqueue is the result of this self asked question.

Let me show you and tell you some of the features of NQq:

* Modular - not like simscan with a big file with all the problem.
* Pluggable - this is what NQq is all about, it support the addition of plugins. There are some now in the darcs server.
* Threaded - this is quite a nice feature for mails with several Rcpts, nqqueue triggers a thread for every Rcpt to be analyzed.
* Fast - This is like simscan. But it improves it when analyzing more than one Rcpt because of the threads.
* Secure and reliable - I been working quite a lot on this, since simscan has several bugs, and I didn't want this on NQq.

Plugins: Well, some of you might be asking "Dude, nice, but how do I write a plugin for NQq?". Well, first of all, I have to tell you that there are two types of plugins:
1st. we have the general plugins. Those plugins are run to an email before to trigger all the threads for every rcpt. Why is this? Well, it would be dumb to call for example a clamav plugin for every user (in every thread). So for example we can write a plugin that should not care about the Rcpts and/or From, like clamav, since it depends on a general database.
2nd. besides of general plugins, there are also per user plugins. These plugins are run in every thread. This is the example of a spam plugin, since it depends on a special per user database.

So now I can show you a small general plugin to block a Sender:

/* vim: set sw=4 sts=4 : */

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <nqqueue.h>

#define PLUGIN_VERSION "1.0"
#define PLUGIN_NAME "black"
#define REJECTED_MESSAGE "Message rejected because of black list"

char *plugin_name()
{
return strdup(PLUGIN_NAME);
}

char *plugin_version()
{
return strdup(PLUGIN_VERSION);
}

/* Parameters:
* params = a char pointer with parameters used to call the module (in this case, the email address to block).
* mail = It's a char pointer to the filename that contains the email.
* From = a char pointer with the From email address. (if it matchs the param, the mail would be blocked)
* Rcpt = an union that contains space for a char pointer (if user pluing) or a pointer to a PUStruct
* struct (if general plugin).
* general = a pointer to a RSStruct struct, which is structure with all the plugins and its return values
* already runned by general plugins
* peruser = a pointer to a RSStruct struct, which is structure with all the plugins and its return values
* already runned by per user plugins
*/
struct ModReturn *plugin_init(char *params, const char *mail, const char *From, const union Tos Rcpt, \
struct RSStruct *general, struct RSStruct *peruser)
{
struct ModReturn *ret = malloc(sizeof(struct ModReturn));

ret->NewFile = NULL;
if (!strcmp(params, From)) {
ret->ret = 1;
ret->rejected = 1;
ret->message = strdup(REJECTED_MESSAGE);
}
else {
ret->ret = 0;
ret->rejected = 0;
ret->message = NULL;
}
return ret;
}


Looks easy don't you think? So, how do we make NQqueue to load our plugin? Simple: in /var/qmail/control/general.cfb put a line like this:
:black=billgates@microsoft.com

That will set the sender billgates@microsoft.com as a blocked server. In fact, this plugin acts just like a black list.
Now your question might be: And how can I block more? Well, you can call the plugin several times, like this:

:black=billgates@microsoft.com;black=steveballmer@microsoft.com

Or you can modify the plugin_init function to allow more than one email (like black=billgates@microsoft.com,steveballmer@microsoft.com) and do some simple parsing with strtok.


As you can see it is very easy to write plugins for NQqueue. I know it stills need a lot of documentation, since at it is now, it's very poor in this aspect. The only documentation in NQqueue so far is a configuration scheme in the NQqueue darcs in case you want to know how to configure it right (it's very easy).

So, those are some of the features in NQqueue there are more of course, but those are enough to mention.
NQqueue needs a lot of testing, so I'm counting with all of you to run tests. Also documentation is needed, and it will take some time to me to write it, so people wanting to write documentation are welcome. Also people writing plugins, I wrote some which are already in my darcs server (a dspam, clamav, blacklist and quarantine) modules.


You can follow NQqueue's development in my darcs server at: http://europa.fapyd.unr.edu.ar/cgi-bin/darcsweb.cgi

Sunday, May 04, 2008

My darcs repository

So, on friday after some times I set up myself to finish the nqqueue. But then I started to see where to version the project.
In the last couple of years I been using berlios, which is great, and I really like it, but there was this issue: "svn/cvs only". So, I started to take a look again at subversion, and found it even more annoying than before (LOL).
I made a request to the berlios team 2 years ago asking for darcs support, but none of the admin team answered. Actually, berlios is kind of abandoned, as nobody takes care of answering to bugs, issues, and features requests... Kind of sad.

A friend of mine gave me this hint about using git so I said "Why not?", let's try it. I spent the whole saturday trying and testing it, and fortunately lots of features absent in subversion existed in git. But stills very complex, specially setting it up was kind of annoying.

By the end of saturday I was kind of dissapointed because of this, so I asked to the people in irc.freeonde.net/#darcs if there was any projects repository outhere using darcs... As expected, the answer was a "NO".

Then I saw the light when "Why don't I create a darcs server?" came to my mind. So, I created a darcs server at europa.fapyd.unr.edu.ar (static IP). But only with ftp access since it was the only thing installed on it. So for example someone could get or pull kpkg like this:

darcs get http://europa.fapyd.unr.edu.ar/darcs/kpkg

When that worked, I decided that there was something missing, and it was the hability to get from http and the web interface. So finally, I installed a simple and small webserver (shttpd) and brought darcsweb to it. Now, it is working and people can follow the development very easily. I even made a modification to the cgi (a python script) to allow people to get a release from the darcs cgi web inteface.

You can see my darcs server up and running here: http://europa.fapyd.unr.edu.ar/cgi-bin/darcsweb.cgi

One thing to look forward is the upload patch cgi (http://europa.fapyd.unr.edu.ar/cgi-bin/upload.cgi), which is a perl script that accept patches from post in the format message/rfc822 (mail format) and deliver those to a Maildir in the server, so then I can apply those. Fancy, don't you think? :)

Ohhh, one last thing... If you follow the links, you'll see the NQqueue (You shouldn't even know about this unless I told you. Eventually I'll drop a comment on this) in the repo, please, don't try it unless you feel very adventured, since there is no release so far, and it has some nasty bugs to be fixed, features to be implemented before to schedule for a release, and the modules API is not yet stable. It is only there so you can check it out (and maybe help if you want?). When NQqueue gets stable, I will drop a release with drums and cymbals. But so far, the code is very unstable!

Wednesday, April 09, 2008

Hanging up switches and bridges

This issue came up today with some people and I did affirmed that you can hang up your switch with some funny code...
How this come? Well, very simple, switches and bridges has a small stack (10 bytes per host connected to it) where they save IP and MAC addresses to know where to send a package once the sender and the receiver are known. So, once the first package is sent, a new entry in the stack was made. So now you know the "theory" I'll leave you to think how could this help you to hang it (Let me give you a hint: OVERFLOW).

Anyways, get the code you'll need to produce this overflow from here: http://dcortarello.googlepages.com/pkinject

Keep in mind that you'll need the pktgen kernel module to run this.
See also that I did this 3 years ago with bash, not even C code, so it shows how easy is to generate network packages to produce this effect, which isn't a big deal when it comes to reproduce it, but to create a security policy to avoid it.

Have fun.

Saturday, March 29, 2008

Kwort 2.4 released

I'm proud to announce that Kwort 2.4 final version has been released after a very long time (more than a year). The system is very stable and very usable.

The core system is based on Slackware and provides a rock solid system, and it's also a great place to start making a full featured and usable desktop environment using Xfce.
This version includes several changes from 2.2 from a new toolchain to a completely new base system. The inclusion of hal provides a great way to communicate the hardware with the desktop making the system a lot more user friendly.

Good things in this new version:
  • Hal: As I said before provides a lot of new features giving the desktop some kind of control of the hardware.
  • New init system: Kwort 2.4 includes a new init system written mostly from scratch. Also it puts all the work together with the new service command.
  • Linux 2.6.24.3: The latest stable version of the linux kernel.
  • Kpkg: The new version of kpkg was re-written from scratch.
  • Kwort User Manager: Provides a simple way to create and remove users with default Kwort templates.
  • Xfce: This new version integrate great with hal.
  • Ristretto: The image viewer of the Xfce project.
  • Mplayer: The most famous video player on Linux is now included in the iso.
  • Pidgin: The latest version of the best multiprotocol IM.
  • Mpd+Gmpc: This is the new combo to play media files in Kwort. Just put your media files in ~/Music, go to gmpc, give update and play.

As in every old version now comes the things that I look forward to improving:
  • Better support for wireless devices: This is not part of Kwort itself, but the kernel, but finally affects Kwort users.
  • Amule: Once again amule is giving the hebbe-jeebes. There is no stable version of amule that works well enough with Kwort. The latest version is dated from middle of 2006 wich is very old and buggy with newer versions of wxGTK.
Screenshots available here: http://kwort.org/?page=ScreenshotView

People who I would like to thank:
Andreas Schipplock for making and maintaining the website, mirroring the iso, working in Kwort core (he made most part of the job with Core) and bring lzma support to Kwort.
Stijn Seger for working in some packages like openntpd and the pm support. And writing the Kwort user manager.
I would like to give a special thanks to the users who ran tests specially to David Luskovec and Juan Martin Villanueva, if it wasn't for you guys, this iso would take even longer to come out.
Manuel Naranjo for reporting bugs, submiting patches for the new init system, hosting the iso and run test all along Kwort core.
Also, I would like to thank all the mirror providers: Ricardo Brisighelli for the development mirror in the UNR, Alberto Ferrer for the mirror in Emanon Linux and the AIRcable people for the mirror at aircable.net.
Finally, but not less important a very big THANKS to Patrick Volkerding for Slackware Linux, the system kwort is based on. I hope I didn't forget anyone.

As usual, if you need support, help, or you just feel like talking about Kwort (or anything else), or you just want to meet the people who is behind Kwort, you can join us on IRC: irc://irc.oftc.net/Kwort

Monday, August 20, 2007

Some flashlights of Kwort 2.4

Well, me and the rest of the team are working in Kwort 2.4 (2.2.2? I dunno, but I think 2.4 will be alright).

Andreas Schipplock (aka Avarus) is working on the core system and as far as I know he is making a remarkable work on it.
One of the most important parts is the lzma compression for the packages, so the final iso will be smaller than the Kwort 2.2 one. He is now working on the installation system, so when he gets done I'll put Kwort desktop on it.



Stijn Segers is working on the new interface for the users admin system (as my mockup looked very bad :-P), so once he finishes with it I will make a Xfce plugin of it and include it in the mcs settings manager.
He will also take care of the kernel. So this time, getting kernel source to compile drivers won't be needed and as he told me we will include some drivers by default like those free ralink ones. But kernel work stopped until 2.6.23 come out, as that one will be the one for Kwort 2.4.

And it's time to tell what I'm doing... Well, until Andreas and Stijn doesn't finish I'm still maintaining 2.2 serie including and upgrading packages (http://www.kwort.org/?page=MorePackages).
But until that happens I'm checking projects and taking decisions for the desktop and in core (helping Andreas and Stijn). Today I did some user custom actions for kwort packages:


For those paranoids (I know you guys are right about this), ktsuss will be included and all those sudo commands will be removed (sudo will still be included, but not used for anything else but xfsm-shutdown-helper). So this custom action showed above use ktsuss in case you ask.


Oh, another interesting things are the fact that kwort is listed in www.xfce.org/download/distros as a Xfce distribution and Kwort being used in school (COBAEH - Cuautepec de Hinojosa - Hidalgo - México) with old machines (Pentium MMX 200Mhz with 32MB ram).

Well, that's all for now folks, I will keep bringing Kwort newsflash :)

Friday, July 27, 2007

Knowing the network speed at a given moment

Well, a friend of mine asked me for this, and it was very interesting to understand what was in /proc/net/dev.

#!/usr/bin/env bash

if [ -z "${1}" ]; then
echo "Give a network interface"
exit 1
fi
DEV=${1}
/sbin/ifconfig ${DEV} >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Please, do man 8 ifconfig to know what a network interface is"
exit 1
fi
LINE_OLD=$(cat /proc/net/dev | grep ${DEV})
sleep 1
LINE_NEW=$(cat /proc/net/dev | grep ${DEV})
while [ "${LINE_OLD}" = "${LINE_NEW}" ]; do
sleep 0.1
LINE_NEW=$(cat /proc/net/dev | grep ${DEV})
done
OLD_DOWN=$(echo ${LINE_OLD/*:/} | awk -F " " '{ print $1 }')
OLD_UP=$(echo ${LINE_OLD/*:/} | awk -F " " '{ print $9 }')
NEW_DOWN=$(echo ${LINE_NEW/*:/} | awk -F " " '{ print $1 }')
NEW_UP=$(echo ${LINE_NEW/*:/} | awk -F " " '{ print $9 }')
REST_DOWN=$((${NEW_DOWN} - ${OLD_DOWN}))
REST_UP=$((${NEW_UP} - ${OLD_UP}))
if [ ${REST_DOWN} -gt 1024 ]; then
echo "DOWNLOAD: $(echo "scale=2;${REST_DOWN}/1024" | bc -lq)k/s"
else
echo "DOWNLOAD: ${REST_DOWN}b/s"
fi
if [ ${REST_UP} -gt 1024 ]; then
echo "UPLOAD: $(echo "scale=2;${REST_UP}/1024" | bc -lq)k/s"
else
echo "UPLOAD: ${REST_UP}b/s"
fi

You can run it this way for example:
while true; do ./netspeed eth0; done


See you guys in the next few days to tell you something new :)

Saturday, March 10, 2007

Kwort Linux (to be released) and Kpkg (released)

Kpkg 2.4 was released some minutes ago, you can download it from here: http://prdownload.berlios.de/kpkg/kpkg-2.4.tar.gz

This version is a bug fix release, now PKG_GOOD and PKG_FAIL works with upgrade as it should and I fixed a weird issue due to a scope problem in bash functions.

As usual, release notes and Changelog can be found here

That's about Kpkg. Now, let's go to the important business. Kwort 2.2 final version will be released in the next couple of hours as some bugs (I hope no more appear) were fixed. The most important upgrades of this final version are kpkg and dialog. Not important upgrades were aaa_base and freedesktop packages that were modified to avoid annoying messages during the install.