Monday, December 26, 2011

Notes/wish list/TODO's...

... for me.
Some of these projects will be posted here in some weeks or months - i hope.

Finished projects:
  • uploading the executable and source of "bool_solver 2"
  • "The (dirty) 7zip password cracker" with exe and source
  • brute forcing [code snippet]

Unfinished projects:
  • Presentation of the project "Dieselpunk PC"
  • Some words about the Open Logic Sniffer
  • Creating a VBS (Video Baseband Signal) with an 8051 (+ Open Logic Sniffer)

Future projects:
  • Reverse engineering the Canon EF protocol with the Open Logic Sniffer

Creating random numbers on a µC [code snippet]

This is a small C function, to feed srand() with a random seed. I wrote it some weeks ago just to test if it would be possible to get random seeds with an 8051 microcontroller without additional hardware. And yes, it is possible. I was using an AT89C51ED, but the code should work with every 8051 compatible microcontroller.
How does it work and why? I took a closer look in the data sheet of the µC and i saw that some bits and bytes in the special function registers (SFRs) are not initialized with "1" or "0". Some bits were marked with "x" and those are the interesting ones. The value of those bits can be "0" or "1" after power up - their initial value is random. All i had to do was to iterate over all those SFR-bytes and XOR them. I am sure generations of 8051 coders have had the same idea, but i did not study all available information regarding 8051 and random numbers.
Just call the function like that "srand(getRandom());", and you will have a new random seed, after each power up of the microcontroller. (A normal µC reset will not give you a new random seed!)

unsigned char getRandom( void )
{
     unsigned char *random;
     unsigned char k;
     unsigned char value;
    random = 0x80; //Starting address of the SFRs
    for (k=0; k <= 127; k++) //iterate over the 128 bytes of the SFRs:
        value ^= random[k]; //XOR the values
    return value; //return the random seed
}

Sunday, September 25, 2011

Convert foobar2000 playlists into something useful

Because i had switched from Windows to Ubuntu (on my desktop computer) a week ago, i had the problem, that i had to say "good bye" to my favorite music player called "foobar2000", because he is only available for Windows.
I had some really cool online radio stations stored in foobar2000.
The biggest problem: foobar2000 stores the playlists (and my radio stations) in a non-open binary file format.

So I decided to write the program called "foobarConverter". It is capable to convert a foobar2000 playlist (".fpl") into ".pls", ".m3u" and extended ".m3u" playlists.
As it is written in Java, it should run on a variety of operating systems.

The program is freeware for non-commercial use.

Example of usage:
xxxx@ubuntu:~/$ java -jar ./foobarConverter.jar ../Radio_2011-09-09.fpl pls
Starting foobar2000 playlist converter.
Converting file to 'pls'...
Conversion done! :)

If you are interested in some details, look there: http://www.foobar2000.org/FAQ
(Question: "Are specifications of the FPL playlist format available? Why doesn't foobar2000 use some user-editable XML-based playlist file format instead?")

Have fun! :)

Saturday, July 23, 2011

New bool solver

Last year i released bool_solver - a little tool to convert boolean algebra into truth tables. I rewrote the program completely from scratch in C. It is now shorter and easier to understand than the old C++ version I hope.

Friday, July 22, 2011

Parsing source code files for function headers and function calls

Some weeks ago I wrote a small program, which is able to print a list of functions and function calls used in a program. It can parse a directory recursively for a given file type.

Here is the source code: functiondiagram.d
And here is the source as a "quote" (a function to present formated source code is missing on blogger.com...):
/*
    This console apllication written in D is able to parse C, C++, D and many more file types.
    It scans the files for functions and function calls and prints a list with all matches for every file.
    As first parameter you must specify a directory name, where the search will start. This folder will be scanned recursively for matches.
    The type of file must be specified by the second parameter.
  
    This code stands under the do-with-it-what-you-want license.
  
    Author: Energized
    E-mail: undervoltage@safe-mail.net
    Blog: http://electric-handicraft.blogspot.com
*/


