Visualizzazione post con etichetta tutorial. Mostra tutti i post
Visualizzazione post con etichetta tutorial. Mostra tutti i post

sabato 20 dicembre 2014

simple image steganography in processing

Hi guys, today I'm posting about a project I started some time ago but which today I refined and made faster.
First of all: what is steganography?
Steganography is the discipline whose purpose is to hide the communication between two people.
Maybe you're wondering what's the difference with criptography (if not go fuck yourself,  just kidding): the difference is that while criptography makes the messages between two people not understandable, steganography's purpose is to completly hide the communication.

An example can be: Person A sends to person B a text file about an ordinary topic, but then imagine that in each paragraph of the text there is a number of commas which goes from 0 to 26.
This number could indicate a letter of the alphabet or a "space" (if = 0).

Now, this is a very simple way to send messages and in computer science people exchange lots of data and there are lots of places where you can hide messages (metadata, audio noise, text font etc..).
In this project I'll show you a REALLY simple and rough way to hide an image in another image.

Before going to the code there is an import concept that I'd like to explain: in each byte there are some bit which affect relatively a few the decimal value of the byte.
These bits are called less significant bits (from now I'll refer to them as LSB).
An example: 10010101 = 149
                      10010100 = 148

so here the Least Significant Bit is this: 10010101 infact here its value affects the decimal number by just one unit.


Now coming back to the idea of steganography in images, for each pixel of an image we have 3 bytes on which we can work: the bytes containing values for red, green and blue colors (and sometimes also for alpha transparency, but I won't talk about this).
Of course the process will work on LSB so the resulting image will be mostly equal to the original (no human eye will notice the difference).
As I said I'll make very simple tutorial so I'll explain you how to hide a binary image (which means with only black and white, NO INTERMEDIATE COLORS) in the blue channel (it's the simplest to work on).
My code has also other limitation due to the fact that I just made a code snippet and not a complete work: the image you want to hide and the "container" image must be of the same size and in .bmp format (I haven't tried other, maybe will work anyway).

Just one more things before the code: to make the program faster I used some bits operation, you want to understand them completly have a look at processing reference for bitwise OR and bitwise AND (maybe also bitshift).
Here is a very simple schematic on how an RGB color variable is stored:



Here is the code: 

PImage img, hidden;
int maxw, maxh;

void setup(){
  colorMode(RGB, 255);
  img = loadImage("img.bmp");
  hidden = loadImage("hidden.bmp");
  maxw = img.width;
  maxh = img.height;
  img.loadPixels();
  hidden.loadPixels();
  }
 
void draw(){
  for(int n = 0; n < maxw*maxh; n++){
    if(hidden.pixels[n] == color(255)){
      img.pixels[n] = img.pixels[n] | unbinary("000000000000000000000001");       }
    else{ 

      img.pixels[n] = img.pixels[n] & unbinary("111111111111111111111110");        }
    }
  img.save("processed.bmp");
  exit();
  }


This code, given a "container" image img.bmp and an image to hide(binary) hidden.bmp we'll process them and output to processed.bmp
This final image so contains in the least significant bit of the blue channel a binary image, to extract it you'll have to make another sketch:

PImage img, hidden;
int maxw, maxh;

void setup(){
  colorMode(RGB, 255);
  img = loadImage("processed.bmp");
  maxw = img.width;
  maxh = img.height;
  img.loadPixels();
  hidden = createImage(maxw, maxh, RGB);
  hidden.loadPixels();
  }
 
void draw(){
  for(int n = 0; n < maxw*maxh; n++){
    if((img.pixels[n] & unbinary("000000000000000000000001")) == 0){
      hidden.pixels[n] = color(0);
      }
    else{
      hidden.pixels[n] = color(255);
      }
    }
  hidden.save("foundhidden.bmp");
  exit();
  }
 

 
This sketch, given an image (processed with the program above) processed.bmp will extract the hidden image and output it in foundhidden.bmp
Here is a zip with all files: link.
I know it's a really rough sketch but I think it can be useful just to understand some concepts of steganography, if you refine the code (store image in all the channels and use more LSB instead of just one) advise me, I'd be happy to see your work.
Everyone is free to use the code in this post but I'd appreciate if you mention my name.
I hopeyou like this post, if you have any question please comment or send me an email to damianoandre@gmail.com

Bye, Dami

lunedì 15 settembre 2014

Change grub boot order in Debian

Here is a little tip:
If you have many OS on the same pc (dual boot) and you want to change the grub default choice follow these steps:
-run debian
-open terminal and type
gksu gedit
(this will start gedit, the default linux text editor with root privileges)
-in gedit open the file /etc/default/grub
-There should be a line like GRUB_DEFAULT=0  , you have to put the order number of the OS you want as default instead of 0.
The number of the order start from 0 not from 1
Here is an example:

0 debian
1 debian (recovery mode)
2 windows 7

so if you want windows 7 as default choice change GRUB_DEFAULT=0 to GRUB_DEFAULT=2
-to make the changes effective open the terminal as root (with su command) and type  update-grub
-now restart the pc and see if everything worked properly

I hope this tip will be useful to you, if you have any question please comment or send me an email to damianoandre@gmail.com

Bye, Dami
 

martedì 9 settembre 2014

How to crack WEP password (educational purpose only)

First of all I want to highlight that cracking password of someone else's access point is illegal.
However you can try with your own router just for educational purpose.
Cracking a WEP password is not difficult, you need mainly 2 things:
-a computer with linux installed in it (I use Debian)
-a wifi adapter (we'll talk about this later)

If you don't have linux installed on your computer don't worry, it's easy to install it and you can have both windows and linux on the same pc (this is called dual boot).
I never used a Mac but I know how to install linux within windows:
-create a backup (for safety)
-shrink the main volume (create a blank partition of about 30GB) --> tutorial
-go to https://wiki.debian.org/it/DebianInstaller/Loader and download the Debian installer
-run it and follow the instruction (be careful to install debian in the partition you just created)
-you've done it, when the computer starts you should be able to choose which OS you want to run

To crack the password you'll need some tools provided in the aircrack suite  but remember that
aircrack supports only some wifi adapters, here's a list.
Now if you have a compatible adapter (I used one with RTL8187B chipset) with the correct drivers installed you can install aircrack by opening the terminal and typing:
su
[your root password] 
apt-get install build-essential 
apt-get install wireless-tools
apt-get install aircrack-ng 

now you're ready to start:
type iwconfig to list all the wireless interfaces connected to your pc.
When you know which one is the right adapter (it should be called something like wlan0) type:
airodump-ng wlan0
start collecting information about the AP (= access point) you want to crack (bssid and channel) and write them somewhere, beacuse you'll need them.
now open another terminal and type:
airodump-ng -c [the channel of the AP] --bssid [the bssid of the AP] [your device for example wlan0] --ignore-negative-one -w output

This will start capturing initialization vectors (IVs) and when you've collected about 40'000 data packets close the terminal, all the IVs information are saved in a file called output-01.cap

Collecting so many packets can take a while but you can make injections to make this operation faster: see aireplay usage here,

Now that you've collected enough IVs run aircrack to find the password:

aircrack-ng -b [bssid of the AP you want to crack] output-01.cap

Now wait till aircrack find the password.
For the geeks who want to understand how wep cracking works here is an explaination.
I hope you like this post and remember: all the information given in this post are just for educational purpose, use this technique only to crack the password of your own access point.

For any question see aircrack-ng documentation, comment or send me an email to damianoandre@gmail.com

Bye, Dami




martedì 10 giugno 2014

Timelapse tutorial (with arduino and digital reflex camera)

Hi guys, today I'll talk about making a timelapse video.
For those who don't know what's a timelapse video, here  is mine:


First of all the components:
-digital camera (nikon, canon, olympus, pentax, sony)
-arduino (any board, UNO, MEGA, duemilanove ecc..)
-IR transmitter led
-220 ohm resistor

For making a timelapse video our camera has to take a photo from the same position each 15/20 sec (depending on what you're trying to do) and probably you don't want to take each picture by yourself, so you'll need an arduino.
First of all connect the led and the resistor to the arduino in this way:







Then using this really nice library our Arduino will shut photos.
Install the library and open arduino IDE.
Then go to File>Examples>MultiCameraIrControl and select your camera brand.
Now just change the loop function like this:

void loop(){
  D600.shutterNow();
  delay(10000);
}


delay function will wait the give milliseconds before shutting another photo; I think 10 seconds are good for many videos but depending on your subject you would have to change this value.

Another part of this project is powering arduino and camera for many hours.
For the camera use the normal power supply and for the arduino I suggest using a 110V/220V--->USB transformer (probably you have one at home, they are used for smartphones or other devices).

The last part of the project is calculating how long we can shoot depending on delay between photos and camera's memory.

For example if I have a 32GB SD and I take a photo every 10 seconds (5MB each photos) I'll be able to shoot photos for: (32'000MB / 5MB ) * 10 sec

Make your own calculation but remember: this works only in theory: there are other variables (battery duration ecc..)

Now you just need to turn on your camera, turn on the remote control mode (look in the instructions), power the arduino and place it in front of your camera as a remote control.

Here is my short timelapse:




I hope you enjoyed this project, if you have any question comment or send me an email to damianoande@gmail.com

Bye, Dami

domenica 22 settembre 2013

Arduino ultrasonic distance measurement

Hi guys' today I'm here with a tutorial about interfacing arduino with ultrasonic distance meter like the HC-SR04.
First of all, the theory:

If we know that the sound take a time t  to reach the obstacle and come back and that
speed s is equal to s=d/t where d is the distance then d=s*t .
We consider that speed of sound is 340.29 meters/seconds that is equal to
0.034029 centimeters/microseconds.

Now let's see the hardware parts, which is very simple:



To start measuring distance you just have to upload this code to the arduino
int trigPin = 2;
int echoPin = 4;

void setup() {
  Serial.begin(9600);
}

void loop(){
  long duration;
  float cm;
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  cm = microsecondsToCentimeters(duration);
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  delay(100);
}
float microsecondsToCentimeters(long microseconds){
  return (microseconds*0.034029)/2;
}


Here is a video of me testing this project:


I hope you like this post, if you have any question please comment or send me an email to damianoandre@gmail.com

Bye,Dami

mercoledì 4 settembre 2013

Use Arduino with RF Modules

Hi guys, today I'm here with a really cool project.
If you have ever wondered how to make 2 arduinos communicates without using expensive shield, here is the solution: there are some RF modules sold for about 2$ (transmitter + receiver)  that offer one way, easy-to-use communication with a range of about 150 meters.
In this post I'll explain how to use this modules.

First of all you'll need:
-2 arduinos
-a rf transmitter
-a rf receiver

STEP 1: the transmitter
Connect the transmitter to arduino this way:




Upload this code to the arduino connected to the transmitter:
 
#include <VirtualWire.h>
void setup(){
  vw_setup(2000); // bps
  }
void loop(){
  send("hello world"); //your message
  delay(1000);
  }
void send (char *message){
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx();
  }

STEP 2: the receiver
Connect the receiver to the arduino this way:





Upload this code to the arduino connected to the receiver:

#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN];
byte messageLength = VW_MAX_MESSAGE_LEN;
void setup(){
  Serial.begin(9600);
  Serial.println("Device is ready");
  vw_setup(2000); //bps
  vw_rx_start();
  }
void loop(){
  if (vw_get_message(message, &messageLength)){
    Serial.print("Received: ");
      for (int i = 0; i < messageLength; i++){
        Serial.write(message[i]);
        }
      Serial.println();
    }
  }

STEP 3: test ;)
Connect the 2 arudino and check with the serial monitor if it works


I hope you like this post, if you have any question please comment or send me an email to damianoandre@gmail.com

Bye, Dami

mercoledì 5 giugno 2013

Small diy electric motor tutorial

Hi, today I'm here with a tutorial for creating a small electric motor.

First of all you will need:
-a power source (5v or more)
-some tape
-some wires
-some NON-insulated wire
-some magnet wire
Most of sites suggest to buy it on online stores but finding it is easier than it seems.
In fact most of windings of transformers or inductors are made with magnet wire.
I took my magnet wire form inductors in a printer power supply circuit.


-a quite strong magnet (I took it from a geomag)

Construction:
-Use your insulated wire to create 4/5 loop coil of about 1.5 cm diameter like this:


-Use a knife to cut insulating layer from your wire, at one end of your wire cut all insulating layer, at the other just half, like this:


cut insulating layer with a knife
 -Use pilers to model NON-insulated wire to create two supports like this:



 -assemble everything like this:





Making it works:
To make it works, put the magnet near the coil, and plug the two supports to your power supply.
The hardest part is calibration, don't give after 2 minutes, just try making adjustments to the coil or the magnet.

Here is my motor working:


I hope you like this post, if you have any question comment or send me an email to damianoandre@gmail.com

Bye, Dami

martedì 9 ottobre 2012

Minecraft zeppelin mod use tutorial

Hi, today i'm posting about the zeppelin minecraft mod.
This mod makes you able to make your bluiding fly.
To use this mod download and install it(premoodded minecraft folder download).
When it's installed try creating a 3x3 square of wooden planks and place in the center an airship controller


then right-click on the airship controller and start flying, to fly use there commands(in the numeric keypad):
8 to go ahead
2 to go back
4 to rotate to left
6 to rotate to right
5 to stop
+ to ascend
- to descend

This works with everything based on wooden planks and iron blocks and if you stay near the airship controller, but if you want to control you airship remotely you need a zeppelin remote, to use that just right click on the airship controller and use the same commands.
Here is a video demostration about the mod:



I hope you like this post, if you have any question comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami