获取app图片
来源:互联网 发布:哈密顿算法 编辑:程序博客网 时间:2024/06/11 14:39
import sys,os.path,shutil
import zipfilefrom struct import *
from zlib import *
import md5
def getNormalizedPNG(filename):
pngheader = "\x89PNG\r\n\x1a\n"
file = open(filename, "rb")
oldPNG = file.read()
file.close()
if oldPNG[:8] != pngheader:
return None
newPNG = oldPNG[:8]
chunkPos = len(newPNG)
# For each chunk in the PNG file
while chunkPos < len(oldPNG):
# Reading chunk
chunkLength = oldPNG[chunkPos:chunkPos+4]
chunkLength = unpack(">L", chunkLength)[0]
chunkType = oldPNG[chunkPos+4 : chunkPos+8]
chunkData = oldPNG[chunkPos+8:chunkPos+8+chunkLength]
chunkCRC = oldPNG[chunkPos+chunkLength+8:chunkPos+chunkLength+12]
chunkCRC = unpack(">L", chunkCRC)[0]
chunkPos += chunkLength + 12
# Parsing the header chunk
if chunkType == "IHDR":
width = unpack(">L", chunkData[0:4])[0]
height = unpack(">L", chunkData[4:8])[0]
# Parsing the image chunk
if chunkType == "IDAT":
try:
# Uncompressing the image chunk
bufSize = width * height * 4 + height
chunkData = decompress( chunkData, -8, bufSize)
except Exception, e:
# The PNG image is normalized
return None
# Swapping red & blue bytes for each pixel
newdata = ""
for y in xrange(height):
i = len(newdata)
newdata += chunkData[i]
for x in xrange(width):
i = len(newdata)
newdata += chunkData[i+2]
newdata += chunkData[i+1]
newdata += chunkData[i+0]
newdata += chunkData[i+3]
# Compressing the image chunk
chunkData = newdata
chunkData = compress( chunkData )
chunkLength = len( chunkData )
chunkCRC = crc32(chunkType)
chunkCRC = crc32(chunkData, chunkCRC)
chunkCRC = (chunkCRC + 0x100000000) % 0x100000000
# Removing CgBI chunk
if chunkType != "CgBI":
newPNG += pack(">L", chunkLength)
newPNG += chunkType
if chunkLength > 0:
newPNG += chunkData
newPNG += pack(">L", chunkCRC)
# Stopping the PNG file parsing
if chunkType == "IEND":
break
return newPNG
def updatePNG(filename):
data = getNormalizedPNG(filename)
if data != None:
tempfil = filename.replace('/','_')
finname = 'icons/'+tempfil
# print finname
file = open(finname, "wb")
file.write(data)
file.close()
return True
return data
def analyseFile(filename):
# print filename
if len(filename)>4:
if filename[-4:]=='.ipa':
print filename
temName = filename[0:-4]
if os.path.exists(temName)==False:
os.mkdir(temName)
# print temName
newfile = temName+'.zip'
os.rename(filename,newfile)
zfile=zipfile.ZipFile(newfile)
zfile.extractall(temName)
tempPath = temName+'/'+'Payload'
filepath = os.path.join(tempPath)
apps = os.listdir(filepath)
for aItem in apps:
fp = tempPath+'/'+aItem
finalPath = os.path.join(fp)
images = os.listdir(finalPath)
for img in images:
if img[-4:].lower() == '.png':
# print img
imgPath = finalPath+'/'+img
imgPath = os.path.join(imgPath)
updatePNG(imgPath)
def func():
if os.path.exists("icons")==False:
os.mkdir("icons")
files = os.listdir(os.getcwd())
for item in files:
analyseFile(item)
if __name__ == "__main__":
if len(sys.argv)==2:
if os.path.exists("icons")==False:
os.mkdir("icons")
analyseFile(sys.argv[1])
else:
func()
- 获取app图片
- app store 中的图片的获取
- iOS获取App Assets图片的方式
- iOSImagesExtractor(获取App上的所有图片)
- 高仿Demo获取该App图片
- 如何获取别人APP中的图片资源
- app 获取ios相册的图片
- 关于如何获取别的app包内图片资源
- iOS小技巧15-获取App安装包中的图片
- 获取网页缓存图片 --- 转至4app海浪whde
- 如何获取自己想要模拟的APP的相关图片?
- 怎样获取苹果APP里的资源图片
- 获取IOS APP应用ipa、car文件全部图片
- iOS逆向工程——获取app素材图片
- 使用Fiddler抓包工具获取App图片资源
- APP图片
- app图片
- 玩转【斗鱼直播APP】系列之获取APP图片资源
- chapter4程序代码
- 判断回文字符串
- 网页三剑客
- 链接动态库vs链接静态库
- zoj2110Tempter of the Bone
- 获取app图片
- 段寄存器的结构
- 第一部分 基本语言 第三章 标准库类型(3.3标准库vector类型)
- VC++程序导出数据到EXCEL
- 5-3 长方体类
- STM32F10x 学习笔记4(CRC计算单元 续)
- 杭电1035 Robot Motion
- 大龄程序员的出路在哪里?
- 安卓-生命周期简述