import std.file;
import std.stdio;
import std.stream;
import std.regexp;

/*
TODO:
- Self defined data types are not recognized
- Comments will be parsed too. This can result in false "positives".
*/


/*
    Function is searching in a line of text/code for function calls and function headers:
*/
string[] returnFunctions( string data )
{
    string regex = r"([\w\d]+)\s*[(]";
    string[] rv;
  

    foreach( m; RegExp( regex, "ig" ).search( data ) )
    {
        if ( (m !is null) && (m.match(1) !is null) ) //is something was found:
        {
            //writefln("> '" ~ m.match(1) ~ "'");
            if ( RegExp( r"^(if|for|foreach|return|while|finally|try|catch)$" ).match( m.match(1) ) is null ) //is the match a reserved word?
            {
                rv ~= m.match(1); //if not, it will be part of our result

                //if no datatype is in front of the match, it is a function call:
                auto n = search( m.pre, r"^\s{0,}(string|bool|int|byte|char|long|short|float|double|void|signed|unsigned|HBITMAP)", "i" );
                if ( n is null )
                    rv ~= ";";
                else
                {
                    /*
                        If an assignment is done (function to variable), false positives will be produced.
                        Then the function call will be misinterpreted as a function header. Thats why we are searching for a
                        semicolon here. Is a semicolon in this line, it is a function call (or a forward declaration).
                    */
                    if ( std.string.find( m.post, ';' ) != -1 ) rv ~= ";";
                }
            }
        }
    }
    return rv;
}


/*
    Shows the result:
*/
void printTree( string[] data )
{
    if (data.length == 1)
        writefln( "\nFunction \"%s()\":", data[0] );
    else
    {
        foreach( t; data )
            if (t != ";") writefln("\t%s();", t);
    }
}


void main( char[][] parameters )
{
    string path = parameters[1];      //as first parameter the program needs a path name
    string extension = parameters[2]; //extension (like "*.cpp")
    string[] result = listdir( path, extension ); //crawl through all files with the given extension in the given directory and all sub directories and store the filenames in the "result" array.
  
    foreach( filename; result ) //scan one file after the other:
    {
        BufferedFile file = new BufferedFile( filename, FileMode.In ); //open the file for reading

        writefln( "\nFile: " ~ filename ); //print the filename
      
        foreach(ulong n, string line; file) //go through the lines and scan them for function names or function calls:
        {
            string[] functions = returnFunctions( line );
          
            if (functions !is null) printTree( functions ); //if the end of file is reached, print the result
        }
        file.close();
    }
}
 And here is an example, how the result looks like:

File: C:\functiondiagram.d

Function "returnFunctions()":
        RegExp();
        search();
        match();
        writefln();
        match();
        RegExp();
        match();
        match();
        match();
        search();
        done();
        call();
        find();

Function "printTree()":
        writefln();
        s();
        writefln();
        s();

Function "main()":

Function "extension()":
        listdir();
        BufferedFile();
        writefln();
        returnFunctions();
        printTree();
        close();

The program is not perfect yet. Some false positives are possible like in the example the function "s()" which is not a function but a regular expression.

Sunday, May 22, 2011

Old dosimeter disassembled

Today i have disassembled an old dosimeter. It is an old soviet model manufactered in (or for) east germany. I made some photos of it, so you can enjoy the old technology used in this device. ;D























Sunday, May 15, 2011

New firmware for the thermometer

Here is an up-to-date version of the clock-thermometer firmware: Thermometer4_-_LCD.c
Because of school I did not have much time to make improvements.

Tuesday, February 22, 2011

Some current and finished projects...

Last month i rewrote my bool solver from scratch. This time i wrote it in pure C - without C++ elements. It has almost all functions of the old version plus some new ones, but the new program is much shorter. Documentation and comments are in german... thats why i do not upload it.

Because the old firmware (version 4) of the AtTiny clock was pretty ugly, i rewrote and changed many parts of the firmware. The new version has the number 5. The new code runs like a charm and as a bonus it eliminates the problems i had with the buttons (it was not a hardware problem).
Release will be soon. Only a calibration function for the quartz is still missing. ^.^°

