Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Embed a ZIP or JAR file within a PNG image to create a tweetable and "executable" PNG-ZIP polyglot image file. CLI / Web tool.

License

NotificationsYou must be signed in to change notification settings

CleasbyCode/pdvzip-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Embed aZIP orJAR file within aPNG image, to create atweetable and "executable"PNG polyglot file.
Share the image onX/Twitter and a few other hosting sites, which will retain the embedded archive.

Withpdvzip, you can embed aZIP/JAR file up to a maximum size of2GB (cover image + archive file).

Compatible sites,listed below, have their ownmuch smaller size limits:-

X/Twitter (5MB),Flickr (200MB),ImgBB (32MB),PostImage (32MB),ImgPile (8MB).

Demo Image
Image credit:@obeca

Based on the similar idea byDavid Buchanan, from his originalPython programtweetable-polyglot-png,
pdvzip uses different methods forstoring andextracting embedded files within aPNG image.

TheLinux/Windows extraction script is stored within theiCCP chunk of thePNG image. The embeddedZIP/JAR file is stored within the lastIDAT chunk of the image.

(You can try thepdvzip Web App, here, if you don't want to download and compile the CLI source code.)

Usage (Linux)

user1@linuxbox:~/Downloads/pdvzip-main/src$g++ main.cpp -O2 -s -o pdvzipuser1@linuxbox:~/Downloads/pdvzip-main/src$sudo cp pdvzip /usr/binuser1@linuxbox:~/Desktop$pdvzipUsage: pdvzip <cover_image> <zip/jar>       pdvzip --infouser1@linuxbox:~/Desktop$pdvzip my_cover_image.png document_pdf.zipCreated PNG-ZIP polyglot image file: pzip_55183.png (4038367 bytes).Complete!user1@linuxbox:~/Desktop$pdvzip my_cover_image.png hello_world.jarCreated PNG-JAR polyglot image file: pjar_19662.png (1016336 bytes).Complete!

Extracting Your Embedded File(s)

Important: When saving images fromX/Twitter, click the image in the post tofully expand it, before saving.

The following section covers the extraction of embeddedZIP files.JAR files are covered later.

pdvzip (forLinux) will attempt toautomatically set executable permissions on newly created polyglot image files.

You will need to manually set executable permissions usingchmod on these polyglot images downloaded from hosting sites.

Twitter.ZIP.Folder.mp4

Linux - using bash (or sh) shell environment.

user1@linuxbox:~/Desktop$./pzip_55183.png

For any other Linux shell environment, you will probably need to invoke bash (or sh) to run the image file.

linuxbox% bash ./pzip_55183.png

Alternative extraction (Linux). Usingwget to download and run the image directly from the hosting site.
X/Twitterwget example:Image with embeddedpython script.

wget -O Fibo.png "https://pbs.twimg.com/media/GLXTYeCWMAAA6B_.png";chmod +x Fibo.png;bash ./Fibo.png

Windows(Rename the image file extension to '.cmd')

G:\demo> ren pzip_55183.png pzip_55183.cmdG:\demo> .\pzip_55183.cmd

Alternative extraction (Windows). Usingiwr to download and run the image directly from the hosting site.
Flickriwr example:Image with embedded mp4 video file.

iwr -o swing.cmd "https://live.staticflickr.com/65535/54025688614_2f9d474cba_o_d.png";.\swing.cmd

Opening the.cmd file from the desktop, on its first run,Windows may display a security warning.
Clear this by clicking 'More info' then select 'Run anyway'.

To avoid security warnings, run the file from aWindows console, as shown in the above example.

For commonvideo & audio files,Linux will use thevlc ormpv media player.Windows uses the default media player.

PDF -Linux will useevince orfirefox.Windows uses the defaultPDF viewer.
Python -Linux &Windows usepython3 to run these programs.
PowerShell -Linux usespwsh (if installed),Windows uses eitherpowershell.exe orpwsh.exe to run these scripts.Folder -Linux usesxdg-open,Windows usespowershell.exe with II (Invoke-Item) command, to open zipped folders.

For any other file type within yourZIP file,Linux &Windows will rely on the operating system's set default method/application. Obviously, the compressed/embedded file needs to be compatible with the operating system you run it on.

If the archive file is JAR or the compressed file type within the ZIP archive isPowerShell,Python,Shell Script or aWindows/Linux Executable, pdvzip will give you the option to provide command-line arguments for your file, if required.

Make sure to enclose arguments containing spaces, such as file & directory names, within "quotation" marks. e.g.

user1@linuxbox:~/Desktop$./pdvzip my_cover_image.png jdvrif_linux_executable.zipFor this file type you can provide command-line arguments here, if required.Linux: -e ../my_cover_image.jpg "../my document file.pdf"

Also, be aware when using arguments for the compressed ZIP file types (not JAR), you are always working from within the subdirectory "pdvzip_extracted".

pdvzip.web.app.mp4

To just get access to the file(s) within theZIP archive, rename the '.png' file extension to '.zip'.
Treat theZIP archive as read-only, do not add or remove files from thePNG-ZIP polyglot file.

Executing Embedded JAR Files

Linux Option 1:

user1@linuxbox:~/Desktop$java -jar pjar_19662.pngNote: If you use this method to run your embedded JAR file, you will have to manually add command-line      arguments (if required) to the end of the command, as your embedded arguments will not work with      this method. e.g.      user1@linuxbox:~/Desktop$ java -jar ./pjar_19662.png -u john_s -a 42 -f "John Smith"

Linux Option 2a, using bash (or sh) shell environment:

user1@linuxbox:~/Desktop$./pjar_19662.pngNote: This method will execute the embedded JAR file and also use any embedded      command-line arguments with the JAR program.

Linux Option 2b, using any other shell environment, you will need to invoke bash (or sh) to execute the image:

linuxbox% bash ./pjar_19662.png

Windows Option 1:

PS C:\Users\Nick\Desktop\jar_demo> java -jar .\pjar_19662.pngNote: If you use this method to run your embedded JAR file, you will have to manually add command-line      arguments (if required) to the end of the command, as your embedded arguments will not work with      this method. e.g.      PS C:\Users\Nick\Desktop\jar_demo> java -jar .\pjar_19662.png -u john_s -a 42 -f "John Smith"

Windows Option 2:

PS C:\Users\Nick\Desktop\jar_demo> ren .\pjar_19662.png .\pjar_19662.cmdPS C:\Users\Nick\Desktop\jar_demo> .\pjar_19662.cmdNote: This method will execute the embedded JAR file and also use any      embedded command-line arguments with the JAR program.
pdvzip_jar_args.mp4

PNG Image Requirements for Arbitrary Data Preservation

PNG file size (image + archive file) must not exceed the hosting site's size limits.
The site will either refuse to upload your image or it will convert your image tojpg, such asX/Twitter.

Dimensions:

The following dimension size limits are specific topdvzip and not necessarily the extact hosting site's size limits.These dimension size limits are for compatibility reasons, allowing it to work with all the above listed platforms.

PNG-32/24 (Truecolor)

Image dimensions can be set between a minimum of68 x 68 and a maximum of899 x 899.

Note: Images that are created & saved within your image editor asPNG-32/24 that are eitherblack & white/grayscale, images with 256 colors or less, will be converted byX/Twitter toPNG-8 and you will lose the embedded content. If you want to use a simple "single" colorPNG-32/24 image, then fill an area with a gradient color instead of a single solid color.X/Twitter should then keep the image asPNG-32/24.(Example).

PNG-8 (Indexed-color)

Image dimensions can be set between a minimum of68 x 68 and a maximum of4096 x 4096.

PNG Chunks:

WithX/Twitter, for example, you canoverfill the followingPNG chunks with arbitrary data,
in which the platform will preserve as long as you keep within the image dimension & file size limits.

bKGD, cHRM, gAMA, hIST,
iCCP, (Limited size chunk. Only10KB max. withX/Twitter).
IDAT, (Use as lastIDAT chunk, after the final imageIDAT chunk).
PLTE, (Use only withPNG-32/24 images).
pHYs, sBIT, sPLT, sRGB,
tRNS. (Use only withPNG-32/24 images).

Other platforms may differ in what chunks they preserve and which ones you can overfill.

pdvzip uses the chunksiCCP (stores extraction script) andIDAT (stores theZIP/JAR file) for your arbitrary data.

ZIP/JAR File Size & Other Important Information

To work out the maximumZIP/JAR file size, start with the size limit, minus the image size, minus1500 bytes (extraction script size).

X/Twitter example: (5MB limit)5,242,880 - (307,200 [image] +1500 [extraction script]) =4,934,180 bytes available for yourZIP/JAR file.

  • Make sure yourZIP/JAR file is a standardZIP/JAR archive, compatible withLinux unzip &Windows Explorer.

  • Do not include more than one.zip file within the mainZIP archive. (.rar files are ok).

  • Do not include otherpdvzip createdPNG image files within the mainZIP archive, as they are essentially.zip files.

  • Use file extensions for your file(s) within theZIP archive:my_doc.pdf,my_video.mp4,my_program.py, etc.

    A file without an extension within aZIP archive will be considered aLinux executable.

  • Paint.net application is recommended for easily creating compatiblePNG image files.

Third-Party Libraries

This project includes the following third-party library:

  • LodePNG by Lode Vandevenne
    • License: zlib/libpng (seeLICENSE file)
    • Copyright (c) 2005-2024 Lode Vandevenne

About

Embed a ZIP or JAR file within a PNG image to create a tweetable and "executable" PNG-ZIP polyglot image file. CLI / Web tool.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++100.0%

[8]ページ先頭

©2009-2025 Movatter.jp