Compare commits
2 commits
69288185c1
...
022dbec73e
Author | SHA1 | Date | |
---|---|---|---|
022dbec73e | |||
60daca96ca |
4 changed files with 118 additions and 54 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024 endernon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
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
|
30
readme.md
Normal file
30
readme.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# respack-decrypter
|
||||
|
||||
This tool allows you to unfuck corrupted images in a resource pack that have been corrupted to be protected.
|
||||
|
||||
# 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/ --debug > ~/log.txt`
|
||||
|
||||
# License
|
||||
|
||||
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
|
112
src/main.rs
112
src/main.rs
|
@ -1,83 +1,83 @@
|
|||
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)]
|
||||
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: Vec<PathBuf>,
|
||||
|
||||
/// Output path
|
||||
#[arg(short, long)]
|
||||
out: Option<PathBuf>,
|
||||
path: PathBuf,
|
||||
|
||||
// /// Output path
|
||||
// #[arg(short, long,default_value="")]
|
||||
// out: PathBuf,
|
||||
/// Debug mode
|
||||
///
|
||||
/// 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() {
|
||||
|
||||
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)")
|
||||
{
|
||||
match entry {
|
||||
Ok(path) => {
|
||||
// println!("{:?}", path.display());
|
||||
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 if pathtype.is_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)") {
|
||||
// match entry {
|
||||
// Ok(path) => {
|
||||
// // println!("{:?}", path.display());
|
||||
// filelist.push(path.display().to_string());
|
||||
// },
|
||||
// Err(e) => {
|
||||
// println!("Shell globbing error");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// panic!("")
|
||||
// }
|
||||
//
|
||||
|
||||
// if debugmode {
|
||||
// for i in filelist.clone() {
|
||||
// println!("List of files: {}",i.display())
|
||||
// }
|
||||
// }
|
||||
|
||||
if realdebugmode {
|
||||
for i in filelist {
|
||||
println!("{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);
|
||||
|
@ -87,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