implant.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:stegator 作者: 1modm 项目源码 文件源码
def get_img(self):
        try:
            imgur = "None"
            download_img = True

            print((colored('[+] Downloading image from Cloud Service...', 'white')))
            while download_img:

                # Remove not valid img downloaded 
                if (os.path.isfile(imgur)):
                    os.remove(imgur)

                imgur = ''.join(random.sample(string.letters+string.digits, 5)) + '.jpg'
                img = urllib2.urlopen("http://i.imgur.com/" + imgur).read()

                if len(img) != 503: # 'image not found' is 503 bytes
                    with open(os.path.join('./', imgur), "wb") as f:
                        f.write(img)
                    f.close()

                    with Image.open(imgur) as im:
                        width, height = im.size

                    # Enough big to insert data
                    if (width > 400 and height > 400):
                        download_img = False

            return imgur
        except:
            print((colored("[-] Get image error", "yellow")))
            if (os.path.isfile(imgur)):
                os.remove(imgur)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号