原始碼
home
開始 -- 用於音訊壓縮以填充 1.44 兆位元組軟碟的腳本
ffmpeg -i "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/p*********g/floppy-disc-*****/original-files/slava-bogu-gelido.mp3" -ac 1 -codec:a libmp3lame -b:a 64k "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/p*********g/floppy-disc-*****/output-files/output_64k_mono_gelido_sb1.mp3"
ffmpeg -i "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/p*********g/floppy-disc-*****/original-files/slava-bogu-non-mi-va.mp3" -ac 1 -ar 16000 -codec:a libmp3lame -b:a 16k "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/p*********g/floppy-disc-*****/output-files/non-mi-va/output_16k_mono_16000_non_mi_va_sb1.mp3"
結尾 -- 用於音訊壓縮以填充 1.44 兆位元組軟碟的腳本
開始 -- 偽隨機效果故障的想像中位元組操作的程式碼 -- 附:快速修改
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class MainDataBend {
public static void main(String[] args) {
String inputFilePath = "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/slava-bogu002/experiment/gnome.jpeg";
String outputFilePath = "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/slava-bogu002/experiment/gnome2.jpeg";
try {
byte[] fileData = readFile(inputFilePath);
int soiIndex = findSOI(fileData);
int eoiIndex = findEOI(fileData);
if (soiIndex == -1 || eoiIndex == -1) {
System.err.println("Impossibile trovare i marker SOI o EOI.");
return;
}
int startManipulationIndex = soiIndex + 2 + 500; // +2 per saltare SOI
int endManipulationIndex = eoiIndex - 500; // -500 per escludere 500 byte prima di EOI
int[] markers = findMarkers(fileData);
if (markers == null) {
System.err.println("Markers not found.");
return;
}
boolean[] excludeBytes = new boolean[fileData.length];
for (int markerIndex : markers) {
if (markerIndex >= 0) {
excludeBytes[markerIndex] = true;
for (int j = -100; j <= 100; j++) {
int excludeIndex = markerIndex + j;
if (excludeIndex >= 0 && excludeIndex < excludeBytes.length) {
excludeBytes[excludeIndex] = true;
}
}
}
}
for (int i = 0; i < fileData.length; i++) {
if (!excludeBytes[i]) {
if (i >= startManipulationIndex && i < endManipulationIndex) {
if (i % 10000 == 0) {
fileData[i] = (byte) ~fileData[i]; // Inverti i byte a intervalli di x
}
if (i % 500000 == 0) {
fileData[i] = (byte) 0xFF; // Sostituisci ogni xesimo byte con 255
}
if (i % 4000 == 0) {
fileData[i] = (byte) (Math.random() * 256); // Assegna un byte casuale
}
int shiftOffset = 5000;
if (i % 5000 == 0 && i+shiftOffset < endManipulationIndex) {
fileData[i] = fileData[i + shiftOffset]; // Sposta i byte di shiftOffset posizioni
}
int blockSize = 100;
byte[] block = new byte[blockSize];
System.arraycopy(fileData, startManipulationIndex, block, 0, blockSize);
for (int j = startManipulationIndex; j < endManipulationIndex; j += 5000) {
if (j + blockSize < fileData.length) {
System.arraycopy(block, 0, fileData, j, blockSize); // Copia il blocco più volte
}
}
for (int x = 0; x < fileData.length; x++) {
if (x > 500 && x < 1000) {
fileData[x] = (byte) (fileData[x] + 10); // Aumenta i byte in un certo range
}
}
int blockSize2 = 500; // Definisci la dimensione del blocco
for (int x = startManipulationIndex; x < endManipulationIndex; x += blockSize2) {
for (int y = 0; y < blockSize2; y++) {
if (x + y < fileData.length) {
fileData[x + y] = (byte) (Math.random() * 256); // Randomizza un intero blocco
}
}
}
String asciiText = "S";
byte[] asciiBytes = asciiText.getBytes(StandardCharsets.US_ASCII);
for (int z = startManipulationIndex; z < endManipulationIndex; z += asciiBytes.length) {
System.arraycopy(asciiBytes, 0, fileData, z, asciiBytes.length); // Sostituisci i byte con il testo ASCII
}
}
}
}
writeFile(outputFilePath, fileData);
System.out.println("Manipolazione completata!");
} catch (Exception e) {
System.err.println("Errore nella lettura del file: " + e.getMessage());
}
}
public static byte[] readFile(String filePath) throws IOException {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
byte[] fileData = new byte[(int) file.length()];
fis.read(fileData);
fis.close();
return fileData;
}
private static void writeFile(String filePath, byte[] data) throws IOException {
try (FileOutputStream fos = new FileOutputStream(filePath)) {
fos.write(data);
}
}
private static int findSOI(byte[] fileData) {
for (int i = 0; i < fileData.length - 1; i++) {
if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xD8) {
return i; // Restituisce l'indice di SOI
}
}
return -1; // Non trovato
}
private static int findEOI(byte[] fileData) {
for (int i = 0; i < fileData.length - 1; i++) {
if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xD9) {
return i; // Restituisce l'indice di EOI
}
}
return -1; // Non trovato
}
private static int[] findMarkers(byte[] fileData) {
int[] markers = new int[5]; // Supponiamo di cercare SOI, EOI e altri marker
int count = 0;
for (int i = 0; i < fileData.length - 1; i++) {
if (fileData[i] == (byte) 0xFF && (fileData[i + 1] >= (byte) 0xE0 && fileData[i + 1] <= (byte) 0xEF)) {
markers[count++] = i; // APP0-APP15
} else if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xDB) {
markers[count++] = i; // DQT
} else if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xC4) {
markers[count++] = i; // DHT
} else if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xDA) {
markers[count++] = i; // SOS
} else if (fileData[i] == (byte) 0xFF && fileData[i + 1] == (byte) 0xFE) {
markers[count++] = i; // COM
}
if (count >= markers.length) break;
}
return markers;
}
}
結尾 -- 偽隨機效果故障的想像中位元組操作的程式碼 -- 附:快速修改
開始 -- 偽隨機故障故障影片的位元組操作代碼 -- 附:快速修改
import java.io.*;
import java.nio.file.*;
import java.util.Random;
public class VideoGlitcher {
public static int counter = 1;
public static void main(String[] args) {
String ffmpegPath = "ffmpeg"; // Assicurati che ffmpeg sia nel PATH di sistema
String tempAVI = "temp_process.avi";
String inputMP4 = "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/programming/glitch-video-java/test-clancy-input.mp4";
String outputMP4 = "/U****/l*********i/D*****p/L***********s/M****a/m*****s/SLAVA?BOGU/programming/glitch-video-java/output/test-clancy-output_"+counter+".mp4";
try {
System.out.println("Convertendo in AVI...");
executeCommand(ffmpegPath, "-i", inputMP4, "-vcodec", "mpeg4", "-b:v", "2M", "-an", tempAVI);
System.out.println("Inizio manipolazione byte...");
byte[] fileData = Files.readAllBytes(Paths.get(tempAVI));
manipulateVideoBytes(fileData);
Files.write(Paths.get(tempAVI), fileData);
System.out.println("Finalizzazione video...");
executeCommand(ffmpegPath, "-y", "-i", tempAVI, "-c:v", "libx264", "-pix_fmt", "yuv420p", outputMP4);
System.out.println("Processo completato! File generato: " + outputMP4);
} catch (Exception e) {
e.printStackTrace();
}
counter++;
}
private static void manipulateVideoBytes(byte[] data) {
Random rand = new Random();
int headerOffset = 20480; // Proteggiamo i primi 20KB (header RIFF/AVI)
int endOffset = data.length - 1024;
System.out.println("Applicando Glitch Pesante su " + data.length + " bytes...");
for (int i = headerOffset; i < endOffset; i++) {
if (i % 30000 == 0 && (i + 1024 < endOffset)) {
byte[] pattern = new byte[512];
System.arraycopy(data, i, pattern, 0, 512);
for (int j = 0; j < 10; j++) {
int target = i + (j * 512);
if (target + 512 < endOffset) {
System.arraycopy(pattern, 0, data, target, 512);
}
}
i += 5000; // Salta avanti per non sovrascrivere il glitch appena fatto
}
if (i % 8000 == 0) {
for (int j = 0; j < 100 && (i + j < endOffset); j++) {
data[i + j] = (byte) (data[i + j] << 2 | (data[i + j] >>> 6));
}
}
if (i % 100000 == 0) {
int swapSize = 4096;
int targetPos = rand.nextInt(endOffset - swapSize - headerOffset) + headerOffset;
if (i + swapSize < endOffset) {
byte[] temp = new byte[swapSize];
System.arraycopy(data, i, temp, 0, swapSize);
System.arraycopy(data, targetPos, data, i, swapSize);
System.arraycopy(temp, 0, data, targetPos, swapSize);
}
}
if (i % 15000 == 0) {
data[i] = (rand.nextBoolean()) ? (byte) 0xFF : (byte) 0x00;
}
}
}
private static void executeCommand(String... command) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder(command);
pb.inheritIO();
Process process = pb.start();
int exitCode = process.waitFor();
if (exitCode != 0) {
throw new RuntimeException("FFmpeg ha fallito con codice: " + exitCode);
}
}
}
結尾 -- 偽隨機故障故障影片的位元組操作代碼 -- 附:快速修改
home