www.main.lv

Don't think just code it

Menu

  • Projects
    • Robatik
    • ArpSni
  • Samples
    • FreeBSD Asm
    • Linux Asm
    • PyGame Tutorial
    • UNIX programming
    • PSP programming
    • AVR
    • Math
  • Contact

Tags

algo (1)asm (19)attractor (2)avr (2)blender (3)bug (1)c (25)coalision (2)debug (3)editor (1)elf (1)fractals (2)freebsd (3)game (3)generator (1)gimp (1)int80h (22)map (1)math (5)mit (1)nano (1)net (2)opengl (1)plugin (1)post (2)povray (1)psp (3)pygame (19)python (28)robatik (2)sdl (3)skype (2)sql (1)towers (2)tutorial (7)voronoi (1)wudu (1)

Archive

  • 2010 august (1)
  • 2010 july (2)
  • 2010 june (1)
  • 2010 april (2)
  • 2010 march (2)
  • 2010 february (2)
  • 2010 january (2)
  • 2009 december (3)
  • 2009 november (8)
  • 2009 october (3)
  • 2009 september (5)
  • 2009 august (1)
  • 2009 july (1)
  • 2009 june (1)
  • 2009 may (1)
  • 2009 april (3)
  • 2009 march (1)
  • 2009 february (2)
  • 2009 january (1)
  • 2008 october (2)
  • 2008 september (4)

2009-11-30 ARP analyzer

Research in ARP protocol. Watch ARP packets , count them and show in list.

Usage
./arpsni eth0

Version 0.1
[2009nov30]

ArpSni.0.1





2009-11-30 Linux ShellCode 1


First shell code writened from example. Shell code is very interesting way how to execute some code.

asm source:

use32				
xor eax, eax
inc eax
xor ebx, ebx
int 80h

fasm code.asm code.bin

bin2hex output:

\x31\xc0\x40\x31\xdb\xcd\x80
C source:

#include <stdio.h>
char code[] = "\x31\xc0\x40\x31\xdb\xcd\x80";
int main()
{
  void (*ret)();
  ret = (void (*)())code;
  ret();
  printf("Nope it not working\n");
}

gcc main.c -o main


run ./main nothing happens. That exactly that code do exits from programm

Source


My variant of Bin2Hex


2009-11-24 C Bin2Hex

Converts binary file to hex file.

Use:
./bin2hex [bin_file] - for local output
./bin2hex [bin_file] [hex_text_file] - for file output

Bin2Hex source


2009-11-15 Pascal Triangle

This is Pascal Triangle. And colors is choseen by reminder of division.
There are 2 ways how thats is made:
1. Simple if division reminder is 0 then red else green
2. Reminder is like alpha chanell of red color.
In gallery shown images are generated by dividing on (17,19,23,41,42,43). There is easy to see that
prime numbers (17,19,41,43) has very structured triangle but not prime (42) is different.
./chessboard div_number - simply show triangle divided by number
./chessboard div image.tga - save programm screen to image.tga
./chessboard div img.tga ant_parm - changes to second coloring type
Why it I call it chessboard? I were trying make such with OpenGL bet result is Pascal Triangle.


Source


2009-11-12 Python Skype Sync Status

This script synhronize your status with selected user status.

python SyncStat.py favorite_uzer



Script


2009-11-12 Python PyGame Tutorial Fullscreen

added new variable tha tcheck in with mode now screen is
fullscreen = False

Used new event type

if event.type == pygame.KEYDOWN:

When pressing key m we making new screen surface in fullscreen mode. If screen is in fuulscreen mode make window.

if event.key == pygame.K_m:		
  if not fullscreen:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) , pygame.FULLSCREEN )
    fullscreen = True
  else:
    screen = pygame.display.set_mode( (SCREEN_X,SCREEN_Y) )
    fullscreen = False



Tutorial Source


2009-11-09 AVR echo

This code tested on ATmega16


#include <avr/io.h>
 
#define FOSC 16000000UL
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1
 
void USART_Init( unsigned int ubrr)
{
	UBRRH = (unsigned char)(ubrr>>8);
	UBRRL = (unsigned char)ubrr;
	UCSRB = (1<<RXEN)|(1<<TXEN);
	UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
}
 
int main()
{
	char c;
	USART_Init( MYUBRR );
	while(1)
	{
		while ( !(UCSRA & (1<<RXC))){};
		c = UDR;
		while (!(UCSRA & (1<<UDRE))){};
		UDR = c;
	}
	return 0;
}



2009-11-08 Linux Assembler Make Directory

Code for creating file:


format ELF executable
 
include 'cdecl.inc'
include 'syscall.inc'
 
mode_t equ dd
 
segment readable executable
start:
	mov eax, SYS_MKDIR
	mov ebx, path
	mov ecx, [mode]
	int 80h
 
	mov eax, SYS_EXIT
	xor ebx, ebx
	int 80h
 
segment readable writeable
path	db 	"dir",0 
mode	mode_t  0777o
fasm makedir.asm -o makedir

Source


© 2010