exploit xpdf
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[FrontPage]] > [[Armadillo-9]] > [[exploit xpdf]]
*xpdf へのバッファオーバーフロー攻撃 [#z0232813]
-x86 の攻撃のときに得た、基礎的な知見を述べています。ARM ...
--[[exploit xpdf on ARM>exploit xpdf_arm]]
**環境 [#b587ffe2]
-CPU: x86
-OS: Debian Sarge
-target: xpdf-3.00
--この脆弱性は xpdf-3.00pl2.patch で対応された。
--Debian のは既にパッチが当たってるので、脆弱性を埋め込ん...
-独自ビルドについて
--lesstif を使った
--configure に書いてあるコンパイラに渡すフラグ -O2 を解除...
--Debian Sarge の xpdf.3.00-orig.tar.gz を参考に、Debian ...
--maskColors を宣言する位置を変える。詳細は後述する。
Gfx.cc:2660 行付近
パッチが当たると、以下のように境界チェックが入る。
if (maskObj.isArray()) {
for (i = 0;
i < maskObj.arrayGetLength() && i < 2*gfxColorMax...
++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;
}
-スタティックリンクについて
--configure を編集して、フラグ -lXxxx の前に -lpthread を...
--g++ -g --static -DHAVE_CONFIG_H -I.. -I./../goo -I./../...
--↑がエラーで落ちるので、-lXm の前に -lXpm を入れる。
**実行結果 [#s16549b8]
-ARM で成功。
~/apps/xpdf_exploit$ ls -ls /tmp/itworked
ls: /tmp/itworked: No such file or directory
~/apps/xpdf_exploit$ ./xpdf_change_arm ./exploit_xpdf_ch...
Error: No display font for 'Courier'
Error: No display font for 'Courier-Bold'
(...snip...)
Error (0): PDF file is damaged - attempting to reconstru...
~/apps/xpdf_exploit$ ls -ls /tmp/itworked
0 -rw-r--r-- 1 a users 0 Aug 24 12:36 /tmp/itworked
-x86 で成功。
--攻撃が成功すると sys_execve が実行され、touch${IFS}/tmp...
--フルパスで指定しないと、スタックの位置がずれてしまって...
/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...
Error (0): PDF file is damaged - attempting to reconstru...
/tmp$ ls -la /tmp/itworked
-rw-r--r-- 1 a a 0 2006-08-14 03:02 /tmp/itworked
**攻撃対象、条件 [#z1ad1f1c]
***脆弱性のある関数 [#f04d51e5]
-Gfx.cc の Gfx::doImage という関数に、バッファオーバーフ...
--脆弱性のある箇所は Gfx.cc の 2660行目あたりである。
-ループの条件で、バッファの境界チェックがなされていないた...
***脆弱性の詳細 [#xb96422d]
-pdf では画像の透明部分を指定するために /Mask [255 255 10...
-上記の Mask が読み込まれる maskColors という固定長バッフ...
**注意点 [#bffa5430]
*攻撃の詳細 [#h8326e49]
**攻撃対象の変数 [#y693a0a2]
ローカル変数の配置は以下のようになっている。
| 0x00000000
|[maskColors] //攻撃対象
|[maskObj] //maskColors の取得に必要な変数
|...
|[return address]
| 0xffffffff
Debian Sarge の環境では、maskColors の先頭からリターンア...
-maskColors の取得には maskObj を使っているので、maskObj ...
--しかし元のコードだと配置が良くないため、単純にオーバー...
-そこでソースコードを以下のように変更し、maskColors より...
--(ARM 版)
--(x86 版)この変更によって、maskColors の先頭からリターン...
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;
*参考 [#q3bc29ab]
-脆弱性の説明と、脆弱性のある箇所について掲載している。~
http://www.idefense.com/intelligence/vulnerabilities/disp...
void Gfx::doImage(Object *ref, Stream *str, GBool inline...
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;
}
...
}
**その他 [#j1ff2775]
pdf の仕組みなどが解ったら書いていく。
Image オブジェクト(?)がある行に、いきなり /Mask などを...
Author とか Creator の後に並んでいる 16進数のようなものは...
終了行:
[[FrontPage]] > [[Armadillo-9]] > [[exploit xpdf]]
*xpdf へのバッファオーバーフロー攻撃 [#z0232813]
-x86 の攻撃のときに得た、基礎的な知見を述べています。ARM ...
--[[exploit xpdf on ARM>exploit xpdf_arm]]
**環境 [#b587ffe2]
-CPU: x86
-OS: Debian Sarge
-target: xpdf-3.00
--この脆弱性は xpdf-3.00pl2.patch で対応された。
--Debian のは既にパッチが当たってるので、脆弱性を埋め込ん...
-独自ビルドについて
--lesstif を使った
--configure に書いてあるコンパイラに渡すフラグ -O2 を解除...
--Debian Sarge の xpdf.3.00-orig.tar.gz を参考に、Debian ...
--maskColors を宣言する位置を変える。詳細は後述する。
Gfx.cc:2660 行付近
パッチが当たると、以下のように境界チェックが入る。
if (maskObj.isArray()) {
for (i = 0;
i < maskObj.arrayGetLength() && i < 2*gfxColorMax...
++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;
}
-スタティックリンクについて
--configure を編集して、フラグ -lXxxx の前に -lpthread を...
--g++ -g --static -DHAVE_CONFIG_H -I.. -I./../goo -I./../...
--↑がエラーで落ちるので、-lXm の前に -lXpm を入れる。
**実行結果 [#s16549b8]
-ARM で成功。
~/apps/xpdf_exploit$ ls -ls /tmp/itworked
ls: /tmp/itworked: No such file or directory
~/apps/xpdf_exploit$ ./xpdf_change_arm ./exploit_xpdf_ch...
Error: No display font for 'Courier'
Error: No display font for 'Courier-Bold'
(...snip...)
Error (0): PDF file is damaged - attempting to reconstru...
~/apps/xpdf_exploit$ ls -ls /tmp/itworked
0 -rw-r--r-- 1 a users 0 Aug 24 12:36 /tmp/itworked
-x86 で成功。
--攻撃が成功すると sys_execve が実行され、touch${IFS}/tmp...
--フルパスで指定しないと、スタックの位置がずれてしまって...
/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...
Error (0): PDF file is damaged - attempting to reconstru...
/tmp$ ls -la /tmp/itworked
-rw-r--r-- 1 a a 0 2006-08-14 03:02 /tmp/itworked
**攻撃対象、条件 [#z1ad1f1c]
***脆弱性のある関数 [#f04d51e5]
-Gfx.cc の Gfx::doImage という関数に、バッファオーバーフ...
--脆弱性のある箇所は Gfx.cc の 2660行目あたりである。
-ループの条件で、バッファの境界チェックがなされていないた...
***脆弱性の詳細 [#xb96422d]
-pdf では画像の透明部分を指定するために /Mask [255 255 10...
-上記の Mask が読み込まれる maskColors という固定長バッフ...
**注意点 [#bffa5430]
*攻撃の詳細 [#h8326e49]
**攻撃対象の変数 [#y693a0a2]
ローカル変数の配置は以下のようになっている。
| 0x00000000
|[maskColors] //攻撃対象
|[maskObj] //maskColors の取得に必要な変数
|...
|[return address]
| 0xffffffff
Debian Sarge の環境では、maskColors の先頭からリターンア...
-maskColors の取得には maskObj を使っているので、maskObj ...
--しかし元のコードだと配置が良くないため、単純にオーバー...
-そこでソースコードを以下のように変更し、maskColors より...
--(ARM 版)
--(x86 版)この変更によって、maskColors の先頭からリターン...
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;
*参考 [#q3bc29ab]
-脆弱性の説明と、脆弱性のある箇所について掲載している。~
http://www.idefense.com/intelligence/vulnerabilities/disp...
void Gfx::doImage(Object *ref, Stream *str, GBool inline...
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;
}
...
}
**その他 [#j1ff2775]
pdf の仕組みなどが解ったら書いていく。
Image オブジェクト(?)がある行に、いきなり /Mask などを...
Author とか Creator の後に並んでいる 16進数のようなものは...
ページ名: