Archive for the 'Hacking' Category

PQA – Query Analyzer for MySQL/PostgreSQL

Wednesday, October 27th, 2004

I found a nice program PQA written in Ruby to show query statistics based on database logs. That sound like almost exactly what I needed, so I tried it on MySQL MT log files and some other data. There were a few bugs that I fixed.

In addition I added a new report printing unique queries and when they occurred. It seems to work fine and with help of awk/make/gnuplot generated a few nice graphs.

Getting a class name from a static method

Monday, October 25th, 2004

public class ClassFromStatic { public static void main(java.lang.String[] args) { someStaticMethod(); }

public static void someStaticMethod() 
{
    System.out.println("I'm in " + new CurrentClassGetter().getClassName() 
        + " class");
}

public static class CurrentClassGetter extends SecurityManager 
{
    public String getClassName() 
    {
        return getClassContext()[1].getName();
    }
}

}

Bind forwarding

Monday, October 25th, 2004

One of the problems with DNS cat is that the sefver may be already running a DNS server. Multiple servers cannot share a single port 53.

The workaround is “DNS forwarding”. (more…)

Java non-blocking I/O

Wednesday, October 20th, 2004

Java SUCKS! Platform independence doesn’t come with a high price. The last two days I have been trying to do asynchronous non-blocking I/O and got really frustrated. Moreover, I come to think that what I really wanted is simply not possible.

Correction – Java sucks LESS ;-) It’s not so well documented though…

I have a fully functional non-blocking IO for Java 1.4. It is multithreaded and it works great. (more…)

Changing permissions hack

Wednesday, October 13th, 2004

chmod -R go=u,go-w /directory

Copying user’s permissions to group and others, clearing write permission (all this to merely preserve x for directories without setting it to all other files).

PPP over SSH

Friday, October 8th, 2004

WHY?????? WHY NOT? ;-) Run this on client:

pppd noauth debug nodetach  10.0.0.1:10.0.0.2 pty 'ssh user@server "pppd noauth debug nodetach notty "'

It works, even if the server asks for password, as it uses a direct terminal I/O, not stdin. Note that for noauth option pppd needs to be run as root (otherwise, some authentication options have to be set).

BTW Chris found this link. I think our one-liner is much nicer ;-)

Tracking connection length

Friday, October 8th, 2004

Inspired by discussions with Ashish, here are some thoughts on tracking connections in Linux.

PROBLEM: flag TCP/UDP connections longer than XXX seconds as suspicious. (more…)

DNS Tunnelling

Wednesday, October 6th, 2004

I got DNSTunelling to work. It’s a PoC code now, but it works. I managed to get ppp up and send a few packets and even SSH to the other computer! The more I think about it, the more I am convinced that the choices I made were not the bad ones.

  1. The use of PPP instead of TUN/TAP – makes the application more language independent (no need for ioctls, fnctls), supports compression, authentication, etc.
  2. The use of dnsjava package – maybe not the fastest one but the code is nice, understandable, doesn’t segfault and the whole thing is only 400 lines of code.
  3. The use of DNS structures – CNAME, instead of IP – it is standard and allows to transmit quite a few data in the CNAME record

(more…)