And one last thing: i disassembled my old Acer travelmate 220 notbook and under the sticker of an IC i found an Atmel AtTiny25 as part of the charging circuit. It communicates directly with the laptop battery through TWI/I²C. The foto was made with my Canon EO350 / Digital Rebel XT / Kiss Digital N with an hand hold lens in retro position - the IC was so damn small:

Thursday, February 17, 2011

Movie about the build of integrated circuits

A movie made by Fairchild semiconductor about building integrated circuits. The video is from 1967!

Fairchild Briefing on Integrated Circuits

I finally watched the whole video (i have never found the time till today)... interesting. :D

Sunday, February 13, 2011

UART - Video

In this small video, you can see a simple counter made with my UART board. The program for counting up the LEDs is running on a PC. The µC only communicates with the PC and is responsive to his commands.

video

Battery adapter

Yesterday i did a 5 minute hack.
Because i have lots of old AA batteries with some residual energy (i guessed) lying arround, but my mp3 player needs AAA batteries, i made this adapter, to make use of the old AA cells.


The AA cells were used in an old compact camera. They do not work in the camera any more - thx to the crappy cam! - but with one of those AA cells i was able to power my mp3 player for about 2 5 hours and the battery is still not empty!
Quite nice for a batterie which seemed to be empty. ;)

I think the images are self explaining.





Friday, January 7, 2011

UART - again

Here is a nice driver for Win2k + WinXP to enable the inportb and outporb commands under those systems: porttalk
This can be quite usefull, if you have old software, and you must work with those software - somehow.
The driver is quite nice. It works perfectly with my UART Testboard  example program (number 3).
I converted it from linux to Open Watcom (16 bit Dos).

Here is the output:

C:\Dokumente und Einstellungen\xxxx>D:\Programme\porttalk\AllowIo.exe D:\Program
me\WATCOM\projects\uart\test3\test3.exe
AllowIO for PortTalk V2.0
Copyright 2002 Craig Peacock
http://www.beyondlogic.org
Executing D:\Programme\WATCOM\projects\uart\test3\test3.exe with a ProcessID of
2089937184
PortTalk Device Driver has set IOPM for ProcessID 2089937184.

C:\Dokumente und Einstellungen\xxxx>

~RS232 Testboard~
Testing all possible combinations...

Handshake is: off
2400 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
2400 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
2400 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 0, hs: false... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 1, hs: false... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 2, hs: false... Device error: '0x00' UART error: 0x0000
Handshake is: on
2400 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
2400 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
2400 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
4800 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
9600 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
14400 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
19200 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
28800 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
38400 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
57600 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 0, hs: true... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 1, hs: true... Device error: '0x00' UART error: 0x0000
115200 Baud, p.: 2, hs: true... Device error: '0x00' UART error: 0x0000
End.

Monday, January 3, 2011

Black screen after upgrading from Ubuntu 10.04 to 10.10

After upgrading my Ubuntu from 10.04 to 10.10 i got only black screens or weird distorted graphics on my Acer Tracelmate 220 laptop with Intel 830 graphics card.

The solution for this misery:

  1. Boot in recovery mode with root console and log on
  2. change the xorg.conf settings to "vesa" ("enable VESA": https://wiki.ubuntu.com/X/Bugs/Mavericki8xxStatus)
  3. Then follow those instructions and set the "nomodesetup" for grub: http://ubuntuforums.org/showthread.php?t=1613132

This gave me back X11 and Gnome - finally! :D

.oO(It cost me only several hours to fix the da** problem...)

Sunday, January 2, 2011

UART toy - version 1.2

I made some modifications for the RS-232 Testboard.
Now the baud rate can be changed and the parity check can be enabled. Tons of other modifications, a new exciting sample program and lots of bug fixes were made too.

You can download the whole package (AVR source code, PC source code + libraries, drawing and the command list) here:
project.zip