Archive for January, 2007
Python: Projection project
Posted by JohannesTheDeveloper in Happy Hacking on January 26th, 2007
Ok, this is a very strange piece of software:

1. A Viewer
Displays 3D points and a coordinate system. Opens a socket for controlling it.
2. A Control panel
Controls angle(s) of the viewer, and the zoom.
What do I do with it?
1. Math plotter: Printing a 3d function
2. To display other data: I did the following hack:

Added a fade out: changes color and deletes data points after a while.
Data points can be added by network command.
Wrote a script that converts IP adresses to data points (in a helix), piped it to telnet, connected to the viewer.
Feeded the script through a pipe from tcpdump.
The code looks like this:
tcpdump -lnq 2>/dev/null | \
grep IP -w --line-buffered | \
sed -u -r 's/^.* ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).+ ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*$/\1,\2/' | \
sed -u -r 's/^(10\.10\.1)/I/'|sed -u -r 's/,(10\.10\.1)/,I/' | \
python /mnt/daten/Daten/Hacking/Python/ipparser.py | \
telnet localhost 7410
On the screen it look like this:
The broadcast is on the top left, external adresses are on the bottom right. I did a nmap pingscan on my network to get more data points (10.10.10-11.*).
All data points you see in the helix are IP Adresses. The red ones were added at the moment (communicating at the moment).
(This is the project I needed http://twoday.tuwien.ac.at/jo/stories/261242/ for.)
I made it for giving complex data a meaning, e.g. astronomical distances. I can use x, y, z, t, and colors for data display.
You can get it here if you are interested: nina-v1.tar.bz2 (bz2, 345 KB)
It is written in Python, with GTK, pygame, etc (you’ll see anyway)
Feedback welcome.
Python: 3D rotation and projection to 2D using a matrix
Posted by JohannesTheDeveloper in Happy Hacking on January 19th, 2007
I was working on a bit of software that should show a vector (3D) on the screen while I can choose the rotation of it.
So I thought: Rotate around each of the axis with the angles, then project it (just cut off the last line of the vector).
This is my code:
P1 = [ [cos(p),sin(p),0], [-sin(p),cos(p),0], [0,0,1] ] P2 = [ [1,0,0], [0,cos(t),sin(t)], [0,-sin(t),cos(t)], ] P3 = [ [cos(x),0,sin(x)], [0,1,0], [-sin(x),0,cos(x)], ] return mmult(mmult(P3,mmult(P2,P1)),v)
p stands for phi, t for theta, and x for … just x. Or xi.
Bash: md5part: Compares 2 files of different length
Posted by JohannesTheDeveloper in fun with Linux on January 15th, 2007
Hmm. I downloaded 2 files, and don’t know if they are equal. Worse, they are not of the same size and I don’t know if one’s file content is corrupted.
#!/bin/sh
a=$1
b=$2
sizea=$(($(wc -c < $a)))
sizeb=$(($(wc -c < $b)))
if [[ $sizea == $sizeb ]]; then
if [[ $(md5sum $a $b|sort -u|wc -l) == "1" ]]; then
echo "equal"
else
echo "different, but same size"
fi
else
if [[ $(($sizea < $sizeb)) == "1" ]]; then
tmp=$a; a=$b; b=$tmp
tmp=$sizea; sizea=$sizeb; sizeb=$tmp
fi
uniq=$({ \
dd if=$a bs=1 count=$sizeb 2>/dev/null | md5sum; \
md5sum < $b; \
}|sort -u|wc -l)
if [[ $uniq == "1" ]]; then
echo "$b is the first part of $a," $sizeb "bytes ("$(($sizeb*100/$sizea))"%)"
else
echo "different files"
fi
fi
Python: Binstream: Displays files binary
Posted by JohannesTheDeveloper in Happy Hacking on January 8th, 2007
I guess everybody implements this once, here is mine: bitstream.py (py, 0 KB)
It produces a nice output like:
[user@thiscomputer Python]$ python ./bitstream.py /home/user/mysecretmsg.txt |head 0 0 1 0 1 0 1 0 0 84 0x54 T 1 0 1 1 0 1 0 0 0 104 0x68 h 2 0 1 1 0 1 0 0 1 105 0x69 i 3 0 1 1 1 0 0 1 1 115 0x73 s 4 0 0 1 0 0 0 0 0 32 0x20 5 0 1 1 0 1 0 0 1 105 0x69 i 6 0 1 1 1 0 0 1 1 115 0x73 s 7 0 0 1 0 0 0 0 0 32 0x20 8 0 1 1 1 0 0 1 1 115 0x73 s 9 0 1 1 0 1 1 1 1 111 0x6f o
As you can see it shows byte number, binary, decimal, hexadecimal and ascii. Might be useful.
Python: Steganography
Posted by JohannesTheDeveloper in Happy Hacking on January 8th, 2007
Wrote a little python file to stenograph data into a bitmap.
bmp_stegano (py, 2 KB)
You may notice that I just started with python.
On the screenshot you can see the data embedded in the bitmap file: Read the LSB of the bitmap (left box) from top to bottom and the message (right box) line by line.
The bitstream python file that produces this beautiful output will be included in another post.
Unix: Chat for two
Posted by JohannesTheDeveloper in fun with Linux on January 1st, 2007
Chat for Two:
Features: Minimalistic, Colored, Extensible ;-)
Both have to have ssh access to a ssh server.
Setup:
$ ssh user@server
# mkfifo Ain
# mkfifo Aout
A does:
ssh user@server ‘cat Ain|while read line; do echo -e “\x1B[00;34m$line\x1B[00m”; done & cat > Aout’
B does:
ssh user@server ‘cat Aout|while read line; do echo -e “\x1B[00;34m$line\x1B[00m”; done & cat > Ain’
Also possible with putty…
Tip: For giving someone else access to your account, you should grant him/her by his/her certificate, instead of giving away your password.
Tip: If you two have both different accounts, you can chmod the fifos to share them.
Recent Comments