fix reading zip with data descriptors
This commit is contained in:
parent
9b1ecd1b42
commit
2c954d8d74
3 changed files with 13 additions and 18 deletions
3
apk_frauder/TODO.md
Normal file
3
apk_frauder/TODO.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- replace panic/unwrap/expect with results
|
||||||
|
- tests
|
||||||
|
- write zip with data descriptor
|
||||||
|
|
@ -33,7 +33,7 @@ pub struct DataDescriptor64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DataDescriptor32 {
|
impl DataDescriptor32 {
|
||||||
const SIGNATURE: Signature = Signature(0x02014b50);
|
const SIGNATURE: Signature = Signature(0x08074b50);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serializable for DataDescriptor32 {
|
impl Serializable for DataDescriptor32 {
|
||||||
|
|
@ -49,6 +49,13 @@ impl Serializable for DataDescriptor32 {
|
||||||
fn deserialize(input: &mut dyn ReadSeek) -> Result<Self> {
|
fn deserialize(input: &mut dyn ReadSeek) -> Result<Self> {
|
||||||
let pos = input.stream_position().unwrap(); //TODO
|
let pos = input.stream_position().unwrap(); //TODO
|
||||||
let signature = Signature::deserialize(input)?;
|
let signature = Signature::deserialize(input)?;
|
||||||
|
println!(
|
||||||
|
"Found: 0x{:x}, expected 0x{:x}, eq: {}",
|
||||||
|
signature.0,
|
||||||
|
Self::SIGNATURE.0,
|
||||||
|
signature == Self::SIGNATURE
|
||||||
|
);
|
||||||
|
|
||||||
let use_signature = if signature != Self::SIGNATURE {
|
let use_signature = if signature != Self::SIGNATURE {
|
||||||
input.seek(SeekFrom::Start(pos)).unwrap(); //TODO
|
input.seek(SeekFrom::Start(pos)).unwrap(); //TODO
|
||||||
false
|
false
|
||||||
|
|
@ -75,7 +82,7 @@ impl Serializable for DataDescriptor32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DataDescriptor64 {
|
impl DataDescriptor64 {
|
||||||
const SIGNATURE: Signature = Signature(0x02014b50);
|
const SIGNATURE: Signature = Signature(0x08074b50);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serializable for DataDescriptor64 {
|
impl Serializable for DataDescriptor64 {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
use apk_frauder::ZipFileReader;
|
//use apk_frauder::ZipFileReader;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
use apk_frauder::data_descriptor::{DataDescriptor, DataDescriptor32};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
/*
|
|
||||||
apk_frauder::replace_dex(
|
apk_frauder::replace_dex(
|
||||||
"app-release.apk",
|
"app-release.apk",
|
||||||
"app-instrumented.apk",
|
"app-instrumented.apk",
|
||||||
|
|
@ -22,17 +19,5 @@ fn main() {
|
||||||
env::var("HOME").expect("$HOME not set")
|
env::var("HOME").expect("$HOME not set")
|
||||||
)),
|
)),
|
||||||
None::<HashMap<String, Option<Cursor<&[u8]>>>>,
|
None::<HashMap<String, Option<Cursor<&[u8]>>>>,
|
||||||
);*/
|
|
||||||
let mut file = File::open("test_data_descriptor.zip").expect("failed to open file");
|
|
||||||
let reader = ZipFileReader::new(&mut file);
|
|
||||||
println!("{:#?}", &reader.files[..4]);
|
|
||||||
assert_eq!(
|
|
||||||
reader.files[0].clone().data_descriptor,
|
|
||||||
Some(DataDescriptor::Zip32(DataDescriptor32 {
|
|
||||||
crc_32: reader.files[0].header.crc_32,
|
|
||||||
compressed_size: reader.files[0].header.compressed_size,
|
|
||||||
uncompressed_size: reader.files[0].header.uncompressed_size,
|
|
||||||
use_signature: false,
|
|
||||||
},),)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue