Sunday, August 9, 2015

Quick old Digital Steg Pt 1

Finished the book so back to blogging again, heres a quick post:


To begin with we can just edit the straight up pixels, not unlike this:

size(200, 200);
loadPixels();  
for (int i = 0; i < pixels.length; i++) {
  float r= random(255);
  color c = color(r);
  pixels[i] = c;
}
updatePixels(); 

We just need to add an algorithm which encodes useful information, perhaps with less data(this image contains 250,000 bits. It might be best if we modify the pixels of an image, for better disguise than an old cctv when the lines are down. Here I'll whip up a quick example to get those started who are here for the first time:

PImage webImg;

void setup(){
size(500, 500);

  String url = "https://processing.org/img/processing-web.png";
  // Load image from a web server
  webImg = loadImage(url, "png");
}
void draw(){
  image(webImg, 0, 0);
loadPixels();  
for (int i = 0; i < 25000; i++) {
  float rand = random(255);
  color c = color(rand);
  pixels[i] = c;
}
updatePixels(); 
}

Of Course creating:
The best way to disguise our messages are clever manipulations of the alpha levels, but lets keep it in "acceptable areas" near the edges of lines, so we will first mess with random alphas for demonstration, then create a "smart" program to hide our messages even more effectively, and then we will make the encoder/decoder.
Okay, so just a random dash of message, or no particular meaning yet:
See? Very sloppy. It is rather obvious those 4 dots caused by:
PImage webImg;

void setup(){
size(500, 500);

  String url = "https://processing.org/img/processing-web.png";
  // Load image from a web server
  webImg = loadImage(url, "png");
}
void draw(){
  image(webImg, 0, 0);
loadPixels();  
for (int a = 0; a < 25; a++) {
  float i=random(pixels.length);
  float rand = random(255);
  color c = color(rand);
  pixels[(int)i] = c;
}
updatePixels(); 
}

So we must use line detection and start to make our message meaningful. Let us start with the latter method and make a simple coding schema:

CODING SCHEMA HERE

Now in addition we can also make messages through the combination of images which are meant to be deciphered by a human reader.The good old syllipsis program will also work just adding a contextualizer i.e. : "userenteredfilename"+".jpg"  based on user input, but lets import the Syllipsis.jar code to speed things up, why code that which you yourself have already written?:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import processing.core.*; 
import processing.data.*; 
import processing.opengl.*; 

import javax.swing.JFileChooser; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class htmlsaver extends PApplet {


String realtime;
String file;
String savers;
boolean btn= false;
String lastInput = new String();
String currentInput = new String();

public void setup()
{

  
   
  background(204);
 size(800, 600);
 smooth();
 


 textAlign(CENTER);
}

public void draw()

{
  
  if (btn == true) {
    fill(255);
  } else {
    noFill();
  }
  rect(20, 60, 75, 75);
  ellipse(60,90,50,50);
   
  fill(0);
text("Thanks for Using Syllipsi By Daniel McCormack",width/2,60);
 text(lastInput, width/2, height/2);
 fill(255, 255, 255);
 text(currentInput, width/2, height*.75f);
 
   


}
public void mousePressed(){
  if (btn){
    exit();
  }
}
public void keyPressed()
{
 if(key == ENTER)
 {
   lastInput = currentInput = currentInput + key;
   currentInput = "";
   lastInput="http://"+lastInput;
 
   
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(null);


{
  println("Saving <HTML> to " + chooser.getSelectedFile().getName());
    file = chooser.getSelectedFile().getName();
   
String currline[] = loadStrings(lastInput);
for (int i = 0 ; i < currline.length; i++) {
  println(currline[i]);
saveStrings(file,currline);
}
}
 }
 else if(key == BACKSPACE && currentInput.length() > 0)
 {
   currentInput = currentInput.substring(0, currentInput.length() - 1);
 }
 else
 {
   currentInput = currentInput + key;
 }
}

public void mouseMoved() { 
  checkButtons(); //for our magical menu
}
  
public void mouseDragged() {
  checkButtons(); //again the gui menu check 
}

public void checkButtons() {
  if (mouseX > 20 && mouseX < 95 && mouseY > 60 && mouseY < 135) {
    btn = true;    //the final gui menu check
    

  } else {
    btn=false;
  }
}




  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "--full-screen", "--bgcolor=#666666", "--stop-color=#cccccc", "htmlsaver" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}
And we only need the new JFileChooser() at the end to save our new "image chain". 
and lets focus on this region:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
public void keyPressed()
{
 if(key == ENTER)
 {
   lastInput = currentInput = currentInput + key;
   currentInput = "";
   lastInput=lastInput+".jpg";//contextualizer
 }

 else if(key == BACKSPACE && currentInput.length() > 0)
 {
   currentInput = currentInput.substring(0, currentInput.length() - 1);
 }
 else
 {
   currentInput = currentInput + key; //input update
 }
}
Let's fix this up with a little bit of reorganizing. We dump the menu chooser in the exit area. The "[ENTER] adds the picture.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import processing.core.*; 
import processing.data.*; 
import processing.opengl.*; 

import javax.swing.JFileChooser; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class htmlsaver extends PApplet {

PImage img;
    
String realtime;
String file;
String savers;
boolean btn= false;
String lastInput = new String();
String currentInput = new String();

public void setup()
{

   

  background(204);
 size(800, 600);
 smooth();
 


 textAlign(CENTER);
}

public void draw()

{
  
  if (btn == true) {
    fill(255);
  } else {
    noFill();
  }
  rect(20, 60, 75, 75);
  ellipse(60,90,50,50);
   
  fill(0);
text("Thanks for Using pixtitch By XOS",width/2,60);
 text(lastInput, width/2, height/2);
 fill(255, 255, 255);
 text(currentInput, width/2, height*.75f);
    
       

String currline[] = loadStrings(lastInput);
for (int i = 0 ; i < currline.length; i++) {
  println(currline[i]);
saveStrings(file,currline);

}
 }
 else if(key == BACKSPACE && currentInput.length() > 0)
 {
   currentInput = currentInput.substring(0, currentInput.length() - 1);
 }
 else
 {
   currentInput = currentInput + key; //input update
 }
}


}
public void mousePressed(){
  if (btn){
    JFileChooser chooser = new JFileChooser(); //prompt a save if the "game" is over
int returnVal = chooser.showOpenDialog(null);


{
  println("Saving pixtitch to " + chooser.getSelectedFile().getName());
    file = chooser.getSelectedFile().getName();
}
  }
}
public void keyPressed()
{
 if(key == ENTER)
 {
   lastInput = currentInput = currentInput + key;
   currentInput = "";
   lastInput=lastInput+".jpg";//contextualizer
   img = loadImage(lastInput);
   image(img, 0, 0); 
 }
}
 


