Skip to content

Commit a3ccd2a

Browse files
committed
enhanced debugging code (disabled in commit)
1 parent 4874b79 commit a3ccd2a

File tree

1 file changed

+40
-26
lines changed
  • src/com/veggiespam/imagelocationscanner

1 file changed

+40
-26
lines changed

src/com/veggiespam/imagelocationscanner/ILS.java

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
import java.io.File;
44
import java.io.FileInputStream;
5-
//import java.io.FileOutputStream; // Only needed when debugging the code
5+
import java.io.FileOutputStream; // for debugging only
66
import java.io.IOException;
7+
import java.text.DateFormat;
8+
import java.text.SimpleDateFormat;
79
import java.io.BufferedInputStream;
810
import java.io.ByteArrayInputStream;
911
import java.util.ArrayList;
1012
import java.util.Collection;
13+
import java.util.Date;
1114
import java.util.List;
15+
import java.util.TimeZone;
1216

1317
import com.drew.imaging.ImageMetadataReader;
1418
import com.drew.imaging.ImageProcessingException;
@@ -116,27 +120,35 @@ public String getAuthor() {
116120
public static String[] scanForLocationInImageBoth(byte[] data) {
117121
String[] results = { EmptyString, EmptyString, EmptyString };
118122

119-
/* // Extreme debugging code for making sure data from Burp/ZAP/new-proxy gets into
120-
// ILS. This code is very slow and not to be compiled in, even with if(debug)
121-
// types of constructs. This code this will save the image file to disk for binary
122-
// import debugging.
123-
String t[] = new String[3];
124-
try{
125-
FileOutputStream o = new FileOutputStream(new File("/tmp/output.jpg"));
126-
o.write(data);
127-
o.close();
128-
} catch (IOException e) {
129-
t[0] = "IOException Exception " + e.toString();
123+
// Extreme debugging code for making sure data from Burp/ZAP/new-proxy gets into
124+
// ILS. This code is very slow and not to be compiled in, even with if(debug)
125+
// types of constructs. This code this will save the image file to disk for binary
126+
// import debugging.
127+
/*
128+
if (false) {
129+
String t[] = { EmptyString, EmptyString, EmptyString };
130+
try{
131+
TimeZone tz = TimeZone.getTimeZone("UTC");
132+
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); // Quoted "Z" to indicate UTC, no timezone offset
133+
df.setTimeZone(tz);
134+
String nowAsISO = df.format(new Date());
135+
FileOutputStream o = new FileOutputStream(new File("/tmp/ILS-debug-" + nowAsISO + ".jpg"));
136+
o.write(data);
137+
o.close();
138+
} catch (IOException e) {
139+
t[0] = "IOException Exception " + e.toString();
140+
t[1] = t[0];
141+
t[2] = t[0];
142+
return t;
143+
}
144+
t[0] = "Scanning " + data.length + "\n\n";
130145
t[1] = t[0];
131146
t[2] = t[0];
132-
return t;
147+
// return t;
148+
// --- if you use this return line, remember to comment out rest of function.
133149
}
134-
t[0] = "Scanning " + data.length + "\n\n";
135-
t[1] = t[0];
136-
t[2] = t[0];
137-
// return t; /* --- if you use this line, remember to comment out rest of function.
138-
*/
139-
150+
*/
151+
140152
try {
141153
BufferedInputStream is = new BufferedInputStream(new ByteArrayInputStream(data, 0, data.length));
142154
Metadata md = ImageMetadataReader.readMetadata(is);
@@ -147,24 +159,26 @@ public static String[] scanForLocationInImageBoth(byte[] data) {
147159
results = scanForPrivacy(md);
148160

149161
if (tmp[0].length() > 0) {
150-
// minor formatting if we have both.
162+
// minor formatting update if we have both Location and Privacy.
151163
results[0] = tmp[0] + "" + results[0];
152164
results[1] = "<ul>" + tmp[1] + results[1] + "</ul>";
153165
results[2] = " " + tmp[2] + results[2];
154166

167+
/*
155168
// AGAIN: this is for extreme debugging
156-
// results[0] = "DBG: " + t[0] + "\n\n" + results[0];
157-
// results[1] = "DBG: " + t[1] + "\n\n" + results[1];
158-
// results[2] = "DBG: " + t[2] + "\n\n" + results[2];
169+
results[0] = "DBG: " + t[0] + "\n\n" + results[0];
170+
results[1] = "DBG: " + t[1] + "\n\n" + results[1];
171+
results[2] = "DBG: " + t[2] + "\n\n" + results[2];
172+
*/
159173
}
160174

161175

162176
} catch (ImageProcessingException e) {
163177
// bad image, just ignore processing exceptions
164-
// DEBUG: return new String("ImageProcessingException " + e.toString());
178+
// DEBUG: return new String("ImageProcessingException: " + e.toString());
165179
} catch (IOException e) {
166180
// bad file or something, just ignore
167-
// DEBUG: return new String("IOException " + e.toString());
181+
// DEBUG: return new String("IOException: " + e.toString());
168182
}
169183

170184
return results;
@@ -376,7 +390,7 @@ public static String[] scanForLocation(Metadata md) {
376390
PanasonicMakernoteDirectory.TAG_LANDMARK,
377391
PanasonicMakernoteDirectory.TAG_LOCATION,
378392
PanasonicMakernoteDirectory.TAG_STATE,
379-
//PanasonicMakernoteDirectory.TAG_WORLD_TIME_LOCATION //not 100% sure, but this might expose timezone aka location - I only see value "HOME".
393+
//PanasonicMakernoteDirectory.TAG_WORLD_TIME_LOCATION // might expose timezone aka location - but I only see value "HOME" in my samples.
380394
};
381395

382396
if (panasonicDirColl != null) {

0 commit comments

Comments
 (0)