4 ms·
Abmagick – abuse ImageMagick to create arbitrary files
- tyingq 4y agoClever. It's creating a 1x13 image and filling it, left to right, with rgb values that correspond to the hex values of each character in "Hello world!\n". Then using the "gray:filename" output to flatten each RGB value (like #484848) into one grayscale value (like #48, 'H'). He first fills it with 6C, which corresponds to a lowercase 'l', to reduce the amount of points that need to be filled in with something different...since 'l' is repeated a lot in "Hello world\n". Edit: A more compact way to get the same outcome: $ convert 'inline:data:image/x-portable-graymap;base64,UDUKMSAxMwoyNTUKSGVsbG8gd29ybGQhCg==' gray:hello
- jwilk 4y agoHah, Cunningham's Law strikes again. Thanks! In my excuse, I developed this first for GraphicsMagick, which doesn't support "inline:".
- tyingq 4y agoNot sure Cunningham's law really applies here. I wasn't aware of the "gray:" functionality before this post. And, as you say, doesn't work on gm anyway :)
- metadat 4y agoFor those unfamiliar with "Cunningham's Law": > Cunningham's Law states "the best way to get the right answer on the internet is not to ask a question; it's to post the wrong answer." > The concept is named after Ward Cunningham, the inventor of wiki software.
- altdataseller 4y agoWhat would be some practical purposes for this?
- viraptor 4y agoExploits come to mind. Since imagemagick's interface is the command line, you'll find many services where some parameter is not properly sanitised and you can inject extra options to "convert". This generator gives you easy to use arbitrary file creation gadgets which can be extremely useful to escalate access.
- tyingq 4y agoYou can even find sites that give you direct access to add imagemagick parameters, like: https://freetoolonline.com/imagemagick-online.html https://freetoolonline.com/imagemagick-online.html
- dontbenebby 4y ago> What would be some practical purposes for this? Anything that uses the library. Imagine someone goes to scan the QR code for an TOTP generator, and they scan the image rather than type the values into the generator, they get their phone rooted. Not a fun way to start a new job or journalism project or whatever.
- dylan604 4y agoThis attack vector is why I'm not a huge fan of QR codes. I am required to use them for some work that I do, but they are created by me and I test them before publishing them. I had to trust the QR code isn't doing anything malicious like routing to an unknown server before redirecting to ultimate URL so it looks legite. There's just nothing in a QR code that allows for "guessing" if it's malicious or not.
- capableweb 4y agoThe problem is not with QR codes themselves, but how readers/scanners present/use QR codes. If you're not allowed to see the full URL/data inside the QR code when scanning it, before going to the URL/taking action on the data, then you need to try a different client.
- PhilipTrauner 4y ago0_0 # Python >= 3.6 is required (https://github.com/jwilk/abmagick/blob/8959fe7c390283d095e4288a4e10c615cd08698c/abmagick#L12 https://github.com/jwilk/abmagick/blob/8959fe7c390283d095e42...) Highly cursed, yet wildly creative way of asserting the language version. Support for underscores in numeric literals landed in 3.6 (PEP-515), < 3.6 chokes on the underscore and raises a syntax error instead.
- jwilk 4y agoSee https://github.com/jwilk/python-syntax-errors https://github.com/jwilk/python-syntax-errors if you need curses for other Python versions.
- PhilipTrauner 4y agoCan't help but feel that this approach might not be that cursed after all, seeing how you actually went through the effort of automatically testing all of these. Nothing beats this guy though: 0_0
- deleted 4y ago[deleted]
- saghm 4y agoThe first time I read this, I thought you were making a wide-eyed emoticon about the fact that it requires Python 3.6
- metadat 4y agoSee also related: "What the fuck Python?" https://github.com/satwikkansal/wtfpython https://github.com/satwikkansal/wtfpython Along with the corresponding HN discussion: https://news.ycombinator.com/item?id=31566031 https://news.ycombinator.com/item?id=31566031 (450 points, 153 comments)