├── .gitignore ├── Downloads.md ├── README.md ├── cmdline ├── gist ├── reddit └── url ├── flash └── xxxswf.py ├── lib ├── aplib.py └── magic.py ├── lznt1 ├── LICENSE ├── Makefile ├── README.md ├── lznt1.c ├── lznt1.h └── lznt1.py └── vmware └── vmware_mount.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.swp 4 | -------------------------------------------------------------------------------- /Downloads.md: -------------------------------------------------------------------------------- 1 | Downloads from 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tools! 2 | Various code snippets that are too small/short to be projects. 3 | Most of the them work, but ymmv. 4 | 5 | ## LICENSE 6 | Each script has the license specified in it 7 | -------------------------------------------------------------------------------- /cmdline/gist: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | ''' 3 | Posts gists from commandline 4 | If the file is binary, a base64 encoded version is posted 5 | 6 | Dependencies: 7 | * requests 8 | * python2.7 or later (argparse) 9 | 10 | By default, the gist is posted anonymously. 11 | 12 | To post gists from an account, you need generate a personal access token at: 13 | https://github.com/settings/applications 14 | 15 | Then, export the personal access token as an environment variable "GIST_TOKEN": 16 | > export GIST_TOKEN=blahblahblah 17 | or just add it to your .bashrc 18 | 19 | Run the program with -h for all options 20 | 21 | For github enterprise, use the following for GISTS_URL: 22 | https://hostname/api/v3/gists 23 | 24 | LICENSE: Public Domain 25 | @author: kbandla 26 | ''' 27 | import os 28 | import pprint 29 | import requests 30 | import json 31 | import argparse 32 | from hashlib import md5 33 | 34 | GISTS_URL = "https://api.github.com/gists" 35 | AUTH_TOKEN = os.environ.get('GIST_TOKEN', None) 36 | 37 | def processData(data): 38 | ''' 39 | data if json encodeable, else base64 40 | returns a tuple - (data, isBase64Encoded) 41 | ''' 42 | try: 43 | json.dumps(data) 44 | return data, False 45 | except Exception as e: 46 | print 'File data might be binary. Base64 encoding it' 47 | return data.encode('base64'), True 48 | 49 | def gist(filepath, description='', private=False): 50 | filename = os.path.basename(filepath) 51 | data = open(filepath).read() 52 | md5sum = md5(data).hexdigest() 53 | data, isBase64Encoded = processData(data) 54 | 55 | headers = {} 56 | if AUTH_TOKEN: 57 | headers = {'Authorization' : 'token %s'%AUTH_TOKEN} 58 | # needed for github enterprise 59 | headers['User-Agent'] = 'cmdgist' 60 | if isBase64Encoded: 61 | description += ' base64' 62 | description += ' ( %s )'%(md5sum) 63 | payload = { 'description': description, 64 | 'public' : not private, 65 | 'files' : { 66 | filename: {'content' : data}, 67 | } 68 | } 69 | try: 70 | payload = json.dumps(payload) 71 | except UnicodeDecodeError as e: 72 | print 'Aborted : %s'%(e) 73 | return 74 | 75 | # Post data 76 | r = requests.post(GISTS_URL, data=payload, headers=headers) 77 | if r.status_code != 201: 78 | print '[%s] Error creating gist:'%(r.status_code) 79 | try: 80 | pprint.pprint(r.json()) 81 | except Exception as e: 82 | print r.text 83 | else: 84 | response = r.json() 85 | url = response.get('html_url',None) 86 | print '%s : %s'%(filepath, url) 87 | 88 | def main(): 89 | parser = argparse.ArgumentParser(description='Gist command line') 90 | parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', 91 | default=False, help='Verbose mode') 92 | parser.add_argument('-p', '--private', dest='private', action='store_true', 93 | default=False, help='Private') 94 | parser.add_argument('-d', '--description', dest='description', action='store', 95 | default='', help='Description') 96 | parser.add_argument('files', nargs='*', default=None) 97 | args = parser.parse_args() 98 | if not args.files: 99 | parser.print_help() 100 | exit() 101 | for filepath in args.files: 102 | if os.path.exists(filepath): 103 | gist(filepath, args.description, args.private) 104 | else: 105 | print 'File %s not found'%(filepath) 106 | 107 | if __name__ == "__main__": 108 | main() 109 | -------------------------------------------------------------------------------- /cmdline/reddit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | ''' 3 | Created on Aug 28, 2010 4 | A reddit client 5 | 6 | LICENSE: Public Domain 7 | @author: kbandla 8 | ''' 9 | import sys 10 | import json 11 | import time 12 | import httplib 13 | import argparse 14 | 15 | try: 16 | from termcolor import colored 17 | color = True 18 | except Exception,e: 19 | color = False 20 | 21 | URL = 'https://www.reddit.com/r/%s/.json' 22 | CLICK_URL = 'https://www.reddit.com/r/%s' 23 | SUBREDDITS = ['programming', 'linux','reverseengineering', 'netsec', 'malware'] 24 | TIME_DIFF = 86400 25 | 26 | def getJSON(subreddit): 27 | conn = httplib.HTTPSConnection('www.reddit.com' , timeout=2) 28 | headers = ({'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22', 29 | 'Accept-Language':'en-US,en;q=0.8', 30 | 'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 31 | }) 32 | conn.request('GET', '/r/%s/.json'%(subreddit), headers=headers) 33 | try: 34 | response = conn.getresponse() 35 | except Exception,e: 36 | print '[%s] Error : %s'%(subreddit, e) 37 | conn.close() 38 | return False 39 | if response.status == 200: 40 | data = response.read() 41 | data = json.loads( data ) 42 | conn.close() 43 | return data 44 | print '[%s] Error getting JSON. HTTP %s '%(subreddit, response.status) 45 | return False 46 | 47 | def reddit(subreddits, days=1, verbose=False): 48 | # clear console 49 | print chr(27) + "[2J" 50 | 51 | for subreddit in subreddits: 52 | url = URL%( subreddit ) 53 | data = getJSON( subreddit ) 54 | if not data: 55 | continue 56 | 57 | if color: 58 | print colored(subreddit, 'red'), CLICK_URL%subreddit 59 | else: 60 | print subreddit, CLICK_URL%subreddit 61 | 62 | if data.has_key('data'): 63 | if data['data'].has_key('children'): 64 | for post in data['data']['children']: 65 | if time.time() - float(post['data']['created']) < TIME_DIFF*days: 66 | title = post['data']['title'] 67 | comments = post['data']['permalink'] 68 | link = post['data']['url'] 69 | if color: 70 | print colored(title, 'white'), colored(link, 'green') 71 | else: 72 | print title, link 73 | print 74 | else: 75 | print 'Data error', data 76 | 77 | def main(): 78 | parser = argparse.ArgumentParser(description='REDDIT') 79 | parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Verbose mode') 80 | parser.add_argument('-d', '--days', dest='days', action='store', default=1, help='Number of days') 81 | parser.add_argument('subreddits', nargs='*', default=SUBREDDITS) 82 | args = parser.parse_args() 83 | if args.verbose: 84 | print 'Found %s subreddits to get'%(len(args.subreddits)) 85 | 86 | reddit( args.subreddits, args.days, args.verbose ) 87 | if __name__ == "__main__": 88 | main() 89 | -------------------------------------------------------------------------------- /cmdline/url: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # A very minimal URL redir analyzer 3 | # Kiran Bandla 4 | 5 | import os 6 | import re 7 | import sys 8 | import httplib, urllib 9 | from urlparse import urlparse 10 | import argparse 11 | import socket 12 | socket.setdefaulttimeout(2) 13 | 14 | import logging 15 | 16 | def getLogger(name, verbose=False, level=logging.DEBUG): 17 | logger = logging.getLogger(name) 18 | logger.setLevel(level) 19 | 20 | handler = logging.StreamHandler(sys.stdout) 21 | handler.setFormatter(logging.Formatter('%(levelname)s %(funcName)s| %(message)s')) 22 | logger.addHandler(handler) 23 | 24 | return logger 25 | 26 | class URLAnalyzer: 27 | ''' 28 | Analyze URLs to check for: 29 | + images 30 | + final landing page 31 | ''' 32 | 33 | def __init__(self, url, logger=None, verbose=False): 34 | self.verbose = verbose 35 | if logger: 36 | self.logger = logger 37 | else: 38 | if verbose: 39 | self.logger = getLogger('url_analyzer') 40 | else: 41 | self.logger = getLogger('url_analyzer', level=logging.INFO) 42 | 43 | self.url = url 44 | self.final = url 45 | self.depth = 0 46 | 47 | self.logger.debug('\033[91m%s\033[0m'%self.url) 48 | self.__scrubURL() 49 | try: 50 | self.__getFinalPage() 51 | except Exception,e: 52 | self.logger.error(e) 53 | 54 | # add individual handlers here ( packetstorm, etc ) 55 | # "This is an article straight from the wires, you can read the full story here" 56 | # see http://packetstormsecurity.com/news/22285 for an example 57 | self.logger.debug('depth = %d'%(self.depth)) 58 | 59 | def __getInverseMarker(self, symbol): 60 | ''' 61 | returns: 62 | < for > 63 | [ for ] etc 64 | ''' 65 | if symbol in ['"', "'", '"""', "'''"]: #identical inverse 66 | return symbol 67 | 68 | symbol_dict = { 69 | '<':'>', 70 | '[':']', 71 | '(':')', 72 | '{':'}', 73 | } 74 | if symbol_dict.has_key(symbol): 75 | return symbol_dict[symbol] 76 | 77 | symbol_dict = dict(zip(symbol_dict.values(), symbol_dict.keys())) 78 | 79 | if symbol_dict.has_key(symbol): 80 | return symbol_dict[symbol] 81 | 82 | return False 83 | 84 | 85 | def __scrubURL(self): 86 | ''' 87 | Cases: 88 | + URL does not start with http, but has http somewhere (http://www.com) 89 | ''' 90 | 91 | if 'http://' in self.url: 92 | position = self.url.find('http') 93 | self.logger.debug('Found "http" in url at position: %d'%(position)) 94 | char_at_pos = self.url[position-1] 95 | inv_char = self.__getInverseMarker( char_at_pos ) 96 | self.logger.debug('Found inverse symbol for %s : %s'%( char_at_pos, inv_char) ) 97 | if not inv_char: 98 | self.url = self.url[position:] 99 | return 100 | # find the right most inverse 101 | target_pos = self.url.rfind( inv_char ) 102 | self.url = self.url[position: target_pos] 103 | return 104 | 105 | # fixes 106 | if not self.url.startswith('http'): 107 | self.url = 'http://'+ self.url 108 | 109 | def __extractURLForward(self, html): 110 | ''' 111 | Extract the target URL from html, is possible 112 | ''' 113 | if 'http-equiv' in html: 114 | # content="0;URL=http://twitter.com/gollmann/status/313393642922442752/photo/1" 115 | self.logger.debug('Found http-equiv in url') 116 | regex = """.*(url|URL)=(?P[^"^>]+).*""" 117 | match = re.match( regex, html ) 118 | if match: 119 | self.final = match.groupdict()['url'] 120 | self.url = self.final 121 | self.logger.debug('Found URL : %s'%(self.url)) 122 | return True 123 | return False 124 | 125 | 126 | def __getFinalPage(self, newUrl=None): 127 | self.depth += 1 128 | if not newUrl: 129 | url = self.url 130 | else: 131 | url = newUrl 132 | 133 | self.logger.debug('Following %s'%(url)) 134 | up = urlparse(url) 135 | if url.startswith('https'): 136 | conn = httplib.HTTPSConnection(up.netloc) 137 | else: 138 | conn = httplib.HTTPConnection(up.netloc) 139 | headers = ({'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22', 140 | 'Accept-Language':'en-US,en;q=0.8', 141 | 'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 142 | }) 143 | conn.request("GET", up.path, headers=headers ) 144 | response = conn.getresponse() 145 | if response.status in xrange(300,400): 146 | # redirect 147 | location = response.getheader('location') 148 | if not location.startswith('http') or location.startswith('https'): 149 | self.logger.debug('3XX location does not start with http(s). Aborting') 150 | self.final = url 151 | return 152 | self.logger.debug('Found a 3XX forward. Following it : %s'%(location) ) 153 | conn.close() 154 | if not location == url: 155 | self.__getFinalPage(location) 156 | else: 157 | self.final = url 158 | content_type = response.getheader('content-type') 159 | content_length = response.getheader('content-length') 160 | if content_length and (int(content_length) in xrange(0,300)): 161 | # this *might* be a url, lets get the data 162 | self.logger.debug('Content length is < 300. This might be a JS redir. Checking out..') 163 | data = response.read() 164 | conn.close() 165 | if self.__extractURLForward(data): 166 | self.logger.debug('It was a JS redir. Checking to make sure its not another redir') 167 | self.__getFinalPage() 168 | self.logger.debug('Looks like that was the final URL') 169 | 170 | def main(): 171 | parser = argparse.ArgumentParser(description='URL Redirector') 172 | parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Verbose mode') 173 | parser.add_argument('urls', nargs='*', default=None) 174 | args = parser.parse_args() 175 | if args.verbose: 176 | print 'Found %s URLs to analyze'%(len(args.urls)) 177 | for url in args.urls: 178 | print URLAnalyzer(url, verbose=args.verbose).final 179 | 180 | if __name__ == "__main__": 181 | main() 182 | -------------------------------------------------------------------------------- /flash/xxxswf.py: -------------------------------------------------------------------------------- 1 | # xxxswf.py was created by alexander dot hanel at gmail dot com 2 | # version 0.1 3 | # Date - 12-07-2011 4 | # To do list 5 | # - Tag Parser 6 | # - ActionScript Decompiler 7 | 8 | import fnmatch 9 | import hashlib 10 | import imp 11 | import math 12 | import os 13 | import re 14 | import struct 15 | import sys 16 | import time 17 | from StringIO import StringIO 18 | from optparse import OptionParser 19 | import zlib 20 | 21 | def checkMD5(md5): 22 | # checks if MD5 has been seen in MD5 Dictionary 23 | # MD5Dict contains the MD5 and the CVE 24 | # For { 'MD5':'CVE', 'MD5-1':'CVE-1', 'MD5-2':'CVE-2'} 25 | MD5Dict = {'c46299a5015c6d31ad5766cb49e4ab4b':'CVE-XXXX-XXXX'} 26 | if MD5Dict.get(md5): 27 | print '\t[BAD] MD5 Match on', MD5Dict.get(md5) 28 | return 29 | 30 | def bad(f): 31 | for idx, x in enumerate(findSWF(f)): 32 | tmp = verifySWF(f,x) 33 | if tmp != None: 34 | yaraScan(tmp) 35 | checkMD5(hashBuff(tmp)) 36 | return 37 | 38 | def yaraScan(d): 39 | # d = buffer of the read file 40 | # Scans SWF using Yara 41 | # test if yara module is installed 42 | # if not Yara can be downloaded from http://code.google.com/p/yara-project/ 43 | try: 44 | imp.find_module('yara') 45 | import yara 46 | except ImportError: 47 | print '\t[ERROR] Yara module not installed - aborting scan' 48 | return 49 | # test for yara compile errors 50 | try: 51 | r = yara.compile(r'rules.yar') 52 | except: 53 | pass 54 | print '\t[ERROR] Yara compile error - aborting scan' 55 | return 56 | # get matches 57 | m = r.match(data=d) 58 | # print matches 59 | for X in m: 60 | print '\t[BAD] Yara Signature Hit:', X 61 | return 62 | 63 | def findSWF(d): 64 | # d = buffer of the read file 65 | # Search for SWF Header Sigs in files 66 | return [tmp.start() for tmp in re.finditer('CWS|FWS|ZWS', d.read())] 67 | 68 | def hashBuff(d): 69 | # d = buffer of the read file 70 | # This function hashes the buffer 71 | # source: http://stackoverflow.com/q/5853830 72 | if type(d) is str: 73 | d = StringIO(d) 74 | md5 = hashlib.md5() 75 | while True: 76 | data = d.read(128) 77 | if not data: 78 | break 79 | md5.update(data) 80 | return md5.hexdigest() 81 | 82 | def verifySWF(f,addr): 83 | # Start of SWF 84 | f.seek(addr) 85 | # Read Header 86 | header = f.read(3) 87 | # Read Version 88 | ver = struct.unpack(' 20: 105 | print ' - [ERROR] Invalid SWF Version' 106 | return None 107 | 108 | if 'CWS' in header: 109 | try: 110 | f.read(3) 111 | tmp = 'FWS' + f.read(5) + zlib.decompress(f.read()) 112 | print ' - CWS Header' 113 | return tmp 114 | 115 | except: 116 | pass 117 | print '- [ERROR]: Zlib decompression error. Invalid CWS SWF' 118 | return None 119 | 120 | elif 'FWS' in header: 121 | try: 122 | tmp = f.read(size) 123 | print ' - FWS Header' 124 | return tmp 125 | 126 | except: 127 | pass 128 | print ' - [ERROR] Invalid SWF Size' 129 | return None 130 | 131 | elif 'ZWS' in header: 132 | """ 133 | bytes 0-3: ZWS+version 134 | bytes 4-7: Uncompressed length (includes ZWS+version (4 bytes) and uncompressed length (4 bytes)) 135 | bytes 8-11: Compressed length 136 | bytes 12-16: LZMAproperties 137 | bytes 17-n: Compressed data 138 | """ 139 | try: 140 | tmp = f.read(size) 141 | print ' - ZWS Header' 142 | return tmp 143 | 144 | except: 145 | pass 146 | print ' - [ERROR] Invalid SWF Size' 147 | return None 148 | else: 149 | print ' - [Error] Logic Error Blame Programmer' 150 | return None 151 | 152 | def headerInfo(f): 153 | # f is the already opended file handle 154 | # Yes, the format is is a rip off SWFDump. Can you blame me? Their tool is awesome. 155 | # SWFDump FORMAT 156 | # [HEADER] File version: 8 157 | # [HEADER] File is zlib compressed. Ratio: 52% 158 | # [HEADER] File size: 37536 159 | # [HEADER] Frame rate: 18.000000 160 | # [HEADER] Frame count: 323 161 | # [HEADER] Movie width: 217.00 162 | # [HEADER] Movie height: 85.00 163 | if type(f) is str: 164 | f = StringIO(f) 165 | sig = f.read(3) 166 | print '\t[HEADER] File header:', sig 167 | if 'C' in sig: 168 | print '\t[HEADER] File is zlib compressed.' 169 | version = struct.unpack('> 3 183 | print '\t[HEADER] Rect Nbit:', nbit 184 | # Curretely the nbit is static at 15. This could be modified in the 185 | # future. If larger than 9 this will break the struct unpack. Will have 186 | # to revist must be a more effective way to deal with bits. Tried to keep 187 | # the algo but damn this is ugly... 188 | f.seek(ta) 189 | rect = struct.unpack('>Q', f.read(int(math.ceil((nbit*4)/8.0))))[0] 190 | tmp = struct.unpack('>7)[2:].zfill(1) 192 | # bin requires Python 2.6 or higher 193 | # skips string '0b' and the nbit 194 | rect = bin(rect)[7:] 195 | xmin = int(rect[0:nbit-1],2) 196 | print '\t[HEADER] Rect Xmin:', xmin 197 | xmax = int(rect[nbit:(nbit*2)-1],2) 198 | print '\t[HEADER] Rect Xmax:', xmax 199 | ymin = int(rect[nbit*2:(nbit*3)-1],2) 200 | print '\t[HEADER] Rect Ymin:', ymin 201 | # one bit needs to be added, my math might be off here 202 | ymax = int(rect[nbit*3:(nbit*4)-1] + str(tmp) ,2) 203 | print '\t[HEADER] Rect Ymax:', ymax 204 | framerate = struct.unpack(' 4 | 5 | ctypes wrapper to decompress aplib-compressed files 6 | Tested against aPLib v1.01 [http://ibsensoftware.com/download.html] 7 | ''' 8 | 9 | from ctypes import * 10 | from hashlib import md5 11 | 12 | def decompress( data ): 13 | '''Returns decompressed data 14 | On Windows, make sure you read the data with the 'rb' option 15 | Like so -> open('shellcode2.pak','rb').read() 16 | ''' 17 | try: 18 | aplib = windll.LoadLibrary('aplib.dll') 19 | except Exception,e: 20 | print 'Error loading dll : %s'%(e) 21 | return None 22 | unpacked_size = aplib._aPsafe_get_orig_size(data) 23 | print 'Unpacked size should be : ', unpacked_size 24 | unpacked_data =create_string_buffer(unpacked_size) 25 | try: 26 | unpacked_bytes = aplib._aPsafe_depack(data, len(data), unpacked_data, len(unpacked_data)) 27 | except Exception,e: 28 | print 'Error unpacking data : %s'%(e) 29 | print 'Unpacked %s bytes [%s]'%(unpacked_bytes, md5(unpacked_data).hexdigest()) 30 | return unpacked_data 31 | -------------------------------------------------------------------------------- /lib/magic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | magic.py 4 | determines a file type by its magic number 5 | 6 | (C)opyright 2000 Jason Petrone 7 | All Rights Reserved 8 | 9 | Command Line Usage: running as `python magic.py file` will print 10 | a description of what 'file' is. 11 | 12 | Module Usage: 13 | magic.whatis(data): when passed a string 'data' containing 14 | binary or text data, a description of 15 | what the data is will be returned. 16 | 17 | magic.file(filename): returns a description of what the file 18 | 'filename' contains. 19 | ''' 20 | 21 | import re, struct, string 22 | 23 | __version__ = '0.1' 24 | 25 | #@kbandla: prioritize important types 26 | magic = [ 27 | 28 | [0L, 'string', '=', 'CWS', 'application/x-shockwave-flash'], 29 | [0L, 'string', '=', 'FWS', 'application/x-shockwave-flash'], 30 | [0L, 'string', '=', 'ZWS', 'application/x-shockwave-flash'], 31 | 32 | [0L, 'string', '=', 'MZ', 'application/x-ms-dos-executable'], 33 | [0L, 'string', '=', 'LZ', 'MS-DOS executable (built-in)'], 34 | [0L, 'string', '=', '@echo off', 'MS-DOS batch file text'], 35 | [128L, 'string', '=', 'PE\000\000', 'MS Windows PE'], 36 | 37 | [0L, 'string', '=', 'PDF', 'Macintosh PDF File (data)'], 38 | [65L, 'string', '=', 'PDF', 'Macintosh PDF File(rsrc + data)'], 39 | [0L, 'string', '=', '%PDF-', 'PDF document'], 40 | 41 | [0L, 'string', '=', 'PK\003\004', 'application/zip'], 42 | [0L, 'string', '=', '\037\213', 'application/x-gzip'], 43 | [0L, 'string', '=', 'BZh', 'application/x-bzip2'], 44 | [0L, 'string', '=', 'BZ', 'application/x-bzip'], 45 | [0L, 'string', '=', '\x5d\x00\x00\x80', 'application/x-lzma'], 46 | [0L, 'string', '=', '\x78\x9c\xec\xbd', 'application/x-zlib'], 47 | 48 | [0L, 'string', '=', '\012debian', 'application/x-dpkg'], 200 | [0L, 'long', '=', 177555L, 'application/x-ar'], 201 | [0L, 'short', '=', 177555L, 'application/data'], 202 | [0L, 'long', '=', 177545L, 'application/data'], 203 | [0L, 'short', '=', 177545L, 'application/data'], 204 | [0L, 'long', '=', 100554L, 'application/x-apl-workspace'], 205 | [0L, 'string', '=', '', 'application/x-ar'], 206 | [0L, 'string', '=', '!\012__________E', 'application/x-ar'], 207 | [0L, 'string', '=', '-h-', 'application/data'], 208 | [0L, 'string', '=', '!', 'application/x-ar'], 209 | [0L, 'string', '=', '', 'application/x-ar'], 210 | [0L, 'string', '=', '', 'application/x-ar'], 211 | [0L, 'belong', '=', 1711210496L, 'application/x-ar'], 212 | [0L, 'belong', '=', 1013019198L, 'application/x-ar'], 213 | [0L, 'long', '=', 557605234L, 'application/x-ar'], 214 | [0L, 'lelong', '=', 177555L, 'application/data'], 215 | [0L, 'leshort', '=', 177555L, 'application/data'], 216 | [0L, 'lelong', '=', 177545L, 'application/data'], 217 | [0L, 'leshort', '=', 177545L, 'application/data'], 218 | [0L, 'lelong', '=', 236525L, 'application/data'], 219 | [0L, 'lelong', '=', 236526L, 'application/data'], 220 | [0L, 'lelong&0x8080ffff', '=', 2074L, 'application/x-arc'], 221 | [0L, 'lelong&0x8080ffff', '=', 2330L, 'application/x-arc'], 222 | [0L, 'lelong&0x8080ffff', '=', 538L, 'application/x-arc'], 223 | [0L, 'lelong&0x8080ffff', '=', 794L, 'application/x-arc'], 224 | [0L, 'lelong&0x8080ffff', '=', 1050L, 'application/x-arc'], 225 | [0L, 'lelong&0x8080ffff', '=', 1562L, 'application/x-arc'], 226 | [0L, 'string', '=', '\032archive', 'application/data'], 227 | [0L, 'leshort', '=', 60000L, 'application/x-arj'], 228 | [0L, 'string', '=', 'HPAK', 'application/data'], 229 | [0L, 'string', '=', '\351,\001JAM application/data', ''], 230 | [2L, 'string', '=', '-lh0-', 'application/x-lha'], 231 | [2L, 'string', '=', '-lh1-', 'application/x-lha'], 232 | [2L, 'string', '=', '-lz4-', 'application/x-lha'], 233 | [2L, 'string', '=', '-lz5-', 'application/x-lha'], 234 | [2L, 'string', '=', '-lzs-', 'application/x-lha'], 235 | [2L, 'string', '=', '-lh -', 'application/x-lha'], 236 | [2L, 'string', '=', '-lhd-', 'application/x-lha'], 237 | [2L, 'string', '=', '-lh2-', 'application/x-lha'], 238 | [2L, 'string', '=', '-lh3-', 'application/x-lha'], 239 | [2L, 'string', '=', '-lh4-', 'application/x-lha'], 240 | [2L, 'string', '=', '-lh5-', 'application/x-lha'], 241 | [0L, 'string', '=', 'Rar!', 'application/x-rar'], 242 | [0L, 'string', '=', 'SQSH', 'application/data'], 243 | [0L, 'string', '=', 'UC2\032', 'application/data'], 244 | [20L, 'lelong', '=', 4257523676L, 'application/x-zoo'], 245 | [10L, 'string', '=', '# This is a shell archive', 'application/x-shar'], 246 | [0L, 'string', '=', '*STA', 'application/data'], 247 | [0L, 'string', '=', '2278', 'application/data'], 248 | [0L, 'string', '=', '\000\004\036\212\200', 'application/core'], 249 | [0L, 'string', '=', '.snd', 'audio/basic'], 250 | [0L, 'lelong', '=', 6583086L, 'audio/basic'], 251 | [0L, 'string', '=', 'MThd', 'audio/midi'], 252 | [0L, 'string', '=', 'CTMF', 'audio/x-cmf'], 253 | [0L, 'string', '=', 'SBI', 'audio/x-sbi'], 254 | [0L, 'string', '=', 'Creative Voice File', 'audio/x-voc'], 255 | [0L, 'belong', '=', 1314148939L, 'audio/x-multitrack'], 256 | [0L, 'string', '=', 'RIFF', 'audio/x-wav'], 257 | [0L, 'string', '=', 'EMOD', 'audio/x-emod'], 258 | [0L, 'belong', '=', 779248125L, 'audio/x-pn-realaudio'], 259 | [0L, 'string', '=', 'MTM', 'audio/x-multitrack'], 260 | [0L, 'string', '=', 'if', 'audio/x-669-mod'], 261 | [0L, 'string', '=', 'FAR', 'audio/mod'], 262 | [0L, 'string', '=', 'MAS_U', 'audio/x-multimate-mod'], 263 | [44L, 'string', '=', 'SCRM', 'audio/x-st3-mod'], 264 | [0L, 'string', '=', 'GF1PATCH110\000ID#000002\000', 'audio/x-gus-patch'], 265 | [0L, 'string', '=', 'GF1PATCH100\000ID#000002\000', 'audio/x-gus-patch'], 266 | [0L, 'string', '=', 'JN', 'audio/x-669-mod'], 267 | [0L, 'string', '=', 'UN05', 'audio/x-mikmod-uni'], 268 | [0L, 'string', '=', 'Extended Module:', 'audio/x-ft2-mod'], 269 | [21L, 'string', '=', '!SCREAM!', 'audio/x-st2-mod'], 270 | [1080L, 'string', '=', 'M.K.', 'audio/x-protracker-mod'], 271 | [1080L, 'string', '=', 'M!K!', 'audio/x-protracker-mod'], 272 | [1080L, 'string', '=', 'FLT4', 'audio/x-startracker-mod'], 273 | [1080L, 'string', '=', '4CHN', 'audio/x-fasttracker-mod'], 274 | [1080L, 'string', '=', '6CHN', 'audio/x-fasttracker-mod'], 275 | [1080L, 'string', '=', '8CHN', 'audio/x-fasttracker-mod'], 276 | [1080L, 'string', '=', 'CD81', 'audio/x-oktalyzer-mod'], 277 | [1080L, 'string', '=', 'OKTA', 'audio/x-oktalyzer-mod'], 278 | [1080L, 'string', '=', '16CN', 'audio/x-taketracker-mod'], 279 | [1080L, 'string', '=', '32CN', 'audio/x-taketracker-mod'], 280 | [0L, 'string', '=', 'TOC', 'audio/x-toc'], 281 | [0L, 'string', '=', '//', 'text/cpp'], 282 | [0L, 'string', '=', '\\\\1cw\\', 'application/data'], 283 | [0L, 'string', '=', '\\\\1cw', 'application/data'], 284 | [0L, 'belong&0xffffff00', '=', 2231440384L, 'application/data'], 285 | [0L, 'belong&0xffffff00', '=', 2231487232L, 'application/data'], 286 | [4L, 'string', '=', 'pipe', 'application/data'], 287 | [4L, 'string', '=', 'prof', 'application/data'], 288 | [0L, 'string', '=', ': shell', 'application/data'], 289 | [0L, 'string', '=', '#!/bin/sh', 'application/x-sh'], 290 | [0L, 'string', '=', '#! /bin/sh', 'application/x-sh'], 291 | [0L, 'string', '=', '#! /bin/sh', 'application/x-sh'], 292 | [0L, 'string', '=', '#!/bin/csh', 'application/x-csh'], 293 | [0L, 'string', '=', '#! /bin/csh', 'application/x-csh'], 294 | [0L, 'string', '=', '#! /bin/csh', 'application/x-csh'], 295 | [0L, 'string', '=', '#!/bin/ksh', 'application/x-ksh'], 296 | [0L, 'string', '=', '#! /bin/ksh', 'application/x-ksh'], 297 | [0L, 'string', '=', '#! /bin/ksh', 'application/x-ksh'], 298 | [0L, 'string', '=', '#!/bin/tcsh', 'application/x-csh'], 299 | [0L, 'string', '=', '#! /bin/tcsh', 'application/x-csh'], 300 | [0L, 'string', '=', '#! /bin/tcsh', 'application/x-csh'], 301 | [0L, 'string', '=', '#!/usr/local/tcsh', 'application/x-csh'], 302 | [0L, 'string', '=', '#! /usr/local/tcsh', 'application/x-csh'], 303 | [0L, 'string', '=', '#!/usr/local/bin/tcsh', 'application/x-csh'], 304 | [0L, 'string', '=', '#! /usr/local/bin/tcsh', 'application/x-csh'], 305 | [0L, 'string', '=', '#! /usr/local/bin/tcsh', 'application/x-csh'], 306 | [0L, 'string', '=', '#!/usr/local/bin/zsh', 'application/x-zsh'], 307 | [0L, 'string', '=', '#! /usr/local/bin/zsh', 'application/x-zsh'], 308 | [0L, 'string', '=', '#! /usr/local/bin/zsh', 'application/x-zsh'], 309 | [0L, 'string', '=', '#!/usr/local/bin/ash', 'application/x-sh'], 310 | [0L, 'string', '=', '#! /usr/local/bin/ash', 'application/x-zsh'], 311 | [0L, 'string', '=', '#! /usr/local/bin/ash', 'application/x-zsh'], 312 | [0L, 'string', '=', '#!/usr/local/bin/ae', 'text/script'], 313 | [0L, 'string', '=', '#! /usr/local/bin/ae', 'text/script'], 314 | [0L, 'string', '=', '#! /usr/local/bin/ae', 'text/script'], 315 | [0L, 'string', '=', '#!/bin/nawk', 'application/x-awk'], 316 | [0L, 'string', '=', '#! /bin/nawk', 'application/x-awk'], 317 | [0L, 'string', '=', '#! /bin/nawk', 'application/x-awk'], 318 | [0L, 'string', '=', '#!/usr/bin/nawk', 'application/x-awk'], 319 | [0L, 'string', '=', '#! /usr/bin/nawk', 'application/x-awk'], 320 | [0L, 'string', '=', '#! /usr/bin/nawk', 'application/x-awk'], 321 | [0L, 'string', '=', '#!/usr/local/bin/nawk', 'application/x-awk'], 322 | [0L, 'string', '=', '#! /usr/local/bin/nawk', 'application/x-awk'], 323 | [0L, 'string', '=', '#! /usr/local/bin/nawk', 'application/x-awk'], 324 | [0L, 'string', '=', '#!/bin/gawk', 'application/x-awk'], 325 | [0L, 'string', '=', '#! /bin/gawk', 'application/x-awk'], 326 | [0L, 'string', '=', '#! /bin/gawk', 'application/x-awk'], 327 | [0L, 'string', '=', '#!/usr/bin/gawk', 'application/x-awk'], 328 | [0L, 'string', '=', '#! /usr/bin/gawk', 'application/x-awk'], 329 | [0L, 'string', '=', '#! /usr/bin/gawk', 'application/x-awk'], 330 | [0L, 'string', '=', '#!/usr/local/bin/gawk', 'application/x-awk'], 331 | [0L, 'string', '=', '#! /usr/local/bin/gawk', 'application/x-awk'], 332 | [0L, 'string', '=', '#! /usr/local/bin/gawk', 'application/x-awk'], 333 | [0L, 'string', '=', '#!/bin/awk', 'application/x-awk'], 334 | [0L, 'string', '=', '#! /bin/awk', 'application/x-awk'], 335 | [0L, 'string', '=', '#! /bin/awk', 'application/x-awk'], 336 | [0L, 'string', '=', '#!/usr/bin/awk', 'application/x-awk'], 337 | [0L, 'string', '=', '#! /usr/bin/awk', 'application/x-awk'], 338 | [0L, 'string', '=', '#! /usr/bin/awk', 'application/x-awk'], 339 | [0L, 'string', '=', 'BEGIN', 'application/x-awk'], 340 | [0L, 'string', '=', '#!/bin/rc', 'text/script'], 341 | [0L, 'string', '=', '#! /bin/rc', 'text/script'], 342 | [0L, 'string', '=', '#! /bin/rc', 'text/script'], 343 | [0L, 'string', '=', '#!/bin/bash', 'application/x-sh'], 344 | [0L, 'string', '=', '#! /bin/bash', 'application/x-sh'], 345 | [0L, 'string', '=', '#! /bin/bash', 'application/x-sh'], 346 | [0L, 'string', '=', '#!/usr/local/bin/bash', 'application/x-sh'], 347 | [0L, 'string', '=', '#! /usr/local/bin/bash', 'application/x-sh'], 348 | [0L, 'string', '=', '#! /usr/local/bin/bash', 'application/x-sh'], 349 | [0L, 'string', '=', '#! /', 'text/script'], 350 | [0L, 'string', '=', '#! /', 'text/script'], 351 | [0L, 'string', '=', '#!/', 'text/script'], 352 | [0L, 'string', '=', '#! text/script', ''], 353 | [0L, 'string', '=', '\037\235', 'application/compress'], 354 | [0L, 'string', '=', '\037\036', 'application/data'], 355 | [0L, 'short', '=', 17437L, 'application/data'], 356 | [0L, 'short', '=', 8191L, 'application/data'], 357 | [0L, 'string', '=', '\377\037', 'application/data'], 358 | [0L, 'short', '=', 145405L, 'application/data'], 359 | [0L, 'leshort', '=', 65398L, 'application/data'], 360 | [0L, 'leshort', '=', 65142L, 'application/data'], 361 | [0L, 'leshort', '=', 64886L, 'application/x-lzh'], 362 | [0L, 'string', '=', '\037\237', 'application/data'], 363 | [0L, 'string', '=', '\037\236', 'application/data'], 364 | [0L, 'string', '=', '\037\240', 'application/data'], 365 | [0L, 'string', '=', '\211LZO\000\015\012\032\012', 'application/data'], 366 | [0L, 'belong', '=', 507L, 'application/x-object-file'], 367 | [0L, 'belong', '=', 70231L, 'application/core'], 368 | [24L, 'belong', '=', 60011L, 'application/data'], 369 | [24L, 'belong', '=', 60012L, 'application/data'], 370 | [24L, 'belong', '=', 60013L, 'application/data'], 371 | [24L, 'belong', '=', 60014L, 'application/data'], 372 | [0L, 'belong', '=', 601L, 'application/x-object-file'], 373 | [0L, 'belong', '=', 607L, 'application/data'], 374 | [0L, 'belong', '=', 324508366L, 'application/x-gdbm'], 375 | [0L, 'lelong', '=', 324508366L, 'application/x-gdbm'], 376 | [0L, 'string', '=', 'GDBM', 'application/x-gdbm'], 377 | [0L, 'belong', '=', 398689L, 'application/x-db'], 378 | [0L, 'belong', '=', 340322L, 'application/x-db'], 379 | [0L, 'string', '=', '\012\012________64E', 'application/data'], 385 | [0L, 'leshort', '=', 399L, 'application/x-object-file'], 386 | [0L, 'string', '=', '\377\377\177', 'application/data'], 387 | [0L, 'string', '=', '\377\377|', 'application/data'], 388 | [0L, 'string', '=', '\377\377~', 'application/data'], 389 | [0L, 'string', '=', '\033c\033', 'application/data'], 390 | [0L, 'string', '=', '!!\012', 'application/x-prof'], 391 | [0L, 'short', '=', 1281L, 'application/x-locale'], 392 | [24L, 'belong', '=', 60012L, 'application/x-dump'], 393 | [24L, 'belong', '=', 60011L, 'application/x-dump'], 394 | [24L, 'lelong', '=', 60012L, 'application/x-dump'], 395 | [24L, 'lelong', '=', 60011L, 'application/x-dump'], 396 | [0L, 'short', '=', 340L, 'application/data'], 397 | [1080L, 'leshort', '=', 61267L, 'application/x-linux-ext2fs'], 398 | [0L, 'string', '=', '\366\366\366\366', 'application/x-pc-floppy'], 399 | [774L, 'beshort', '=', 55998L, 'application/data'], 400 | [510L, 'leshort', '=', 43605L, 'application/data'], 401 | [1040L, 'leshort', '=', 4991L, 'application/x-filesystem'], 402 | [1040L, 'leshort', '=', 5007L, 'application/x-filesystem'], 403 | [1040L, 'leshort', '=', 9320L, 'application/x-filesystem'], 404 | [1040L, 'leshort', '=', 9336L, 'application/x-filesystem'], 405 | [0L, 'string', '=', '-rom1fs-\000', 'application/x-filesystem'], 406 | [395L, 'string', '=', 'OS/2', 'application/x-bootable'], 407 | [0L, 'string', '=', 'FONT', 'font/x-vfont'], 408 | [0L, 'short', '=', 436L, 'font/x-vfont'], 409 | [0L, 'short', '=', 17001L, 'font/x-vfont'], 410 | [0L, 'string', '=', '%!PS-AdobeFont-1.0', 'font/type1'], 411 | [6L, 'string', '=', '%!PS-AdobeFont-1.0', 'font/type1'], 412 | [0L, 'belong', '=', 4L, 'font/x-snf'], 413 | [0L, 'lelong', '=', 4L, 'font/x-snf'], 414 | [0L, 'string', '=', 'STARTFONT font/x-bdf', ''], 415 | [0L, 'string', '=', '\001fcp', 'font/x-pcf'], 416 | [0L, 'string', '=', 'D1.0\015', 'font/x-speedo'], 417 | [0L, 'string', '=', 'flf', 'font/x-figlet'], 418 | [0L, 'string', '=', 'flc', 'application/x-font'], 419 | [0L, 'belong', '=', 335698201L, 'font/x-libgrx'], 420 | [0L, 'belong', '=', 4282797902L, 'font/x-dos'], 421 | [7L, 'belong', '=', 4540225L, 'font/x-dos'], 422 | [7L, 'belong', '=', 5654852L, 'font/x-dos'], 423 | [4098L, 'string', '=', 'DOSFONT', 'font/x-dos'], 424 | [0L, 'string', '=', '', 'archive'], 483 | [0L, 'string', '=', 'FORM', 'IFF data'], 484 | [0L, 'string', '=', 'ARF_BEGARF', 'PHIGS clear text archive'], 485 | [0L, 'string', '=', '@(#)SunPHIGS', 'SunPHIGS'], 486 | [0L, 'string', '=', 'GKSM', 'GKS Metafile'], 487 | [0L, 'string', '=', 'BEGMF', 'clear text Computer Graphics Metafile'], 488 | [0L, 'beshort&0xffe0', '=', 32L, 'binary Computer Graphics Metafile'], 489 | [0L, 'beshort', '=', 12320L, 'character Computer Graphics Metafile'], 490 | [0L, 'string', '=', 'yz', 'MGR bitmap, modern format, 8-bit aligned'], 491 | [0L, 'string', '=', 'zz', 'MGR bitmap, old format, 1-bit deep, 16-bit aligned'], 492 | [0L, 'string', '=', 'xz', 'MGR bitmap, old format, 1-bit deep, 32-bit aligned'], 493 | [0L, 'string', '=', 'yx', 'MGR bitmap, modern format, squeezed'], 494 | [0L, 'string', '=', '%bitmap\000', 'FBM image data'], 495 | [1L, 'string', '=', 'PC Research, Inc', 'group 3 fax data'], 496 | [0L, 'string', '=', 'PI', 'PC pointer image data'], 497 | [0L, 'string', '=', 'CI', 'PC color icon data'], 498 | [0L, 'string', '=', 'CP', 'PC color pointer image data'], 499 | [0L, 'string', '=', '/* XPM */', 'X pixmap image text'], 500 | [0L, 'leshort', '=', 52306L, 'RLE image data,'], 501 | [0L, 'string', '=', 'Imagefile version-', 'iff image data'], 502 | [0L, 'belong', '=', 1504078485L, 'x/x-image-sun-raster'], 503 | [0L, 'beshort', '=', 474L, 'x/x-image-sgi'], 504 | [0L, 'string', '=', 'IT01', 'FIT image data'], 505 | [0L, 'string', '=', 'IT02', 'FIT image data'], 506 | [2048L, 'string', '=', 'PCD_IPI', 'x/x-photo-cd-pack-file'], 507 | [0L, 'string', '=', 'PCD_OPA', 'x/x-photo-cd-overfiew-file'], 508 | [0L, 'string', '=', 'SIMPLE =', 'FITS image data'], 509 | [0L, 'string', '=', 'This is a BitMap file', 'Lisp Machine bit-array-file'], 510 | [0L, 'string', '=', '!!', 'Bennet Yee\'s "face" format'], 511 | [0L, 'beshort', '=', 4112L, 'PEX Binary Archive'], 512 | [3000L, 'string', '=', 'Visio (TM) Drawing', '%s'], 513 | [0L, 'leshort', '=', 502L, 'basic-16 executable'], 514 | [0L, 'leshort', '=', 503L, 'basic-16 executable (TV)'], 515 | [0L, 'string', '=', '\210OPS', 'Interleaf saved data'], 516 | [0L, 'string', '=', '', 'Compiled SGML rules file'], 783 | [0L, 'string', '=', '', 'A/E SGML Document binary'], 784 | [0L, 'string', '=', '', 'A/E SGML binary styles file'], 785 | [0L, 'short', '=', 49374L, 'Compiled PSI (v1) data'], 786 | [0L, 'short', '=', 49370L, 'Compiled PSI (v2) data'], 787 | [0L, 'short', '=', 125252L, 'SoftQuad DESC or font file binary'], 788 | [0L, 'string', '=', 'SQ BITMAP1', 'SoftQuad Raster Format text'], 789 | [0L, 'string', '=', 'X SoftQuad', 'troff Context intermediate'], 790 | [0L, 'belong&077777777', '=', 600413L, 'sparc demand paged'], 791 | [0L, 'belong&077777777', '=', 600410L, 'sparc pure'], 792 | [0L, 'belong&077777777', '=', 600407L, 'sparc'], 793 | [0L, 'belong&077777777', '=', 400413L, 'mc68020 demand paged'], 794 | [0L, 'belong&077777777', '=', 400410L, 'mc68020 pure'], 795 | [0L, 'belong&077777777', '=', 400407L, 'mc68020'], 796 | [0L, 'belong&077777777', '=', 200413L, 'mc68010 demand paged'], 797 | [0L, 'belong&077777777', '=', 200410L, 'mc68010 pure'], 798 | [0L, 'belong&077777777', '=', 200407L, 'mc68010'], 799 | [0L, 'belong', '=', 407L, 'old sun-2 executable'], 800 | [0L, 'belong', '=', 410L, 'old sun-2 pure executable'], 801 | [0L, 'belong', '=', 413L, 'old sun-2 demand paged executable'], 802 | [0L, 'belong', '=', 525398L, 'SunOS core file'], 803 | [0L, 'long', '=', 4197695630L, 'SunPC 4.0 Hard Disk'], 804 | [0L, 'string', '=', '#SUNPC_CONFIG', 'SunPC 4.0 Properties Values'], 805 | [0L, 'string', '=', 'snoop', 'Snoop capture file'], 806 | [36L, 'string', '=', 'acsp', 'Kodak Color Management System, ICC Profile'], 807 | [0L, 'string', '=', '#!teapot\012xdr', 'teapot work sheet (XDR format)'], 808 | [0L, 'string', '=', '\032\001', 'Compiled terminfo entry'], 809 | [0L, 'short', '=', 433L, 'Curses screen image'], 810 | [0L, 'short', '=', 434L, 'Curses screen image'], 811 | [0L, 'string', '=', '\367\002', 'TeX DVI file'], 812 | [0L, 'string', '=', '\367\203', 'font/x-tex'], 813 | [0L, 'string', '=', '\367Y', 'font/x-tex'], 814 | [0L, 'string', '=', '\367\312', 'font/x-tex'], 815 | [0L, 'string', '=', 'This is TeX,', 'TeX transcript text'], 816 | [0L, 'string', '=', 'This is METAFONT,', 'METAFONT transcript text'], 817 | [2L, 'string', '=', '\000\021', 'font/x-tex-tfm'], 818 | [2L, 'string', '=', '\000\022', 'font/x-tex-tfm'], 819 | [0L, 'string', '=', '\\\\input\\', 'texinfo Texinfo source text'], 820 | [0L, 'string', '=', 'This is Info file', 'GNU Info text'], 821 | [0L, 'string', '=', '\\\\input', 'TeX document text'], 822 | [0L, 'string', '=', '\\\\section', 'LaTeX document text'], 823 | [0L, 'string', '=', '\\\\setlength', 'LaTeX document text'], 824 | [0L, 'string', '=', '\\\\documentstyle', 'LaTeX document text'], 825 | [0L, 'string', '=', '\\\\chapter', 'LaTeX document text'], 826 | [0L, 'string', '=', '\\\\documentclass', 'LaTeX 2e document text'], 827 | [0L, 'string', '=', '\\\\relax', 'LaTeX auxiliary file'], 828 | [0L, 'string', '=', '\\\\contentsline', 'LaTeX table of contents'], 829 | [0L, 'string', '=', '\\\\indexentry', 'LaTeX raw index file'], 830 | [0L, 'string', '=', '\\\\begin{theindex}', 'LaTeX sorted index'], 831 | [0L, 'string', '=', '\\\\glossaryentry', 'LaTeX raw glossary'], 832 | [0L, 'string', '=', '\\\\begin{theglossary}', 'LaTeX sorted glossary'], 833 | [0L, 'string', '=', 'This is makeindex', 'Makeindex log file'], 834 | [0L, 'string', '=', '**TI82**', 'TI-82 Graphing Calculator'], 835 | [0L, 'string', '=', '**TI83**', 'TI-83 Graphing Calculator'], 836 | [0L, 'string', '=', '**TI85**', 'TI-85 Graphing Calculator'], 837 | [0L, 'string', '=', '**TI92**', 'TI-92 Graphing Calculator'], 838 | [0L, 'string', '=', '**TI80**', 'TI-80 Graphing Calculator File.'], 839 | [0L, 'string', '=', '**TI81**', 'TI-81 Graphing Calculator File.'], 840 | [0L, 'string', '=', 'TZif', 'timezone data'], 841 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000', 'old timezone data'], 842 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000', 'old timezone data'], 843 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000', 'old timezone data'], 844 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000', 'old timezone data'], 845 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\005\000', 'old timezone data'], 846 | [0L, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\000', 'old timezone data'], 847 | [0L, 'string', '=', '.\\\\"', 'troff or preprocessor input text'], 848 | [0L, 'string', '=', '\'\\\\"', 'troff or preprocessor input text'], 849 | [0L, 'string', '=', '\'.\\\\"', 'troff or preprocessor input text'], 850 | [0L, 'string', '=', '\\\\"', 'troff or preprocessor input text'], 851 | [0L, 'string', '=', 'x T', 'ditroff text'], 852 | [0L, 'string', '=', '@\357', 'very old (C/A/T) troff output data'], 853 | [0L, 'string', '=', 'Interpress/Xerox', 'Xerox InterPress data'], 854 | [0L, 'short', '=', 263L, 'unknown machine executable'], 855 | [0L, 'short', '=', 264L, 'unknown pure executable'], 856 | [0L, 'short', '=', 265L, 'PDP-11 separate I&D'], 857 | [0L, 'short', '=', 267L, 'unknown pure executable'], 858 | [0L, 'long', '=', 268L, 'unknown demand paged pure executable'], 859 | [0L, 'long', '=', 269L, 'unknown demand paged pure executable'], 860 | [0L, 'long', '=', 270L, 'unknown readable demand paged pure executable'], 861 | [0L, 'string', '=', 'begin uuencoded', 'or xxencoded text'], 862 | [0L, 'string', '=', 'xbtoa Begin', "btoa'd text"], 863 | [0L, 'string', '=', '$\012ship', "ship'd binary text"], 864 | [0L, 'string', '=', 'Decode the following with bdeco', 'bencoded News text'], 865 | [11L, 'string', '=', 'must be converted with BinHex', 'BinHex binary text'], 866 | [0L, 'short', '=', 610L, 'Perkin-Elmer executable'], 867 | [0L, 'beshort', '=', 572L, 'amd 29k coff noprebar executable'], 868 | [0L, 'beshort', '=', 1572L, 'amd 29k coff prebar executable'], 869 | [0L, 'beshort', '=', 160007L, 'amd 29k coff archive'], 870 | [6L, 'beshort', '=', 407L, 'unicos (cray) executable'], 871 | [596L, 'string', '=', 'X\337\377\377', 'Ultrix core file'], 872 | [0L, 'string', '=', 'Joy!peffpwpc', 'header for PowerPC PEF executable'], 873 | [0L, 'lelong', '=', 101557L, 'VAX single precision APL workspace'], 874 | [0L, 'lelong', '=', 101556L, 'VAX double precision APL workspace'], 875 | [0L, 'lelong', '=', 407L, 'VAX executable'], 876 | [0L, 'lelong', '=', 410L, 'VAX pure executable'], 877 | [0L, 'lelong', '=', 413L, 'VAX demand paged pure executable'], 878 | [0L, 'leshort', '=', 570L, 'VAX COFF executable'], 879 | [0L, 'leshort', '=', 575L, 'VAX COFF pure executable'], 880 | [0L, 'string', '=', 'LBLSIZE=', 'VICAR image data'], 881 | [43L, 'string', '=', 'SFDU_LABEL', 'VICAR label file'], 882 | [0L, 'short', '=', 21845L, 'VISX image file'], 883 | [0L, 'string', '=', '\260\0000\000', 'VMS VAX executable'], 884 | [0L, 'belong', '=', 50331648L, 'VMS Alpha executable'], 885 | [1L, 'string', '=', 'WPC', '(Corel/WP)'], 886 | [0L, 'string', '=', 'core', 'core file (Xenix)'], 887 | [0L, 'byte', '=', 128L, '8086 relocatable (Microsoft)'], 888 | [0L, 'leshort', '=', 65381L, 'x.out'], 889 | [0L, 'leshort', '=', 518L, 'Microsoft a.out'], 890 | [0L, 'leshort', '=', 320L, 'old Microsoft 8086 x.out'], 891 | [0L, 'lelong', '=', 518L, 'b.out'], 892 | [0L, 'leshort', '=', 1408L, 'XENIX 8086 relocatable or 80286 small model'], 893 | [0L, 'long', '=', 59399L, 'object file (z8000 a.out)'], 894 | [0L, 'long', '=', 59400L, 'pure object file (z8000 a.out)'], 895 | [0L, 'long', '=', 59401L, 'separate object file (z8000 a.out)'], 896 | [0L, 'long', '=', 59397L, 'overlay object file (z8000 a.out)'], 897 | [0L, 'string', '=', 'ZyXEL\002', 'ZyXEL voice data'], 898 | ] 899 | 900 | magicNumbers = [] 901 | 902 | def strToNum(n): 903 | val = 0 904 | col = long(1) 905 | if n[:1] == 'x': n = '0' + n 906 | if n[:2] == '0x': 907 | # hex 908 | n = string.lower(n[2:]) 909 | while len(n) > 0: 910 | l = n[len(n) - 1] 911 | val = val + string.hexdigits.index(l) * col 912 | col = col * 16 913 | n = n[:len(n)-1] 914 | elif n[0] == '\\': 915 | # octal 916 | n = n[1:] 917 | while len(n) > 0: 918 | l = n[len(n) - 1] 919 | if ord(l) < 48 or ord(l) > 57: break 920 | val = val + int(l) * col 921 | col = col * 8 922 | n = n[:len(n)-1] 923 | else: 924 | val = string.atol(n) 925 | return val 926 | 927 | def unescape(s): 928 | # replace string escape sequences 929 | while 1: 930 | m = re.search(r'\\', s) 931 | if not m: break 932 | x = m.start()+1 933 | if m.end() == len(s): 934 | # escaped space at end 935 | s = s[:len(s)-1] + ' ' 936 | elif s[x:x+2] == '0x': 937 | # hex ascii value 938 | c = chr(strToNum(s[x:x+4])) 939 | s = s[:x-1] + c + s[x+4:] 940 | elif s[m.start()+1] == 'x': 941 | # hex ascii value 942 | c = chr(strToNum(s[x:x+3])) 943 | s = s[:x-1] + c + s[x+3:] 944 | elif ord(s[x]) > 47 and ord(s[x]) < 58: 945 | # octal ascii value 946 | end = x 947 | while (ord(s[end]) > 47 and ord(s[end]) < 58): 948 | end = end + 1 949 | if end > len(s) - 1: break 950 | c = chr(strToNum(s[x-1:end])) 951 | s = s[:x-1] + c + s[end:] 952 | elif s[x] == 'n': 953 | # newline 954 | s = s[:x-1] + '\n' + s[x+1:] 955 | else: 956 | break 957 | return s 958 | 959 | class magicTest: 960 | def __init__(self, offset, t, op, value, msg, mask = None): 961 | if t.count('&') > 0: 962 | mask = strToNum(t[t.index('&')+1:]) 963 | t = t[:t.index('&')] 964 | if type(offset) == type('a'): 965 | self.offset = strToNum(offset) 966 | else: 967 | self.offset = offset 968 | self.type = t 969 | self.msg = msg 970 | self.subTests = [] 971 | self.op = op 972 | self.mask = mask 973 | self.value = value 974 | 975 | 976 | def test(self, data): 977 | if self.mask: 978 | data = data & self.mask 979 | if self.op == '=': 980 | if self.value == data: return self.msg 981 | elif self.op == '<': 982 | pass 983 | elif self.op == '>': 984 | pass 985 | elif self.op == '&': 986 | pass 987 | elif self.op == '^': 988 | pass 989 | return None 990 | 991 | def compare(self, data): 992 | #print str([self.type, self.value, self.msg]) 993 | try: 994 | if self.type == 'string': 995 | c = ''; s = '' 996 | for i in range(0, len(self.value)+1): 997 | if i + self.offset > len(data) - 1: break 998 | s = s + c 999 | [c] = struct.unpack('c', data[self.offset + i]) 1000 | data = s 1001 | elif self.type == 'short': 1002 | [data] = struct.unpack('h', data[self.offset : self.offset + 2]) 1003 | elif self.type == 'leshort': 1004 | [data] = struct.unpack('H', data[self.offset : self.offset + 2]) 1007 | elif self.type == 'long': 1008 | [data] = struct.unpack('l', data[self.offset : self.offset + 4]) 1009 | elif self.type == 'lelong': 1010 | [data] = struct.unpack('l', data[self.offset : self.offset + 4]) 1013 | else: 1014 | #print 'UNKNOWN TYPE: ' + self.type 1015 | pass 1016 | except: 1017 | return None 1018 | 1019 | # print str([self.msg, self.value, data]) 1020 | return self.test(data) 1021 | 1022 | 1023 | def load(file): 1024 | global magicNumbers 1025 | lines = open(file).readlines() 1026 | last = { 0: None } 1027 | for line in lines: 1028 | if re.match(r'\s*#', line): 1029 | # comment 1030 | continue 1031 | else: 1032 | # split up by space delimiters, and remove trailing space 1033 | line = string.rstrip(line) 1034 | line = re.split(r'\s*', line) 1035 | if len(line) < 3: 1036 | # bad line 1037 | continue 1038 | offset = line[0] 1039 | type = line[1] 1040 | value = line[2] 1041 | level = 0 1042 | while offset[0] == '>': 1043 | # count the level of the type 1044 | level = level + 1 1045 | offset = offset[1:] 1046 | l = magicNumbers 1047 | if level > 0: 1048 | l = last[level - 1].subTests 1049 | if offset[0] == '(': 1050 | # don't handle indirect offsets just yet 1051 | print 'SKIPPING ' + string.join(list(line[3:])) 1052 | pass 1053 | elif offset[0] == '&': 1054 | # don't handle relative offsets just yet 1055 | print 'SKIPPING ' + string.join(list(line[3:])) 1056 | pass 1057 | else: 1058 | operands = ['=', '<', '>', '&'] 1059 | if operands.count(value[0]) > 0: 1060 | # a comparison operator is specified 1061 | op = value[0] 1062 | value = value[1:] 1063 | else: 1064 | print str([value, operands]) 1065 | if len(value) >1 and value[0] == '\\' and operands.count(value[1]) >0: 1066 | # literal value that collides with operands is escaped 1067 | value = value[1:] 1068 | op = '=' 1069 | 1070 | mask = None 1071 | if type == 'string': 1072 | while 1: 1073 | value = unescape(value) 1074 | if value[len(value)-1] == ' ' and len(line) > 3: 1075 | # last value was an escaped space, join 1076 | value = value + line[3] 1077 | del line[3] 1078 | else: 1079 | break 1080 | else: 1081 | if value.count('&') != 0: 1082 | mask = value[(value.index('&') + 1):] 1083 | print 'MASK: ' + mask 1084 | value = value[:(value.index('&')+1)] 1085 | try: value = strToNum(value) 1086 | except: continue 1087 | msg = string.join(list(line[3:])) 1088 | new = magicTest(offset, type, op, value, msg, mask) 1089 | last[level] = new 1090 | l.append(new) 1091 | 1092 | def whatis(data): 1093 | for test in magicNumbers: 1094 | m = test.compare(data) 1095 | if m: return m 1096 | # no matching, magic number. is it binary or text? 1097 | for c in data: 1098 | if ord(c) > 128: 1099 | return 'data' 1100 | # its ASCII, now do text tests 1101 | if string.find('The', data, 0, 8192) > -1: 1102 | return 'English text' 1103 | if string.find('def', data, 0, 8192) > -1: 1104 | return 'Python Source' 1105 | return 'ASCII text' 1106 | 1107 | 1108 | def file(file): 1109 | try: 1110 | return whatis(open(file, 'r').read(8192)) 1111 | except Exception, e: 1112 | if str(e) == '[Errno 21] Is a directory': 1113 | return 'directory' 1114 | else: 1115 | raise e 1116 | 1117 | 1118 | #### BUILD DATA #### 1119 | #load('mime-magic') 1120 | #f = open('out', 'w') 1121 | #for m in magicNumbers: 1122 | # f.write(str([m.offset, m.type, m.op, m.value, m.msg]) + ',\n') 1123 | #f.close 1124 | 1125 | import sys 1126 | for m in magic: 1127 | magicNumbers.append(magicTest(m[0], m[1], m[2], m[3], m[4])) 1128 | 1129 | if __name__ == '__main__': 1130 | import sys 1131 | for arg in sys.argv[1:]: 1132 | msg = file(arg) 1133 | if msg: 1134 | print arg + ': ' + msg 1135 | else: 1136 | print arg + ': unknown' 1137 | -------------------------------------------------------------------------------- /lznt1/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2011-2014 Kiran Bandla 3 | All rights reserved, all wrongs reversed. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | 3. The names of the authors and copyright holders may not be used 18 | to endorse or promote products derived from this software 19 | without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /lznt1/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc -shared -o liblznt1.so -fPIC lznt1.c 3 | -------------------------------------------------------------------------------- /lznt1/README.md: -------------------------------------------------------------------------------- 1 | # PyLZNT1 2 | 3 | Python wrapper for Microsoft's lznt1 compression 4 | 5 | ## LICENSE 6 | BSD-3 clause 7 | -------------------------------------------------------------------------------- /lznt1/lznt1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | */ 19 | 20 | /** 21 | * @file 22 | * 23 | * LZNT1 decompression 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | //#include "wimboot.h" 32 | #include "lznt1.h" 33 | 34 | /** 35 | * Decompress LZNT1-compressed data block 36 | * 37 | * @v data Compressed data 38 | * @v limit Length of compressed data up to end of block 39 | * @v offset Starting offset within compressed data 40 | * @v block Decompression buffer for this block, or NULL 41 | * @ret out_len Length of decompressed block, or negative error 42 | */ 43 | static ssize_t lznt1_block ( const void *data, size_t limit, size_t offset, 44 | void *block ) { 45 | const uint16_t *tuple; 46 | const uint8_t *copy_src; 47 | uint8_t *copy_dest = block; 48 | size_t copy_len; 49 | size_t block_out_len = 0; 50 | unsigned int split = 12; 51 | unsigned int next_threshold = 16; 52 | unsigned int tag_bit = 0; 53 | unsigned int tag = 0; 54 | 55 | while ( offset != limit ) { 56 | 57 | /* Extract tag */ 58 | if ( tag_bit == 0 ) { 59 | tag = *( ( uint8_t * ) ( data + offset ) ); 60 | offset++; 61 | if ( offset == limit ) 62 | break; 63 | } 64 | 65 | /* Calculate copy source and length */ 66 | if ( tag & 1 ) { 67 | 68 | /* Compressed value */ 69 | if ( offset + sizeof ( *tuple ) > limit ) { 70 | printf ( "LZNT1 compressed value overrun at " 71 | "%#zx\n", offset ); 72 | return -1; 73 | } 74 | tuple = ( data + offset ); 75 | offset += sizeof ( *tuple ); 76 | copy_len = LZNT1_VALUE_LEN ( *tuple, split ); 77 | block_out_len += copy_len; 78 | if ( copy_dest ) { 79 | copy_src = ( copy_dest - 80 | LZNT1_VALUE_OFFSET ( *tuple, 81 | split ) ); 82 | while ( copy_len-- ) 83 | *(copy_dest++) = *(copy_src++); 84 | } 85 | 86 | } else { 87 | 88 | /* Uncompressed value */ 89 | copy_src = ( data + offset ); 90 | if ( copy_dest ) 91 | *(copy_dest++) = *copy_src; 92 | offset++; 93 | block_out_len++; 94 | } 95 | 96 | /* Update split, if applicable */ 97 | while ( block_out_len > next_threshold ) { 98 | split--; 99 | next_threshold <<= 1; 100 | } 101 | 102 | /* Move to next value */ 103 | tag >>= 1; 104 | tag_bit = ( ( tag_bit + 1 ) % 8 ); 105 | } 106 | 107 | return block_out_len; 108 | } 109 | 110 | /** 111 | * Decompress LZNT1-compressed data 112 | * 113 | * @v data Compressed data 114 | * @v len Length of compressed data 115 | * @v buf Decompression buffer, or NULL 116 | * @ret out_len Length of decompressed data, or negative error 117 | */ 118 | ssize_t lznt1_decompress ( const void *data, size_t len, void *buf ) { 119 | const uint16_t *header; 120 | const uint8_t *end; 121 | size_t offset = 0; 122 | ssize_t out_len = 0; 123 | size_t block_len; 124 | size_t limit; 125 | void *block; 126 | ssize_t block_out_len; 127 | 128 | while ( offset != len ) { 129 | 130 | /* Check for end marker */ 131 | if ( ( offset + sizeof ( *end ) ) == len ) { 132 | end = ( data + offset ); 133 | if ( *end == 0 ) 134 | break; 135 | } 136 | 137 | /* Extract block header */ 138 | if ( ( offset + sizeof ( *header ) ) > len ) { 139 | printf ( "LZNT1 block header overrun at %#zx\n", offset ); 140 | return -1; 141 | } 142 | header = ( data + offset ); 143 | offset += sizeof ( *header ); 144 | 145 | /* Process block */ 146 | block_len = LZNT1_BLOCK_LEN ( *header ); 147 | if ( LZNT1_BLOCK_COMPRESSED ( *header ) ) { 148 | 149 | /* Compressed block */ 150 | printf ( "LZNT1 compressed block %#zx+%#zx\n", 151 | offset, block_len ); 152 | limit = ( offset + block_len ); 153 | block = ( buf ? ( buf + out_len ) : NULL ); 154 | block_out_len = lznt1_block ( data, limit, offset, 155 | block ); 156 | if ( block_out_len < 0 ) 157 | return block_out_len; 158 | offset += block_len; 159 | out_len += block_out_len; 160 | 161 | } else { 162 | 163 | /* Uncompressed block */ 164 | if ( ( offset + block_len ) > len ) { 165 | printf ( "LZNT1 uncompressed block overrun at " 166 | "%#zx+%#zx\n", offset, block_len ); 167 | return -1; 168 | } 169 | printf ( "LZNT1 uncompressed block %#zx+%#zx\n", 170 | offset, block_len ); 171 | if ( buf ) { 172 | memcpy ( ( buf + out_len ), ( data + offset ), 173 | block_len ); 174 | } 175 | offset += block_len; 176 | out_len += block_len; 177 | } 178 | } 179 | 180 | return out_len; 181 | } 182 | -------------------------------------------------------------------------------- /lznt1/lznt1.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZNT1_H 2 | #define _LZNT1_H 3 | 4 | /* 5 | * Copyright (C) 2012 Michael Brown . 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as 9 | * published by the Free Software Foundation; either version 2 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | * 02110-1301, USA. 21 | */ 22 | 23 | /** 24 | * @file 25 | * 26 | * LZNT1 decompression 27 | * 28 | */ 29 | 30 | #include 31 | 32 | /** Extract LZNT1 block length */ 33 | #define LZNT1_BLOCK_LEN( header ) ( ( (header) & 0x0fff ) + 1 ) 34 | 35 | /** Determine if LZNT1 block is compressed */ 36 | #define LZNT1_BLOCK_COMPRESSED( header ) ( (header) & 0x8000 ) 37 | 38 | /** Extract LZNT1 compressed value length */ 39 | #define LZNT1_VALUE_LEN( tuple, split ) \ 40 | ( ( (tuple) & ( ( 1 << (split) ) - 1 ) ) + 3 ) 41 | 42 | /** Extract LZNT1 compressed value offset */ 43 | #define LZNT1_VALUE_OFFSET( tuple, split ) ( ( (tuple) >> split ) + 1 ) 44 | 45 | extern ssize_t lznt1_decompress ( const void *data, size_t len, void *buf ); 46 | 47 | #endif /* _LZNT1_H */ 48 | -------------------------------------------------------------------------------- /lznt1/lznt1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from ctypes import * 3 | from pdb import set_trace 4 | 5 | def decompress(data): 6 | ''' 7 | ''' 8 | data_len = len(data) 9 | data = create_string_buffer(data) 10 | print len(data) 11 | unpacked_data = create_string_buffer(len(data)*2) 12 | try: 13 | lznt1 = cdll.LoadLibrary('liblznt1.so') 14 | unpacked_len = lznt1.lznt1_decompress(data, len(data), unpacked_data) 15 | print unpacked_len 16 | print len(unpacked_data.raw) 17 | if unpacked_len == -1: 18 | print 'Error: Could not decompress data' 19 | return False 20 | return unpacked_data 21 | except Exception,e: 22 | print '%s'%e 23 | 24 | if __name__ == "__main__": 25 | data = open(sys.argv[1]).read() 26 | unpacked = decompress(data) 27 | -------------------------------------------------------------------------------- /vmware/vmware_mount.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Example code to Mount/Unmount ISOs on VMware ESX/ESXi using pysphere 3 | based on Sebastián Tello's code: 4 | https://groups.google.com/d/msg/pysphere/f75KE4RZBzc/8qjNrC06CEQJ 5 | 6 | pysphere: https://code.google.com/p/pysphere/ 7 | 8 | @kbandla 9 | 3/25/2013 10 | ''' 11 | from pysphere import VIServer, VITask 12 | from pysphere.resources import VimService_services as VI 13 | 14 | server = VIServer() 15 | 16 | def ReconfigureVM(vm, cdrom): 17 | # create a new VM Reconfigure Task 18 | request = VI.ReconfigVM_TaskRequestMsg() 19 | _this = request.new__this(vm._mor) 20 | _this.set_attribute_type(vm._mor.get_attribute_type()) 21 | request.set_element__this(_this) 22 | 23 | # new device change spec 24 | spec = request.new_spec() 25 | dev_change = spec.new_deviceChange() 26 | dev_change.set_element_device(cdrom) 27 | dev_change.set_element_operation("edit") 28 | 29 | spec.set_element_deviceChange([dev_change]) 30 | request.set_element_spec(spec) 31 | ret = server._proxy.ReconfigVM_Task(request)._returnval 32 | 33 | task = VITask(ret, server) 34 | status = task.wait_for_state([task.STATE_SUCCESS,task.STATE_ERROR]) 35 | if status == task.STATE_SUCCESS: 36 | print "%s: successfully reconfigured" % vm.properties.name 37 | return True 38 | elif status == task.STATE_ERROR: 39 | print "%s: Error reconfiguring vm"% vm.properties.name 40 | return False 41 | 42 | def mount_iso(vm_path, iso_path, connect=True): 43 | ''' 44 | Connect an ISO to a VM 45 | @vm_path : $str; Path to the VM 46 | Example: '[datastore1] YOUR_VM_PATH/YOUR_VM_IMAGE.vmx' 47 | @iso_path : $str; Path to the ISO 48 | Example: '[datastore1] ISO/cdrom.iso' 49 | 50 | returns a bool, indicating the success 51 | ''' 52 | # get the VM object 53 | vm = server.get_vm_by_path( vm_path ) 54 | # get the cdrom 55 | cdrom = None 56 | for dev in vm.properties.config.hardware.device: 57 | if dev._type == "VirtualCdrom": 58 | cdrom = dev._obj 59 | # found cdrom 60 | break 61 | 62 | # mark as 'Connected' 63 | cdrom.Connectable.Connected = connect 64 | # mark as 'Connect at power on' 65 | cdrom.Connectable.StartConnected = connect 66 | 67 | if connect: 68 | # config 69 | iso = VI.ns0.VirtualCdromIsoBackingInfo_Def("iso").pyclass() 70 | iso.set_element_fileName(iso_path) 71 | cdrom.set_element_backing(iso) 72 | 73 | # reconfigure the VM 74 | return ReconfigureVM(vm, cdrom) 75 | 76 | def unmount_iso( vm_path ): 77 | return mount_iso( vm_path, iso_path=None, connect=False) 78 | 79 | # == Testing == 80 | def testMountISO(mount=True): 81 | server.connect(SERVER, USER, PASSWORD) 82 | vm_path = '[datastore1] YOUR_VM_PATH/YOUR_VM_IMAGE.vmx' 83 | ISO_PATH ='[datastore1] ISO/cdrom.iso' 84 | if mount: 85 | mount_iso( vm_path, ISO_PATH) 86 | else: 87 | unmount_iso( vm_path ) 88 | server.disconnect() 89 | 90 | if __name__ == "__main__": 91 | testMountISO() 92 | --------------------------------------------------------------------------------