public void mouseMoved() { 
  checkButtons(); //for our magical menu
}
  
public void mouseDragged() {
  checkButtons(); //again the gui menu check 
}

public void checkButtons() {
  if (mouseX > 20 && mouseX < 95 && mouseY > 60 && mouseY < 135) {
    btn = true;    //the final gui menu check
    

  } else {
    btn=false;
  }
}




  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "--full-screen", "--bgcolor=#666666", "--stop-color=#cccccc", "htmlsaver" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}
And now focus on this:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public void keyPressed()
{
 if(key == ENTER)
 {
   lastInput = currentInput = currentInput + key;
   currentInput = "";
   lastInput=lastInput+".jpg";//contextualizer
   img = loadImage(lastInput);
   int x=img.width
   int a=a+25
   image(img, a, 0,25,25);
 }
}
And now to wrap things up:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import processing.core.*; 
import processing.data.*; 
import processing.opengl.*; 

import javax.swing.JFileChooser; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class htmlsaver extends PApplet {

PImage img;
    
String realtime;
String file;
String savers;
boolean btn= false;
String lastInput = new String();
String currentInput = new String();

public void setup()
{
int a=0;
   

  background(204);
 size(800, 600);
 smooth();
 


 textAlign(CENTER);
}

public void draw()

{
  
  if (btn == true) {
    fill(255);
  } else {
    noFill();
  }
  rect(20, 60, 75, 75);
  ellipse(60,90,50,50);
   
  fill(0);
text("Thanks for Using pixtitch By XOS",width/2,60);
 text(lastInput, width/2, height/2);
 fill(255, 255, 255);
 text(currentInput, width/2, height*.75f);
    
       

String currline[] = loadStrings(lastInput);
for (int i = 0 ; i < currline.length; i++) {
  println(currline[i]);
saveStrings(file,currline);

}
 }
 else if(key == BACKSPACE && currentInput.length() > 0)
 {
   currentInput = currentInput.substring(0, currentInput.length() - 1);
 }
 else
 {
   currentInput = currentInput + key; //input update
 }
}


}
public void mousePressed(){
  if (btn){
    JFileChooser chooser = new JFileChooser(); //prompt a save if the "game" is over
int returnVal = chooser.showOpenDialog(null);


{
  println("Saving pixtitch to " + chooser.getSelectedFile().getName());
    file = chooser.getSelectedFile().getName();
}
  }
}
public void keyPressed()
{
 if(key == ENTER)
 {
   lastInput = currentInput = currentInput + key;
   currentInput = "";
   lastInput=lastInput+".jpg";//contextualizer
   img = loadImage(lastInput);
   int x=img.width
   int a=a+25
   image(img, a, 0,25,25);
 }
}
 


public void mouseMoved() { 
  checkButtons(); //for our magical menu
}
  
public void mouseDragged() {
  checkButtons(); //again the gui menu check 
}

public void checkButtons() {
  if (mouseX > 20 && mouseX < 95 && mouseY > 60 && mouseY < 135) {
    btn = true;    //the final gui menu check
    

  } else {
    btn=false;
  }
}




  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "--full-screen", "--bgcolor=#666666", "--stop-color=#cccccc", "htmlsaver" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}

No comments:

Post a Comment