shits fucked
This commit is contained in:
parent
60daca96ca
commit
022dbec73e
3 changed files with 74 additions and 48 deletions
5
log.txt
Normal file
5
log.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
input path DIR
|
||||
Filepath: "/new2/git/wynn-pack-temp/assets/minecraft/textures/colormap/foliage.png"
|
||||
Dimensions: (256, 256)
|
||||
Colorspace: RGB
|
||||
BitDepth: Eight
|
23
readme.md
23
readme.md
|
@ -1,15 +1,30 @@
|
|||
# respack-decrypter
|
||||
|
||||
This tool
|
||||
This tool allows you to unfuck corrupted images in a resource pack that have been corrupted to be protected.
|
||||
|
||||
# I want some logs
|
||||
# Usage
|
||||
|
||||
- download the Rust-Lang for your system
|
||||
- download this repository
|
||||
- run `cargo build --release` in the directory
|
||||
- check `./target/release`
|
||||
- run `respack-decrypter` if you are on linux/mac (RUN `chmod +x respack-decrypter` ON IT FIRST)
|
||||
- run `respack-decrypter.exe` if you are on windows
|
||||
|
||||
# syntax
|
||||
|
||||
Check `--help` for syntax or `-h` for shortened explanation
|
||||
|
||||
# I want some logs for checking wtf is happening
|
||||
|
||||
Pipe your output to a new filename.
|
||||
|
||||
Note: It might not work for SOME linux shells. But major ones e.g. `zsh`,`bash` support it.
|
||||
|
||||
`respack-decrypter --path ~/somedir > ~/log.txt`
|
||||
`respack-decrypter --path ~/somedir/ --debug > ~/log.txt`
|
||||
|
||||
# License
|
||||
|
||||
It's all MIT, except the example inventory.png which is courtesy of Wynncraft. Zeer you better not come after me for this one
|
||||
It's all MIT, except the example corrupted inventory.png which is courtesy of Wynncraft.
|
||||
|
||||
Zeer you better not come after me for this one, you still haven't answered my gdpr req yet
|
94
src/main.rs
94
src/main.rs
|
@ -1,9 +1,12 @@
|
|||
use image::ImageBuffer;
|
||||
use zune_png::{zune_core::options::DecoderOptions, PngDecoder};
|
||||
use clap::Parser;
|
||||
use glob::glob;
|
||||
use std::fs::metadata;
|
||||
use std::path::{Path, PathBuf};
|
||||
use image::ImageBuffer;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::{
|
||||
fs::{metadata, File},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use zune_png::{zune_core::options::DecoderOptions, PngDecoder};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
|
@ -11,75 +14,70 @@ struct Args {
|
|||
/// Input path
|
||||
///
|
||||
/// Include a file path or a directory path. Do not use any asterisks or wildcards.
|
||||
/// If the path includes spaces you may find it useful to use speechmarks (" ") around the path.
|
||||
#[arg(short, long)]
|
||||
path: PathBuf,
|
||||
|
||||
/// Output path
|
||||
#[arg(short, long,default_value="")]
|
||||
out: PathBuf,
|
||||
|
||||
// /// Output path
|
||||
// #[arg(short, long,default_value="")]
|
||||
// out: PathBuf,
|
||||
/// Debug mode
|
||||
#[arg(short, long, default_value_t=false)]
|
||||
///
|
||||
/// Either "true" or "false"
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
debug: bool,
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
// argument parsing yep
|
||||
let Args: Args = Args::parse();
|
||||
let pathfr = Args.path.clone();
|
||||
let outfr = match Args.out {
|
||||
Some(realoutpath) => {
|
||||
realoutpath
|
||||
},
|
||||
None => {
|
||||
Args.path
|
||||
}
|
||||
};
|
||||
let realdebugmode = Args.debug;
|
||||
|
||||
let mut filelist: Vec<String> = Vec::new();
|
||||
let debugmode = Args.debug;
|
||||
|
||||
let mut filelist: Vec<PathBuf> = Vec::new();
|
||||
|
||||
let pathtype = metadata(&pathfr).unwrap();
|
||||
if pathtype.is_file() {
|
||||
|
||||
}
|
||||
else if pathtype.is_dir() {
|
||||
filelist.push(PathBuf::from(format!("{:?}", pathtype)));
|
||||
println!("input path FILE");
|
||||
} else if pathtype.is_dir() {
|
||||
println!("input path DIR");
|
||||
// parse file list if it's a dir
|
||||
for entry in glob(&format!("{}/**/*.png", pathfr.clone().display())).expect("Failed to read glob pattern (you should panic)") {
|
||||
for entry in glob(&format!("{}/**/*.png", pathfr.clone().display()))
|
||||
.expect("Failed to read glob pattern (you should panic)")
|
||||
{
|
||||
match entry {
|
||||
Ok(path) => {
|
||||
// println!("{:?}", path.display());
|
||||
filelist.push(path.display().to_string());
|
||||
},
|
||||
filelist.push(path.display().to_string().parse().unwrap());
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Shell globbing error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
panic!("that input is neither file nor dir and thats scary")
|
||||
} else {
|
||||
panic!("that input is neither file nor dir and thats scary...")
|
||||
}
|
||||
|
||||
// if debugmode {
|
||||
// for i in filelist.clone() {
|
||||
// println!("List of files: {}",i.display())
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if realdebugmode {
|
||||
for i in filelist {
|
||||
println!("List of files: {i}")
|
||||
}
|
||||
for thatpath in filelist {
|
||||
encoder(thatpath, debugmode)
|
||||
}
|
||||
}
|
||||
|
||||
fn encoder(filepath: PathBuf, modeDebug: bool) {
|
||||
let file = File::open(&filepath).unwrap();
|
||||
let mut data = BufReader::new(file);
|
||||
let mut buf = Vec::new();
|
||||
data.read_to_end(&mut buf).unwrap();
|
||||
|
||||
let data = include_bytes!("../inventory.png");
|
||||
|
||||
|
||||
|
||||
|
||||
let mut decoder = PngDecoder::new_with_options(data, DecoderOptions::new_cmd());
|
||||
|
||||
let mut decoder = PngDecoder::new_with_options(buf, DecoderOptions::new_cmd());
|
||||
decoder.decode_headers().unwrap();
|
||||
let dim = decoder.get_dimensions().unwrap();
|
||||
//dbg!(dim);
|
||||
|
@ -89,10 +87,18 @@ fn main() {
|
|||
//dbg!(&data);
|
||||
let depth = decoder.get_depth().unwrap();
|
||||
|
||||
if modeDebug {
|
||||
println!("Filepath: {:?}", filepath);
|
||||
println!("Dimensions: {:?}", dim);
|
||||
println!("Colorspace: {:?}", col);
|
||||
println!("BitDepth: {:?}", depth);
|
||||
}
|
||||
|
||||
// TODO: figure out propper color checks rn we assume data is RGBA
|
||||
|
||||
let out: ImageBuffer<image::Rgba<u8>, Vec<u8>> =
|
||||
ImageBuffer::from_raw(dim.0 as u32, dim.1 as u32, data).unwrap();
|
||||
|
||||
out.save("out.png").unwrap();
|
||||
out.save(filepath.clone()).unwrap();
|
||||
println!("wrote file {:?}\n",filepath)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue