For the creation of this post I was inspired by this , this and this . If these rarjpegs can be created, then they can also be defined among ordinary "innocent" images. Immediately, .jpg and .png fall under suspicion. But how to distinguish rarzhpeg from the usual picture?
A banal size comparison (if, for example, a picture is larger than 10 MB, then it can be a rarjpeg) does not help - there can be different sizes: a 10Kb picture with a single-line textbook hidden in it or a large photo with a rather large audio file inside. How would you distinguish?
I would do this: calculate the image size ( высота*ширина*глубина_цвета ) and compare it with the actual file size. Not agreed - it means rarzhpeg. But how then to calculate the size of EXIF and compression (jpg), they are also part of the image?
UPDATE Wrote a working (rather smart) algorithm in Java (tested on Android). It works calmly with png + zip / rar, jpg + zip / rar.
//Определим заголовки файлов String HEADER_RAR = "Rar!"; //Для .rar это будет Rar! String HEADER_ZIP = new String(new BigInteger("504B0304", 16).toByteArray()); //а для .zip будет "PK" и ещё два нечитаемых символа, поэтому мы получим их из HEX-кода //создаём массив строк с путями к нужным изображениям (ArrayList<String> mImages) ArrayList<String> mRarjpegs = new ArrayList<String>(); //массив с путями к раржпегам for (String path : mImages) { //проверяем каждый файл try { BufferedReader br = new BufferedReader(new FileReader(path)); String line; while ((line = br.readLine()) != null) //открываем файл построчно... { if (line.contains(HEADER_RAR) || line.contains(HEADER_ZIP)) // ...если в строке нашёлся заголовок одного из архивов... { mRarjpegs.add(path); // ...то добавим его в список раржпегов break; // ...и выйдем из цикла, чтобы не считывать остальную часть файла } } } catch (Exception ex) { /* что-то своё */ } } //На выходе получим mRarjpegs, наполненный путями
0xFF, 0xD9) far to the end of the file. Facebook and VKontakte download pictures resample, so there the RAR part will not work. So, when uploading images, you can pinch them with GD or ImageMagick, so as not to miss too much. - Sergiks